tfmri.math.normalize_no_nan
tfmri.math.normalize_no_nan¶
- normalize_no_nan(tensor, ord='euclidean', axis=None, name=None)[source]¶
Normalizes
tensoralong dimensionaxisusing specified norm.- Parameters
tensor – A
Tensorof typefloat32,float64,complex64,complex128.ord –
Order of the norm. Supported values are
'fro','euclidean',1,2, np.inf and any positive real number yielding the corresponding p-norm. Default is'euclidean'which is equivalent to Frobenius norm iftensoris a matrix and equivalent to 2-norm for vectors. Some restrictions apply: a) The Frobenius norm'fro'is not defined forvectors, b) If axis is a 2-tuple (matrix norm), only
'euclidean', ‘fro',1,2, np.inf are supported. See the description ofaxison how to compute norms for a batch of vectors or matrices stored in a tensor.axis –
If
axisis None (the default), the input is considered a vector and a single vector norm is computed over the entire set of values in the tensor, i.e.norm(tensor, ord=ord)is equivalent tonorm(reshape(tensor, [-1]), ord=ord). Ifaxisis a Python integer, the input is considered a batch of vectors, andaxisdetermines the axis intensorover which to compute vector norms. Ifaxisis a 2-tuple of Python integers it is considered a batch of matrices andaxisdetermines the axes intensorover which to compute a matrix norm. Negative indices are supported. Example: If you are passing a tensor thatcan be either a matrix or a batch of matrices at runtime, pass
axis=[-2,-1]instead ofaxis=Noneto make sure that matrix norms are computed.name – The name of the op.
- Returns
A normalized
Tensorwith the same shape astensor.