piratesailor
piratesailor

Reputation: 285

How to manually set net and other parameters for a solver in caffe python programming?

With the content of solver.prototxt as the following:

test_iter: 2
test_interval: 50
base_lr: 0.001
lr_policy: "step"
gamma: 0.1
stepsize: 100
display: 20
max_iter: 500
momentum: 0.9
weight_decay: 0.005
solver_mode: CPU

I tried the following code in caffe:

solver = caffe.SGDSolver('< some long path >/solver.prototxt')
solver.net = < some code created net >
solver.solve()

I got the following error:

... [ ... solver.cpp:67] Check failed: num_train_nets >= 1 (0 vs. 1) SolverParameter must specify a train net using one of these fields: net, net_param, train_net, train_net_param * Check failure stack trace: *

I wonder if there is a possible way to manually set the parameters of a solver by python code not by only load a prototxt file?

Upvotes: 1

Views: 440

Answers (1)

dambromain
dambromain

Reputation: 311

I'm not familiar with pycaffe, but according to your error, I think you are just missing a train net in your solver.prototxt. Add a line like this :

train_net: "path/to/your/train.prototxt"

and it should be ok.

I don't know what version of caffe you have but in the current one, the error should be (same line in solver.cpp, close content) :

CHECK_GE(num_train_nets, 1) << "SolverParameter must specify a train net "
<< "using one of these fields: " << field_names;

which makes the error simpler to identify.

Upvotes: 0

Related Questions