简体   繁体   中英

How to normalise a 3D array

I have a 3D numpy array of a user defined length and i don't know how to normalise it. The usual packages such as numpy and scipy only accept 2D arrays so i'm a bit stumped. The code for my numpy array can be seen below. Matrix=np.zeros((a,a,a)) Where a is a user define value

Why do you want to normalize an array with all zeros !

A = np.random.randn(2, 2, 2)
# A = np.zeros((2, 2, 2))
Amax = np.max(A)
Amin = np.min(A)
Range = Amax - Amin
Anrm = ((A - Amin)/Range - 0.5) * 2   

Try using the above code, also refer the MatLab code https://in.mathworks.com/matlabcentral/answers/364721-how-to-normalize-3d-array-with-negative-and-positive-values-to-values-between-1-and-1

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM