TorchDefaultInitializationStrategy<T>

Models & Types · AiDotNet.Initialization

PyTorch’s default initialization of nn.Conv*d and nn.Linear: kaiming_uniform_ with a = √5, which is U(±1/√fan_in) for the weight, and U(±1/√fan_in) for the bias.

Inheritance: InitializationStrategyBase<T> → TorchDefaultInitializationStrategy<T>

For Beginners

Use this when porting a PyTorch model whose code builds its layers and never calls an init function on them; it reproduces the weights such a model starts training from.

How It Works

Reference implementations that never re-initialize their modules train from this distribution, so a port that wants their starting point needs it rather than the gain-scaled Kaiming default of the convolution layers, whose bound is √3 times wider for an identity activation and whose biases start at zero.

Constructors

Constructor Summary
TorchDefaultInitializationStrategy() Creates the strategy with the framework’s default thread-safe RNG.
TorchDefaultInitializationStrategy(Random rng) Creates the strategy with a caller-supplied Random source.

Properties

Property Summary
bool IsLazy { get; }
bool LoadFromExternal { get; }

Methods

Method Summary
void InitializeBiases(Tensor<T> biases)
void InitializeWeights(Tensor<T> weights, int inputSize, int outputSize)