Debugging 在keras中显示或保存中间图像张量

Debugging 在keras中显示或保存中间图像张量,debugging,tensorflow,keras,Debugging,Tensorflow,Keras,我正在调试一个自定义的损失函数,我想在目标函数的中间计算步骤中可视化生成的图像。tf_summary_图像或简单的imshow将是完美的,但如果没有使用适当的提要调用sess.run(),则摘要将无法工作。为简单起见,假设我有: def custom_objective(y_pred, y_true): diff = y_pred - y_true #Here I would need something to save and/or show the diff image

我正在调试一个自定义的损失函数,我想在目标函数的中间计算步骤中可视化生成的图像。tf_summary_图像或简单的imshow将是完美的,但如果没有使用适当的提要调用sess.run(),则摘要将无法工作。为简单起见,假设我有:

def custom_objective(y_pred, y_true):
    diff = y_pred - y_true
    #Here I would need something to save and/or show the diff image
    square = K.square(diff)
    #Here I would need something to save and/or show the square image
    mean = K.mean(square, axis=-1)
    return mean

有什么建议吗?

您能发布在使用自定义损耗运行模型时出现的错误吗?我没有收到错误,我只想分析一些中间输出,因为我的损耗没有减少,所以我想看看计算中是否有错误