numpy normalize matrix
def normalize(v):
norm = np.linalg.norm(v)
if norm == 0:
return v
return v / norm
0
5
import numpy as np
x= np.random.random((3,3))
print("Original Array:")
print(x)
xmax, xmin = x.max(), x.min()
x = (x - xmin)/(xmax - xmin)
print("After normalization:")
print(x)
Thank you!
5
0
Are there any code examples left?
New code examples in category Python