TensorFlow 'module' object has no attribute 'global_variables_initializer'

前端 未结 4 582
日久生厌
日久生厌 2021-02-05 01:51

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

And it has an error.

AttributeError                         


        
相关标签:
4条回答
  • 2021-02-05 02:02

    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

    0 讨论(0)
  • 2021-02-05 02:12

    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.

    0 讨论(0)
  • 2021-02-05 02:28

    In Tensorflow 2.0 , it does away from session and switches to eager execution. You can still run your code using session if you refer to tf.compat library and disable eager execution. This command should do the work:

    tf.compat.v1.global_variables_initializer()
    
    0 讨论(0)
  • 2021-02-05 02:29

    In older versions, it was called tf.initialize_all_variables.

    0 讨论(0)
提交回复
热议问题