I have a bunch of code written using Keras that was installed as a separate pip install and the import statements are written like from keras.models import Sequential
, etc..
On a new machine, I have Tensorflow installed which now includes Keras inside the contrib directory. In order to keep the versions consistent I thought it would be best to use what's in contrib instead of installing Keras separately, however this causes some import issues.
I can import Keras using import tensorflow.contrib.keras as keras
but doing something like from tensorflow.contrib.keras.models import Sequential
gives ImportError: No module named models, and from keras.models import Sequential
gives a similar ImportError: No module named keras.models.
Is there a simple method to get the from x.y import z
statements to work? If not it means changing all the instances to use the verbose naming (ie.. m1 = keras.models.Sequential()
) which isn't my preferred syntax but is do-able.