Table of Contents

Class LazyInitializationStrategy<T>

Namespace
AiDotNet.Initialization
Assembly
AiDotNet.dll

Lazy initialization strategy that defers weight allocation until first Forward() call.

public class LazyInitializationStrategy<T> : InitializationStrategyBase<T>, IInitializationStrategy<T>

Type Parameters

T

The numeric type used for calculations.

Inheritance
LazyInitializationStrategy<T>
Implements
Inherited Members

Remarks

This strategy significantly speeds up network construction by not allocating or initializing weight tensors until they are actually needed. This is particularly useful for tests and when comparing network architectures without actually running them.

For Beginners: Think of lazy initialization like making dinner reservations versus cooking dinner. The reservation (lazy) is fast - the cooking happens later when you actually need it. This makes creating networks much faster when you just want to inspect them or compare their structures.

Properties

IsLazy

Gets a value indicating whether this strategy defers initialization until first use.

public override bool IsLazy { get; }

Property Value

bool

true if initialization is deferred until first Forward() call; false if initialization happens immediately.

LoadFromExternal

Gets a value indicating whether weights should be loaded from an external source.

public override bool LoadFromExternal { get; }

Property Value

bool

true if weights should be loaded from file or other external source; false if weights should be randomly initialized.

Methods

InitializeBiases(Tensor<T>)

Initializes the biases tensor with appropriate values.

public override void InitializeBiases(Tensor<T> biases)

Parameters

biases Tensor<T>

The biases tensor to initialize.

InitializeWeights(Tensor<T>, int, int)

Initializes the weights tensor with appropriate values.

public override void InitializeWeights(Tensor<T> weights, int inputSize, int outputSize)

Parameters

weights Tensor<T>

The weights tensor to initialize.

inputSize int

The number of input features.

outputSize int

The number of output features.