Adversarial attacks and adversarial robustness in computational pathology

Narmin Ghaffari Laleh, Daniel Truhn, Gregory Patrick Veldhuizen, Tianyu Han, Marko van Treeck, Roman D. Buelow, Rupert Langer, Bastian Dislich, Peter Boor, Volkmar Schulz, Jakob Nikolas Kather

Abstract

Artificial Intelligence (AI) can support diagnostic workflows in oncology by aiding diagnosis and providing biomarkers directly from routine pathology slides. However, AI applications are vulnerable to adversarial attacks. Hence, it is essential to quantify and mitigate this risk before widespread clinical use. Here, we show that convolutional neural networks (CNNs) are highly susceptible to white- and black-box adversarial attacks in clinically relevant weakly-supervised classification tasks. Adversarially robust training and dual batch normalization (DBN) are possible mitigation strategies but require precise knowledge of the type of attack used in the inference. We demonstrate that vision transformers (ViTs) perform equally well compared to CNNs at baseline, but are orders of magnitude more robust to white- and black-box attacks. At a mechanistic level, we show that this is associated with a more robust latent representation of clinically relevant categories in ViTs compared to CNNs. Our results are in line with previous theoretical studies and provide empirical evidence that ViTs are robust learners in computational pathology. This implies that large-scale rollout of AI models in computational pathology should rely on ViTs rather than CNN-based classifiers to provide inherent protection against perturbation of the input data, especially adversarial attacks.

Introduction

As computational pathology transitions from research environments to clinical practice, AI models are increasingly tasked with high-stakes decisions, such as cancer subtyping and biomarker identification. While these models often achieve human-level performance, they remain "black boxes" susceptible to adversarial attacks. These attacks involve malicious, sub-visual perturbations to an image that, while undetectable to a human pathologist, can cause an AI model to make confident, incorrect predictions. In a clinical setting, such vulnerabilities could lead to misdiagnosis, inappropriate treatment plans, or insurance fraud. This study quantifies these risks across standard architectures and explores the inherent robustness of Vision Transformers (ViTs) as a potential solution.

Methodology

The researchers conducted a comparative analysis between two dominant AI architectures:

  1. Convolutional Neural Networks (CNNs): Specifically ResNet50 and Big Transfer (BiT), which process images by identifying local hierarchical patterns like edges and textures.
  2. Vision Transformers (ViTs): An architecture that decomposes images into discrete patches and employs self-attention mechanisms to understand global relationships across the entire image.
Schematic comparison of ResNet and ViT architectures.

The models were subjected to a battery of six adversarial algorithms, including white-box attacks (e.g., Projected Gradient Descent (PGD), Fast Gradient Sign Method (FGSM)) where the attacker has full access to model parameters, and black-box attacks (e.g., Square attack) where only the model's output is accessible. The study also evaluated "hardening" techniques, such as adversarial training and Dual Batch Normalization (DBN), to determine if CNN vulnerabilities could be effectively mitigated.

Experimental Setup and Datasets

To ensure generalizability, the study utilized four distinct patient cohorts across two major cancer types:

  • Renal Cell Carcinoma (RCC): Models were trained on the TCGA-RCC dataset (897 patients) and validated on the independent AACHEN-RCC cohort (249 patients) to distinguish between three histological subtypes.
  • Gastric Cancer: Models were trained on TCGA-GASTRIC (191 patients) and validated on the BERN-GASTRIC cohort (249 patients) to classify tumors into diffuse or intestinal types.

Results and Discussion

Baseline Performance Parity

On clean, unperturbed images, both ResNet and ViT architectures performed exceptionally well and were statistically indistinguishable. For RCC subtyping, both models achieved an Area Under the Receiver Operating Characteristic (AUROC) of approximately 0.96. In gastric cancer subtyping, the performance was also comparable (p=0.24), establishing a level playing field for robustness testing.

Comprehensive overview of architectures, baseline performance, and histological data.

The Fragility of CNNs

Under adversarial pressure, the performance of CNNs collapsed. When subjected to high-strength PGD noise—noise so slight it remains invisible to the human eye—the ResNet’s AUROC for RCC subtyping plummeted from 0.960 to 0.429. In the more challenging gastric cancer task, the model's accuracy effectively dropped to zero. This suggests that CNNs rely on fragile, local "anchors" that are easily disrupted by targeted noise.

The Inherent Robustness of ViTs

In contrast, ViTs demonstrated remarkable resilience without any specialized "hardening" during training. Under the same high-strength PGD attack that crippled the CNN, the ViT maintained a robust AUROC of 0.827 for RCC. This resilience is attributed to the ViT's global attention mechanism; rather than fixating on tiny pixel groups, ViTs spread their focus across multiple regions of the tissue slide, making it significantly harder for localized perturbations to derail the classification.

Latent Space and Interpretability

Using Principal Component Analysis (PCA), the authors visualized the models' internal representations. Under attack, the CNN’s internal clusters for different cancer types became a jumbled mess, losing all discriminative power. Conversely, the ViT’s latent space remained organized, with distinct clusters for each category. Grad-CAM visualizations further confirmed that ViTs maintain a more holistic view of the histological features compared to the hyper-localized focus of CNNs.

Conclusion

While techniques like adversarial training can bolster CNN performance against specific threats, they often fail to generalize to unknown attack types. Vision Transformers offer a superior alternative by providing inherent, "out-of-the-box" protection against adversarial perturbations. For the safe and secure rollout of AI in clinical pathology, the results strongly suggest that ViT-based architectures should be prioritized over traditional CNNs to ensure diagnostic integrity against both accidental and malicious data corruption.

Summary updated

BibTeX
@inproceedings{laleh2022adversarial,
  author = {Narmin Ghaffari Laleh and Daniel Truhn and Gregory Patrick Veldhuizen and Tianyu Han and Marko van Treeck and Roman D. Buelow and Rupert Langer and Bastian Dislich and Peter Boor and Volkmar Schulz and Jakob Nikolas Kather},
  title = {{Adversarial attacks and adversarial robustness in computational pathology}},
  booktitle = {Nature Communications},
  year = {2022},
  doi = {10.1038/s41467-022-33266-0},
}
Figure