corewise_stack_norm =================== .. py:function:: t3toolbox.corewise.corewise_stack_norm(X, n_stack) .. code-block:: python 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 :py:func:`corewise_norm`, but vectorized over the leading ``n_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``, matching :py:func:`corewise_norm`). It is the ``sqrt`` of the per-slice :py:func:`corewise_stack_dot` of ``X`` with itself. Use this (not :py:func:`corewise_norm`, which collapses *every* axis including the stack) for a vectorized norm. .. rubric:: 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]