今天我装了tensorflow-gpu 1.4, keras 2.1.6发现运行keras模型的时候出现了以下的错误:、
Traceback (most recent call last):
File "models.py", line 24, in <module>
model = NIH()
File "models.py", line 19, in NIH
model.add(Activation('softmax'))
File "/home/eric/anaconda3/lib/python3.6/site-packages/keras/models.py", line 522, in add
output_tensor = layer(self.outputs[0])
File "/home/eric/anaconda3/lib/python3.6/site-packages/keras/engine/topology.py", line 619, in __call__
output = self.call(inputs, **kwargs)
File "/home/eric/anaconda3/lib/python3.6/site-packages/keras/layers/core.py", line 304, in call
return self.activation(inputs)
File "/home/eric/anaconda3/lib/python3.6/site-packages/keras/activations.py", line 29, in softmax
return K.softmax(x)
File "/home/eric/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2963, in softmax
return tf.nn.softmax(x, axis=axis)
TypeError: softmax() got an unexpected keyword argument 'axis'
就网上说是keras 2.1.6的softmax没有axis这个参数了,于是,我回退了keras版本:
pip install keras==2.1
然后程序就不报错误了,完工。