Skip to main content
. 2021 Nov 22;11(11):1281. doi: 10.3390/life11111281
Algorithm 4. The DenseNet121 model description.
Input: CXR images of dimension 500 × 500 pixels from the Training CXR-Dataset
Output: DenseNet model weights
1. epochs ← 100
2. for each image in the dataset do
3. resize the image to 224 × 224 pixels
4. normalize the image pixels values from (0,255) to (0,1)
5. end
6. Load the DenseNet121 model pre-trained on the ImageNet dataset
7. Make non-trainable all the layers of the model
8. Add a Flatten layer to the model output to obtain a 1-D array of features
9. Apply a batch normalization to the 1-D array of features
10. Add a fully connected layer with 512 hidden neurons
11. Apply a dropout for inactivate units (20%) in the previous layer
12. Add a fully connected layer with 256 hidden neurons
13. Apply a dropout for inactivate units (65%) in the previous layer
14. Apply a batch normalization
15. Add a fully connected layer with four hidden units and a softmax activation function.
16. Optimize the model with Adam optimizer using a learning_rate = 0.001 and a decay = learning_rate/epochs
17. Train the model for the given number of epochs and a batch size of 32
18. Save the final model