Masked Images Are Counterfactual Samples for Robust Fine-tuning

Yao Xiao, Ziyi Tang, Pengxu Wei, Cong Liu, Liang Lin
3/6/2023
cs.CVcs.LG

Official code: Coxy7/robust-finetuning (14 stars, Apache-2.0, last commit 2023-03-24).

Abstract

Deep learning models are challenged by the distribution shift between the training data and test data. Recently, the large models pre-trained on diverse data have demonstrated unprecedented robustness to various distribution shifts. However, fine-tuning these models can lead to a trade-off between in-distribution (ID) performance and out-of-distribution (OOD) robustness. Existing methods for tackling this trade-off do not explicitly address the OOD robustness problem. In this paper, based on causal analysis of the aforementioned problems, we propose a novel fine-tuning method, which uses masked images as counterfactual samples that help improve the robustness of the fine-tuning model. Specifically, we mask either the semantics-related or semantics-unrelated patches of the images based on class activation map to break the spurious correlation, and refill the masked patches with patches from other images. The resulting counterfactual samples are used in feature-based distillation with the pre-trained model. Extensive experiments verify that regularizing the fine-tuning with the proposed masked images can achieve a better trade-off between ID and OOD performance, surpassing previous methods on the OOD performance. Our code is available at https://github.com/Coxy7/robust-finetuning.

View on arXivView PDF

Code Implementations(1)

Apache-2.0

[CVPR 2023] Code for the paper "Masked Images Are Counterfactual Samples for Robust Fine-tuning"

141Shell, PythonMar 24, 20233 years agoApache-2.0

Similar Papers

Cite this paper

@article{xiao2023masked,
  title  = {Masked Images Are Counterfactual Samples for Robust Fine-tuning},
  author = {Yao Xiao and Ziyi Tang and Pengxu Wei and Cong Liu and Liang Lin},
  year   = {2023},
  eprint = {2303.03052},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2303.03052v3},
  journal = {CVPR 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2303.03052.svg)](https://codeofpaper.com/paper/2303.03052)

Discussion