Reputation: 1479
I used sklearn.preprocessing.normalize
before but I wonder there are other ways by Numpy (or something else) for L1-norm of matrix? Can we use numpy.linalg.norm(x, ord=None, axis=None, keepdims=False)
instead of sklearn
one?
According to the document, linalg.norm params seem not possible for matrix nor L1
x : array_like Input array. If axis is None, x must be 1-D or 2-D.
ord : {non-zero int, inf, -inf, ‘fro’, ‘nuc’}, optional
Upvotes: 0
Views: 802
Reputation: 2996
Yes. numpy.linalg.norm
is for Matrix or vector norm.
It depends on which kind of L1 matrix norm you want. You can specify it with argument ord
. (Doc)
numpy.linalg.norm(x, ord=None, axis=None, keepdims=False)
ord=inf
ord=0
ord=nuc
Upvotes: 1