出现这个问题,有几种解决办法,可以调低一下keras的版本,比如:
pip install keras==2.1
不过还有个更方便的方法,从错误可知softmax中不包含axis这个参数,那么把axis参数替换成dim就可以了。源代码是这样的:
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)
更改成这样:
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, dim=axis)
就是改了最后一行。
来源:oschina
链接:https://my.oschina.net/u/4327545/blog/3600517