平均绝对值误差 计算标签和预测之间的绝对差值的平均值。 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