LayerCal is a free, browser-based calculator for deep learning models. Drag layers onto a canvas to get parameter counts, forward-pass FLOPs and memory estimates, then export the model as runnable PyTorch, TensorFlow or JAX code. Nothing is uploaded and no account is needed. The formulas it uses are below.
| Layer | Parameters | Notes |
|---|---|---|
| Embedding | V × E | Vocabulary size by embedding dimension |
| Linear | I × O + O | Bias term adds one per output unit |
| Conv2D | Cin × Cout × K² + Cout | Independent of input resolution |
| LSTM | 4(IH + H² + 2H) × L × dir | Four gates, two bias vectors per gate |
| GRU | 3(IH + H² + 2H) × L × dir | Three gates, so 75 percent of an LSTM |
| Transformer block | 12d² + 13d | When dff equals 4d |
| Self-attention | 4(d² + d) | Query, key, value and output projections |
| BatchNorm, LayerNorm | 2F | One scale and one shift per feature |
| ReLU, Softmax, Dropout, Pooling | 0 | No learnable parameters |
| Mode | Bytes per parameter | Breakdown |
|---|---|---|
| Inference FP32 | 4 | Weights only |
| Inference FP16 or BF16 | 2 | Weights only |
| Inference INT8 | 1 | Quantised weights |
| Training with Adam | 16 | Weights, gradients and two moment buffers, at any precision |
Activation memory is excluded because it depends on batch size and input shape.
input_dim × output_dim
weights plus one bias per output unit. A Conv2D layer has in_channels × out_channels × kernel_size²
weights plus one bias per output channel. An Embedding layer has vocab_size × embedding_dim
weights. LSTM and GRU repeat their gate formula once per layer and once per direction. Activation,
dropout and pooling layers have no learnable parameters at all.
4(d² + d) for the four attention
projections, 2 × d × d_ff + d_ff + d for the feed-forward network,
and 4d for the two layer norms. With d_ff = 4d
that collapses to 12d² + 13d, so a block with d_model 512 and
d_ff 2048 has 3,152,384 parameters.
2 × I × O, and a Conv2D layer costs
2 × Cin × Cout × K² × Hout × Wout.
Attention adds a quadratic term in sequence length. Because every figure depends on input shape,
LayerCal shows the shapes it assumed directly under the FLOPs number.