caffe优化方法

caffe中的solver负责处理模型优化过程,通过网络前向传播产生的loss和后向传播产生的梯度进行模型优化(更新模型中的权重)来降低loss.
caffe中的solver有:

  • Stochastic Gradient Descent (type: “SGD”)
  • AdaDelta (type:”AdaDelta”)
  • Adaptive Gradient (type: “AdaGrad”)
  • Adam (type: “Adam”)
  • Nesterov’s Accelerated Gradient (type: “Nesterov”)
  • RMSprop (type: “RMSProp”)

solver是关于损失函数最小的优化问题的求解.
其中前向传播计算给定数据集 D 的损失表达式为

L(W)=1|D|i|D|fW(X(i))+λr(W)
其中, fW 是给定数据集 D 上的损失函数,r(W)为正则化项, λ 是正则化项的权重,称为weight decay,用于防止过拟合.由于 |D| 往往很大,所以将其划分为多个mini-batch N,|N|<<|D| ,每次迭代计算下面的损失:

L(W)1NiNfW(X(i))+λr(W)

后向传播更新网络权重

Wt+1=Wt+ΔW
其中权重更新量 ΔW 的计算涉及到 fW , r(W) 梯度信息以及其他针对不同优化策略的计算量。
不同的优化策略只是权重更新方法不同。

SGD

随机梯度下降(Stochastic gradient descent)

Vt+1=μVtαL(Wt)Wt+1=Wt+Vt+1
其中, μ 是momentum,是更新量 Vt+1 的权重, α 是学习率,是负梯度的的权重。
学习率的更新策略有:

// 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.

参见:/caffe-master/src/caffe/proto/caffe.proto,在线的点击这里

AdaDelta

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值