三维数组的归一化

二维数组的归一化

最初使用sklearn 的normalize 进行过归一化

from sklearn.preprocessing import normalize
fea_0 = normalize(fea_0, axis=0, norm='l1');
fea_1 = normalize(fea_1, axis=0, norm='l1')

但是其函数的具体解释里面

 Parameters
    ----------
    X : {array-like, sparse matrix} of shape (n_samples, n_features)
        The data to normalize, element by element.
        scipy.sparse matrices should be in CSR format to avoid an
        un-necessary copy.

shape (n_samples, n_features)只能进行二维数组的归一化
如果进行三维数组的归一化,一个是reshape成二维数组再reshape成三维数组
要么用for循环,讲三维数组切成很多个二维数组进行归一化再拼到一起

三维数组的归一化

import torch.nn.functional as f
f.normalize(input, p=2, dim=2)

你可能感兴趣的:(python,sklearn,机器学习)