pythontensorflowkerascpu

import error keras.models Dense, LSTM, Embedding


I have trouble running the code from this this neural language model tutorial. It seems that I cannot import the relevant packages from keras.models although I have installed keras and tensorflow.

a) keras installed

b) TensorFlow installed

c) Spyder error message

I also tried to run the import command in the Windows console. There the error message says something about "the CPU supports instructions that this TensorFlow binary was not compiled to use".

d) Error message in windows console

Background info: I am using Spyer 3.2.3 and have installed python 3.6.0.

Could you please help me to find out what the issue is?

Thank you, very much appreciated!


Solution

  • Dense is not a model. Dense is a layer, and it's in keras.layers:

    from keras.layers import Dense,LSTM,Embedding
    from keras.models import Sequential,Model
    

    Often I work importing everything at once and forget about it:

    from keras.layers import *
    from keras.models import *
    import keras.backend as K #for some advanced functions