chanwcom
chanwcom

Reputation: 4650

How to use "keras" directly rather than to use "tensorflow.keras" in importing lines

I am trying to use a third party library that is using tensorflow and keras internally. I encountered one issue in using this library.

In that library, it is assumed that keras is available as a top-level module name.

For example, the following lines are frequently used inside this library.

from keras.layers import Dense

In my configuration, it is somewhat different, so I need to import lines as follows:

from tensorflow.keras.layers import Dense

Since that library is not that small, it is not efficient for me to manually edit all such lines. What would be the best way to resolve this problem?

Upvotes: 0

Views: 41

Answers (1)

Oluwafemi John
Oluwafemi John

Reputation: 66

You will need to install keras:

  • If you are using Windows or virtual environment: pip install keras

  • For Linux or Mac environment: sudo pip install keras

Then, afterwards you can use from keras.layers import Dense instead.

Upvotes: 1

Related Questions