Learn R Programming

ggmlR (version 0.6.1)

ag_linear: Create a dense layer with learnable parameters

Description

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.

Usage

ag_linear(in_features, out_features, activation = NULL)

Value

List with W, b, forward(x), params()

Arguments

in_features

Input dimension

out_features

Output dimension

activation

"relu", "sigmoid", "tanh", "softmax", or NULL

Examples

Run this code
# \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