Skip to content
StackDecode

Param Counter

Count parameters and fp32 memory for Dense, Conv2D, Embedding, LayerNorm and attention layers.

NeweasyRuns in your browser

How it works

A parameter is one learnable number. Each layer type has a closed-form count:

  • Dense / Linear: in × out + out
  • Conv2D: k_h × k_w × in_c × out_c / groups + out_c
  • Embedding: vocab × dim
  • LayerNorm: 2 × dim (scale + shift)
  • Multi-Head Attention: 4 × d² + 4 × d
  • Conv2D weights are shared across every spatial position, so the count does not depend on image size.groups splits channels into independent sets (depthwise conv uses groups = in_c).
  • Attention has four d×d projections (query, key, value, output), each with an optional bias of size d. The number of heads splits d but does not change the count.
  • Memory is params × bytes per parameter, shown in MB (1 MB = 220 bytes). It covers the weights only, not activations, gradients or optimiser state.