【发布时间】:2020-04-04 13:45:58
【问题描述】:
我正在定义一个自定义损失函数。例如,让我们以loss function = L1 loss + L2 loss.
当我做model.fit_generator() 时,每批之后都会打印整体损失函数。但我想查看L1 loss 和L2 loss 的各个值。我怎样才能做到这一点?
我想知道各个术语的值以了解它们的相对比例。
tf.print(l1_loss, output_stream=sys.stdout)正在抛出异常,说tensorflow.python.eager.core._FallbackException: This function does not handle the case of the path where all inputs are not already EagerTensors.。即使
tf.print('---')也只是在开头打印---,而不是每批都打印。tf.keras.backend.print_tensor(l1_loss)没有打印任何内容
【问题讨论】:
-
您尝试过
sess.run(l1_loss)和sess.run(l2_loss),以及必要的feed_dicts? -
我使用的是 tensorflow 2.0。我正在使用
model.fit_generator()训练模型。sess.run()这里无处可做。
标签: python tensorflow logging tensorflow2.0 tf.keras