简体   繁体   English

如何规范化 3D 数组

[英]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.我有一个用户定义长度的 3D numpy 数组,但我不知道如何对其进行标准化。 The usual packages such as numpy and scipy only accept 2D arrays so i'm a bit stumped.通常的包,如 numpy 和 scipy 只接受二维数组,所以我有点难住。 The code for my numpy array can be seen below.我的 numpy 数组的代码可以在下面看到。 Matrix=np.zeros((a,a,a)) Where a is a user define value Matrix=np.zeros((a,a,a))其中 a 是用户定义的值

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尝试使用上面的代码,也参考 MatLab 代码https://in.mathworks.com/matlabcentral/answers/364721-how-to-normalize-3d-array-with-negative-and-positive-values-to-values -1 和 1 之间

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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