TensorFlow 'module' object has no attribute 'global_variables_initializer'

你。 提交于 2019-12-20 11:04:39

问题


I'm new to Tensorflow I'm running a Deep learning Assignment from Udacity on iPython notebook. link

And it has an error.

AttributeError                            Traceback (most recent call last)
`<ipython-input-18-3446420b5935>` in `<module>`()
  2 
  3 with tf.Session(graph=graph) as session:
----> 4   tf.global_variables_initializer().run()

AttributeError: 'module' object has no attribute 'global_variables_initializer'

Please help! How can I fix this? Thank you.


回答1:


In older versions, it was called tf.initialize_all_variables.




回答2:


Seems like you're using tensorflow 0.11 or older versions. If you see this git-commit, they replaced initialize_all_variables with global_variables_initializer.

So, either you can use initialize_all_variables or update to a newer version i.e. (0.12) or later.




回答3:


In Tensorflow 1.11 You can use both initialize_all_variables().run() or tf.global_variables_initializer()

  #tf.global_variables_initializer().run()
  tf.initialize_all_variables().run()

both of then works fine on



来源:https://stackoverflow.com/questions/40511562/tensorflow-module-object-has-no-attribute-global-variables-initializer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!