我必须使用平均绝对误差实现一个损失函数,而不调用内置函数。下面的代码是否正确?因为我的损失值很快就从28.xx上升到0.00028。
同时,RMSE等其他损失函数具有更标准的损失曲线
loss = tf.reduce_sum(tf.abs(y_pred - Y) / nFeatures)
发布于 2019-05-31 20:45:16
您可以根据MAE公式实现自己的lost函数:
import tensorflow as tf
MAE = tf.reduce_mean(tf.abs(y_true - y_pred))
您还可以在此answer中查看自定义的损失函数
或
import numpy as np
MAE = np.average(np.abs(y_true - y_pred), weights=sample_weight, axis=0)
或
from tensorflow.python.ops import math_ops
MAE = math_ops.abs(y_true - y_pred)
https://stackoverflow.com/questions/56401346
复制相似问题