Extracting the weights of a trained caffe network

4,345 views
Skip to first unread message

Lama Saouma

unread,
Feb 25, 2015, 4:07:56 AM2/25/15
to caffe...@googlegroups.com

Hello everyone,

I have a question regarding the usage of Caffe Library in a distributed model that I am building. I need, mainly, to send the weights of a trained network from one node to another. I thought of two alternatives:

1-      Creating the final caffemodel on the sending node, and then sending that file to the other node, which parses the caffemodel and then extracts the weights from it.

2-      Sending the individual weight values calculated, with a key that tells the other node to which parameter this value belongs without packaging the network into caffemodels on the sender node. The receiver node later will take the weights belonging to each key and use them in their corresponding position based on the key associated with them.

The second alternative seems much better in terms of performance and easiness of implementation. However, I need to ask you about how to access each parameter (i.e. weight) of the network, before packaging into caffemodel, in order to send it individually to the other node. What is the syntax needed for accessing those weights?

If that is not possible, could you please help me with a code snippet that would guide me on how to parse the caffemodel file in order to extract the weights?

Thank you in advance.

sunil surineni

unread,
Feb 25, 2015, 7:55:37 AM2/25/15
to caffe...@googlegroups.com
hei Lama Saouma ,

did you succeed parsing the caffemodel ..if so please let me know the procedure ..
if possible i have the code you used 
i need to parse the caffemodel to C program

Thanks in advance

sunil surineni

unread,
Feb 25, 2015, 7:56:27 AM2/25/15
to caffe...@googlegroups.com
sorry if possible can i have your code 


On Wednesday, February 25, 2015 at 2:37:56 PM UTC+5:30, Lama Saouma wrote:

Lama Saouma

unread,
Feb 25, 2015, 8:25:44 AM2/25/15
to caffe...@googlegroups.com
Sorry not yet. I just started working on it and I appreciate any help from people who have parsed caffemodel before (or help in my alternative approach).

Evan Shelhamer

unread,
Feb 25, 2015, 3:31:43 PM2/25/15
to Lama Saouma, caffe...@googlegroups.com
For reading and editing model parameters from Python see these two examples from the home page:


When a net is loaded in Python its data, diffs, and params are all exposed.

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/c5df3ef6-38af-4a37-b0e7-b625d9e21716%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Evgeniy Koryagin

unread,
Apr 15, 2015, 7:28:03 PM4/15/15
to caffe...@googlegroups.com
Hi, Lama. Did you succeed with the task? 

Brahimi Mohamed

unread,
Jun 28, 2016, 8:45:59 AM6/28/16
to Caffe Users
Me too I need to parse Caffe model inorder to get weights of all filters. 
Reply all
Reply to author
Forward
0 new messages