python examples for convert numpy array into lmdb/training network

2,692 views
Skip to first unread message

jason liang

unread,
May 6, 2015, 6:07:01 AM5/6/15
to caffe...@googlegroups.com
Hi,

I am a student who is working on a course project to train CNNs on a custom image dataset I have. I am seeking some examples of doing the following operations in python (I cannot find any such examples either in codebase or the documentation):

1)Given a 4D numpy array (the dimensions of the array are # images, height, width, # channels) of image data and 1D array of associated labels, output a lmdb directory suitable for training by caffe (like the mnist_train_lmdb directory generated in the mnist tutorial). 

2)In python, train the same 4D numpy array of training images and 1D array of training labels by providing a pair of network and solver configuration files (like the lenet.prototxt and lenet_solver.prototxt files in the mnist tutorial). 

I would appreciate any help on this.

Thanks,

Jason Liang

Yoann

unread,
May 6, 2015, 6:17:21 AM5/6/15
to caffe...@googlegroups.com
Hi,

1) https://groups.google.com/forum/#!searchin/caffe-users/python$20script/caffe-users/-vWuaM3bnro/RB4xzpI8xeUJ

2) To train a network, you should use a command line. Ex: caffe train  --gpu=0 --solver=solver.prototxt

Best,
Yoann

jason liang

unread,
May 6, 2015, 6:34:15 AM5/6/15
to caffe...@googlegroups.com
Hi Yoann, 

Thanks for pointing out the code for 1). As for 2), Are you sure there is no way to train a network in python :(?

Raffael

unread,
May 6, 2015, 8:26:14 AM5/6/15
to caffe...@googlegroups.com
Hi Jason,

of course you can simply invoke the caffe executable from Python - which is effectively just as good.

I just composed this IPython Notebook for the purpose of illustrating a problem:


Everything seems to work fine but predicting doesn't seem to work. According to the in-code-documentation this function is supposed to be applied on images. I try to train a net on classifying points (x,y). 

Any ideas? :)

Yoann

unread,
May 6, 2015, 8:40:03 AM5/6/15
to caffe...@googlegroups.com
You do not need to use the predict function which use and preprocess input images.
You need to write your own function which will I suppose mostly consist in a line with "net.forward(...)".

Anyway, you should start a new topic, it will be less confusing ;)

Raffael

unread,
May 6, 2015, 8:43:37 AM5/6/15
to caffe...@googlegroups.com
Hello Yoann,

thanks for your reply. Actually, I already posted this questions few hours ago:


Would highly appreciate if you could have a look at it and give me your hints/ideas/insights. Or maybe even links to sample code?

Kind Regards

Raffael
Reply all
Reply to author
Forward
0 new messages