pyhgf.utils.weight_initialisation.orthogonal_init#

pyhgf.utils.weight_initialisation.orthogonal_init(n_parents, n_children, gain=1.0, seed=None)[source]#

Orthogonal initialisation.

Takes the orthogonal factor of a random matrix’s SVD, scaled by gain. Every singular value is then exactly one, so the layer applies the same gain to every direction of its input rather than stretching some and squashing others. The returned vector is row-major over an (n_children, n_parents) matrix, which is the shape callers reshape it to. Orthogonality means W.T @ W = I when there are at least as many children as parents, so every input direction keeps its length. With fewer children than parents the layer is a projection and no matrix can preserve every direction; the best available is W @ W.T = I, which preserves length within the row space.

Parameters:
  • n_parents (int) – Number of parent (input) nodes — fan-in.

  • n_children (int) – Number of child (output) nodes — fan-out.

  • gain (float) – Multiplicative scaling factor (default 1.0). A norm-preserving nonlinearity would need none, but the ReLU family roughly halves the variance passing through it, so gain=sqrt(2) is the usual compensation.

  • seed (int | None) – Optional random seed for reproducibility.

Returns:

Weight vector of length n_parents * n_children, row-major over an (n_children, n_parents) matrix.

Return type:

numpy.ndarray