Pruning CXR Models

PyTorch · TorchXRayVision · Model Pruning · Medical AI Fairness

Research question

Can a chest X-ray model become small enough for resource-constrained devices without losing diagnostic performance or increasing demographic bias? This course project for Deep Learning Beyond Accuracy at NC State tests that trade-off directly.

Method

We applied unstructured L1 pruning to the convolutional weights of a pretrained TorchXRayVision DenseNet-121 model. The evaluation used 2,797 unique patients from the NIH ChestX-ray8 test set and focused on atelectasis, infiltration, pleural thickening, and pneumonia.

We tested sparsity from 0% through 100%. At each level, we measured AUROC, recall, and specificity. We also compared worst-group accuracy and true-positive-rate disparity across sex and age groups.

Performance under pruning

Line chart showing almost no AUROC change through 80 percent pruning, followed by sharp declines at higher sparsity levels
AUROC stays close to the unpruned baseline through 80% sparsity. Most conditions decline sharply above 85% to 90%.

The model retained nearly all baseline AUROC through 80% sparsity. Beyond 85% to 90%, performance fell quickly. At extreme pruning levels, predictions became almost constant: recall moved toward 1 while specificity collapsed toward 0.

Fairness across age groups

Four charts comparing AUROC, worst-group accuracy, true-positive-rate disparity, and accuracy gaps across age groups and pruning levels
Age-group metrics remain stable through 80% sparsity. Changes at extreme sparsity occur alongside total model failure.

Pruning did not materially worsen or correct the existing performance gaps between sex or age groups before the model collapsed. This suggests that the observed inequities came mainly from the training data, not from the low-magnitude weights removed during pruning.

What the weights show

Weight distributions across DenseNet model blocks at zero, 80, and 90 percent pruning
High-magnitude weights remain structurally similar at 80% sparsity, showing substantial redundancy in the pretrained model.

Contributions and status

I worked on exploratory data analysis, data cleaning, TorchXRayVision setup and integration, and results analysis.

This is exploratory course-project work preserved for reference. The repository contains rough notebooks, incomplete experiments, and environment-specific paths rather than a repeatable production pipeline.