TorchLean API

NN.Runtime.Autograd.Torch.Initialization

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:

References:

A deterministic scheme for initializing a tensor of Float values.

Instances For

    Reject initializer parameters that would produce invalid floating-point samples.

    Instances For

      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
              def Runtime.Autograd.Torch.Init.xavierUniform (outDim inDim : ) (seed : := 0) :

              Initialize a matrix with the Xavier/Glorot uniform distribution and gain 1.

              Instances For
                def Runtime.Autograd.Torch.Init.kaimingUniform (outDim inDim : ) (seed : := 0) :

                Initialize a matrix with the Kaiming/He uniform distribution for ReLU networks.

                Instances For