Table of Contents

Interface IInitializationStrategy<T>

Namespace
AiDotNet.Initialization
Assembly
AiDotNet.dll

Defines a strategy for initializing neural network layer parameters.

public interface IInitializationStrategy<T>

Type Parameters

T

The numeric type used for calculations.

Remarks

This interface allows control over when and how layer weights are initialized. Different strategies can be used for different use cases: - Lazy: Defer initialization until first Forward() call (fast construction) - Eager: Initialize immediately on construction (current behavior) - FromFile: Load weights from a file instead of random initialization - Zero: Initialize all weights to zero (useful for testing)

For Beginners: This controls how the network sets up its initial weights.

Different strategies have different trade-offs:

  • Lazy initialization makes network construction fast (good for tests)
  • Eager initialization is the traditional approach (slightly slower construction)
  • FromFile loads pre-trained weights (for transfer learning)

Properties

IsLazy

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

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.

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.

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.

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.