AttributeError

错误:

AttributeError Traceback (most recent call last) in () 1 sess = tf.Session()----> 2 writer = tf.train.SummaryWriter("logs/,sess.graph")AttributeError: module 'tensorflow.python.training.training' has no attribute 'SummaryWriter'

解决:

这是因为在1.0版本中,tf.train.SummaryWriter已经改为tf.summary.FileWriter


错误:

In [21]: sub = tf.sub(x,a)---------------------------------------------------------------------------AttributeError Traceback (most recent call last)in()

----> 1 sub = tf.sub(x,a)

AttributeError: module 'tensorflow' has no attribute 'sub'

解决:

改成:sub = tf.subtract(x,a)


错误:

AttributeError: module 'tensorflow' has no attribute 'histogram_summary'

解决:

改成:tf.summary.histogram()


错误:

AttributeError: module 'tensorflow' has no attribute 'scalar_summary'

解决:

改成:tf.summary.scalar('loss',loss)


错误:

AttributeError: module 'tensorflow' has no attribute 'merge_all_summaries'

解决:

改成:tf.summary.merge_all()



错误:

---------------------------------------------------------------------------AttributeError Traceback (most recent call last) in ()----> 1 with tf.Session as sess: 2 sess.run(init) 3 for _ in range(3): 4 sess.run(update) 5 print(sess.run(state))AttributeError: __exit__


解决:

把 with tf.Session as sess: 改成 sess = tf.Session() 


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容