- ‘activations’: www.mathworks.com/help/deeplearning/ref/seriesnetwork.activations.html
- 'minibatchpredict’: www.mathworks.com/help/deeplearning/ref/minibatchpredict.html
How to view the output of each and every hidden layer in a deep neural network
28 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am using deep neural network with 10 hidden layers and I want to view the output of each and every hidden layer.
When I execute the model I can see only the final result but I am unable to see the output of each and every hidden layer.
could anyone help me to view the output of each hidden layer.
0 comentarios
Respuestas (1)
Shantanu Dixit
el 17 de Jul. de 2024
Hi Prabha,
It is my understanding that you want to view the output of each and every hidden layer in the deep neural network. To view the output at every layer you can use ‘activations’ or ‘minibatchpredict’.
‘activations’ takes in three input arguments namely network (‘SeriesNetwork’), image, layername or number.
net = alexnet; % 'SeriesNetwork'
I = imread('peppers.png'); % Read the image
I = imresize(I, [227 227]);
plot(net)
actLayerPool1 = activations(net,I,"pool1"); %% output corresponding to pool1
disp(size(actLayerPool1));
actLayerConv1 = activations(net,I,"conv1"); %% output corresponding to layer 2 or conv1
disp(size(actLayerConv1));
Alternatively one can obtain the intermediate output maps using ‘minibatchpredict’. Here the network should be initialised be as a ‘dlnetwork’ and the input should include batch dimension (‘SSCB’)
% Define the layers of the network
layers = [
imageInputLayer([28 28 1], Normalization="none", Name="input")
convolution2dLayer(3, 8, Padding="same", Name="conv_1")
reluLayer(Name="relu_1")
fullyConnectedLayer(10, Name="fc")
softmaxLayer(Name="softmax")
];
net = dlnetwork(layers); %% dlnetwork
disp(net);
sampleInput = rand(28, 28, 1);
dlSampleInput = dlarray(sampleInput, 'SSCB');
activations_conv_layer = minibatchpredict(net,dlSampleInput,Outputs="conv_1"); %% corresponding to conv_1
activations_fc = minibatchpredict(net,dlSampleInput,Outputs="fc"); %% corresponding to fully connected layer
Refer to the following MathWorks documentation for better understanding
0 comentarios
Ver también
Categorías
Más información sobre Image Data Workflows en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!