C:\Users\AppData\Local\Continuum\anaconda3\lib\site-packages\keras\engine\sequential.py:110: UserWarning: Sequential.model is deprecated. Sequential is a subclass of Model, you can just use your Sequential instance directly. warnings.warn('Sequential.model is deprecated.

When executing the model in jupyter notebook Its working in ipynb file format but stops working when execute in the VS code in python file format.

from keras.models import Sequential
from keras.layers import Dense, Activation, Embedding, Flatten, LSTM, Dropout, Conv1D, SpatialDropout1D
from keras.optimizers import Adam

model = Sequential()
model.add(Embedding(max_fatures, embed_dim,input_length = x.shape[1]))
model.compile(loss = 'categorical_crossentropy', optimizer='adam',metrics = ['acc'])

Saving the model

with open('tokenizer.pickle', 'wb') as handle:
pickle.dump(tokenizer, handle, protocol=pickle.HIGHEST_PROTOCOL)
  • 2
    $\begingroup$ We need more information to help here. The warning you posted simply indicates that Sequential.Model is an old way of doing things and that you can simply use Sequential by itself without the call of model. Nevertheless this does not impact the code or the model. What is the warning in VS Code, what does "not working" mean? $\endgroup$ – Fnguyen Nov 7 '19 at 11:19
  • $\begingroup$ "Sequential.model` is deprecated. Sequential is a subclass of Model, you can just use your Sequential instance directly. warnings.warn(Sequential.model is deprecated. - This is the exact error i am getting, working fine till the model is training, but at the time of saving the model It throws up the error. Don't know the reason why it is doing so , Earlier it was working all good. $\endgroup$ – neeraj04 Nov 7 '19 at 11:24
  • 1
    $\begingroup$ Have you checked whether the model saved regardless? As said this error is basically reminding you to update your code but does not otherwise indicate an issue. I have had this before and the model still saves and loads (albeit throwing that error).As per this question the warnings also are due to how Keras implements TF and can not be addressed by you changing code. $\endgroup$ – Fnguyen Nov 7 '19 at 11:29
  • 2
    $\begingroup$ Also in your code you write model.model.save this is one model too many. $\endgroup$ – Fnguyen Nov 7 '19 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.