【问题标题】:Does caffe multiply the regularization parameter to biased?caffe 是否将正则化参数乘以有偏?
【发布时间】:2016-08-25 13:38:06
【问题描述】:

我有很多关于正则化和偏见在 caffe 中的工作方式的问题。

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

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

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

提前致谢,

阿夫辛

【问题讨论】:

    标签: caffe regularized


    【解决方案1】:

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

    1. 是的。默认情况下,网络中确实存在偏差。例如caffe.proto中的ConvolutionParameterInnerProductParameter中,bias_term的默认值为true,这意味着网络中的convolution/innerproduct层默认会有偏差。
    2. 是的。损失层得到的损失值不包含正则化项的值。它只是考虑调用函数net_->ForwardBackward()之后的正则化,实际上是在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_multsolver.prototxt中的weight_decay都是两个变量时,求解器才会考虑正则化中的偏差值大于零。

      详情请见functoinvoid SGDSolver::Regularize()

    希望这会对你有所帮助。

    【讨论】:

    • 感谢 Dale 的全面解释
    • void SGDSolver::Regularize() 中,正如你提到的,当这两个参数都不为零时,net_params 确实是learnable_params,被更新了。你知道我们在 caffe 中哪里有偏见是learnable_params 的成员吗?
    • 它在Net<Dtype>::AppendParam() 函数中,在net.cpp 中。 @AfshinOroojlooy
    猜你喜欢
    • 2020-05-27
    • 2022-11-17
    • 1970-01-01
    • 1970-01-01
    • 2014-02-16
    • 2017-11-16
    • 1970-01-01
    • 2020-08-01
    • 2015-02-10
    相关资源
    最近更新 更多