INGOAMPT learning series · Day 23
Choose a weight scale that fits your layer. LeCun uses 1 / fan-in, Glorot uses 2 / (fan-in + fan-out), and He uses 2 / fan-in as target weight variances. Below, the complete original lesson is followed by a worked calculation, practical qualifications and primary sources.
Understanding Weight Initialization Strategies in Deep Learning: 2024 Updates and Key Techniques
Deep learning has revolutionized machine learning, enabling us to solve complex tasks that were previously unattainable. A critical factor in the success of these models is the initialization of their weights. Proper weight initialization can significantly impact the speed and stability of the training process, helping to avoid issues like vanishing or exploding gradients. In this blog post, we’ll explore some of the most widely-used weight initialization strategies—LeCun, Glorot, and He initialization—and delve into new advancements as of 2024.
The Importance of Weight Initialization
Weight initialization is a crucial step in training neural networks. It involves setting the initial values of the weights before the learning process begins. If weights are not initialized properly, the training process can suffer from issues like slow convergence, vanishing or exploding gradients, and suboptimal performance. To address these challenges, researchers have developed various initialization methods, each tailored to specific activation functions and network architectures.
Classic Initialization Strategies
LeCun Initialization
LeCun Initialization, introduced by Yann LeCun, is particularly effective for networks using the SELU activation function. It initializes weights using a normal distribution with variance inversely proportional to the number of input units (fan-in\text{fan-in}):
Variance = 1 / fan-in\text{Variance} = \frac{1}{\text{fan-in}}
Example Code:
import tensorflow as tf
# LeCun Initialization Example
model = tf.keras.Sequential([
tf.keras.layers.Dense(64, activation='selu', kernel_initializer='lecun_normal', input_shape=(784,)),
tf.keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.summary()
Glorot Initialization (Xavier Initialization)
Glorot Initialization (Xavier Initialization) balances the variance of the weights across layers by considering both the number of input and output units:
Variance = 2 / (fan-in + fan-out)\text{Variance} = \frac{2}{\text{fan-in} + \text{fan-out}}
It is particularly effective for tanh, sigmoid, and softmax activation functions.
Example Code:
import tensorflow as tf
# Glorot (Xavier) Initialization Example
model = tf.keras.Sequential([
tf.keras.layers.Dense(64, activation='tanh', kernel_initializer='glorot_normal', input_shape=(784,)),
tf.keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.summary()
He Initialization
He Initialization was developed for networks using ReLU and its variants. It scales the variance of the weights based on the number of input units:
Variance = 2 / fan-in\text{Variance} = \frac{2}{\text{fan-in}}
Example Code:
import tensorflow as tf
# He Initialization Example
model = tf.keras.Sequential([
tf.keras.layers.Dense(64, activation='relu', kernel_initializer='he_normal', input_shape=(784,)),
tf.keras.layers.Dense(10, activation='softmax')
])
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.summary()
What’s New in 2024
AutoInit: Analytic Signal-Preserving Initialization
AutoInit is a recent innovation that adapts automatically to different neural network architectures by analytically tracking the mean and variance of signals through the network. This ensures stable gradients across layers, improving training in deep architectures like transformers and residual networks.
Example Code:
import autoinit
import tensorflow as tf
model = tf.keras.Sequential([
tf.keras.layers.Dense(64, activation='relu', input_shape=(784,)),
tf.keras.layers.Dense(10, activation='softmax')
])
# Apply AutoInit
autoinit.apply(model)
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.summary()
Comparison Table
| Initialization Method | Recommended Activation Functions | Variance Formula | Use Cases |
|---|---|---|---|
| LeCun Initialization | SELU | Variance = 1 / fan-in\text{Variance} = \frac{1}{\text{fan-in}} | Networks using SELU activation for stable training. |
| Glorot Initialization (Xavier) | Tanh, Sigmoid, Softmax | Variance = 2 / (fan-in + fan-out)\text{Variance} = \frac{2}{\text{fan-in} + \text{fan-out}} | Common in feedforward networks with balanced gradients. |
| He Initialization | ReLU, variants | Variance = 2 / fan-in\text{Variance} = \frac{2}{\text{fan-in}} | Deep networks with ReLU activations. |
Corrections and context for the original lesson
The original wording above is retained as published. These notes clarify its broad recommendations and its historical “2024” framing.
Match initialization to the whole network
For a dense layer, fan-in is its number of input features and fan-out is its number of output units. An initializer sets the starting weights, before an optimizer sees training data. Its scale is a starting condition, not a substitute for checking activations, gradients, learning rates and losses during training.
SELU is commonly paired with LeCun normal under self-normalizing network assumptions. If using dropout in that setting, consult the SELU guidance on AlphaDropout. Input normalization, network structure and the assumptions of the self-normalizing analysis still matter. Glorot is a useful baseline for tanh-like networks; the original references to sigmoid and softmax are broad guidance, not a universal prescription for every layer using those activations. A softmax output layer does not determine the correct initializer for all hidden layers. He initialization targets ReLU-style signal propagation; modified activations can require a different gain.
Normal does not mean an unrestricted Gaussian in these Keras APIs. The documented lecun_normal, glorot_normal and he_normal initializers draw from truncated-normal distributions with the documented scaling. The formulas describe target weight variance. A finite random sample need not have exactly that sample variance. The square root gives the target standard deviation, which is a different quantity.
Why the ReLU factor is two
As a teaching approximation, suppose independent, zero-mean weights are independent of the inputs and the layer has n inputs with a common input second moment. For the weighted sum z, the second moment scales with n times the weight variance:
With symmetric pre-activation z, ReLU removes the negative half and halves the second moment. Choosing Var(w) = 2/n compensates for that factor in this approximation. This is not a claim that ReLU halves the centered variance: its output has a positive mean. Independence and symmetry are simplifying assumptions, and trained or complex residual networks need more careful analysis.
AutoInit: corrected date and API warning
AutoInit’s preprint was submitted in September 2021, revised in November 2022 and listed for AAAI 2023. It was not first introduced in 2024. Its authors study signal mean and variance propagation and report results on several architectures; those results do not guarantee stable gradients or better training for every new model.
The upstream README imports the AutoInit class and calls its initialize_model method. The original autoinit.apply(model) call is retained for historical completeness, but is not exported by that upstream package. Do not run it as a supported API example. This revision does not certify AutoInit compatibility with your current TensorFlow/Keras release. Follow-up: test the upstream method in an isolated, version-pinned environment before relying on it. Review the upstream license for your intended use.
Worked example: 784 inputs and 64 hidden units
The first dense layer in the original examples receives 784 input values and produces 64 activations. Keep this same shape when comparing initializers; otherwise a difference in scale may simply reflect a different fan-in or fan-out.

The first layer has 784 × 64 weights and 64 biases: 50,240 parameters. The 64-to-10 output layer has 640 weights and 10 biases: 650 parameters. The total is 50,890. This is a direct count assuming the default bias in each dense layer, not a captured TensorFlow summary.
A small calculation you can reproduce
This dependency-free Python calculation was executed for this revision. It checks formulas and parameter arithmetic only; it does not import Keras, generate initialized weights or train a model.
from math import sqrt
fan_in, fan_out = 784, 64
variances = {
"LeCun": 1 / fan_in,
"Glorot": 2 / (fan_in + fan_out),
"He": 2 / fan_in,
}
for name, variance in variances.items():
print(f"{name}: variance={variance:.8f}, sd={sqrt(variance):.8f}")
print("parameters:", (784 + 1) * 64 + (64 + 1) * 10)
Expected rounded output: LeCun variance 0.00127551 and SD 0.03571429; Glorot variance 0.00235849 and SD 0.04856429; He variance 0.00255102 and SD 0.05050763; parameters 50890. The original models compile with sparse categorical cross-entropy, which expects integer class labels. A model summary or successful compile is not evidence of successful learning.
Questions about weight initialization
Is He always better because its weights start larger?
No. The appropriate scale depends on the activation, layer dimensions and architecture. The comparison chart holds dimensions fixed and shows a scale difference, not a training-quality comparison.
Can I use the same constant for every weight?
Identical starting weights can leave neurons in the same layer symmetric, so they learn the same features. Random weight initializers break that symmetry. Biases can often start at zero without creating the same issue when weights differ.
Is variance the same as standard deviation?
No. Standard deviation is the square root of variance. For this He example, the target variance is about 0.00255102 and its square root is about 0.05050763.
Does initialization fix an unstable training run?
It can help, but instability can also come from data scaling, the loss, learning rate, precision or network architecture. Inspect actual activations and gradients in the training environment before assigning the cause.
Were the TensorFlow and AutoInit examples executed here?
No. All four historical listings were syntax checked and preserved. The new pure-Python arithmetic was executed separately. TensorFlow/AutoInit runtime and training remain unverified; the AutoInit call in the original example is unsupported by the cited upstream API.
How should I compare two initializers fairly?
Keep architecture, data split, preprocessing, optimizer settings and training budget fixed. Use multiple controlled random seeds, report variability and evaluate on held-out data. This lesson reports no such training experiment.
Primary sources and further study
- Keras initializer API: definitions and distribution scaling for LeCun, Glorot and He initializers.
- Keras activation API: SELU assumptions and practical notes.
- Glorot and Bengio, Understanding the difficulty of training deep feedforward neural networks (2010).
- He and colleagues, Delving Deep into Rectifiers (2015).
- Klambauer and colleagues, Self-Normalizing Neural Networks (2017).
- Bingham and Miikkulainen, AutoInit preprint and publication history.
- Official AutoInit source and usage: check its requirements and license before use.
Expanded and checked 17 November 2026. Original historical wording and code remain above, with separate corrections. Formula arithmetic and the chart were checked independently; no training performance was measured.
