Unable to import Keras(from TensorFlow 2.0) in PyCharm

前端 未结 2 1365
臣服心动
臣服心动 2020-12-17 23:05

I have just installed the stable version of TensorFlow 2.0 (released on October 1st 2019) in PyCharm.

The problem is that the keras package

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-17 23:56

    For PyCharm Users

    For those who use PyCharm. Install future (EAP) release 2019.3 EAP build 193.3793.14 from here. With that, you will be able to use autocomplete for the current stable release of TensorFlow (i.e. 2.0). I have tried it and it works :).

    For other IDEs

    For users with other IDEs, this will be resolved only after the stable version is released, which is anyways the case now. But this might take some more time for a fix. See the comment here. I assume it will be wise to wait and keep using version 2.0.0.b1. On the other hand avoid imports from tensorflow_core if you do not want to refactor your code in the future.

    Note: for autocomplete to work use import statement as below

    import tensorflow.keras as tk
    
    # this does not work for autocomplete 
    # from tensorflow import keras as tk  
    

    The autocomplete works for TensorFlow 2.0.0 on CPU version, but the autocomplete does not work for the GPU version.

提交回复
热议问题