How to split caffemodel into 2 parts? and also how to merge

55 views
Skip to first unread message

Real_yangyang

unread,
May 8, 2018, 5:54:49 AM5/8/18
to Caffe Users
I have a caffemodel, and I want split it into 2 parts. (eg,: head.caffemodel, and tail.caffemodel)

How can I manage to do so?

Another question is that  how can I merge two caffemodel into one?

Thanks for your help

Przemek D

unread,
Aug 20, 2018, 8:13:02 AM8/20/18
to Caffe Users
The hard way would be to split a prototxt first (e.g. whole.prototxt -> head.prototxt & tail.prototxt) and then instantiate head.prototxt using weights from whole.caffemodel - Caffe will only copy weights from those layers that are present in both the prototxt and the caffemodel. So if you save this model as head.caffemodel, it will only contain the layers from head.prototxt.
But maybe you don't need to do that? As said above, Caffe only tries to import the layers which are found in the prototxt, and if they're not present in the caffemodel, it skips them. So is the explicit splitting of the model necessary?

Sanjana Soni

unread,
Jun 2, 2020, 11:42:01 PM6/2/20
to Caffe Users
Hi Przemek D,

Like you said we can have two models for each split. I am facing issue in passing the output of first split as input to the next split. How that can be done?
Any help will be appreciated.
For splitting part, I have made two prototxt files, first file has all convolution and pooling layers and in second file all fully connected layers. I have added one python custom layers in second file.

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