Create visually appealing activation maps

Source: Deep Learning on Medium

Create visually appealing activation maps

In this tutorial, you will how to create to make activations map more visually appealing, without loosing information about the map.

Despite the wide availability of large databases and pre-trained CNN models, sometimes it becomes quite difficult to understand what and how exactly your large model is learning, especially for people without the required background of Machine Learning.

Vizualizer class

First of all, we are going to create a class called Visualized. We will initialize the class with everything needed to plot an activation map for the model. Then we will add a visualize method

The only tricky part in the code is the color_precision variable, let me explain.

standardization forula

We are going to standardize the feature maps. Then we clip every negative values (i.e: they had a lower value than the mean of the feature map) to zero, and multiply positive values by 255//color_precision. If we put color_precision to 1, almost every positive values will be equal to 255, however with a bigger value (3/4 gives good results) we can have a more precise segmentation of the map.

The code

You can find here the visualizer class, with a fully functional example. Feel free to use the class to visualize your trained CNNs.