2976 words
15 minutes
Chasing Symmetries: A New Wave of Physics-Inspired Deep Learning

Chasing Symmetries: A New Wave of Physics-Inspired Deep Learning#

In the last decade, deep learning has proven its astonishing capacity to extract complex patterns from huge amounts of data. Computers have learned to recognize images, translate text in real time, discover new drugs, and even generate entire worlds with generative adversarial networks (GANs). However, a critical challenge has emerged: designing neural networks that more transparently respect and exploit the fundamental structure of the real world.

This is where physics-inspired deep learning steps in. By incorporating concepts like symmetries, invariances, and physical laws into neural architectures, researchers have started to build models that not only show improved accuracy but also demonstrate better interpretability, efficiency, stability, and robustness to real-world variations. This blog post explores the basics of symmetries in physics, examines deep learning models that exploit these symmetries, and shows you how to build your own physics-inspired neural networks—whether you are new to the field or a veteran seeking advanced, cutting-edge expansions.


Table of Contents#

  1. What Do We Mean by Symmetry?
  2. Why Are Symmetries Important in Physics and ML?
  3. Models Inspired by Symmetries
  4. Breaking Down Equivariance and Invariance
  5. Introduction to Group Theory for Machine Learning
  6. Physics-Informed Neural Networks (PINNs)
  7. Equivariant Neural Networks from the Ground Up
  8. Getting Started with Implementations
  9. Advanced Techniques for Professionals
  10. Further Directions and Conclusion

What Do We Mean by Symmetry?#

When we talk about a system having symmetry, we refer to the system’s invariance under certain transformations. For a physical object, symmetry might mean something remains unchanged when we rotate it, translate it, or reflect it. For example, a perfect sphere remains the same under any rotation about its center. Similarly, for equations governing physical phenomena, certain transformations leave those equations looking the same.

Symmetry in mathematics is captured using the language of group theory. A group is a set equipped with an operation that combines any two of its elements to form another element, in a way that satisfies certain axioms (closure, associativity, identity, inverses). Examples of groups include the set of rotations in 3D space (SO(3)) or the group of symmetries of a square (the dihedral group D4). Each of these transformations can be viewed as an operation in the group.


Why Are Symmetries Important in Physics and ML?#

In physics, fundamental principles like Noether’s theorem link symmetries to conservation laws (e.g., translational symmetry �?conservation of momentum, rotational symmetry �?conservation of angular momentum). Thus, it’s no accident that many of our most powerful physical theories, from classical mechanics to quantum field theory, revolve around symmetry.

In machine learning—especially deep learning—exploiting symmetry helps in two major ways:

  1. Data Efficiency: If a model is designed to be invariant or equivariant under certain transformations, it can learn more efficiently from fewer samples. For instance, convolutional neural networks (CNNs) exploit translational invariance by using shared filters across an image, leading to significantly fewer learnable parameters compared to naive fully connected networks.

  2. Regularization and Generalization: Symmetry can serve as a form of structural regularization. By design, the model obeys constraints that reflect the underlying organization of its input or the physical reality it aims to replicate. This leads to better performance when extrapolating to unseen data or more complex system states.

The new wave of physics-inspired deep learning aims to generalize these concepts to more sophisticated symmetries (rotations, reflections, permutations, continuous gauge transformations, etc.), as well as incorporate actual physical equations (like partial differential equations) into a neural network’s architecture or training objective.


Models Inspired by Symmetries#

Classical CNNs and Translational Symmetry#

The first big success in leveraging symmetry in deep learning was provided by convolutional neural networks (CNNs). By moving a “convolutional kernel�?across an image, the network outputs features that remain meaningful regardless of where an object is located in the image. This explicitly uses the group of translations (in 2D images). CNNs have been the workhorse of computer vision tasks for years, demonstrating that capturing even a single type of symmetry (translational) can be extraordinarily profitable.

Group Equivariant CNNs#

Group Equivariant CNNs (G-CNNs) generalize translational convolution to other symmetry groups (e.g., rotations, flips). Instead of applying the same kernel to just different translations of the data, these networks apply specialized kernels to rotations, reflections, or even more general transformations. By doing so, they capture invariances in a structured way.

Physics-Informed Neural Networks (PINNs)#

