Method for generating a detailed visualization of machine learning model behavior
A method is provided for generating a visualization for explaining a behavior of a machine learning (ML) model. In the method, an image is input to the ML model for an inference operation. The input image has an increased resolution compared to an image resolution the ML model was intended to receive as an input. A resolution of a plurality of resolution-independent convolutional layers of the neural network are adjusted because of the increased resolution of the input image. A resolution-independent convolutional layer of the neural network is selected. The selected resolution-independent convolutional layer is used to generate a plurality of activation maps. The plurality of activation maps is used in a visualization method to show what features of the image were important for the ML model to derive an inference conclusion. The method may be implemented in a computer program having instructions executable by a processor.
1 . A method for generating a visualization for explaining a behavior of a machine learning (ML) model having a neural network, the method comprising:
selecting an image for input to the ML model for an inference operation, wherein the image has an increased resolution compared to an image resolution the ML model was intended to receive as an input;
increasing a resolution of a plurality of resolution-independent convolutional layers of the neural network because of the increased resolution of the input image that is selected for the inference operation;
selecting a resolution-independent convolutional layer of the neural network;
inputting the input image into the ML model for the inference operation;
using the selected resolution-independent convolutional layer to generate a plurality of activation maps;
using the plurality of activation maps in a visualization method to generate the visualization to show a user which features of the image were important for the ML model to derive an inference conclusion; and
presenting results of application of the visualization method to the user on a display for analysis.
2 . The method of claim 1 , wherein selecting the resolution-independent convolutional layer further comprises selecting a final convolutional layer of the plurality of resolution-independent convolutional layers.
3 . The method of claim 1 , wherein the visualization method is a Grad-CAM (gradient-weighted class activation mapping) visualization method.
4 . The method of claim 1 , wherein selecting the image for input to the ML model for an inference operation further comprises upscaling the image to provide the increased resolution.
5 . The method of claim 1 , further comprising generating a plurality of heat maps from the plurality of activation maps to use in the visualization method.
6 . The method of claim 1 , wherein the neural network is used for one of image classification, object detection, semantic segmentation, or instance segmentation.
7 . The method of claim 1 , further comprising adding a layer after a final resolution-independent convolutional layer of the plurality of resolution-independent convolutional layers to adjust for a mismatch between an output size of the final resolution-independent convolutional layer and an input of a first resolution-dependent layer.
8 . The method of claim 7 , wherein the added layer comprises one of either an average pooling layer, max pooling layer, global average pooling layer, or global max pooling layer.
9 . The method of claim 1 , further comprising:
adding a fully connected layer after the plurality of resolution-independent convolutional layers; and
training only the added fully connected layer.
10 . The method of claim 1 , further comprising computing an average gradient for each activation map of the plurality of activation maps.
11 . A computer program comprising instructions executable by a processor, for executing a method for generating a visualization for explaining a behavior of a machine learning (ML) model having a neural network, the executable instructions comprising:
instructions for selecting an image for input to the ML model for an inference operation, wherein the image has an increased resolution compared to an image resolution the ML model was intended to receive as an input;
instructions for increasing a resolution of a plurality of resolution-independent convolutional layers of the neural network because of the increased resolution of the input image;
instructions for selecting a resolution-independent convolutional layer of the neural network;
instructions for inputting the input image into the ML model for the inference operation;
instructions for using the selected resolution-independent convolutional layer to generate a plurality of activation maps;
instructions for using the plurality of activation maps in a visualization method to generate the visualization to show a user which features of the image were important for the ML model to derive an inference conclusion; and
instructions for presenting results of application of the visualization method to the user on a display for analysis.
12 . The computer program of claim 11 , wherein the instructions for selecting the convolutional layer further comprises instructions for selecting a final convolutional layer of the plurality of resolution-independent convolutional layers.
13 . The computer program of claim 11 , wherein the visualization method is a Grad-CAM (gradient-weighted class activation mapping) visualization method.
14 . The computer program of claim 11 , wherein the instructions for selecting the image for input to the ML model for an inference operation further comprises instructions for upscaling the image to provide the increased resolution.
15 . The computer program of claim 11 , further comprising instructions for generating a plurality of heat maps from the plurality of activation maps to use in the visualization method.
16 . The computer program of claim 11 , wherein the neural network is used for one of image classification, object detection, semantic segmentation, or instance segmentation.
17 . The computer program of claim 11 , further comprising instructions for adding a layer after a final convolutional layer of the plurality of resolution-independent convolutional layers to adjust for a mismatch between an output size of the final resolution-independent convolutional layer and an input of a first resolution-dependent layer.
18 . The computer program of claim 17 , wherein the added layer comprises one of either an average pooling layer, max pooling layer, global average pooling layer, or global max pooling layer.
19 . The computer program of claim 11 , further comprising:
adding a fully connected layer after the plurality of resolution-independent convolutional layers; and
training only the added fully connected layer.
20 . The computer program of claim 11 , further comprising computing an average gradient for each activation map of the plurality of activation maps.