我正在尝试使用def'tf.losses.mean_squared_error'。但是我越来越
NameError: name 'Reduction' is not defined
我正在使用TF 1.13。
是某些导入问题,还是tf.losses.mean_squared_error函数有任何更新?
我的代码如下。
def reg_loss(pred, GT):
loss = tf.losses.mean_squared_error(
labels = GT,
predictions = pred,
weights=1.0,
scope=None,
loss_collection=tf.GraphKeys.LOSSES,
reduction=Reduction.SUM_BY_NONZERO_WEIGHTS)
return reg_loss
谁能帮我解决这个问题?
最佳答案
使用tf.losses.Reduction.SUM_BY_NONZERO_WEIGHTS
这解决了我的问题。