G-CNNs focus on symmetry in the architecture. Another line of thought, Physics-Informed Neural Networks (PINNs), enforces physical constraints (e.g., the Navier–Stokes equations for fluid flow, or Maxwell’s equations for electromagnetism) on the training process. PINNs can discover solutions to differential equations or train with significantly less real-world data, leveraging known forms of physical laws as constraints.

Lie-Parameterized Neural Networks (Gauge Symmetries)#

For more advanced tasks, some network designs explicitly incorporate Lie group constraints, relevant for gauge theories in physics (as in electromagnetism or more advanced quantum field theories). These advanced networks enforce local group symmetries, or gauge symmetries, which broaden the concept of rotation evaluations at different points in space-time.


Breaking Down Equivariance and Invariance#

Much of the magic in symmetry-based deep learning can be captured by two phenomena:

  1. Invariance: A function ( f ) is invariant under a group transformation ( g ) if ( f(g \cdot x) = f(x) ). For example, if you rotate an image of a cat, you still want the classifier to recognize it as a cat.

  2. Equivariance: A function ( f ) is equivariant under a group transformation ( g ) if ( f(g \cdot x) = g’ \cdot f(x) ) for some possibly related transformation ( g’ ). For instance, in a rotation-equivariant layer, rotating an input might result in rotating the feature maps in a meaningful way (rather than losing or changing the interpretation).

CNNs are translationally equivariant layers that naturally yield translation-invariant global features (e.g., after pooling). Through carefully designed convolution-like operations, G-CNNs can become rotation- or reflection-equivariant.


Introduction to Group Theory for Machine Learning#

Before diving further, it helps to briefly recap some group theory concepts. We’ll keep it simple here, though you can find entire textbooks on the subject.

  • Group Elements (( g )): These are the “actions�?you can perform (like rotate by 90°, reflect across an axis, or more generally a transformation in a Lie group).
  • Identity Element (( e )): The “do nothing�?transformation.
  • Inverse (( g^{-1} )): The operation that “undoes�?( g ).
  • Closure: If ( a ) and ( b ) are elements in the group, then ( a \circ b ) is also in the group.
  • Associativity: ( (a \circ b) \circ c = a \circ (b \circ c) ).

For continuous symmetries (like rotations in 3D), you typically deal with Lie groups and their generating Lie algebras. In constructing equivariant neural networks, we identify the transformations that data might undergo—like rotations in images, or permutations in sets—and build them into the design so that the network’s output respects or utilizes these transformations appropriately.

Below is a brief table illustrating some common groups and their typical use-cases in machine learning:

Group NameSymbolTypeExample of Application
Translation(\mathbb{R}^n)ContinuousCNNs (2D translations for images)
RotationSO(n)Continuous, Lie3D object recognition, molecule analysis
ReflectionO(n)DiscreteMirror symmetry for images/models
PermutationS(n)DiscreteGraph neural networks on sets
DihedralDnDiscrete2D symmetrical shapes (e.g., polygons)
Gauge GroupsSU(N)Continuous, LieQuantum field theories, advanced ML

Physics-Informed Neural Networks (PINNs)#

Physics-Informed Neural Networks aim to incorporate known physical laws or equations, like partial differential equations (PDEs), directly into the training objective. For instance, if a PDE (like the Navier–Stokes equation) describes fluid flows, a PINN will embed that PDE in the loss function. The network is then penalized not just for deviating from training data, but also for deviations from that PDE. This approach can:

  1. Reduce the need for large labeled datasets, especially when data is expensive or scarce to collect.
  2. Encourage physically consistent solutions without needing to manually enforce boundary or continuity conditions across domain boundaries.

Example: Solving the Poisson Equation with a PINN#

Consider the Poisson equation in 2D: [

  • \nabla^2 u(x, y) = f(x, y) ] with boundary conditions ( u = 0 ) on the domain boundary. A PINN for this scenario might involve these steps:
  1. Architecture: A feedforward neural network taking ((x, y)) as input and outputting (u).
  2. Loss Function:
    • Physics Loss: The PDE residual (\left| -\nabla^2 u - f(x, y) \right|^2).
    • Boundary Loss: The mismatch on boundary points ( \left| u_{\text{predicted}}(x_{\text{b}}, y_{\text{b}}) - 0 \right|^2).
    • (Optional) Data Loss: If some ground truth (u) is known at certain interior points, incorporate it too.

The total loss is a weighted sum: (\mathrm{Loss} = \alpha \cdot \mathrm{PhysicsLoss} + \beta \cdot \mathrm{BoundaryLoss} + \gamma \cdot \mathrm{DataLoss}).

