【问题标题】:PixelCNN training error 'keepdims'PixelCNN 训练错误“keepdims”
【发布时间】:2023-03-12 10:30:01
【问题描述】:

尝试使用 PixelCNN 我收到以下输入参数错误:

C:\Users\cknau\Downloads\pixel-cnn-master\pixel-cnn-master>python train2.py
input args:
 {
    "data_dir":"D:\\PixelCNN\\dataset",
    "save_dir":"D:\\PixelCNN\\samples",
    "data_set":"cifar",
    "save_interval":20,
    "load_params":false,
    "nr_resnet":5,
    "nr_filters":160,
    "nr_logistic_mix":10,
    "resnet_nonlinearity":"concat_elu",
    "class_conditional":false,
    "energy_distance":false,
    "learning_rate":0.001,
    "lr_decay":0.999995,
    "batch_size":16,
    "init_batch_size":16,
    "dropout_p":0.5,
    "max_epochs":5000,
    "nr_gpu":8,
    "polyak_decay":0.9995,
    "num_samples":1,
    "seed":1
}

错误:

T

raceback (most recent call last):
      File "train2.py", line 120, in <module>
        loss_gen.append(loss_fun(tf.stop_gradient(xs[i]), out))
      File "C:\Users\cknau\Downloads\pixel-cnn-master\pixel-cnn-master\pixel_cnn_pp\nn.py", line 83, in discretized_mix_logistic_loss
        log_probs = tf.reduce_sum(log_probs,3) + log_prob_from_logits(logit_probs)
      File "C:\Users\cknau\Downloads\pixel-cnn-master\pixel-cnn-master\pixel_cnn_pp\nn.py", line 27, in log_prob_from_logits
        m = tf.reduce_max(x, axis, keepdims=True)
    TypeError: reduce_max() got an unexpected keyword argument 'keepdims'

谁能帮帮我?我有 NumPy 1.13,所以这不是问题。

【问题讨论】:

    标签: python numpy artificial-intelligence


    【解决方案1】:

    我猜你的 tensorflow 版本可能与 Pixelnet 不兼容 正如keep_dims: Deprecated alias for keepdims. 所描述的here,也许你有一个像0.rxx 这样的旧版本,尝试升级tf 或从keepdims to keep_dims 更改关键字

    【讨论】:

      【解决方案2】:

      我正在使用 facenet,我已经更改了 detect_face.py 文件中的 softmax 函数。

      正确的代码是:

      @layer
      def softmax(self, target, axis, name=None):
              max_axis = tf.reduce_max(target, axis, keep_dims =True)
              target_exp = tf.exp(target-max_axis)
              normalize = tf.reduce_sum(target_exp, axis, keep_dims =True)
              softmax = tf.div(target_exp, normalize, name)
              return softmax
      

      【讨论】:

        猜你喜欢
        • 2012-02-27
        • 1970-01-01
        • 1970-01-01
        • 2019-01-05
        • 1970-01-01
        • 2018-03-07
        • 2017-04-20
        • 2017-09-29
        • 2016-08-09
        相关资源
        最近更新 更多