背景
升级keras后,原来可以使用的
model.add(Activation('softmax'))
出现了TypeError:softmax() got an unexpected keyword argument 'axis’错误
解决
打开tensorflow_backend.py文件
line 3221中
def softmax(x, axis=-1):
"""Softmax of a tensor.
# Arguments
x: A tensor or variable.
axis: The dimension softmax would be performed on.
The default is -1 which indicates the last dimension.
# Returns
A tensor.
"""
return tf.nn.softmax(x, axis=axis)
中的axis都去掉。
即可解决问题。