InvariantConstraint#

class InvariantConstraint(rep)[source]#

Bases: Module

Orthogonally project vectors onto \(\mathrm{Fix}(\rho)\).

For representation \(\rho_{\mathcal{X}}\), this parametrization enforces

\[\mathbf{b} \in \mathrm{Fix}(\rho_{\mathcal{X}}) = \{\mathbf{v}\in\mathcal{X}: \rho_{\mathcal{X}}(g)\mathbf{v}=\mathbf{v},\ \forall g\in\mathbb{G}\},\]

by applying \(\mathbf{P}_{\mathrm{inv}}\) from invariant_orthogonal_projector().

Note

Runtime behavior depends on mode. In training mode (model.train()), the projection is recomputed each forward pass. In inference mode (model.eval()), the projected output is cached for the same unchanged input tensor (same object identity and version counter), which is faster. With the cache active, the operation is equivalent to a symmetry-agnostic fixed linear map \(\mathbf{b}\mapsto\mathbf{P}_{\mathrm{inv}}\mathbf{b}\).

Parameters:

rep (Representation)

rep#

Representation \(\rho\) whose action defines invariance, dimension rep.size.

Type:

Representation

inv_projector#

Orthogonal projector of shape (rep.size, rep.size) onto the fixed subspace \(\mathrm{Fix}(\rho)\).

Type:

Tensor

Precompute the invariant projector for the supplied representation.

forward(b)[source]#

Project b onto the invariant subspace using the precomputed projector.

Return type:

Tensor

Parameters:

b (Tensor)

invalidate_cache()[source]#

Clear cached projection so it is recomputed on next use.

Return type:

None

load_state_dict(state_dict, strict=True)[source]#

Load parameters and clear cached projected bias.

Parameters:

strict (bool)

right_inverse(tensor)[source]#

Return a parameter tensor whose projection equals tensor.

Return type:

Tensor

Parameters:

tensor (Tensor)