3

我有一个千层面代码。我想使用 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。等待答案。

4

1 回答 1

2

看来你已经做对了。元参数与您的
tell caffe 结合使用正则化 with 。weight_decayregularization_type: "L2"'solver.prototxt'L2weight_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。

于 2017-01-11T08:41:07.497 回答