Simple Algorithm
Deep Learning · Emergence · 28 min

Symmetries & Conservation Laws

Permutation and rescaling symmetries, and the quantities gradient flow conserves.

Swap two hidden units of a trained network, together with their weights, and nothing changes: same function, same loss, a different point in weight space. Deep networks are full of such symmetries. They make the loss landscape massively redundant, and, through an analogue of Noether's theorem, they force gradient flow to conserve quantities that shape what training finds.

What you’ll learn

  • Enumerate the weight-space symmetries of MLPs (permutations, sign flips, positive rescalings, translations and scalings) and count the discrete ones.
  • State what is known about identifiability for tanh and ReLU networks, and what non-identifiability implies for distances, averaging and sharpness.
  • Prove that a continuous symmetry makes the gradient orthogonal to its orbit, and derive the conservation laws of gradient flow, including the balancedness of homogeneous networks.
  • Quantify how finite step sizes and weight decay break these laws, and describe uses of symmetry: teleportation, weight-space networks and alignment.

The symmetries of weight space

SymmetryTransformation at hidden layer ℓ\ellNeedsGroup
PermutationW(ℓ)→PW(ℓ)W^{(\ell)}\to PW^{(\ell)}, b(ℓ)→Pb(ℓ)\mathbf b^{(\ell)}\to P\mathbf b^{(\ell)}, W(ℓ+1)→W(ℓ+1)P⊤W^{(\ell+1)}\to W^{(\ell+1)}P^\topany elementwise ϕ\phinℓ!n_\ell! permutation matrices PP
Sign flipnegate unit jj's incoming weights, bias and outgoing weightsodd ϕ\phi, such as tanh2nℓ2^{n_\ell}
Positive rescalingW(ℓ)→DW(ℓ)W^{(\ell)}\to DW^{(\ell)}, b(ℓ)→Db(ℓ)\mathbf b^{(\ell)}\to D\mathbf b^{(\ell)}, W(ℓ+1)→W(ℓ+1)D−1W^{(\ell+1)}\to W^{(\ell+1)}D^{-1}, DD positive diagonalϕ(cz)=c ϕ(z)\phi(cz)=c\,\phi(z) for c>0c>0: ReLU, leaky ReLUcontinuous, nℓn_\ell dimensions
Translationadd c1c\mathbf 1 to the bias of the logitsa softmax outputcontinuous, 1 dimension
ScaleW→cWW\to cW, c>0c>0, for weights feeding a normalization layerBatchNorm or LayerNorm after the layercontinuous, 1 dimension
General linearW(ℓ)→AW(ℓ)W^{(\ell)}\to AW^{(\ell)}, W(ℓ+1)→W(ℓ+1)A−1W^{(\ell+1)}\to W^{(\ell+1)}A^{-1}, AA invertibleϕ\phi the identity (linear networks)continuous, nℓ2n_\ell^2 dimensions
The sigmoid has a sign flip too, since σ(−z)=1−σ(z)\sigma(-z)=1-\sigma(z): flip unit jj and add its outgoing weights to the next layer's biases. GELU and SiLU are neither odd nor homogeneous, so a generic GELU network has only the permutations.

For a tanh network the discrete symmetries combine: each hidden layer contributes 2nℓ nℓ!2^{n_\ell}\,n_\ell! sign-and-permutation transformations, and for generic weights they give distinct weight vectors (Chen, Lu & Hecht-Nielsen, 1993). One hidden layer of 10 tanh units already gives 210⋅10!≈3.7×1092^{10}\cdot10!\approx3.7\times10^9 copies of every weight vector, all with the same loss on every data set. Every minimum of the loss comes with its whole orbit.

Predict before you look

How many weight vectors compute exactly the same function as a generic tanh network with one hidden layer of 5 units (counting the original)?

Show the answer

3840

5!=1205!=120 orderings of the units, times 25=322^5=32 sign patterns: 3,8403{,}840. Permutations alone would give 120120, sign flips alone 3232; they combine independently.

Identifiability, and what its failure implies

So for tanh networks the table is complete: the function determines the weights up to the finite group. For ReLU networks the continuous rescalings join the permutations, and Phuong and Lampert (2020) showed that for every architecture with non-increasing widths there are networks for which permutations and positive rescalings are the only function-preserving transformations; their proof reads the weights off the boundaries between the network's linear regions. Not every network is so rigid. A unit that never activates on the input domain, for example, can have any outgoing weights, and Rolnick and Kording (2020) point out that such extra symmetries occur on a set of networks of positive measure. They also showed the constructive flip side: from input–output queries alone one can often recover a deep ReLU network's architecture and weights up to its symmetries.

