Changing the name of a trained Caffemodel (Preferably through python)

1,185 views
Skip to first unread message

Dimitris Marm

unread,
Sep 28, 2015, 5:41:55 AM9/28/15
to Caffe Users
Hello

I have a question about renaming a set of layers in a pre-trained caffemodel.  Is this possible ?

I am asking as I want to use two pre-trained models that happen to have same names (eg. conv1) and this will cause an overlap when I will try to copy their weights from elsewhere.

I would preferably like to do the renaming in python.

Thanks


Dimitris Marm

unread,
Sep 29, 2015, 3:42:19 PM9/29/15
to Caffe Users
I was thinking that such a process should be relatively easy !


Evan Shelhamer

unread,
Sep 29, 2015, 6:12:59 PM9/29/15
to Dimitris Marm, Caffe Users
Check out the net surgery example. Any `caffe.Net` loaded in Python exposes its parameters through the `params` ordered dictionary and these params are mutable arrays. You can load both pre-trained models then assign their weights into the new network to be trained as you like independently of the layer names.

As an alternative, the `.caffemodel` is a serialized protobuf so you could load it through the `caffe_pb2` Python module and directly modify it. However, the pycaffe net surgery way is the simplest in my opinion.

Happy brewing,

Evan Shelhamer



--
You received this message because you are subscribed to the Google Groups "Caffe Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to caffe-users...@googlegroups.com.
To post to this group, send email to caffe...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/caffe-users/2ff0d355-456f-4345-ac67-215fa1eda896%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages