corewise_stack_norm#
- t3toolbox.corewise.corewise_stack_norm(X, n_stack)#
def corewise_stack_norm( X: NDArrayTree, # tree; each leaf shape = stack_shape + (core dims) n_stack: int, # number of leading stack axes kept (one norm per stack slice) ) -> NDArray: # array of shape = common stack_shape (scalar when n_stack==0)
Like
corewise_norm(), but vectorized over the leadingn_stack(stack) axes.Returns an array of shape equal to the common leading stack shape – one norm per stack slice (a scalar when
n_stack == 0, matchingcorewise_norm()). It is thesqrtof the per-slicecorewise_stack_dot()ofXwith itself. Use this (notcorewise_norm(), which collapses every axis including the stack) for a vectorized norm.Examples
>>> import numpy as np >>> import t3toolbox.corewise as cw >>> X = (np.ones((2, 3)), np.ones((2, 4, 5))) # stack=(2,), then core axes >>> print(cw.corewise_stack_norm(X, 1)) # sqrt(3 + 20) per slice [4.79583152 4.79583152]
- Parameters:
X (NDArrayTree)
n_stack (int)
- Return type: