Numpy 中的均方误差? [英] Mean Squared Error in Numpy?
本文介绍了Numpy 中的均方误差?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
numpy 中是否有计算两个矩阵之间的均方误差的方法?
Is there a method in numpy for calculating the Mean Squared Error between two matrices?
我尝试过搜索,但没有找到.是用不同的名字吗?
I've tried searching but found none. Is it under a different name?
如果没有,你如何克服这个问题?你是自己写的还是使用不同的库?
If there isn't, how do you overcome this? Do you write it yourself or use a different lib?
推荐答案
您可以使用:
mse = ((A - B)**2).mean(axis=ax)
或
mse = (np.square(A - B)).mean(axis=ax)
- with
ax=0
沿行执行平均值,对于每一列,返回一个数组 - with
ax=1
沿列执行平均值,对于每一行,返回一个数组 - 使用
ax=None
沿数组按元素执行平均值,返回标量值 - with
ax=0
the average is performed along the row, for each column, returning an array - with
ax=1
the average is performed along the column, for each row, returning an array - with
ax=None
the average is performed element-wise along the array, returning a scalar value
这篇关于Numpy 中的均方误差?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文