作者:穿脚蹼的鱼 | 来源:互联网 | 2023-08-27 13:14
ImtryingtoaddsomeTensorBoardloggingtoamodelwhichusesthenewtf.estimatorAPI.我正在尝试向使用
I'm trying to add some TensorBoard logging to a model which uses the new tf.estimator API.
我正在尝试向使用新的tf.estimator API的模型添加一些TensorBoard日志记录。
I have a hook set up like so:
我有一个类似这样的挂钩:
summary_hook = tf.train.SummarySaverHook(
save_secs=2,
output_dir=MODEL_DIR,
summary_op=tf.summary.merge_all())
# ...
classifier.train(
input_fn,
steps=1000,
hooks=[summary_hook])
In my model_fn
, I am also creating a summary
-
在我的model_fn中,我还创建了一个摘要。
def model_fn(features, labels, mode):
# ... model stuff, calculate the value of loss
tf.summary.scalar("loss", loss)
# ...
However, when I run this code, I get the following error from the summary_hook
: Exactly one of scaffold or summary_op must be provided.
This is probably because tf.summary.merge_all()
is not finding any summaries and is returning None
, despite the tf.summary.scalar
I declared in the model_fn
.
但是,当我运行这段代码时,我从summary hook中得到了以下错误:必须提供一个scaffold或summary_op。这可能是因为tf.summary.merge_all()没有找到任何摘要,也没有返回任何摘要,尽管有tf.summary。我在model_fn中声明的标量。
Any ideas why this wouldn't be working?
你知道为什么这行不通吗?
3 个解决方案