添加InfogainLoss层时出错?

2024-05-01 11:10:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我按照here的说明为类创建权重矩阵,并添加Infogainloss函数,它可以处理我的不平衡数据。最后几层

    ....
layer {
      name: "score_fr"
      type: "Convolution"
      bottom: "fc7"
      top: "score_fr"
      param {
        lr_mult: 1
        decay_mult: 1
      }
      param {
        lr_mult: 2
        decay_mult: 0
      }
      convolution_param {
        num_output: 5 #21
        pad: 0
        kernel_size: 1
        weight_filler {
            type: "xavier"
        }   
        bias_filler {
            type: "constant"
         } 
      }
    }
    layer {
      name: "upscore"
      type: "Deconvolution"
      bottom: "score_fr"
      top: "upscore"
      param {
        lr_mult: 0
      }
      convolution_param {
        num_output: 5 #21
        bias_term: false
        kernel_size: 64
        stride: 32
        group: 5 #2
        weight_filler: { 
             type: "bilinear" 
         }
      }
    }
    layer {
      name: "score"
      type: "Crop"
      bottom: "upscore"
      bottom: "data"
      top: "score"
      crop_param {
        axis: 2
        offset: 19
      }
    }
    layer {
      name: "accuracy"
      type: "Accuracy"
      bottom: "score"
      bottom: "label"
      top: "accuracy"
      include {
        phase: TEST
      }
    }
    layer {
      name: "prob"
      type: "Softmax" # NOT SoftmaxWithLoss
      bottom: "score"
      top: "prob"
      softmax_param { axis: 1 } # compute prob along 2nd axis
    }
    layer {
      bottom: "score"
      bottom: "label"
      top: "infoGainLoss"
      name: "infoGainLoss"
      type: "InfogainLoss"
      infogain_loss_param {
        source: "/.../infogainH.binaryproto"
        axis: 1  # compute loss and probability along axis
      }
    }

并编辑/添加了此link中包含的文件。但是,在网络中创建层时会出现错误:

^{pr2}$
  1. 如何解决这个错误?这个错误是从哪里来的?在
  2. 这个参数到底在做什么?在

    softmax_param { axis: 1 } # compute prob along 2nd axis

如果有人能提出任何建议,我将不胜感激。 谢谢。在


Tags: namelayerparamtoptypefrscorecompute