def custom_loss():
def loss(y_true, y_pred):
y_pred_new = K.tf.math.round(y_pred) #error thrown because of this statement
# other statements #
y_new = K.tf.math.subtract(y_pred_new, y_true)
# other statements #
return K.tf.math.reduce_sum(y_new)
return loss
我要构建的损失函数涉及四舍五入 最终乙状结肠层的预测为0或1。
K.tf.math.round显示以下错误:
ValueError:操作具有
None
用于渐变。请确定 您所有的操作都定义了渐变(即 可区分的)。不带渐变的常见操作:K.argmax,K.round, 埃瓦尔。
如何替换张量的舍入功能?或对此可以做什么?