Clear Filters
Clear Filters

Can we plot the output of in-between layers in deep neural network?

8 views (last 30 days)
I have a deep neural network having 297 layers. I want to visualize the output of some of the layers that are in-between this network for analysis purpose. Is it possible way to do that? Or should I create the network upto the layer where I want to take the output and plot the output using the 'plot' command?

Accepted Answer

Antoni Woss
Antoni Woss on 14 Sep 2023
You can access the intermediate activations of a network by setting the name-value argument, Outputs, in the predict call. See the following documentation page for examples on this syntax: https://uk.mathworks.com/help/deeplearning/ref/dlnetwork.predict.html#d126e63879. You can select 1 or many layers for which to extract these intermediate activations using this name-value argument.
  2 Comments
BIPIN SAMUEL
BIPIN SAMUEL on 19 Sep 2023
Edited: BIPIN SAMUEL on 19 Sep 2023
Thank You @Antoni Woss, do we have to train again the network upto the layer where we want to get the output? or can we directly use "predict" command with argument 'Outputs' in the %Testing% session after %Training% the whole network?
Also, in function shown below what does "using any of the previous syntaxes" (in the comment session) means?
[Y1,...,YK] = predict(___,Outputs=layerNames) %returns the outputs Y1, …, YK during inference for the specified layers using any of the previous syntaxes.
Antoni Woss
Antoni Woss on 19 Sep 2023
No, you do not need to retrain the network. The command will just returned the intermediate activations of the network passed to the function on the layer specified. If the network is a trained network, then the activations will be that of the trained network.
The "using any of the previous syntaxes" refers to the positional argument syntaxes in the documentation page. It means that you can use the name-value arguments with any of the previously defined syntaxes.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!