standardize#
- class brainstate.nn.standardize(x, axis=-1, variance=None, epsilon=1e-05, where=None)[source]#
Standardize (normalize) an array.
Normalizes an array by subtracting the mean and dividing by the standard deviation \(\sqrt{\mathrm{variance}}\).
- Parameters:
x (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – Input array.axis (
int|tuple[int,...] |None) – The axis or axes along which to compute the mean and variance. Default is -1.variance (
Array|ndarray|bool|number|bool|int|float|complex|Quantity|None) – Pre-computed variance. If None, variance is computed fromx.epsilon (
Array|ndarray|bool|number|bool|int|float|complex|Quantity) – A small constant added to the variance to avoid division by zero. Default is 1e-5.where (
Array|ndarray|bool|number|bool|int|float|complex|Quantity|None) – Elements to include in the computation.
- Returns:
Standardized array with the same shape as the input.
- Return type:
Array|Quantity