【问题标题】:L2 regularization in caffe, conversion from lasagnecaffe 中的 L2 正则化,从千层面转换
【发布时间】:2017-05-25 21:51:00
【问题描述】:

我有一个千层面密码。我想使用 caffe 创建相同的网络。我可以转换网络。但我需要有关千层面的超参数的帮助。千层面中的超参数如下所示:

lr = 1e-2
weight_decay = 1e-5

prediction = lasagne.layers.get_output(net['out'])
loss = T.mean(lasagne.objectives.squared_error(prediction, target_var))

weightsl2 = lasagne.regularization.regularize_network_params(net['out'], lasagne.regularization.l2)
loss += weight_decay * weightsl2

如何在 caffe 中执行 L2 正则化部分?我是否必须在每个卷积/内积层之后添加任何层进行正则化?我的solver.prototxt中的相关部分如下:

base_lr: 0.01
lr_policy: "fixed"
weight_decay: 0.00001
regularization_type: "L2"
stepsize: 300
gamma: 0.1  
max_iter: 2000
momentum: 0.9

也发布在http://datascience.stackexchange.com。等待答案。

【问题讨论】:

  • 请不要在多个 stackexchange 网站上发布重复的问题。
  • 发布在数据科学上,等待答案,没有得到回复,然后我在 stackoverflow 上发布。今后我将避免多次发帖。

标签: deep-learning caffe lasagne regularized


【解决方案1】:

看来您已经做对了。
weight_decay 元参数与 regularization_type: "L2" 结合在您的 'solver.prototxt' 中告诉 caffe 使用 L2 正则化和 weight_decay = 1e-5

您可能想要调整的另一件事是正则化对每个参数的影响程度。您可以通过

为网络中的每个参数blob设置此
param { decay_mult: 1 }

例如,带有偏差的"InnerProduct" 层有两个参数:

layer {
  type: "InnerProduct"
  name: "fc1"
  # bottom and top here
  inner_product_param { 
    bias_term: true
    # ... other params
  }
  param { decay_mult: 1 } # for weights use regularization
  param { decay_mult: 0 } # do not regularize the bias
}

默认情况下,decay_mult 设置为 1,即网络的所有权重都被正则化相同。您可以更改它以规范更多/更少特定的参数 blob。

【讨论】:

  • 你知道如何选择最大范数正则化吗?我只能找到 L1 和 L2 类型
  • @user8264 AFAIK Caffe 还没有最大范数正则化。
猜你喜欢
  • 2017-07-14
  • 2016-07-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-02-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多