出現這個問題,有幾種解決辦法,可以調低一下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)
就是改了最后一行。
