This is a very simple instruction of how to construct DenseNet121 from scratch which is very easy for one who wants to modify some layers. To make sure that this implementation is correct, I try to test the result on CIFAR10. The result for the first 5 epochs (with the pre-trained weights on ImageNet) and 20 epochs (without the pre-trained weights on ImageNet) of training:
Model | Result (%) |
---|---|
Original DenseNet121 without ImageNet weights (20 epochs) | 16.17 |
Original DenseNet121 with the fixed ImageNet weights | 61.15 |
Original DenseNet121 with the adjustable ImageNet weights | 82.06 |
Implemented DenseNet121 without ImageNet weights (20 epochs) | 64.33 |
Implemented DenseNet121 with the adjustable ImageNet weights | 82.85 |
Custom DenseNet121 without ImageNet weights (20 epochs) | 64.60 |
The ImageNet weights of a pre-trained DenseNet 121 can be downloaded using the keras-team's link: https://github.com/keras-team/keras-applications/releases/download/densenet/densenet121_weights_tf_dim_ordering_tf_kernels_notop.h5
Here is an example of the modified DenseNet121.
Please feel free to edit and adjust for creating your own custom DenseNet!