Runtime Layer Helpers #
Sequential layer constructors over the lower-level TorchLean runtime surface. These keep the direct
runtime API available while the higher-level NN.API.Public.nn namespace provides named-field configs.
Sequential Layer Helpers #
Runtime.Autograd.TorchLean.NN exposes layers (LayerDef σ τ) and sequential models
(Seq σ τ). This namespace provides direct Seq constructors and common derived shapes such as
flattenLinear.
For the more fully-documented public surface (named-field configs, blocks, etc.), see
NN.API.Public under API.nn.
Lift a single layer into a sequential model.
Instances For
Linear layer over vectors (returns a 1-layer Seq).
Instances For
Pointwise ReLU activation, preserving the input shape.
Instances For
Elementwise SiLU/Swish.
Instances For
Pointwise GELU activation, preserving the input shape.
Instances For
Pointwise logistic sigmoid activation, preserving the input shape.
Instances For
Pointwise hyperbolic tangent activation, preserving the input shape.
Instances For
Softmax over the flattened tensor entries for the current runtime layer convention.
Instances For
Pointwise square map, preserving the input shape.
Instances For
Reduce-sum to a scalar.
Instances For
Flatten any input shape into a 1D vector of length Spec.Shape.size s.
Instances For
Dropout layer that is active in training mode and identity in eval mode.
Instances For
Flatten -> Linear head, with the input dimension computed from the input shape.
Instances For
Sequential 2D convolution layer for CHW inputs.
Instances For
Sequential max-pooling layer for CHW inputs.
Instances For
Sequential padded max-pooling layer for CHW inputs.
Instances For
Sequential average-pooling layer for CHW inputs.
Instances For
Sequential padded average-pooling layer for CHW inputs.
Instances For
Global average-pooling over C×H×W inputs.
PyTorch analogy: torch.nn.functional.adaptive_avg_pool2d(x, output_size=1) followed by
flattening the spatial axes.
Instances For
Global average-pooling over N×C×H×W inputs.
PyTorch analogy: torch.nn.functional.adaptive_avg_pool2d(x, output_size=1) and then reshaping
to (N, C).
Instances For
Sequence-wise layer normalization.
PyTorch analogy: torch.nn.LayerNorm(embedDim) applied to each position in a sequence.
Instances For
Sequence-wise RMS normalization.
PyTorch analogy: an RMSNorm-style layer over (seqLen × embedDim) tensors.
Instances For
Mode-aware batch norm on a single C×H×W image tensor.
PyTorch analogy: torch.nn.BatchNorm2d(channels) on a single sample, with the layer's mode
controlling whether running statistics are updated or reused.
Instances For
Eval-mode batch norm on a single C×H×W image tensor with explicit running statistics.
PyTorch analogy: torch.nn.BatchNorm2d(...).eval() with running_mean and running_var.
Instances For
Instance normalization over N×C×H×W tensors.
PyTorch analogy: torch.nn.InstanceNorm2d(c, affine=True) with NCHW layout.
Instances For
Group normalization over N×C×H×W tensors.
PyTorch analogy: torch.nn.GroupNorm(groups, c) with NCHW layout.
Instances For
Batch norm over N×C×H×W tensors in training mode.
PyTorch analogy: torch.nn.BatchNorm2d(c) during training, where batch statistics are used.
Instances For
Multi-head self-attention over sequence embeddings.
PyTorch analogy: torch.nn.MultiheadAttention(embed_dim=dModel, num_heads=numHeads) in self-
attention mode, with explicit n × dModel shapes.