zoukankan      html  css  js  c++  java
  • 【报错相关】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)

    就是改了最后一行。

  • 相关阅读:
    MySQL多表查询
    多表关联
    MySQL数据类型 约束
    初识数据库
    socker server和 event
    os 模块 和 os模块下的path模块
    sys 模块
    time 模块
    目录规范

  • 原文地址:https://www.cnblogs.com/lky-learning/p/10588965.html
Copyright © 2011-2022 走看看