Deterministic parameter initialization #
Pure, reproducible initializers for TorchLean.Tensor Float. These definitions are used when
building model parameters before they enter a runtime session. Large runtime backends may provide
more specialized allocation paths, but they should implement the same initialization scheme.
The formulas follow the corresponding PyTorch initializers:
Scheme.xavierUniformuses the Glorot boundsqrt (6 / (fanIn + fanOut));Scheme.kaimingUniformuses the ReLU-oriented He boundsqrt (6 / fanIn).
References:
- Glorot and Bengio, Understanding the difficulty of training deep feedforward neural networks, AISTATS 2010.
- He et al., Delving Deep into Rectifiers, ICCV 2015.
- PyTorch initialization reference: https://pytorch.org/docs/stable/nn.init.html
Xavier/Glorot uniform bound.
The zero-fan case has no meaningful random interval. Returning zero keeps direct scheme use finite and agrees with the empty-tensor behavior expected when a weight has no elements.
Instances For
Kaiming/He uniform bound.
A zero fan-in uses the degenerate interval [0, 0], avoiding infinities and NaN in host and
runtime initialization paths.
Instances For
Return sample idx from sch, using the counter-based stream determined by seed.
Instances For
Initialize the row-major buffer directly, avoiding recursive subtensor construction.
Flat index i still receives sampleAt sch seed i, preserving the seed and sample order.
Instances For
Initialize a matrix with the Xavier/Glorot uniform distribution and gain 1.
Instances For
Initialize a matrix with the Kaiming/He uniform distribution for ReLU networks.