【问题标题】:How to write a solver.prototxt satisfy a given condition in CAFFE?如何在 CAFFE 中编写满足给定条件的solver.prototxt?
【发布时间】:2017-05-26 00:13:33
【问题描述】:

我正在编写遵循论文规则https://arxiv.org/pdf/1604.02677.pdf的solver.prototxt

在训练阶段,学习率最初设置为 0.001,当损失停止下降到 10−7 时,学习率下降了 10 倍。折扣权重最初设置为 1,每一万次迭代减少 10 倍,直到边际值 10-3。

注意,折扣权重在 Caffe 中为 loss_weight。根据以上信息,我将求解器编写为

train_net: "train.prototxt"
lr_policy: "step"
gamma: 0.1
stepsize: 10000
base_lr: 0.001 #0.002

在train.prototxt中,我也设置了

layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "deconv"
  bottom: "label"
  top: "loss"
  loss_weight: 1
}

但是,我仍然不知道如何设置求解器以满足规则“当损失停止减少到 10−7 时减少 10 倍”“减少每一万次迭代增加 10 倍,直到边际值 10−3"。我没有发现任何 caffe 规则可以作为参考:

// The learning rate decay policy. The currently implemented learning rate
// policies are as follows:
//    - fixed: always return base_lr.
//    - step: return base_lr * gamma ^ (floor(iter / step))
//    - exp: return base_lr * gamma ^ iter
//    - inv: return base_lr * (1 + gamma * iter) ^ (- power)
//    - multistep: similar to step but it allows non uniform steps defined by
//      stepvalue
//    - poly: the effective learning rate follows a polynomial decay, to be
//      zero by the max_iter. return base_lr (1 - iter/max_iter) ^ (power)
//    - sigmoid: the effective learning rate follows a sigmod decay
//      return base_lr ( 1/(1 + exp(-gamma * (iter - stepsize))))
//
// where base_lr, max_iter, gamma, step, stepvalue and power are defined
// in the solver parameter protocol buffer, and iter is the current iteration.

如果有人知道,请给我一些编写solver.prototxt 以满足上述条件的指南。

【问题讨论】:

    标签: machine-learning neural-network deep-learning caffe


    【解决方案1】:

    学习率降低

    部分问题在于短语decreased by a factor of 10 when the loss stopped decreasing till 10e−7 不太合理。我认为,也许作者试图说,每次损失停止下降时,他们都会将学习率降低 10 倍,直到学习率达到 10e-7。

    如果是这样,那么这是一个手动过程,而不是您可以使用 Caffe 参数选择的过程。最重要的是,“当损失停止下降时”是一个重要的判断,尽管多头移动平均线会给你一个很好的指示。我希望作者手动执行此操作,从检查点停止并重新开始训练。

    可以使用step 的学习率衰减策略获得类似的效果:将 gamma 设置为 0.1,并将 step 参数设置得足够高,以确保在每次降低率之前训练已经趋于平稳.这会浪费一些计算机时间,但可能会为您省去整体麻烦。

    折扣重量

    在 Caffe 中,损失权重只是模型中各种损失之间的相对权重,是用于实现最终损失统计的线性因子。 Caffe 不提供权重的运行时更改。也许这是作者手动调整的其他内容。

    我尝试阅读论文中关于“折扣重量”的两个引用的区域,但发现很难阅读。我会等到有人校对和编辑那篇论文的语法和清晰度。同时,我希望这个答案对您有所帮助。

    您可以找到更多信息here

    【讨论】:

    • 谢谢修剪。这很有帮助。你也可以看看作者关于discount weight的另一篇论文,他也在sciencedirect.com/science/article/pii/S1053811917303348中使用过
    • 我明白了;感谢您的参考。英语在这方面要好一些。这些权重不是您可以从solver.prototxt 动态调整的。但是,如果您想增强代码并将其提交给 BVLC,我相信他们会很好地考虑您添加的功能。
    • 还有一件事,你说我们可以在训练的时候手动调整权重。我们该怎么做?因为我们只能在每次快照后保存solverstate和caffemodel文件。
    • 对。您运行 10000 次迭代,拍摄快照,然后停止训练。更改solver.prototxt 并从该快照重新启动。简而言之,这是一个繁琐的微调过程。
    猜你喜欢
    • 2021-05-19
    • 1970-01-01
    • 2021-12-17
    • 1970-01-01
    • 2017-02-20
    • 2018-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多