我有两个3d数组A A.shape=[335,71,57]
和B B.shape=[335,71,57]
,我用这种方法计算它们之间的均方根
rmse=sqrt(mean_squared_error(A,B))
当然,我得到了一个标量。怎么写才能得到rmse.shape=[335,71,57]
这样的另一个三维数组呢?实际上,我需要为数组中的每个位置获取一个rmse
值。
谢谢
发布于 2021-02-17 06:45:20
下面是一个例子:
A = np.random.rand(10,10,10)
B = np.random.rand(10,10,10)
mse = ((A-B)**2)
rmse = np.sqrt(mse)
第三行将得到每个元素的平方误差,最后一行将得到每个元素的根。
请注意,您要查找的不是MSE,因为MSE是平方误差的平均值,而您要查找的是每个项目。
通过添加mse = mse.mean(axis=ax)
,你可以得到你选择的轴上的平均值(在取根之前)。
例如:
A = np.random.rand(10,10,10)
B = np.random.rand(10,10,10)
mse = ((A-B)**2).mean(axis=0)
rmse = np.sqrt(mse)
将采用每行的RMSE。
https://stackoverflow.com/questions/66236344
复制相似问题