Non-identifiability has practical consequences:

  • Distances between networks are meaningless without alignment. Two runs from different seeds can compute nearly the same function with hidden units in different orders, and averaging their weights then mixes unrelated units. Aligning permutations first is the basis of weight matching and model merging (Mode Connectivity & Permutation Symmetry).
  • Sharpness is not a property of the function. Rescaling one layer of a ReLU network by α\alpha and the next by 1/α1/\alpha leaves the function unchanged but scales the curvature in each block of weights, so a minimum can be made arbitrarily sharp without changing what it computes (Dinh et al., 2017; see Sharpness-Aware Minimization).
  • Critical points come in families. Symmetric configurations, such as two units with identical weights, are fixed by some symmetries; such points are often saddles, and gradient descent from a symmetric start can never break the tie. That is why weights must start random.
Check your understanding

A hidden ReLU unit has incoming weights w\mathbf w, bias bb and outgoing weight vector v\mathbf v. Which change leaves the network's function unchanged?

  1. (2w, b, v/2)(2\mathbf w,\ b,\ \mathbf v/2)
  2. (−w, −b, −v)(-\mathbf w,\ -b,\ -\mathbf v)
  3. (2w, 2b, v/2)(2\mathbf w,\ 2b,\ \mathbf v/2)
  4. (2w, 2b, 2v)(2\mathbf w,\ 2b,\ 2\mathbf v)
Show the answer

C. (2w, 2b, v/2)(2\mathbf w,\ 2b,\ \mathbf v/2)

ReLU⁡(2w⊤x+2b)=2ReLU⁡(w⊤x+b)\operatorname{ReLU}(2\mathbf w^\top\mathbf x+2b)=2\operatorname{ReLU}(\mathbf w^\top\mathbf x+b), and halving the outgoing weights undoes the factor 22. The bias belongs to the pre-activation, so it scales with the incoming weights.

Noether for gradient flow

DerivationProof, and the three classic laws
  1. ddtQ(θt)=⟨∇Q,θ˙t⟩=−⟨ξ(θt),∇L(θt)⟩=0\frac{d}{dt}Q(\boldsymbol\theta_t)=\big\langle\nabla Q,\dot{\boldsymbol\theta}_t\big\rangle=-\big\langle\boldsymbol\xi(\boldsymbol\theta_t),\nabla\loss(\boldsymbol\theta_t)\big\rangle=0

    (a) Differentiate the invariance L(gαθ)=L(θ)\loss(g_\alpha\boldsymbol\theta)=\loss(\boldsymbol\theta) at α=0\alpha=0. (b) Along gradient flow:

  2. translation: ∑i∈Aθi=const,scale: ∥θA∥2=const\text{translation: }\sum_{i\in A}\theta_i=\text{const},\qquad\text{scale: }\norm{\boldsymbol\theta_A}^2=\text{const}

    Translation of a parameter block AA (logit biases before a softmax): gαθA=θA+α1g_\alpha\boldsymbol\theta_A=\boldsymbol\theta_A+\alpha\mathbf 1, so ξ=1A=∇⟨1A,θ⟩\boldsymbol\xi=\mathbf 1_A=\nabla\langle\mathbf 1_A,\boldsymbol\theta\rangle. Scale of a block feeding a normalization layer: ξ=θA=∇12∥θA∥2\boldsymbol\xi=\boldsymbol\theta_A=\nabla\tfrac12\norm{\boldsymbol\theta_A}^2.

  3. ⟨∂L∂win,win⟩+∂L∂b b=⟨∂L∂wout,wout⟩⟹∥win∥2+b2−∥wout∥2=const\Big\langle\frac{\partial\loss}{\partial\mathbf w_{\text{in}}},\mathbf w_{\text{in}}\Big\rangle+\frac{\partial\loss}{\partial b}\,b=\Big\langle\frac{\partial\loss}{\partial\mathbf w_{\text{out}}},\mathbf w_{\text{out}}\Big\rangle\quad\Longrightarrow\quad \norm{\mathbf w_{\text{in}}}^2+b^2-\norm{\mathbf w_{\text{out}}}^2=\text{const}

    Rescaling at a hidden ReLU unit: incoming weights and bias win,b\mathbf w_{\text{in}},b scale by eαe^\alpha and outgoing weights wout\mathbf w_{\text{out}} by e−αe^{-\alpha}. The generator (win,b,−wout)(\mathbf w_{\text{in}},b,-\mathbf w_{\text{out}}) is the gradient of 12(∥win∥2+b2−∥wout∥2)\tfrac12(\norm{\mathbf w_{\text{in}}}^2+b^2-\norm{\mathbf w_{\text{out}}}^2), and (a) reads

  4. ddt(∥W(ℓ)∥F2+∥b(ℓ)∥2−∥W(ℓ+1)∥F2)=0\frac{d}{dt}\Big(\norm{W^{(\ell)}}_F^2+\norm{\mathbf b^{(\ell)}}^2-\norm{W^{(\ell+1)}}_F^2\Big)=0

    Summing over the units of layer ℓ\ell (rows of W(ℓ)W^{(\ell)}, entries of b(ℓ)\mathbf b^{(\ell)}, columns of W(ℓ+1)W^{(\ell+1)}) gives one law per pair of adjacent layers:

These are conservation laws in the sense of mechanics, and the analogy with Noether's theorem (continuous symmetry, conserved quantity) was developed by Kunin et al. (2021). Du, Hu and Lee (2018) proved the layer-wise law for fully connected and convolutional networks with linear, ReLU or leaky ReLU activations and drew the key consequence: layers are automatically balanced. If training starts from small weights, the differences of squared norms start near zero and stay there, while the norms themselves grow by orders of magnitude, so every layer ends up with nearly the same norm. Gradient flow cannot pile all the growth into one layer.

Linear networks have the bigger symmetry W(ℓ)→AW(ℓ)W^{(\ell)}\to AW^{(\ell)}, W(ℓ+1)→W(ℓ+1)A−1W^{(\ell+1)}\to W^{(\ell+1)}A^{-1}, and the same argument conserves a whole matrix, W(ℓ)W(ℓ)⊤−W(ℓ+1)⊤W(ℓ+1)W^{(\ell)}W^{(\ell)\top}-W^{(\ell+1)\top}W^{(\ell+1)}. Arora, Cohen and Hazan (2018) started it at zero ("balanced" initialization) and showed that the end-to-end matrix then follows a preconditioned gradient flow: depth acts as a preconditioner that can accelerate convergence (Learning Dynamics of Deep Linear Networks). Are there more conservation laws than the symmetries give? Marcotte, Gribonval and Peyré (2023) characterized all functions conserved by every gradient flow of a model, through the Lie algebra generated by the model's Jacobian, and found for several ReLU architectures that the known rescaling laws are complete.

Broken conservation: step size, weight decay, noise

Training is not gradient flow. With a finite step, a penalty or a different optimizer, the conserved quantities drift, and the drift itself is informative.

DerivationOne gradient step, exactly
  1. ∥u−ηgu∥2−∥v−ηgv∥2=(∥u∥2−∥v∥2)−2η(⟨u,gu⟩−⟨v,gv⟩)+η2(∥gu∥2−∥gv∥2)\norm{\mathbf u-\eta\mathbf g_{\mathbf u}}^2-\norm{\mathbf v-\eta\mathbf g_{\mathbf v}}^2=\big(\norm{\mathbf u}^2-\norm{\mathbf v}^2\big)-2\eta\big(\langle\mathbf u,\mathbf g_{\mathbf u}\rangle-\langle\mathbf v,\mathbf g_{\mathbf v}\rangle\big)+\eta^2\big(\norm{\mathbf g_{\mathbf u}}^2-\norm{\mathbf g_{\mathbf v}}^2\big)

    Take one step θ←θ−η g\boldsymbol\theta\leftarrow\boldsymbol\theta-\eta\,\mathbf g and expand the squared norms of the two blocks of a rescaling symmetry, u=(win,b)\mathbf u=(\mathbf w_{\text{in}},b) and v=wout\mathbf v=\mathbf w_{\text{out}}:

  2. Δk+1=Δk+η2(∥gu∥2−∥gv∥2),Δ=∥u∥2−∥v∥2\Delta_{k+1}=\Delta_k+\eta^2\big(\norm{\mathbf g_{\mathbf u}}^2-\norm{\mathbf g_{\mathbf v}}^2\big),\qquad \Delta=\norm{\mathbf u}^2-\norm{\mathbf v}^2

    The middle term vanishes by the symmetry identity, for the full gradient and equally for every mini-batch gradient, since each mini-batch loss has the same symmetry. Only a second-order term remains:

  3. Over a time t=kηt=k\eta the drift adds up to about η∫0t(∥gu∥2−∥gv∥2) ds\eta\int_0^t(\norm{\mathbf g_{\mathbf u}}^2-\norm{\mathbf g_{\mathbf v}}^2)\,ds: it vanishes as η→0\eta\to0 at fixed tt. For a scale symmetry, ⟨θA,gA⟩=0\langle\boldsymbol\theta_A,\mathbf g_A\rangle=0 gives ∥θA∥2←∥θA∥2+η2∥gA∥2\norm{\boldsymbol\theta_A}^2\leftarrow\norm{\boldsymbol\theta_A}^2+\eta^2\norm{\mathbf g_A}^2: weights feeding a normalization layer grow at every step, which steadily shrinks their effective learning rate (What Weight Decay Really Does).

  4. Δ(t)=e−2λtΔ(0)+η∫0te−2λ(t−s)(∥gu(s)∥2−∥gv(s)∥2) ds\Delta(t)=e^{-2\lambda t}\Delta(0)+\eta\int_0^te^{-2\lambda(t-s)}\big(\norm{\mathbf g_{\mathbf u}(s)}^2-\norm{\mathbf g_{\mathbf v}(s)}^2\big)\,ds

    Weight decay λ2∥θ∥2\tfrac\lambda2\norm{\boldsymbol\theta}^2 adds −λθ-\lambda\boldsymbol\theta to the flow, so Δ˙=−2λΔ\dot\Delta=-2\lambda\Delta: the imbalance decays exponentially. Kunin et al. (2021) combine both effects in one formula, which they found to match training of VGG-16 on Tiny ImageNet closely:

