---
id: wiki-2026-0508-symmetry-and-invariance
title: Symmetry and Invariance
category: 10_Wiki/Topics
status: verified
canonical_id: self
aliases: [Equivariance, Group Equivariant Networks, Invariant ML]
duplicate_of: none
source_trust_level: A
confidence_score: 0.9
verification_status: applied
tags: [equivariance, group-theory, geometric-deep-learning, neural-network]
raw_sources: []
last_reinforced: 2026-05-10
github_commit: pending
tech_stack:
  language: python
  framework: pytorch
---

# Symmetry and Invariance

## 매 한 줄
> **"매 inductive bias 의 가장 powerful form"**. Physical / geometric world 의 symmetry (rotation, translation, permutation, scale) 을 architecture 에 baking → sample efficiency, generalization, interpretability 의 dramatic 개선. 2026 의 AlphaFold 3, EGNN, equivariant diffusion 의 mainstream.

## 매 핵심

### 매 invariance vs equivariance
- **Invariance**: f(g·x) = f(x) — 매 transformed input 의 output 의 동일.
- **Equivariance**: f(g·x) = g·f(x) — 매 input transform → output 의 same transform.
- 매 CNN 의 translation-equivariant (conv) + global pooling 의 translation-invariant.

### 매 group types
- **Translation** (T(d)): CNN 의 default.
- **Rotation** (SO(2), SO(3)): equivariant CNN (E(2)-CNN), spherical CNN.
- **Permutation** (S_n): GNN, DeepSets — 매 set / graph input.
- **Scale**: scale-equivariant network (less common).
- **Lorentz / Galilean**: physics-informed.

### 매 modern arch
- **EGNN** (Satorras 2021): E(n)-equivariant graph network — 매 molecule / particle.
- **AlphaFold 3** (2024): SE(3)-equivariant — 매 protein structure.
- **Equivariant diffusion** (e.g., DiffDock 2024): 매 SE(3)-equivariant noise/denoise.
- **Graph Transformers** (GraphGPS): 매 permutation equivariant.

### 매 응용
1. Drug discovery — 매 molecule rotation 의 same energy.
2. Protein folding (AlphaFold).
3. Particle physics — 매 Lorentz symmetry.
4. 3D vision, point cloud (PointNet permutation, SE(3)-Transformer).
5. Robotics manipulation — 매 pose-equivariant policy.

## 💻 패턴

### DeepSets (permutation-invariant)
```python
import torch
import torch.nn as nn

class DeepSets(nn.Module):
    def __init__(self, in_dim, hidden, out_dim):
        super().__init__()
        self.phi = nn.Sequential(nn.Linear(in_dim, hidden), nn.ReLU(),
                                  nn.Linear(hidden, hidden))
        self.rho = nn.Sequential(nn.Linear(hidden, hidden), nn.ReLU(),
                                  nn.Linear(hidden, out_dim))
    def forward(self, x):  # x: (batch, set_size, in_dim)
        return self.rho(self.phi(x).sum(dim=1))
```

### EGNN (E(n)-equivariant graph layer)
```python
class EGNNLayer(nn.Module):
    def __init__(self, hidden):
        super().__init__()
        self.edge_mlp = nn.Sequential(nn.Linear(2*hidden + 1, hidden), nn.SiLU(),
                                       nn.Linear(hidden, hidden))
        self.coord_mlp = nn.Sequential(nn.Linear(hidden, hidden), nn.SiLU(),
                                        nn.Linear(hidden, 1))
        self.node_mlp = nn.Sequential(nn.Linear(2*hidden, hidden), nn.SiLU(),
                                       nn.Linear(hidden, hidden))
    def forward(self, h, x, edge_index):
        i, j = edge_index
        diff = x[i] - x[j]
        dist = (diff ** 2).sum(-1, keepdim=True)
        e = self.edge_mlp(torch.cat([h[i], h[j], dist], dim=-1))
        x_new = x + (diff * self.coord_mlp(e)).index_add_(0, i, ...)
        h_new = h + self.node_mlp(torch.cat([h, e.sum_aggr(j)], dim=-1))
        return h_new, x_new
```

