关于使用Keras 中Sequential语句引用时报错的解决方法
如果使用以下两句引用时报错Cannot find reference 'Sequential' in 'models.py'
from keras.models import Sequential
from keras.layers import Dense,Dropout
那么请将上面两句改成
from tensorflow.python.keras import layers, models
在使用sequential和dense时
用
models.Sequential()和
layers.Dense即可解决。
本文介绍了解决在使用Keras的Sequential模型时遇到的引用错误的方法。若在引入Sequential和Dense时出现Cannotfindreference'Sequential'in'models.py'错误,可以通过更改导入方式来解决:使用fromtensorflow.python.kerasimportlayers,models,并采用models.Sequential()和layers.Dense()的形式进行调用。
1741

被折叠的 条评论
为什么被折叠?



