caffe是否将正则化参数乘以有偏差?

Does caffe multiply the regularization parameter to biased?

我对正则化和偏差在 caffe 中的工作方式有很多疑问。

首先,默认情况下网络中存在偏差,是吗? 或者,我需要让caffe添加它们?

其次,它在获取损失值的时候,没有考虑正则化。这样对吗?我的意思是损失只包含损失函数值。据我了解,它只是考虑梯度计算中的正则化。对吗?

第三,caffe在获取梯度的时候,是否也考虑了正则化中的偏置值?还是只考虑正则化中网络的权重?

提前致谢,

阿夫欣

对于你的3个问题,我的回答是:

  1. 是的。默认情况下,网络中确实存在偏见。例如ConvolutionParameterInnerProductParameter中的caffe.protobias_term的默认值为true,即convolution/innerproduct层默认情况下,网络会有偏差。
  2. 是的。损失层得到的损失值不包含正则化项的值。它只考虑调用函数 net_->ForwardBackward() and in fact in ApplyUpdate() 函数后的正则化,其中更新网络参数。
  3. 以网络中的卷积层为例:

    layer {
      name: "SomeLayer"
      type: "Convolution"
      bottom: "data"
      top: "conv"
      #for weights
      param {
        lr_mult: 1 
        decay_mult: 1.0 #coefficient of regularization for weights
                        #default is 1.0, here is for the sake of clarity  
      }
      #for bias
      param {
        lr_mult: 2
        decay_mult: 1.0 #coefficient of regularization for bias
                        #default is 1.0, here is for the sake of clarity 
      } 
      ...  #left 
    }
    

    这道题的答案是:当caffe获取梯度时,求解器会考虑正则化中的偏置值,只有2个变量:上面的第二个decay_mult和里面的weight_decay solver.prototxt 都大于零。

    详情请见函数void SGDSolver::Regularize().

希望对您有所帮助。