Caffe: How to get `solver.prototxt` parameters by code?

点点圈 提交于 2020-01-04 03:18:07

问题


I want to access the solver.prototxt parameters such as base_lr (Base Learning Rate) or weight_decay from python code.

is there any way to access these from the solver.net object ?

Thank you


回答1:


According to this tutorial, you can access it by :

### define solver
from caffe.proto import caffe_pb2
s = caffe_pb2.SolverParameter()

# Set a seed for reproducible experiments:
# this controls for randomization in training.
s.random_seed = 0xCAFFE

# Specify locations of the train and (maybe) test networks.
s.train_net = train_net_path
s.test_net.append(test_net_path)
s.test_interval = 500  # Test after every 500 training iterations.
s.test_iter.append(100) # Test on 100 batches each time we test.

s.max_iter = 10000     # no. of times to update the net (training iterations)

# EDIT HERE to try different solvers
# solver types include "SGD", "Adam", and "Nesterov" among others.
s.type = "SGD"
# Set the initial learning rate for SGD.
s.base_lr = 0.01  # EDIT HERE to try different learning rates

etc.



来源:https://stackoverflow.com/questions/38026431/caffe-how-to-get-solver-prototxt-parameters-by-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!