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

你可能感兴趣的:(优化,caffe,梯度,Loss,Solver)