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

后端 未结 2 511
忘了有多久
忘了有多久 2020-12-11 15:11
>import tensorflow

>import tensorflow.contrib

>tensorflow.contrib

module \'tensorflow.contrib\' from \'D:\\\\ProgramData\\\\Anaconda3\\\\lib\\\\site-pack         


        
相关标签:
2条回答
  • 2020-12-11 15:43

    tensorflow.__init__() explicitly deletes its reference to the tensorflow.python module after importing everything from it.

    The reason for that is to provide access to the submodules contained in the python package in the top-level tensorflow namespace. A few things from the tensorflow.core package are also imported and made available in the tensorflow namespace.

    I think that the idea is not to import tensorflow.python directly. Those classes, objects, and submodules of python that are intended to be used by applications are made available simply by import tensorflow.

    0 讨论(0)
  • 2020-12-11 15:52

    Worked for me by using the following import line:

    from tensorflow.python import keras
    

    Cheers!

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