本文介绍了Caffe:如何通过代码获取`solver.prototxt`参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

有什么方法可以从solver.net对象访问它们吗?

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

谢谢

推荐答案

根据本教程,您可以通过以下方式访问它:

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

这篇关于Caffe:如何通过代码获取`solver.prototxt`参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-23 06:59