deepmd.dpmodel.descriptor.dpa4c_nn.readout#
Fixed invariant readout for degree-wise DPA4C moments.
Classes#
Contract degree-wise moments into fixed O(3)-invariant features. |
Module Contents#
- class deepmd.dpmodel.descriptor.dpa4c_nn.readout.InvariantReadout(channels: int, lmax: int, *, precision: str = DEFAULT_PRECISION, trainable: bool = True, seed: int | list[int] | None = None)[source]#
Bases:
deepmd.dpmodel.NativeOPContract degree-wise moments into fixed O(3)-invariant features.
The readout carries no learned nonlinearity. Degrees one and two first pass through full-width residual channel maps, after which three fixed contractions are emitted: the exact channel Gram of every non-scalar degree, a Cartesian bispectrum over every O(3)-even degree triple, and the projected quartic
|Q_b v_a|^2. The scalar moments are prepended unchanged.- Parameters:
- channels
Scalar degree-zero channel width.
- lmax
Maximum angular degree.
- precision
Parameter precision.
- trainable
Whether the channel-alignment and probe projections are trainable.
- seed
Random seed reserved for the readout.
- call(moments: Any) Any[source]#
Build invariant features from flat degree-wise moments.
The output concatenates the scalar moments, the exact aligned Grams in degree order, the bispectrum in degree-triple order, and the projected quartic.
- Parameters:
- moments
Flat moment tensor with shape
(N, S), whereS = sum((2 * l + 1) * degree_channels[l]).
- Returns:
AnyInvariant features with shape
(N, get_dim_out()).
- build_grams(blocks: list[Any], xp: Any) list[Any][source]#
Build Frobenius-isometric exact channel Grams.
- build_bispectrum(projected: list[Any], xp: Any) tuple[list[Any], Any][source]#
Contract projected moments with fixed Cartesian Gaunt tensors.
- Parameters:
- projected
Probe-projected degree blocks. Entry
l - 1has shape(N, 2 * l + 1, bispectrum_ranks[l - 1]).- xp
Array namespace associated with
projected.
- Returns:
bispectrumIndependent cubic contractions grouped by degree triple.
quarticProjected
|Q_b v_a|^2values with shape(N, K_2 * K_1).
- contract_vector_tensor(vector: Any, packed_tensor: Any, xp: Any) tuple[Any, Any][source]#
Contract the
112triple and reuseQ_b v_afor the quartic.Both outputs are built from the same matrix-vector intermediate \(Q_bv_a\), so the quartic costs one extra reduction rather than a second contraction.
- Parameters:
- vector
Degree-one probes with shape
(N, 3, K_1).- packed_tensor
Degree-two probes with shape
(N, 5, K_2).- xp
Array namespace associated with the probes.
- Returns:
bispectrum_112Full ordered cubic contractions with shape
(N, K_1 * K_1 * K_2).quarticValues \(|Q_bv_a|^2\) with shape
(N, K_2 * K_1).
- contract_bispectrum(coupling: Any, value_1: Any, value_2: Any, value_3: Any, xp: Any) Any[source]#
Contract one angular coupling without backend-specific
einsum.- Parameters:
- coupling
Cartesian Gaunt tensor with shape
(2 * l1 + 1, 2 * l2 + 1, 2 * l3 + 1).- value_1
First degree block with shape
(N, 2 * l1 + 1, K_1).- value_2
Second degree block with shape
(N, 2 * l2 + 1, K_2).- value_3
Third degree block with shape
(N, 2 * l3 + 1, K_3).- xp
Array namespace associated with the degree blocks.
- Returns:
AnyOrdered contractions with shape
(N, K_1 * K_2 * K_3).
- get_dim_out() int[source]#
Return the geometric output width.
- Returns:
intScalar moments, aligned exact Grams, bispectrum probes, and the projected quartic.
- classmethod deserialize(data: dict[str, Any]) InvariantReadout[source]#
Deserialize an
InvariantReadout.- Parameters:
- data
Versioned dictionary produced by
serialize().
- Returns:
InvariantReadoutReconstructed readout with restored projections.