Applied AI Vol. 2

Equivariance vs Invariance: Building Symmetry Into a Model

If shifting the input shifts the output, the model is equivariant. If the output ignores the shift, it is invariant. Knowing which you need changes the architecture.

Applied AI Vol. 2 · 4 min read

A model for images, molecules or point clouds should respect the symmetries of its data. Equivariance is the precise way to say how.

Two definitions

A function f is invariant to a transformation g if applying g to the input does not change the output. A classifier that says “cat” should give the same answer if the image is shifted a few pixels.

A function is equivariant if applying g to the input applies a corresponding transformation to the output. A convolutional layer is translation equivariant: shift the image and the feature map shifts the same way.

Why it helps

Building in a symmetry means the model does not have to learn it from data separately for every orientation or position. This can improve data efficiency and generalization when the symmetry really holds, and it guarantees consistent behavior under the transformation.

Choosing what to enforce

  • For a classification label, you usually want invariance at the output, built from equivariant features that are pooled at the end.
  • For predicting forces on atoms, you want the output vectors to rotate when the molecule rotates, so equivariance is the right property.
  • For generative models of molecules or 3D structures, an equivariant network allows the learned distribution to respect rotations and translations.

When not to

If the symmetry is only approximate, such as an upright orientation that matters in photographs, forcing it can hurt. Test with and without, and check performance on transformed inputs to confirm the model behaves as intended.

More guides from this book