TypeError: softmax() got an unexpected keyword argument 'axis' Activation('softmax') 不存在
TypeError: softmax() got an unexpected keyword argument 'axis’
出现这个问题是因为 keras 版本高, 与tensorflow 结合出现了问题
错误信息
解决方法
1 .对keras 版本进行降级, 卸载 重新安装 指定版本 pip install keras==2.1
2.找到报错 目录, 找到 大约在3231行
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)