When training convolutional neural network (CNN), we mostly rely on training and validation loss to assess the performance of the trained model.
Often the need to visualise the feature maps learned by the trained CNN is overlooked. Probably because it is easier to retrain a network with new parameters rather than looking at each individual feature map.
To make the visualisation of the feature maps an easier task I am going to show the usage of a GUI toolbox. Once setup, it is extremely easy to visualise the features maps using this toolbox. The tool is available at Github to visualise models trained in Keras.
Once setup, to start the GUI interface simply run:
This will pop up a GUI interface:
The first step is to select the Keras trained model file (*h5/*hdf5) using browse option in GUI
Note: You can save pertained models from keras application to hdf5/h5 format as:
from keras.applications.vgg16 import VGG16 model = VGG16(include_top=False, weights=’imagenet’) model.save(‘model-vgg16.hdf5’)
Once model is selected click ‘Parse Model’ button. This will save the model flowchart as PNG file in the current working directory and you will be able to see all the layer names in the ‘choose a Layer’ drop down menu. Select a layer for which you want to visualise features maps, then select an input image using the ‘input Image’ button.
Click on ‘Compute Feature’ button, which will compute all the feature maps for the selected layer in the background. Wait for few seconds to finish computation, the wait time will depend on the complexity of the model.
Once finished computation of the feature map you can visualise feature map using the ‘Display’ button.
Many options are available to visualise feature maps such as numerous colormaps from the ‘Display colormap’ menu and the number of images to display per panel can be selected from the drop down menus as well.
Some of the feature maps visualised using the GUI for VGG16 are shown below, it is very easy to to visualise the feature maps using this GUI just select the layer name from the drop down menu.
The currently supported input image formats are JPEG, PNG, TIFF, and BMP. Options are available to load any arbitrary image format and additional preprocessing steps can be added. Visit authors Github for more info.