Jérémy Blain
Jérémy Blain

Reputation: 249

Get hidden layer outputs

I make a densenet network from gluon.vision

densenet = vision.densenet121(pretrained=True, ctx=mx.cpu())

I want to get the outputs of each convolutionnal layer (after a prediction), to plot them afterwards (features maps). I can't do densenet.get_internals() (as I saw on internet and Github), as my network is not a Symbol but a HybridBlock.

Upvotes: 0

Views: 796

Answers (1)

Jérémy Blain
Jérémy Blain

Reputation: 249

I find a solution in mxnet forum : Gluon, get features maps of a CNN

Actually, you have to transform the gluon model to a symbol using methods export() to save parameters (method from HybridBlock), and mx.sym.load() to load them.

function get_interals()["name_of_the_layer"] get all the layers from begining to this layer, so you can do feat_maps = net(image) to get all the features maps for this layer.

Then you can do a SummaryWriter in mxBoard to export it to Tensorboard.

Upvotes: 1

Related Questions