
Create a neural network module by specifying a directed acyclic graph (DAG)
nndag.RdUsing a list of formulas as input, dagnn generates an nn_module()
neural network with a compact syntax
Arguments
- ...
A list of formulas specifying a directed acyclic graph (DAG). See details for the correct syntax.
- .fns
A list of functions for generating neural network layers. Named elements are mapped to layer names in the DAG, a single unnamed element can be included which acts as the default.
[.]syntax is accepted for list names (see details).- .args
A list of named argument lists. Each element should be a named list with arguments to be passed to the corresponding
.fns. In the upper level list, named elements are mapped to layer names in the DAG, and a single unnamed element can be included which acts as the default.[.]syntax is accepted for list names (see details).- .act
A list of functions for generating neural network activation for corresponding layers. Named elements are mapped to layer names in the DAG, a single unnamed element can be included which acts as the default.
[.]syntax is accepted for list names (see details).
Examples
dag <- nndag(i_1 = ~ 19,
c = ~ 1,
p_1 = i_1 + c ~ 11,
`e_[.]` = p_1 + c ~ c(32, 16, 8))
print(dag)
#> An `nn_module` containing 1,599 parameters.
#>
#> ── Modules ─────────────────────────────────────────────────────────────────────
#> • layers: <nn_module_list> #1,599 parameters
#> • activations: <nn_module_list> #0 parameters
print(dag$layers)
#> An `nn_module` containing 1,599 parameters.
#>
#> ── Modules ─────────────────────────────────────────────────────────────────────
#> • 0: <nn_linear> #231 parameters
#> • 1: <nn_linear> #416 parameters
#> • 2: <nn_linear> #720 parameters
#> • 3: <nn_linear> #232 parameters