mindquantum.utils.normalize
- mindquantum.utils.normalize(vec_in, axis=0)[source]
Normalize the input vectors based on specified axis.
- Parameters
vec_in (Union[list[number], numpy.ndarray]) – Vector you want to normalize.
axis (int) – Along which axis you want to normalize your vector. Default:
0
.
- Returns
numpy.ndarray, Vector after normalization.
Examples
>>> from mindquantum.utils import normalize >>> vec_in = np.array([[1, 2, 3], [4, 5, 6]]) >>> normalize(vec_in) array([[0.24253563, 0.37139068, 0.4472136 ], [0.9701425 , 0.92847669, 0.89442719]]) >>> normalize(vec_in, 1) array([[0.26726124, 0.53452248, 0.80178373], [0.45584231, 0.56980288, 0.68376346]])