A network trained on a long sequence of tasks can lose the ability to learn new ones. Three diagnostics track it: the fraction of dormant units, the effective rank of a layer's features, and the growth of the weight norm. Implement them on a matrix of hidden activations.
dormant_ratio(H, tau)
H is an (N, U) array of post-activation values of one layer over inputs. The score of unit is its mean absolute activation divided by the mean of those means over all units: . If every unit has mean absolute activation zero, every score is 0.(ratio, dormant_indices): the fraction of dormant units as a Python float and the sorted list of their indices.effective_rank(H, eps=1e-12)
H, take the singular values of the centred matrix, normalise them to (ignoring values below eps), and return as a Python float. If all singular values are below eps, return 0.0.plasticity_report(H, W, tau, decimals=4)
W is the layer's weight matrix of any shape. Return a dict with keys "dormant_ratio", "effective_rank", "weight_norm" (the Frobenius norm of W), rounded to decimals.np.abs(H).mean(axis=0) gives one number per unit; the normaliser is its mean.np.linalg.svd(Hc, compute_uv=False) returns the singular values directly.