ag_linear: Create a dense layer with learnable parameters

View source: R/autograd.R

ag_linearR Documentation

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)

Arguments

in_features

Input dimension

out_features

Output dimension

activation

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

Value

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

Examples


layer <- ag_linear(4L, 8L, activation = "relu")
x     <- ag_tensor(matrix(runif(4 * 16), 4, 16))
out   <- layer$forward(x)


ggmlR documentation built on July 14, 2026, 1:08 a.m.