Can one train caffe using Python?

3,203 views
Skip to first unread message

Steven

unread,
May 21, 2015, 1:09:30 PM5/21/15
to caffe...@googlegroups.com
I've tried to train Caffe using the Python interface as follows:

me@ARL-M6800:~/Caffe/caffe$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import caffe
>>> import os
>>> caffe_home='/home/me/Caffe/'
>>> MODEL_FILE = os.path.join(caffe_home,'caffe/examples/mnist/lenet.prototxt')
>>> solver = caffe.SGDSolver(MODEL_FILE)
WARNING
: Logging before InitGoogleLogging() is written to STDERR
I0521
10:08:26.456539  7351 solver.cpp:26] SG!: About to ReadProtoFromTextFileOrDie from/home/me/Caffe/caffe/examples/mnist/lenet.prototxt # Note: I added this message to ensure I was tracing the code correctly
[libprotobuf ERROR google/protobuf/text_format.cc:245] Error parsing text-format caffe.SolverParameter: 1:5: Message type "caffe.SolverParameter" has no field named "name".
F0521
10:08:26.459609  7351 io.hpp:54] Check failed: ReadProtoFromTextFile(filename, proto)
*** Check failure stack trace: ***
Aborted (core dumped)

I get the same result when I use lenet_train_test.prototxt as my model file.

When I look at lenet.prototxt and lenet_train_test.prototxt, the first line in each case is:

name: "LeNet"

So, I don't really understand the error message.

I was trying to follow the suggestion given in issue#294 -  https://github.com/BVLC/caffe/pull/294

solver = caffe.SGDSolver('solver.prototxt')
solver
.net.set_input_arrays(data, labels)
solver
.solve()

but seem to be missing something. If anyone has an idea, it would help me alot.

Thanks,

Steven

Ashudeep Singh

unread,
May 21, 2015, 3:41:03 PM5/21/15
to caffe...@googlegroups.com
The one you mention here "lenet.prototxt" mentions the network and not the solver. 
A solver is the one that mentions the network file and other stuff like learning rate, policy, file to snapshot the training to etc.
A network file will describe the network (like the lenet.prototxt). Try with lenet_solver.prototxt in the same folder as your solver.

--
Ashudeep

Steven

unread,
May 21, 2015, 5:46:21 PM5/21/15
to caffe...@googlegroups.com
Thanks! 
Reply all
Reply to author
Forward
0 new messages