Skip to content

collect_weight_statistics ​

python
collect_weight_statistics(model: nn.Module) -> list[LayerWeightStatistics]

Measure every convolutional and linear layer's weights.

A purely structural read of the model, useful alongside activation statistics. A weight matrix whose effective rank is a small fraction of its size has many output units pointing the same way, so the layer is narrower than it looks; a spectral norm drifting far above its initial value is the usual sign of an optimiser pushing on a layer that has stopped contributing.

Parameters:

  • model (Module) – The model.

Returns:

  • list[LayerWeightStatistics] – One entry per Conv2d or Linear layer, in definition order.

Source