win下的环境为keras2.16,运行lstm时报错
TypeError: softmax() got an unexpected keyword argument 'axis'
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-7-ec539a8d38d4> in <module>()
7
8 model.add(Dropout(0.2))#随机失活,避免过拟合,在训练的时候
----> 9 model.add(Dense(y.shape[1],activation="softmax"))#稠密层中定义激活函数,整体是一个softmax层,
10 ####待查softmax层的原理,softmax的keras实现,
11 #y.shape[1]是词典长度,activation是激活函数,Dense(y.shape[1],activation="softmax")是一个输出层,
解决方案:回退keras版本
keras 2.1.6的softmax没有axis这个参数了,于是,我回退了keras版本:
pip uninstall Keras
pip install keras==2.1
问题解决