Using this code you can visualize the features represented by a layer in a CNN using Guided Backpropagation (GBP) and calculate the SSIM Cut to find optimal depth to avoid overfitting.
Python 3.7 or later
see requirement.txt
for exact authors environment.
At first, we need to train a model and save the model. The following code will train a model on Weedling dataset and save the model that has the highest testing accuracy.
python Train_ResNet_Save_Model.py
Next, we need to calculate GBP of each convolutional layer of ResNet-50, as follows
python Save_Layerwise_GBP.py
Save_Layerwise_GBP.py takes a trained model and saves the GBP of each layer in, 'results/'.
Finally we need to run
python SSIM_Cut.py
SSIM_Cut.py takes the generated GBP images and calculate the SSIM Cut Curve for that model and saves the result in, './results'.
Here is an example of the GBP of different models on the Weedling dataset:
GBP of the final convolutional layer for different CNN models used in the study on the Weedling dataset.