Below is a simplified code snippet in Python (using a pseudo deep learning interface) that demonstrates the general structure of a PINN:

import numpy as np
import torch
import torch.nn as nn
# Define our network
class PoissonPINN(nn.Module):
def __init__(self, hidden_units=32):
super(PoissonPINN, self).__init__()
self.layers = nn.Sequential(
nn.Linear(2, hidden_units),
nn.ReLU(),
nn.Linear(hidden_units, hidden_units),
nn.ReLU(),
nn.Linear(hidden_units, 1) # Output is u(x, y)
)
def forward(self, x):
return self.layers(x)
# PDE residual function
def poisson_residual(u_pred, coords, f_func):
# coords is shape [N, 2] with x, y
# We'll approximate the Laplacian with autodiff:
# u_pred is shape [N, 1]
x = coords[:, 0].requires_grad_(True)
y = coords[:, 1].requires_grad_(True)
u = pinn(torch.stack([x, y], dim=1))
# Gradient of u w.r.t x
grad_u_x = torch.autograd.grad(u, x,
torch.ones_like(u),
create_graph=True)[0]
# Gradient of u w.r.t y
grad_u_y = torch.autograd.grad(u, y,
torch.ones_like(u),
create_graph=True)[0]
# Second derivatives
grad_u_xx = torch.autograd.grad(grad_u_x, x,
torch.ones_like(grad_u_x),
create_graph=True)[0]
grad_u_yy = torch.autograd.grad(grad_u_y, y,
torch.ones_like(grad_u_y),
create_graph=True)[0]
laplacian = grad_u_xx + grad_u_yy
# PDE: -laplacian(u) - f(x, y) = 0
return (-laplacian - f_func(x, y))**2
# Example f(x, y)
def f_func(x, y):
return x * 0 + y * 0 + 1.0 # a constant for simplicity
# Instantiate the PINN
pinn = PoissonPINN(hidden_units=32)
optimizer = torch.optim.Adam(pinn.parameters(), lr=1e-3)
# Example training data
num_points = 1000
xy_inside = torch.rand(num_points, 2)
xy_boundary = torch.rand(num_points, 2) # Suppose we know boundary points
for epoch in range(1000):
optimizer.zero_grad()
# Physics loss
physics_loss = poisson_residual(None, xy_inside, f_func).mean()
# Boundary loss (u should be 0)
u_pred_boundary = pinn(xy_boundary)
boundary_loss = torch.mean(u_pred_boundary**2)
total_loss = physics_loss + boundary_loss
total_loss.backward()
optimizer.step()
if epoch % 100 == 0:
print(f"Epoch {epoch}, Loss: {total_loss.item():.4e}")

This snippet is a toy example, but it demonstrates the concept of enforcing physical laws via the PDE residual in the loss function. As you expand your approach to real-world PDEs or more complicated domains, the same principles will apply.


Equivariant Neural Networks from the Ground Up#

Equivariant neural networks (E-Nets) focus on ensuring that certain transformations of the input lead to predictable transformations of the output. Key subsets of these networks include:

Group Equivariant Convolutional Networks (G-CNN)#

  • Definition: For an input image, transformations from a group ( G ) (e.g., rotations, reflections) are applied, and the CNN’s convolution kernels are designed to handle those transformations in a structured manner.
  • Advantages: They require fewer parameters for the same expressive power and are more robust in tasks where orientation or viewpoint changes are common.

Permutation Equivariant Networks#

  • Applications: Commonly used in set-based or graph-based data. These networks are built so that permuting the elements of the input set results in a corresponding permutation of output indices.
  • Key Idea: Using sum or mean pooling can achieve permutation invariance, while specialized layers can ensure permutation equivariance.

O(3)-Equivariant Networks for 3D#

  • Use-Case: Common in computational chemistry (molecular property prediction) and 3D shape analysis. For molecular data, we want the network’s output to be invariant (e.g., total energy) or equivariant (e.g., forces) under rotations and translations in 3D space.

Getting Started with Implementations#

Building equivariant layers from scratch can be rather technical, but various libraries and frameworks have emerged to simplify it. Below are a few:

  • E2CNN (PyTorch): For 2D rotational/reflectional equivariante convolutions.
  • Escnn (PyTorch): Another library for group equivariant neural networks in PyTorch.
  • LieConv: For continuous group convolutions (handling 2D, 3D rotations).
  • Pytorch Geometric: Not purely “equivariant�?but offers advanced GNN frameworks which you can adapt with group or permutation equivariances.

