How to copy weights/biases between two heterogeneous network?

348 views
Skip to first unread message

Liu Jiang

unread,
Oct 23, 2015, 11:51:12 AM10/23/15
to Caffe Users
Hi all,
  Two networks are not completely the same, but they are the same in some layers.I need to copy the weights of some layers of the trained network to  the corresponding layers of the other network.Anyone knows how to solve this issue?

Taesik Na

unread,
Oct 23, 2015, 10:16:36 PM10/23/15
to Caffe Users
Hi,
You might want to check this example.
http://nbviewer.ipython.org/github/BVLC/caffe/blob/tutorial/examples/03-fine-tuning.ipynb

From this example, you can check how to copy the parameters from one network to other network.
solver.net.copy_from('models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel')
The above code enables that the pretrained weights will be loaded into another model, matching layers by name.

Brahimi Mohamed

unread,
Mar 1, 2017, 1:15:56 PM3/1/17
to Caffe Users

Brahimi Mohamed

unread,
Mar 1, 2017, 1:18:20 PM3/1/17
to Caffe Users
Just name the commun layer with same name.
Reply all
Reply to author
Forward
0 new messages