我有一个烤宽面条代码。我想使用 caffe 创建相同的网络。我可以转换网络。但我需要有关烤宽面条超参数的帮助。 lasagne 中的超参数如下所示:
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 .等待答案。
最佳答案
看来你已经做对了。
weight_decay
元参数与 'solver.prototxt'
中的 regularization_type: "L2"
相结合,告诉 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。
关于deep-learning - caffe 中的 L2 正则化,从 lasagne 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41585226/