Here’s an example snippet using a hypothetical e2cnn-style interface for building a rotation-equivariant convolutional layer:

import e2cnn
from e2cnn import gspaces
from e2cnn import nn as e2nn
# Define the group of rotations by 4 distinct angles: 0°, 90°, 180°, 270°
r2_act = gspaces.Rot2dOnR2(N=4)
# Input feature type: 1-channel scalar field
in_type = e2nn.FieldType(r2_act, [r2_act.trivial_repr])
# Output feature type: 16 channels, each being a regular representation
out_type = e2nn.FieldType(r2_act, 16 * [r2_act.regular_repr])
# Build an equivariant convolution
conv = e2nn.R2Conv(in_type, out_type, kernel_size=3, padding=1, bias=False)
# Example forward usage
import torch
x = torch.randn(1, 1, 32, 32) # batch=1, channels=1, 32x32 image
x_g = e2nn.GeometricTensor(x, in_type)
y_g = conv(x_g)
y = y_g.tensor # shape: [1, 16 * size_of_rep, 32, 32]

This example sets up a rotationally equivariant convolution for an image. Under the hood, it manipulates filters so that rotating the input image yields a corresponding rotation in the output feature maps.


Advanced Techniques for Professionals#

Once you have a solid grasp of the fundamentals, you can level up with the following techniques:

1. Combining PINNs with Equivariance#

Imagine you are modeling a physical system governed by PDEs, like fluid flows around an object with inherent rotational symmetry. You could combine the PDE constraints from PINNs with rotational-equivariant architectures to drastically reduce the complexity of your problem. For instance, reflecting or rotating boundary conditions might reduce the domain you need to model.

2. Gauge Equivariant Neural Networks#

Gauge symmetries appear in electromagnetism, quantum chromodynamics, and more. A gauge transformation might vary from point to point in your domain, but the physical observables remain invariant. Building neural networks that incorporate these gauge symmetries allows for stable generalization and physically meaningful representations—particularly relevant in advanced scientific computing and partial differential equation solving.

3. Lie Transformer and Continuous Symmetries#

Transformers have gained considerable traction in recent years. Researchers are exploring how to build Lie Transformers that incorporate transformations from continuous groups. They might replace standard self-attention with a layer that is equivariant under rotations or translations. This approach stands to benefit scenarios where attention-based models (like in natural language processing or 3D geometry tasks) meet continuous group symmetries.

4. Neural Operators (DeepONet, FNO)#

A growing field is focusing on Neural Operators, which map function spaces to function spaces. These handle infinite-dimensional analogs of data, capturing entire fields (like temperature or velocity profiles) rather than discrete points. Frameworks like Deep Operator Networks (DeepONet) or Fourier Neural Operators (FNO) have soared in popularity for solving PDEs quickly. They often embed or can be combined with symmetry considerations, ensuring that the operator respects the underlying symmetries of the physical system.

5. Uncertainty Quantification and Bayesian Approaches#

Real physical systems are seldom deterministic. Combining physics-based priors, group symmetries, and Bayesian inference can yield robust, interpretable models that provide uncertainty estimates—crucial for high-stakes domains like aerospace engineering, seismology, or medical imaging.


Example Code: Building a Simple 2D Equivariant Network#

Below is a more expanded code example demonstrating how you might build a rotation-equivariant network for a simple classification task on 2D images using the e2cnn Python library. This code is conceptual and might need adaptation to run directly.

