Caffe:如何通过代码获取`solver.prototxt`参数?

时间:2016-06-25 08:15:26

标签: python neural-network deep-learning caffe conv-neural-network

我想从python代码访问solver.prototxt参数,例如base_lr(基本学习率)或weight_decay

有没有办法从solver.net对象访问这些?

谢谢

1 个答案:

答案 0 :(得分:1)

根据this tutorial,您可以通过以下方式访问它:

### 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