【报错相关】TypeError: softmax() got an unexpected keyword argument 'axis'
出现这个问题,有几种解决办法,可以调低一下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)
就是改了最后一行。
 作者:李是李雅普诺夫的李  出处:http://www.cnblogs.com/lky-learning/  如需交流或转载,请联系本人,欢迎关注公众号:一刻AI  如果文中有什么错误,欢迎指出。以免更多的人被误导。 |