numpy中的均方误差? [英] Mean Squared Error in Numpy?

查看:911
本文介绍了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)

  • ax=0一起,沿着行执行平均值,对于每一列,返回一个数组
  • 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