TorchLean NN: Activation and Shape Layers #
ReLU activation layer (no parameters).
PyTorch analogues: torch.nn.ReLU / torch.nn.functional.relu.
Instances For
SiLU (a.k.a. swish) activation layer (no parameters).
PyTorch analogues: torch.nn.SiLU / torch.nn.functional.silu.
Instances For
GELU activation layer (no parameters), using the tanh approximation.
PyTorch analogues: torch.nn.GELU(approximate='tanh') /
torch.nn.functional.gelu(x, approximate='tanh'). PyTorch's default nn.GELU() uses the exact
erf form, which TorchLean does not implement.
Instances For
Shape-preserving softmax layer along axis.
Instances For
Shape-preserving stable log-softmax layer along axis.
Instances For
Pointwise square x ↦ x^2 (no parameters).
PyTorch analogy: torch.square(x) / x.square().
Instances For
Sum-reduce all elements of the input to a scalar (no parameters).
PyTorch analogy: x.sum().
Instances For
Flatten any tensor to a 1D vector of length Spec.Shape.size s (no parameters).
PyTorch analogy: torch.flatten(x) or x.reshape(-1).
Instances For
Dropout layer controlled by Mode.
- In
Mode.train, randomly zeroes entries with probabilityp. - In
Mode.eval, it is the identity. - At
p = 1, training returns zero exactly rather than evaluating the undefined scale1 / (1-p).
We store p as a scalar parameter tensor (with requiresGrad := false) so it can be threaded
through the unified parameter list without being optimized.
PyTorch analogy: torch.nn.Dropout(p) / torch.nn.functional.dropout(x, p, training=...).