Predict before you look

At one step of plain gradient descent with η=0.1\eta=0.1, a ReLU unit's incoming-side gradient has ∥gu∥2=4\norm{\mathbf g_{\mathbf u}}^2=4 and its outgoing-side gradient ∥gv∥2=1\norm{\mathbf g_{\mathbf v}}^2=1. By how much does Δ=∥u∥2−∥v∥2\Delta=\norm{\mathbf u}^2-\norm{\mathbf v}^2 change?

Show the answer

0.03

η2(4−1)=0.01×3=0.03\eta^2(4-1)=0.01\times3=0.03. The first-order terms cancel exactly, so the law is broken only at order η2\eta^2 per step. Halving the step size quarters the drift per step and halves it per unit of training time.

Momentum, in the continuous-time model, mainly rescales time and keeps the laws; adaptive optimizers such as Adam rescale each coordinate separately, so the update is no longer orthogonal to the orbit and the laws need not hold even for small steps. The conserved and slowly drifting quantities are therefore fingerprints of the optimizer, which is one way to study what an optimizer's implicit bias is.

Putting symmetry to work

  • Teleportation. Moving along an orbit changes the parameters but not the loss, and different points of an orbit can have very different gradients. Symmetry teleportation jumps along the orbit to a point with a steeper gradient, then resumes descent; Zhao, Dehmamy, Walters and Yu (2022) showed it speeds up gradient descent and AdaGrad on test functions, multilayer regressions and MNIST, and related it to second-order methods.
  • Networks that read networks. Models that take another network's weights as input, to predict its accuracy, edit an implicit neural representation or generate weights, should give the same answer for every permutation of the hidden units. Navon et al. (2023) and Zhou et al. (2023) characterized the linear layers that are equivariant to these permutations and built weight-space networks from them.
  • Alignment before averaging. Matching the units of two independently trained networks, and then interpolating, removes much of the loss barrier between them (Mode Connectivity & Permutation Symmetry, Model Merging & Task Arithmetic).

Key takeaways

  • MLPs have weight-space symmetries: n!n! permutations per hidden layer for any activation, 2n2^n sign flips for odd ones, positive rescalings for ReLU, plus translations before a softmax and scalings before normalization; every minimum comes with its whole orbit.
  • Tanh networks are identifiable up to permutations and sign flips (Sussmann, 1992); for ReLU networks, permutations and rescalings are the only symmetries for suitable networks but not for all.
  • A continuous symmetry makes the gradient orthogonal to its orbit; when the generator is a gradient field, its potential is conserved by gradient flow. For ReLU networks, ∥W(ℓ)∥F2+∥b(ℓ)∥2−∥W(ℓ+1)∥F2\norm{W^{(\ell)}}_F^2+\norm{\mathbf b^{(\ell)}}^2-\norm{W^{(\ell+1)}}_F^2 is conserved, so small initializations stay balanced.
  • Finite steps break the laws only at order η2\eta^2 per step, weight decay makes imbalances decay like e−2λte^{-2\lambda t}, and adaptive optimizers need not respect them; symmetries are used for teleportation, weight-space learning and model alignment.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