### Group convolution (rotation equivariance)
```python
# e2cnn library
from e2cnn import gspaces, nn as enn

r2_act = gspaces.Rot2dOnR2(N=8)  # 8 discrete rotations
in_type = enn.FieldType(r2_act, 3 * [r2_act.trivial_repr])
out_type = enn.FieldType(r2_act, 16 * [r2_act.regular_repr])

conv = enn.R2Conv(in_type, out_type, kernel_size=5)
# input rotated by 45° → output 의 45°-rotated counterpart
```

### Data augmentation as approximate equivariance
```python
import torchvision.transforms as T

aug = T.Compose([
    T.RandomRotation(180),
    T.RandomHorizontalFlip(),
    T.RandomVerticalFlip(),
])
# 매 cheap baseline — works but no strict guarantee
```

### SE(3)-Transformer attention (sketch)
```python
# se3-transformer-pytorch
from se3_transformer_pytorch import SE3Transformer

model = SE3Transformer(
    dim=64, heads=8, depth=4,
    num_degrees=2, valid_radius=10
)
# input: features + 3D coords; output equivariant under rotation+translation
```

### Invariance test (validation)
```python
def test_invariance(model, x, group_action):
    y = model(x)
    y_g = model(group_action(x))
    assert torch.allclose(y, y_g, atol=1e-5), "not invariant"

def test_equivariance(model, x, group_action):
    y = model(x)
    y_g = model(group_action(x))
    assert torch.allclose(group_action(y), y_g, atol=1e-5), "not equivariant"
```

## 매 결정 기준
| 상황 | Approach |
|---|---|
| 매 image (translation) | CNN |
| 매 set / graph | DeepSets / GNN |
| 매 molecule / 3D points | EGNN, SE(3)-Transformer |
| 매 protein structure | AlphaFold-style SE(3) |
| 매 quick baseline | data augmentation |
| 매 strict guarantee + small data | exact equivariant arch |

**기본값**: 매 small data + clear symmetry → equivariant arch. 매 large data → augmentation often sufficient.

## 🔗 Graph
- 부모: [[Geometric-Deep-Learning]] · [[Inductive-Bias]]
- 변형: [[EGNN]] · [[SE_3_-Transformer]] · [[Group-Convolution]]
- 응용: [[AlphaFold]] · [[DiffDock]] · [[Drug-Discovery]] · [[Point-Cloud]]
- Adjacent: [[Graph-Neural-Network]] · [[Transformer]] · [[Group-Theory]]

## 🤖 LLM 활용
**언제**: 매 scientific ML task 의 architecture choice (molecule, physics, geometry), 매 small-data regime 의 inductive bias 강화.
**언제 X**: 매 plain text / language (no clear geometric symmetry — Transformer permutation-equivariance 만 충분), 매 huge data + flat structure (augmentation OK).

## ❌ 안티패턴
- **매 augmentation 만 의존 (data scarce)**: 매 strict equivariance 의 generalize 더 잘함 — 매 sample efficiency.
- **Equivariant arch 의 over-engineering (data abundant)**: 매 large-data regime 에서 plain Transformer 가 따라잡음.
- **Approximate equivariance 의 unstated**: 매 floating-point + non-linearity 로 매 exact 가 깨질 수 있음 — 매 test_equivariance assertion 추가.

## 🧪 검증 / 중복
- Verified (Cohen & Welling 2016 Group Equivariant CNN; Satorras et al. 2021 EGNN; Bronstein et al. 2021 "Geometric Deep Learning"; Jumper et al. 2021/2024 AlphaFold 2/3).
- 신뢰도 A.

## 🕓 Changelog
| 날짜 | 변경 |
|---|---|
| 2026-05-08 | Phase 1 |
| 2026-05-10 | Manual cleanup — group theory + EGNN + SE(3) + AlphaFold context |
