InvariantBias#
- class InvariantBias(in_rep)[source]#
Bases:
ModuleModule parameterizing a learnable \(\mathbb{G}\)-invariant bias.
For representation space \(\mathcal{X}\), this module enforces \(\rho_{\mathcal{X}}(g)\mathbf{b}=\mathbf{b}\) for all \(g\in\mathbb{G}\). Hence only trivial-irrep coordinates in the irrep-spectral basis carry free parameters.
If the input representation does not contain the trivial irrep (no trivial/invariant subspace), the module behaves as the identity function.
Note
Runtime behavior depends on mode. In training mode (
model.train()), the invariant bias is recomputed each forward pass. In inference mode (model.eval()), the expanded invariant bias is cached and reused untilbias_dofchanges orinvalidate_cache()is called, which is faster. With the cache active, the forward path is the same computation as the standard symmetry-agnostic bias addinput + bwith fixedb.- in_rep#
Representation defining the symmetry action on \(\mathcal{X}\).
- Type:
- out_rep#
Same as
in_rep(bias acts in the same space).- Type:
- bias_dof#
Learnable trivial-subspace coefficients (present only if
has_bias=True).- Type:
Parameter
Construct the invariant bias module.
- Parameters:
in_rep (
Representation) – Representation \(\rho_{\text{in}}\) of the input space (same as output space).
- property bias#
Invariant bias; recomputed in training, cached otherwise.
- expand_bias()[source]#
Expand the learnable parameters into the invariant bias in the original basis.
- expand_bias_spectral_basis()[source]#
Return the invariant bias expressed in the irrep-spectral basis.