Ever wondered what filters created in Convolutional Neural Network layers look like? I have used the popular VGG16 model and visualized various filters from different layers of CNN. I did this by using the gradient ascent optimization algorithm to visualize images that maximally activate specific filters from different layers of the model. I have chosen TensorFlow as my machine learning framework. The first image represents the random picture that is chosen by the algorithm. 2nd, 3rd, 4th, and 5th images are randomly selected filters at a variety of blocks and convolutional layers, and their locations have shown in their title. It is obvious that, as you progress through the convolutional layers and blocks, you see that the images are more detailed and suitable for detailed filtering. At the last block of the VGG16 model, the trained network is already created its filter for the corresponding picture for classification. Furthermore, the loss function of the images increases as the block number increases because of its complex characterization but it is 0 at the block 5 location.
* Python3
* TensorFlow
* Keras
* Jupyter Notebook or any suitable integrated development environment (IDE)
- Download the Main.py
- Open it with any IDE which is suitable for Python Machine Learning.
- You can change the iteration number to observe further information about filters and loss functions in the system.
- Additionally, you can try other trained CNNs and look at image classification accuracy.
Please share your comments and ideas about the project with me. Thank you for your time.