A generic tanh network has one hidden layer of 6 units. How many weight vectors compute exactly its function?

  1. 720720
  2. 46,08046{,}080
  3. 6464
  4. 1,4401{,}440
Show the answer

B. 46,08046{,}080

6!=7206!=720 permutations times 26=642^6=64 sign patterns: 46,08046{,}080.

Question 2

For a hidden ReLU unit with incoming weights w\mathbf w, bias bb and outgoing weights v\mathbf v, which quantity is conserved by gradient flow on any loss?

  1. ∥w∥2+b2+∥v∥2\norm{\mathbf w}^2+b^2+\norm{\mathbf v}^2
  2. ∥w∥⋅∥v∥\norm{\mathbf w}\cdot\norm{\mathbf v}
  3. ∥w∥2+b2−∥v∥2\norm{\mathbf w}^2+b^2-\norm{\mathbf v}^2
  4. ∥w∥2−b2−∥v∥2\norm{\mathbf w}^2-b^2-\norm{\mathbf v}^2
Show the answer

C. ∥w∥2+b2−∥v∥2\norm{\mathbf w}^2+b^2-\norm{\mathbf v}^2

The rescaling symmetry's generator (w,b,−v)(\mathbf w,b,-\mathbf v) is the gradient of 12(∥w∥2+b2−∥v∥2)\tfrac12(\norm{\mathbf w}^2+b^2-\norm{\mathbf v}^2), which is therefore conserved. The bias scales with the incoming weights, so it enters with the same sign.

Question 3

Gradient flow with weight decay λ2∥θ∥2\tfrac\lambda2\norm{\boldsymbol\theta}^2 is run on a ReLU network. What happens to a unit's imbalance Δ=∥u∥2−∥v∥2\Delta=\norm{\mathbf u}^2-\norm{\mathbf v}^2?

  1. It stays exactly constant, as without weight decay
  2. It decays as Δ(t)=e−2λtΔ(0)\Delta(t)=e^{-2\lambda t}\Delta(0)
  3. It grows as e2λte^{2\lambda t}
  4. It decreases linearly to zero at t=1/λt=1/\lambda
Show the answer

B. It decays as Δ(t)=e−2λtΔ(0)\Delta(t)=e^{-2\lambda t}\Delta(0)

The penalty adds −λθ-\lambda\boldsymbol\theta to the velocity, contributing −2λ∥u∥2-2\lambda\norm{\mathbf u}^2 and −2λ∥v∥2-2\lambda\norm{\mathbf v}^2 to their derivatives, while the loss terms still cancel: Δ˙=−2λΔ\dot\Delta=-2\lambda\Delta. Weight decay actively balances the layers.

Question 4

Two networks with the same architecture are trained from different random seeds and both reach low loss. Why does averaging their weights usually give a poor network?

  1. Their hidden units sit in unrelated orders, so the average combines units that compute different features
  2. Averaging always doubles the weights' norm
  3. Two minima of a nonconvex loss can never be connected by a low-loss path
  4. The averaged network has twice as many parameters
Show the answer

A. Their hidden units sit in unrelated orders, so the average combines units that compute different features

Permutation symmetry means the two solutions may be equivalent up to reordering, but their raw weight vectors are not aligned. Aligning the units first (weight or activation matching) often makes the average, and the straight path between the two, much better.

Further reading

  • H. J. Sussmann, "Uniqueness of the weights for minimal feedforward nets with a given input-output map," Neural Networks 5 (1992).
  • A. M. Chen, H. Lu & R. Hecht-Nielsen, "On the geometry of feedforward neural network error surfaces," Neural Computation 5 (1993).
  • S. S. Du, W. Hu & J. D. Lee, "Algorithmic regularization in learning deep homogeneous models: Layers are automatically balanced," NeurIPS (2018).
  • D. Kunin, J. Sagastuy-Brena, S. Ganguli, D. L. K. Yamins & H. Tanaka, "Neural mechanics: Symmetry and broken conservation laws in deep learning dynamics," ICLR (2021).
  • M. Phuong & C. H. Lampert, "Functional vs. parametric equivalence of ReLU networks," ICLR (2020).
  • S. Marcotte, R. Gribonval & G. Peyré, "Abide by the law and follow the flow: Conservation laws for gradient flows," NeurIPS (2023).