The following gives error:
print numpy.linalg.norm(2) # returns 2
print numpy.linalg.norm(2, np.inf) # returns error,
print numpy.linalg.norm(2, np.inf) # returns the same error:
ValueError: Improper number of dimensions to norm.
How can I use the above norm with non numpy array input?
As the doc string states:
In [165]: np.linalg.norm?
Definition: np.linalg.norm(x, ord=None, axis=None)
...
Parameters
----------
x : array_like
Input array. If `axis` is None, `x` must be 1-D or 2-D.
the first argument to norm
should be an array_like object. Therefore use
In [167]: np.linalg.norm([2], np.inf)
Out[167]: 2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With