From keras.engine. topology import network

What are the possible ways to install topology for Keras. Because the following import command gives error.

from keras.engine.topology import network

ModuleNotFoundError: No module named ‘keras.engine.topology’

This might depend on the Keras version you are using. Look into if the keras.engine.topology has depricated.

You can force install an earlier version by:
pip install 'keras==2.1.6' --force-reinstall
Where 2.1.6 is a suitable example. You may try
import tensorflow.python.keras.engine
But you will not be able to import topology from tensorflow.python.keras.engine .
Please refer to the answers in similar issue1, issue2.

1 Like

Thanks Sushree for the response!
I changed the Keras version and found the topology module under dist-package. I need to import Network from topology but it shows an error. Provided use used Network() in the later section of the code.

ImportError: cannot import name ‘Network’ from ‘keras.engine.topology’ (/usr/local/lib/python3.7/dist-packages/keras/engine/