UserWarning:不推荐使用`Sequential.model`

问题描述 投票:0回答:1

Log:

C:\ Users \ AppData \ Local \ Continuum \ anaconda3 \ lib \ site-packages \ keras \ engine \ sequential.py:110:

UserWarning:不推荐使用Sequential.modelSequentialModel的子类,您可以只使用Sequential实例直。 warnings.warn('Sequential.model已过时。'

在jupyter笔记本中执行模型时,其以.ipynb文件格式工作,但在以.py文件格式的VS代码执行时停止工作。

代码:

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.add(SpatialDropout1D(0.5))
model.compile(loss = 'categorical_crossentropy', optimizer='adam',metrics = ['acc'])
model.summary()

保存模型:

model.model.save('my_model.h5')
with open('tokenizer.pickle', 'wb') as handle:
    pickle.dump(tokenizer, handle, protocol=pickle.HIGHEST_PROTOCOL)
python tensorflow machine-learning keras sequential
1个回答
0
投票

[UserWarning

© www.soinside.com 2019 - 2024. All rights reserved.