【问题标题】:Can't set Solver to Adam in Caffe?无法在 Caffe 中将 Solver 设置为 Adam?
【发布时间】:2018-01-05 16:00:04
【问题描述】:

这是我的solver.prototxt:

net: "models/dcnf-fcsp-alexnet/train_val.prototxt"
#test_iter: 1000
#test_interval: 1000
test_initialization: false
base_lr: 0.0001
lr_policy: "step"
gamma: 0.01
stepsize: 50000
display: 20
max_iter: 1000000
momentum: 0.9
weight_decay: 0.0005
snapshot: 10000
snapshot_prefix: "/data/lesi/dcnf-fcsp-alexnet/"
type: "Adam"
solver_mode: GPU

显然应该将类型设置为 Adam。然而,当我使用这个求解器进行培训时,我的主管指出它看起来像是在使用 SGD(因为它说的是 sdg_solver.cpp):

I0728 16:18:59.490665 27998 sgd_solver.cpp:106] Iteration 41860, lr = 0.0001
I0728 16:19:26.414223 27998 solver.cpp:228] Iteration 41880, loss = 1.45618
I0728 16:19:26.414342 27998 solver.cpp:244]     Train net output #0: loss = 1.45618 (* 1 = 1.45618 loss)
I0728 16:19:26.414355 27998 sgd_solver.cpp:106] Iteration 41880, lr = 0.0001
I0728 16:19:53.348322 27998 solver.cpp:228] Iteration 41900, loss = 1.44106
I0728 16:19:53.348362 27998 solver.cpp:244]     Train net output #0: loss = 1.44106 (* 1 = 1.44106 loss)

这只是一些控制台输出混乱还是我实际上在使用 SGD?如果是这样,为什么它不会切换到亚当?我看不出这里还需要什么其他步骤...

【问题讨论】:

    标签: neural-network deep-learning caffe solver gradient-descent


    【解决方案1】:

    "Adam" 是“SGD”求解器的一个特例:使用小批量,每次迭代都会给出局部梯度的随机估计。不同的求解器类型在使用此随机估计更新权重的方式上有所不同。
    查看您的'solverstate''caffemodel' 快照,您会注意到'solverstate' 占用的磁盘空间是'caffemodel' 的两倍——这是因为"Adam" 求解器存储每个可训练参数均值和标准差(“时刻”)。如果您使用普通的“SGD”求解器,您的 'caffemodel''solverstate' 将具有相同的文件大小。

    【讨论】:

    • 很好的答案!求解器状态的大小确实是两倍!谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-25
    • 2015-09-12
    • 2015-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-20
    相关资源
    最近更新 更多