- ‘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
조회 수: 16 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Shantanu Dixit
2024년 7월 17일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!