I'm trying to calculate the 3-norm of the matrix y here but I keep getting an error that says
ValueError: Invalid norm order for matrices.
This is the code that I tried
y = np.random.rand(5,1)
print(y)
p = 3
ly = npla.norm(y,p)
print('ly =',ly,)
I'm not sure how to go about calculating the 3-norm here so any help would be appreciated
You need to specify axis=0
in the norm
method since you have a 5x1 matrix and you want to calculate the norm over column 1.
If you would have just a python list, it would be okay without.
Cheers!
As seen in the norm documentation the standard inputs does not include order=3.
As stated in the post previous you need to add an axis parameter where x=0.
try:
np.linalg.norm(yourMatrix,3,axis=0)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.