How to use caffe Matlab Wrapper to finetune ConvNets

731 views
Skip to first unread message

Terry Chen

unread,
Aug 2, 2015, 4:50:49 AM8/2/15
to Caffe Users
Hi, I recently wanna to use caffe matlab wrapper to online finetune the alexnet or some others. Using new caffe Solver can directly train net but cannot finetune the net. Anyone know how to finetune Net in matlab? Thanks. 

Devendra Mandan

unread,
Aug 2, 2015, 1:05:04 PM8/2/15
to Caffe Users

Maybe I don't entirely understand your problem, but you can follow the flickr style finetuning tutorial as it is, it will work, you don't need to use the matlab wrapper for this.
Message has been deleted

Ronghang Hu

unread,
Aug 2, 2015, 1:26:23 PM8/2/15
to Caffe Users
You are able to use the matlab wrapper for fine-tuning. Here is the procedure:

solver = caffe.Solver('your_solver.prototxt');
solver.net.copy_from('your_pretrained_weights.caffemodel');
solver.solve();

Terry Chen

unread,
Aug 2, 2015, 1:41:27 PM8/2/15
to Caffe Users
Thanks a lot. It works for me. 

Terry Chen

unread,
Aug 2, 2015, 1:43:03 PM8/2/15
to Caffe Users
Yes,Ronghang's answer solve my problem. Thank you. 

Terry Chen

unread,
Aug 2, 2015, 1:54:13 PM8/2/15
to Caffe Users
Hi, Ronghang, can I set data layer in train_val.prototxt as empty, just set as deploy file:
input: "data"
input_dim: 1
input_dim: 3
input_dim: 48
input_dim: 48

input: "label"
input_dim: 1
input_dim: 2
input_dim: 1
input_dim: 1

and use maltab to set data?  I have changed the train_val.prototxt like this, it make matlab crash.  How to do that? Thank you . 


On Sunday, August 2, 2015 at 10:26:23 AM UTC-7, Ronghang Hu wrote:

Ronghang Hu

unread,
Aug 2, 2015, 2:05:32 PM8/2/15
to Caffe Users
No, I don't think you can do that right now in matlab wrapper. There is an interface to do that in python wrapper which allows you to use MemoryDataLayer and load data from numpy array, but this feature has not been implemented in matlab wrapper yet.

To overcome, you can resort to HDF5DataLayer (store your data as .h5 file), or use python wrapper instead.

Devendra Mandan

unread,
Aug 2, 2015, 2:11:10 PM8/2/15
to Caffe Users
Sorry, but can you please answer my question also https://groups.google.com/forum/#!topic/caffe-users/e_xEICAwsdI

Prophecies

unread,
Oct 26, 2015, 4:21:44 PM10/26/15
to Caffe Users
Can you tell me how to load pretrained weights when my new network contains pretrained network as only a part of whole thing?
e.g previous network say X, with pretrained weights X.caffemodel

My network

some layers -> X' -> some  more layers -> accuracy & loss where X' is X with input and output layers stripped.

In this case, how to selectively initialize the parts of network containing X with weights from X.caffemodel ?

Thanks in advance.

Douglas Almonfrey

unread,
Aug 17, 2016, 1:23:52 PM8/17/16
to Caffe Users
Hi, is it possible to change data layer input size prior fini-tunning in matlab? I'm using windows data layer and I want to fine-tune the network for a 128x64 input size. Thanks!

Royi

unread,
Aug 19, 2016, 3:00:44 AM8/19/16
to Caffe Users
Ronghang,

Do you use MATLAB on Windows?
Whenever I write solver = caffe.Solver('your_solver.prototxt'); MATLAB crashes.
Though for the same .prototxt the Command Line works perfectly.

Thank You.
Reply all
Reply to author
Forward
0 new messages