![]()
使用
tf.get_default_session().run(self.train_op,..., )
时候返回:‘NoneType‘ object has no attribute ‘run‘的错误,这是因为使用了
sess = tf.Session(config=config)
应该使用:
sess = tf.InteractiveSession(config=config)
因为:Unlike tf.InteractiveSession, a tf.Session becomes a default only inside with block (it's a context manager):

参考文献为:
本文解释了在使用tf.get_default_session().run()时遇到的'NoneType'对象无run属性错误,并指导读者如何从交互式会话而非普通会话中正确执行操作。关键在于理解tf.InteractiveSession与tf.Session的区别及其在with块中的应用。
1457

被折叠的 条评论
为什么被折叠?



