Early detection and classification of pneumonia are helpful to reduce mortality. As the current algorithms are not particularly effective in pneumonia classification, and DenseNet has the advantages of solving gradient disappearance, reducing model parameters, and feature reusing in the deep networks, this paper proposes a method based on DenseNet to classify pneumonia in chest X-ray images. For highlighting the pneumonia information in the feature map, a feature
channel attention block Squeeze and Excitation (SE) is added to DenseNet. To further focus on the lesion region, we replace the average pooling of the third transition layer in DenseNet with max-pooling. By comparing several activation functions, we choose PReLU to avoid neuron death in the process of model training ultimately. Moreover, we preprocess the chest X-ray2017 dataset with data augmentation and normalization. Experiments show that our model’s Accuracy, Precision, Recall and F1-score can reach 92.8%, 92.6%, 96.2%, 94.5%, while the original DenseNet’s Accuracy, Precision, Recall and F1-score are only 90.4%, 90.6%, 94.4%, 92.5% respectively.