powered by
Returns a closure-based layer. Because ag_param uses environment semantics, the optimizer updates W and b in-place, and forward() always uses the latest weights.
ag_linear(in_features, out_features, activation = NULL)
List with W, b, forward(x), params()
W
b
forward(x)
params()
Input dimension
Output dimension
"relu", "sigmoid", "tanh", "softmax", or NULL
# \donttest{ layer <- ag_linear(4L, 8L, activation = "relu") x <- ag_tensor(matrix(runif(4 * 16), 4, 16)) out <- layer$forward(x) # }
Run the code above in your browser using DataLab