import torch
import torch.nn as nn
import torch.optim as optim
from e2cnn import gspaces
from e2cnn import nn as e2nn
class EquivariantNet(nn.Module):
def __init__(self, N=4, in_channels=1, out_classes=10):
super(EquivariantNet, self).__init__()
# Rotations by 0°, 90°, 180°, 270°
r2_act = gspaces.Rot2dOnR2(N=N)
# Define input and output field types
in_type = e2nn.FieldType(r2_act, in_channels * [r2_act.trivial_repr])
mid_type = e2nn.FieldType(r2_act, 16 * [r2_act.regular_repr])
out_type = e2nn.FieldType(r2_act, 32 * [r2_act.regular_repr])
# Layers
self.block1 = e2nn.SequentialModule(
e2nn.R2Conv(in_type, mid_type, kernel_size=3, padding=1, bias=False),
e2nn.ReLU(mid_type, inplace=True),
e2nn.PointwiseAvgPool(mid_type, kernel_size=2, stride=2)
)
self.block2 = e2nn.SequentialModule(
e2nn.R2Conv(mid_type, out_type, kernel_size=3, padding=1, bias=False),
e2nn.ReLU(out_type, inplace=True),
e2nn.PointwiseAvgPool(out_type, kernel_size=2, stride=2)
)
# Final fully connected layer operates on trivial representaion
# after pooling or flattening.
# We'll do global average pooling to get an invariant descriptor
self.gpool = e2nn.GroupPooling(out_type)
# Once we have pooled, the representation is trivial -> single channel
# But overall channel dimension is out_type.size
self.linear = nn.Linear(32, out_classes)
def forward(self, x):
x_g = e2nn.GeometricTensor(x, self.block1[0].in_type)
x_g = self.block1(x_g)
x_g = self.block2(x_g)
# Global pooling over the spatial dimensions to get 1x1
x_pooled = x_g.tensor.mean(dim=[2, 3]) # shape: [batch, channel]
# Now group pool to remove group dimension -> shape: [batch, 32]
x_pooled_g = e2nn.GeometricTensor(x_pooled.unsqueeze(-1).unsqueeze(-1), self.block2[-1].out_type)
x_gpooled = self.gpool(x_pooled_g).tensor.squeeze(-1).squeeze(-1)
# Classification
logits = self.linear(x_gpooled)
return logits
# Usage Example:
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = EquivariantNet().to(device)
optimizer = optim.Adam(model.parameters(), lr=1e-3)
criterion = nn.CrossEntropyLoss()
# Suppose train_loader yields (images, labels), where images shape: [B, 1, 28, 28]
for epoch in range(10):
for images, labels in train_loader:
images = images.to(device)
labels = labels.to(device)
optimizer.zero_grad()
logits = model(images)
loss = criterion(logits, labels)
loss.backward()
optimizer.step()
print(f"Epoch {epoch}, Loss: {loss.item():.4f}")

Key Takeaways of This Example#

  • We used the Rot2dOnR2(N=4) group from e2cnn to build a network that is equivariant to 4 discrete rotations.
  • Each convolution changes the field type (number and type of channels).
  • GroupPooling leads to a globally invariant descriptor, suitable for classification.

Further Directions and Conclusion#

Learning Symmetries from Data#

Although we have described how to hard-code known symmetries into a network, an ongoing area of research is learning symmetries directly from data. For example, if you do not know the true transformation group that preserves your data distribution, you might try to discover it automatically. These approaches typically involve:

  • Generative modeling frameworks that decode latent variables in a way that unrolls transformations observed in the dataset.
  • Self-supervised learning tasks that guess transformation invariants, encouraging the model to learn or reveal the underlying group structure.

Extensions to Large-Scale Systems#

In big engineering problems—like climate modeling or nuclear fusion simulations—the synergy between data-driven learning and physics-based constraints holds enormous promise. The ability to handle multiscale phenomena while respecting physical invariances can substantially cut computational costs and provide breakthroughs in high-complexity scenarios.

Final Thoughts#

The pursuit of symmetries in neural networks, reminiscent of the search for symmetries in fundamental physics, seeks universality, efficiency, and truth. Models that intrinsically recognize physical laws or symmetrical structures can better generalize, require less data, and produce more trustworthy outputs in real-world applications.

In summary, the new wave of physics-inspired deep learning is about:

  1. Incorporating known transformations (translations, rotations, reflections, permutations, gauge transformations) into network architectures.
  2. Enforcing physical constraints (e.g., PDEs) in the training process to produce models that comply with real-world laws out of the box.
  3. Building robust, generalized solutions that scale to complex, potentially high-dimensional systems.

By mastering these techniques, you’ll be poised to contribute to cutting-edge research, tackle industrial-scale scientific problems, and perhaps discover new symmetries or principles along the way. The synergy of deep learning and physics is still in its infancy, and we can only imagine what revolutions await as these fields unite even further.

Chasing Symmetries: A New Wave of Physics-Inspired Deep Learning
https://science-ai-hub.vercel.app/posts/d2d33420-6ae5-4ebd-ada5-21085e0e03e9/8/
Author
Science AI Hub
Published at
2025-05-18
License
CC BY-NC-SA 4.0