xnn.common.models.ops#

Tensor operations shared across model families (gnn / cnn / dnn).

Kept here, at the models level, because they are common to more than one architecture type. Per-family helpers live under the family package instead (e.g. models/gnn/base.py), and graph-level reductions that every model needs live on InteratomicPotential (aggregate_energy).

Module Attributes

ATOMIC_MASSES

Standard atomic weights (u) by atomic number, Z = 0 to 99 (the ASE table), for center_of_mass().

Functions

build_triplets(edge_index, num_nodes)

Enumerate neighbour pairs (j, k) sharing a centre i.

cell_volume(cell)

Volume of row-vector cells (..., 3, 3) as the scalar triple product.

center_of_mass(pos, atomic_numbers, batch, ...)

Center of mass of every structure of a batch.

glorot_orthogonal_(weight[, scale])

Initialize a weight matrix as a (semi-)orthogonal matrix with Glorot variance.

make_activation(activation)

Return a fresh activation module from a name or a module instance.

scatter_sum(src, index, dim_size)

Sum rows of src into dim_size buckets given by index (dim 0).

segment_sum(x, lengths)

Sum of consecutive segments of x along dim 0; lengths (int64) sum to len(x).

shifted_softplus(x)

Shifted softplus ssp(x) = ln(0.5 e^x + 0.5) with ssp(0) = 0.

softplus_inverse(x)

Return y such that softplus(y) = x (x > 0, float or array).

structure_sum(src, index, dim_size)

Sum per-atom values into per-structure totals, accumulated in float64.

Classes

GaussianActivation(*args, **kwargs)

Gaussian activation exp(-x^2) (the original ANI-1 hidden activation).

ScaledTanh(*args, **kwargs)

1.59223 tanh(x), the scaled hyperbolic tangent of the RuNNer networks.

ShiftedSoftplus(*args, **kwargs)

Module form of shifted_softplus(), for use inside nn.Sequential.

Softplus(*args, **kwargs)

Softplus log(1 + e^x) evaluated exactly at every x, as max(x, 0) + log1p(e^-|x|).

Square(*args, **kwargs)

x^2.