mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

Extracting layer weights

Open jmschrei opened this issue 10 years ago • 6 comments

I'd like to extract the learned weights from a layer (not the layer output for some input). I've been looking for a notebook which does this. Can someone point me in the right direction?

jmschrei avatar May 21 '16 21:05 jmschrei

If you are using model.FeedForward, you can get all weights dictionary by getting m.arg_params, where m is the model

antinucleon avatar May 21 '16 21:05 antinucleon

Great, thanks! Do I need to do anything to make it not optimize out those layers? Basically I want to extract all of the weights from my first convolution layer.

jmschrei avatar May 21 '16 21:05 jmschrei

No. Weight will not be optimized out :)

antinucleon avatar May 21 '16 21:05 antinucleon

Working great, thanks!

jmschrei avatar May 23 '16 07:05 jmschrei

m.arg_params return to me a dictionary, how to extract the learned weights?

No41Name avatar Feb 25 '17 21:02 No41Name

In R is model$arg_params to take all and model$arg_params$fc1_weight to take onli the weight of layer one.

dma100180 avatar Aug 25 '17 12:08 dma100180