Matlab bug and deadly error while trying to visualize FasterRCNN network feature maps from softmax layer
Afficher commentaires plus anciens
I want to visualize the feature maps extracted from the softmax layer of a trained FasterRCNN network. I am aware that this can be done for the RCNN networks as in the DeepLearningRCNNObjectDetectionExample.m with the below code.
% Extract the activations from the softmax layer. These are the classification scores
% produced by the network as it scans the image.
featureMap = activations(rcnn.Network, testImage, 'softmax', 'OutputAs', 'channels');
% The softmax activations are stored in a 3-D array.
size(featureMap)
The 3rd dimension in featureMap corresponds to the object classes
rcnn.ClassNames
The stop sign feature map is stored in the first channel
stopSignMap = featureMap(:, :, 1);
The size of the activations output is smaller than the input image due to the downsampling operations in the network. To generate a nicer visualization, resize stopSignMap to the size of the input image. This is a very crude approximation that maps activations to image pixels and should only be used for illustrative purposes.
% Resize stopSignMap for visualization
[height, width, ~] = size(testImage);
stopSignMap = imresize(stopSignMap, [height, width]);
% Visualize the feature map superimposed on the test image.
featureMapOnImage = imfuse(testImage, stopSignMap);
figure
imshow(featureMapOnImage)
But when I do the same of my fasterRCNNObjectDetector it gives an error as:
Error using vision.cnn.FastRCNN/activations (line 207)
Expected layer to match one of these values:
'imageinput', 'conv_1', 'relu_1', 'conv_2', 'relu_2', 'roi pooling layer', 'fc_1', 'relu_3', 'fc_2', 'softmax', 'classoutput'
The input, 'OutputAs', did not match any of the valid values.
Please read below for the update; I discovered a bug and a deadly error while trying to visualize the fasterRCNN feature maps.
Réponses (1)
Joss Knight
le 30 Mai 2017
Modifié(e) : Joss Knight
le 30 Mai 2017
0 votes
The activations function of the vision.cnn.FastRCNN is undocumented and Hidden and so not officially supported. Its inputs are not carefully parsed to ensure they are valid and so yes, you can make things crash if you use it.
For what it's worth, the fifth argument ' inputLayer ' is for internal use and you shouldn't use it, Just let it default to 1.
outputLayer is supposed to be the layer who's output you want to inspect, not the layer after.
2 commentaires
Matlab_user
le 1 Juin 2017
Joss Knight
le 7 Juin 2017
I can't really comment I'm afraid. Clearly there are many undocumented limitations of this undocumented undisclosed function. If you like I can take your question as a request to make this function public.
Catégories
En savoir plus sur Parallel and Cloud dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!