首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >L2正则化在咖啡,转换从千层面

L2正则化在咖啡,转换从千层面
EN

Stack Overflow用户
提问于 2017-01-11 07:40:28
回答 1查看 2.4K关注 0票数 3

我有一个千层面密码。我想用caffe创建相同的网络。我可以转换网络。但我需要帮忙处理千层面的超参数。千层面的超参数看上去就像:

代码语言:javascript
复制
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的相关部分如下:

代码语言:javascript
复制
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上发布。等待答案。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-01-11 08:41:07

看来你已经弄好了。

weight_decay元参数与'solver.prototxt'中的regularization_type: "L2"相结合,告诉caffe在weight_decay = 1e-5中使用L2正则化。

您可能还要调整的另一件事是正则化对每个参数的影响程度。您可以为网络中的每个参数blob设置以下内容

代码语言:javascript
复制
param { decay_mult: 1 }

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

代码语言:javascript
复制
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,即网的所有权重都是正则化的。您可以更改这一点,以规范更多/不太特定的参数块。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41585226

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档