pyhgf.utils.weight_initialisation.sparse_init#
- pyhgf.utils.weight_initialisation.sparse_init(n_parents, n_children, sparsity=0.9, std=0.01, seed=None)[source]#
Sparse initialisation.
Most weights are set to zero; only a fraction
1 - sparsityof entries are drawn from \(\\mathcal{N}(0, \\text{std}^2)\).- Parameters:
n_parents (int) – Number of parent (input) nodes — fan-in.
n_children (int) – Number of child (output) nodes — fan-out.
sparsity (float) – Fraction of weights set to zero (default 0.9 → 90 % zeros).
std (float) – Standard deviation of the non-zero entries (default 0.01).
seed (int | None) – Optional random seed for reproducibility.
- Returns:
Weight vector of length
n_parents * n_children.- Return type:
numpy.ndarray