tf.keras.losses.MeanAbsoluteError 损失函数 示例

平均绝对值误差

计算标签和预测之间的绝对差值的平均值。‎

在这里插入图片描述

import tensorflow as tf
y_true = [[0., 1.], [0., 0.]]
y_pred = [[1., 1.], [1., 0.]]
# Using 'auto'/'sum_over_batch_size' reduction type.
mae = tf.keras.losses.MeanAbsoluteError()
mae(y_true, y_pred).numpy()
0.5

猜你喜欢

转载自blog.csdn.net/weixin_44493841/article/details/121512085
今日推荐