visualizing what convnets learn gradient of the african elephantclass with regard to the output feature map of block _conv vector of shape ( ,)where each entry is the mean intensity of the gradient over specific feature-map channel grads gradients(african_elephant_outputlast_conv_layer output)[ pooled_grads mean(gradsaxis=( )iterate function([model input][pooled_gradslast_conv_layer output[ ]]pooled_grads_valueconv_layer_output_value iterate([ ]for in range( )conv_layer_output_value[:: *pooled_grads_value[iheatmap np mean(conv_layer_output_valueaxis=- the channel-wise mean of the resulting feature map is the heatmap of the class activation values of these two quantitiesas numpy arraysgiven the sample image of two elephants lets you access the values of the quantities you just definedpooled_grads and the output feature map of block _conv given sample image multiplies each channel in the feature-map array by how important this channel iswith regard to the elephantclass for visualization purposesyou'll also normalize the heatmap between and the result is shown in figure listing heat map post -processing heatmap np maximum(heatmap heatmap /np max(heatmapplt matshow(heatmap figure african elephant class act ivation heatmap over the est picture licensed to