欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 人工智能 > pytorch >内容正文

pytorch

深度学习中常用的误差方法

发布时间:2025/3/21 pytorch 50 豆豆
生活随笔 收集整理的这篇文章主要介绍了 深度学习中常用的误差方法 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

深度学习中常用的误差方法有:

  • 标准差(Standard Deviation):

 标准差也叫均方差,是方差的算术平方根,反应数据的离散程度 ,标准差越小,数据偏离平均值越小,反之亦然 。

公式为:

python代码为:

import math#平均值 def get_average(records):return sum(records) / len(records)#方差 def get_variance(records):average = get_average(records)return sum([(x - average) ** 2 for x in records]) / len(records)#标准差 def get_standard_deviation(records):variance = get_variance(records)return math.sqrt(variance)
  • 均方误差MSE(mean-square error)

均方误差 反映估计量与被估计量之间的差异程度。MSE越小,预测结果月精确 。

公式为 :

 

python代码为:

def get_mse(records_real, records_predict):if len(records_real) == len(records_predict):return sum([(x - y) ** 2 for x, y in zip(records_real, records_predict)]) / len(records_real)else:return None
  • 均方根误差RMSE(root mean squared error)

均方根误差为均方误差的算术平方根。公式为:

python代码为:

def get_rmse(records_real, records_predict):mse = get_mse(records_real, records_predict)if mse:return math.sqrt(mse)else:return None
  • 平均绝对误差MAE(mean absolute error)

python代码为:

def get_mae(records_real, records_predict):if len(records_real) == len(records_predict):return sum([abs(x - y) for x, y in zip(records_real, records_predict)]) / len(records_real)else:return None

参考资料:

【1】https://blog.csdn.net/cqfdcw/article/details/78173839

【2】https://blog.csdn.net/mouday/article/details/87936476

总结

以上是生活随笔为你收集整理的深度学习中常用的误差方法的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。