RuntimeError: tf.summary.FileWriter is not compatible with eager execution. Use tf.contrib.summary

在使用TensorFlow时遇到错误:RuntimeError: tf.summary.FileWriter不兼容Eager Execution。有两种解决方案:1. 通过tf.disable_eager_execution()禁用Eager Execution,但此方法无法解决因启用Eager Execution引发的问题;2. 按照错误提示,改用tf.contrib.summary。有关tf.contrib.summary的文档可参考链接:http://man.hubwiz.com/docset/TensorFlow.docset/Contents/Resources/Documents/api_docs/python/tf/contrib/summary.html 和 http://tensorflow.biotecan.com/python/Python_1.8/tensorflow.google.cn/api_docs/python/tf/contrib/summary/image.html。
摘要由CSDN通过智能技术生成

 Here is my code:

tf.enable_eager_execution()
writer = tf.summary.FileWriter(result_path+'logs/')
for epoch in range(epochs):
    if step_count % 100 == 0:
                ref = tf.summary.image("G_ref/{}".format(step_count), image_batch, max_outputs=12)
                merge_sum = tf.summary.merge([ref])
                sum = sess.run(merge_sum)
                writer.add_summary(sum, step_count)
                writer.flush()

Error: 

Traceback (most recent call last):
  File "main.py", line 60, in <module>
    writer = tf.compat.v1.summary.FileWriter(result_path+'logs/')
  File "/home/jieyang/.conda/envs/tensorflow/lib/python3.7/site-packages/tensorflow_core/python/summary/writer/writer.py", line 360, in __init__
    "tf.summary.FileWriter is not compatible with eager execution. "
RuntimeError: tf.summary.FileWriter is not compatible with e
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值