potentialpaper

Improving Context-Shift Robustness of Convolutional Networks via Context-Regularized Cross-Entropy

Jinen Setpal, Chaoyue Liu

NeurIPS 2026

Edit this page

Or clone it with git

Run in a terminal:

Needs Git LFS. To push, use an API key from your profile as the password.

Or let your agent set it up

It checks and sets up everything: signing in, git, the clone, credentials and an SSH key.

TL;DR. We develop an approach to improve the robustness of convolutional networks under context-shift (i.e., when targets are present in novel environments).

Abstract. Image classification models often encounter objects in diverse and unpredictable contexts at test time, which may differ substantially from those seen during training. This phenomenon, termed context shift, exposes a key fragility in neural networks: when models rely on non-causal contextual cues for prediction, shifts in context can lead to significant performance degradation. In this paper, we propose a novel training framework to improve the robustness of convolutional neural networks under context shift. Our approach leverages spatial feature attribution to guide models toward making predictions that rely less on contextual regions and more on object-relevant features. As a first step, recognizing a theoretical limitation of existing feature attribution methods we introduce a new variant, ContrastiveCAMs, which produces more faithful attribution maps of model predictions. Building on ContrastiveCAMs, we further propose Context-Regularized Cross-Entropy (CR-CE), a modification of the standard cross-entropy loss that regularizes the model’s attention by suppressing the influence of contextual regions, thereby improving robustness to context shift. We evaluate the effectiveness of our approach on several medium-to-large scale datasets (Waterbirds, Spawrious, ImageNet/ImageNet-BG, Hard-ImageNet), and report consistent improvements in context-shift robustness.

Are you an author? Claim this paper to see who's reading it, with views and other statistics, and to write about it here.

Claim this paper
How does this paper connect to your work? Write how you built on it, compared with it or reproduced it, or add a summary, a critique or errata.
Or make it interactive:
Start writing

edit · history

DateVersionSubmitted toPDFEvidence
1 May 2026NeurIPS 2026submittedNeurIPS 2026Accept (poster)reviews ↓[1]PDF[1]
Missing a version?

NeurIPS 2026

Accept (poster) · 3 reviews · OpenReview

Updated 25 Nov 2026, 03:47 UTC.

Program Chairs · DecisionOpenReview ↗
Decision
Accept (poster)
Read decision
Meta-review

The paper presents a training strategy designed to enhance the robustness of CNN-based classifiers against context shifts. The approach leverages state-of-the-art segmentation models to extract object masks from training images and introduces a regularization loss that encourages the classifier to focus on the object itself rather than contextual cues. Specifically, the loss enforces alignment between the class activation map and the segmented object region. Experimental results across multiple datasets demonstrate that the proposed method effectively improves robustness to context shifts while maintaining strong classification performance. A key strength highlighted across the reviews is the simplicity and practicality of the proposed CR-CE loss, which integrates naturally into standard classification training without requiring substantial architectural modifications. Reviewers also appreciated the use of modern segmentation models and the empirical evidence showing that the method successfully shifts model attention toward object regions. The experimental gains on datasets such as Waterbirds and Spawrious are particularly compelling and indicate that the approach can significantly improve robustness under severe context shifts. However, there are some concerns: Reviewer 1 questioned the novelty of ContrastiveCAMs relative to recent attribution methods such as DiffGradCAM and noted that the experimental comparisons do not sufficiently isolate the contribution of the proposed CR-CE loss from the benefits obtained by incorporating object masks during training. Multiple reviewers also observed that the baseline comparisons could be strengthened by including additional mask-based or explanation-guided approaches and by evaluating simpler segmentation-based alternatives. Another recurring concern is the dependence on object masks and the lack of detailed analysis regarding robustness to mask quality or segmentation errors. Furthermore, the reported gains on ImageNet-BG are more modest and appear to involve a trade-off with standard accuracy, raising questions about the practical benefit of the method in large-scale natural image settings. Additional ablations examining mask quality, masking approximations, and the behavior of ContrastiveCAMs would strengthen the paper. Reviewers also noted the limited architectural diversity of the experiments, which are currently restricted to ResNet-50 variants, and the lack of discussion regarding applicability beyond CNN-based image classification. The authors are expected to address all these issues in the rebuttal stage.

Final justification

I recommend acceptance. The paper addresses an important and timely problem—improving robustness to context shifts in image classification—and proposes a simple yet effective training strategy that can be readily integrated into existing CNN-based classification pipelines. The proposed CR-CE loss is intuitive, practical, and does not require substantial architectural modifications, making it particularly attractive from both a research and deployment perspective. The experimental results consistently demonstrate improved robustness across multiple benchmarks, with especially strong gains on challenging datasets such as Waterbirds and Spawrious. The evidence also indicates that the method successfully encourages models to focus on object regions rather than spurious contextual cues, which directly supports the paper’s central motivation. While the reviewers raise valid concerns regarding novelty, the scope of baseline comparisons, and the dependence on segmentation masks, I do not view these issues as sufficiently significant to outweigh the paper’s strengths. The core contribution lies not in introducing a fundamentally new attribution method, but in presenting a simple and effective regularization framework that leverages modern segmentation models to improve robustness in a practical manner. The reported empirical improvements are convincing, and the proposed approach appears broadly applicable within the CNN-based classification setting considered in the paper. As an important note, reference [38] appears to be a hallucinated citation and should be corrected. I would also like to emphasize that the presence of multiple such references would be a serious concern and could constitute grounds for automatic rejection.

Area Chair rR12 · Meta-reviewOpenReview ↗
Read meta-review
Meta-review

The paper presents a training strategy designed to enhance the robustness of CNN-based classifiers against context shifts. The approach leverages state-of-the-art segmentation models to extract object masks from training images and introduces a regularization loss that encourages the classifier to focus on the object itself rather than contextual cues. Specifically, the loss enforces alignment between the class activation map and the segmented object region. Experimental results across multiple datasets demonstrate that the proposed method effectively improves robustness to context shifts while maintaining strong classification performance. A key strength highlighted across the reviews is the simplicity and practicality of the proposed CR-CE loss, which integrates naturally into standard classification training without requiring substantial architectural modifications. Reviewers also appreciated the use of modern segmentation models and the empirical evidence showing that the method successfully shifts model attention toward object regions. The experimental gains on datasets such as Waterbirds and Spawrious are particularly compelling and indicate that the approach can significantly improve robustness under severe context shifts. However, there are some concerns: Reviewer 1 questioned the novelty of ContrastiveCAMs relative to recent attribution methods such as DiffGradCAM and noted that the experimental comparisons do not sufficiently isolate the contribution of the proposed CR-CE loss from the benefits obtained by incorporating object masks during training. Multiple reviewers also observed that the baseline comparisons could be strengthened by including additional mask-based or explanation-guided approaches and by evaluating simpler segmentation-based alternatives. Another recurring concern is the dependence on object masks and the lack of detailed analysis regarding robustness to mask quality or segmentation errors. Furthermore, the reported gains on ImageNet-BG are more modest and appear to involve a trade-off with standard accuracy, raising questions about the practical benefit of the method in large-scale natural image settings. Additional ablations examining mask quality, masking approximations, and the behavior of ContrastiveCAMs would strengthen the paper. Reviewers also noted the limited architectural diversity of the experiments, which are currently restricted to ResNet-50 variants, and the lack of discussion regarding applicability beyond CNN-based image classification. The authors are expected to address all these issues in the rebuttal stage.

Final justification

I recommend acceptance. The paper addresses an important and timely problem—improving robustness to context shifts in image classification—and proposes a simple yet effective training strategy that can be readily integrated into existing CNN-based classification pipelines. The proposed CR-CE loss is intuitive, practical, and does not require substantial architectural modifications, making it particularly attractive from both a research and deployment perspective. The experimental results consistently demonstrate improved robustness across multiple benchmarks, with especially strong gains on challenging datasets such as Waterbirds and Spawrious. The evidence also indicates that the method successfully encourages models to focus on object regions rather than spurious contextual cues, which directly supports the paper’s central motivation. While the reviewers raise valid concerns regarding novelty, the scope of baseline comparisons, and the dependence on segmentation masks, I do not view these issues as sufficiently significant to outweigh the paper’s strengths. The core contribution lies not in introducing a fundamentally new attribution method, but in presenting a simple and effective regularization framework that leverages modern segmentation models to improve robustness in a practical manner. The reported empirical improvements are convincing, and the proposed approach appears broadly applicable within the CNN-based classification setting considered in the paper. As an important note, reference [38] appears to be a hallucinated citation and should be corrected. I would also like to emphasize that the presence of multiple such references would be a serious concern and could constitute grounds for automatic rejection.

1 comment
Authors · CommentOpenReview ↗

Response to meta review

We thank the AC and reviewers for their constructive and comprehensive reviews and meta review. These reviews helped a lot in strengthening the paper. We have provided a detailed rebuttal for each of the reviews and hope that they address all the concerns raised in the reviews. We provide a summary of the rebuttal here for AC’s reference, and welcome AC to check the details in each of our responses.

Regarding the novelty of ContrastiveCAM: "Reviewer 1 questioned the novelty of ContrastiveCAMs relative to recent attribution methods such as DiffGradCAM"

A: We apologize for the oversight of the technical similarity between the definitions of ContrastiveCAM and DiffGradCAM. We will give credit to DiffGradCAM [1] for the invention of this type of CAMs.

However, this does not affect the novelty and contributions of this paper. Because ContrastiveCAM and DiffGradCAM are based on different CAMs (HiResCAM and GradCAM, respectively), the key property of ContrastiveCAM (Proposition 3.6) does not hold for DiffGradCAM, and the loss functions (standard CE or CR-CE) cannot be expressed as a function of DiffGradCAMs. Therefore, our context-shift robustness technique does not extend to DiffGradCAMs.

For your reference, we list the novelty and contributions of our paper here: (1) the theoretical connection between (CE-type) loss and CAMs (i.e., Proposition 3.6); and (2) the CR-CE training framework for context-shift robustness.

Regarding the modest gain on ImageNet-BG: "the reported gains on ImageNet-BG are more modest ... raising questions about the practical benefit of the method in large-scale natural image settings."

A: We hypothesize that the modest gain on the context-shifted images of ImageNet-BG is due to the fact that most of these shifted-contexts are not “misleading” at all, as the image backgrounds are randomly selected from a set of generic contexts. Therefore, in the standard CE training, most of these shifted-contexts do not actually result in wrong predictions, as evident by the high accuracy on context-shifted ImageNet-BG.

We think that the benefits of our method become significant in adversarial settings where the shifted-contexts have semantically opposite meanings to the object, like in the Waterbirds and Spawrious datasets. We will include empirical evidence in the revision.

Regarding additional experimental comparisons and/or evaluations:

We conducted extensive experiments to address the raised concerns. Please see the detailed experimental results in the rebuttal to reviews. Overall, these additional experimental results are in favor of our proposed method, and strengthen the paper. We will add these comparisons in the revision.

  • Comparison with mask-based methods: our method shows stronger context-shift robustness compared with mask-based methods: mask-only method [2] and Causal Feature Alignment [3].
  • Robustness to segmentation mask quality. When tested on manually added mask noise, the performance of our method suffers a slight drop, verifying that it does not rely on high quality of segmentation masks, as claimed in the paper.
  • Test on different architecture. We tested our method on a different CNN-based architecture, specifically, EfficientNetv2 [4], as well as different ResNet scales (ResNet-18). The results show that our method remains effective in improving the context-shift robustness across various architectures.

[1] Piland, Jacob, Chris Sweet, and Adam Czajka. "Diffgradcam: A universal class activation map resistant to adversarial training." arXiv preprint arXiv:2506.08514 (2025).
[2] Aniraj, Ananthu, Cassio F. Dantas, Dino Ienco, and Diego Marcos. "Masking strategies for background bias removal in computer vision models." In Proceedings of the IEEE/CVF international conference on computer vision, pp. 4397-4405. 2023.
[3] Venkataramani, Rahul, Parag Dutta, Vikram Melapudi, and Ambedkar Dukkipati. "Causal feature alignment: Learning to ignore spurious background features." In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pp. 4666-4674. 2024.
[4] Tan, Mingxing, and Quoc Le. "Efficientnetv2: Smaller models and faster training." In International conference on machine learning, pp. 10096-10106. PMLR, 2021.

Reviewer amfBOpenReview ↗
Rating
4/6
Confidence
3/5
Quality
3/4
Clarity
3/4
Significance
2/4
Originality
3/4
Contribution type
general
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

Summary

This paper studies context-shift robustness in convolutional neural networks. The main idea is that CNNs often rely too much on background/context rather than the actual object, which hurts performance when the object appears in an unusual environment. The authors first point out a limitation of HiResCAM-style attribution under softmax, then propose ContrastiveCAMs as a more prediction-faithful attribution method. Based on this, they introduce Context-Regularized Cross-Entropy (CR-CE), which uses object-context masks during training to reduce context influence. Experiments on Waterbirds-100, Spawrious, ImageNet-BG, and Hard-ImageNet show improved robustness under context shift, especially on Waterbirds and Spawrious.

Strengths and weaknesses

Strengths and Weaknesses

Strengths. The problem is clear and meaningful. The paper gives intuitive examples showing how background can dominate prediction, especially in Figure 1. The theoretical motivation for ContrastiveCAMs is also fairly clean: the authors explain the softmax shift issue and connect it to attribution faithfulness through Eq. 4–11. CR-CE is simple and easy to understand, since it modifies the CE loss rather than adding a large extra module (Eq. 12). The experimental results are strong on several benchmarks. For example, on Waterbirds-100, shifted accuracy improves from around 41.74/38.40 with CE to 76.79/81.37 with CR-CE, and Spawrious also shows clear gains over CE, ABN, and GALS (Table 2; Table 3).

Weaknesses. The main limitation is the reliance on object-context masks during training. The paper says imperfect masks are acceptable, but the main text does not provide enough analysis on how sensitive the method is to mask quality (Sec. 4; Sec. 5.1). This matters because in real applications, good masks may be expensive or noisy. Another limitation is that the method is mainly designed for CNNs; the authors note that it does not naturally extend to ViTs (Limitations). The comparison with prior explanation-guided methods is also somewhat incomplete, since RRR and energy-based baselines are omitted due to computational cost (Sec. 5.1). Finally, the gains on ImageNet-BG are relatively modest: CR-CE improves shifted accuracy only slightly while reducing no-shift accuracy (Table 2), so the benefit on large-scale natural images is less clear than on smaller or more controlled benchmarks.

Questions

Key Questions for Authors

  1. How robust is CR-CE to noisy or inaccurate object-context masks? A mask-noise study would help clarify whether the method is practical outside curated datasets.

  2. Why is the improvement on ImageNet-BG relatively small compared with Waterbirds and Spawrious? Understanding this would help judge the method’s scalability and real-world impact.

  3. Could the authors include at least one cheaper comparison with RRR or an energy-based method on a smaller dataset? This would make the empirical comparison more complete, even if ImageNet-scale experiments are too expensive.

Suggestions for Improvement

The paper would be stronger with an ablation on mask quality, such as using eroded, dilated, or partially corrupted masks. It would also help to report training time and memory overhead more explicitly, since the paper claims CR-CE has only minor computational cost. For ImageNet-BG, the authors could add a short failure-case analysis to explain when CR-CE helps and when it does not. Finally, adding even a small-scale comparison with omitted explanation-guided baselines would make the experimental section more convincing.

Limitations

Limitations

The authors do discuss two important limitations: the method does not naturally extend to transformer architectures, and it requires object-context segmentation during training. This is a fair discussion. However, the paper could further discuss the cost and reliability of obtaining masks, the effect of mask noise, and possible issues in multi-object or ambiguous-background images.

Final justification

All my concerns are addressed, however, I agree with the novelty concerns raised by Reviewer Fr6z, so I will maintain Borderline accept.

Formatting concerns

N/A

4 comments
Authors · RebuttalOpenReview ↗
Rebuttal

We thank the reviewer for their constructive and comprehensive review.


W1: "The main limitation is the reliance on object-context masks during training. The paper says imperfect masks are acceptable, but the main text does not provide enough analysis on how sensitive the method is to mask quality (Sec. 4; Sec. 5.1). This matters because in real applications, good masks may be expensive or noisy.", Q1: "How robust is CR-CE to noisy or inaccurate object-context masks? A mask-noise study would help clarify whether the method is practical outside curated datasets.", & S1: "The paper would be stronger with an ablation on mask quality, such as using eroded, dilated, or partially corrupted masks."
A: Thank you and reviewer FYep for bringing up this point. We certainly agree: a mask-noise study can provide useful empirical evidence towards the practicality of our proposed method. We test the tolerance of imperfect object-context masks by corrupting them using random affine transformations. The corrupted masks share a mIoU of ~60% with the original masks. We report accuracies from training on these corrupted masks in the table below:

CAM Resolution Approach Waterbirds (No Context Shift) Waterbirds (Context Shifted) Spawrious (Many-to-Many Corr., Hard Subtask)
7x7 CE 98.66 ± 0.10 41.74 ± 4.15 77.63 ± 0.47
7x7 CR-CE 93.81 ± 0.12 76.79 ± 0.18 86.53 ± 0.87
7x7 CR-CE (Noisier Masks) 92.7 ± 0.46 74.34 ± 1.31 84.76 ± 2.6
14x14 CE 98.48 ± 0.09 38.4 ± 1.79 64.98 ± 0.86
14x14 CR-CE 93.9 ± 0.04 81.37 ± 0.39 86.13 ± 0.33
14x14 CR-CE (Noisier Masks) 93.26 ± 2.16 78.79 ± 3.64 85.34 ± 1.9

We note that despite the imperfect masks, CR-CE incurs only a minor drop in context-shifted accuracy. This analysis provides empirical support to the statement on mask tolerance in the paper.

W3: "The comparison with prior explanation-guided methods is also somewhat incomplete, since RRR and energy-based baselines are omitted due to computational cost (Sec. 5.1).", Q3: "Could the authors include at least one cheaper comparison with RRR or an energy-based method on a smaller dataset? This would make the empirical comparison more complete, even if ImageNet-scale experiments are too expensive.", & S4: "Finally, adding even a small-scale comparison with omitted explanation-guided baselines would make the experimental section more convincing."
A: We started training runs for the energy-based guidance method [1] but given the limited time of rebuttal, we unfortunately do not have the numbers ready yet. We will make sure to update this question with the updated numbers as soon as we have it ready.

[1] Sukrut Rao, Moritz Böhle, Amin Parchami-Araghi, and Bernt Schiele. Studying how to efficiently and effectively guide models with explanations. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1922–1933, 2023.

W4: "Finally, the gains on ImageNet-BG are relatively modest: CR-CE improves shifted accuracy only slightly while reducing no-shift accuracy (Table 2), so the benefit on large-scale natural images is less clear than on smaller or more controlled benchmarks.", & Q2: "Why is the improvement on ImageNet-BG relatively small compared with Waterbirds and Spawrious? Understanding this would help judge the method’s scalability and real-world impact."
A: We hypothesize that the modest improvement on context-shifted ImageNet-BG arises because images of ImageNet-BG are random combinations of objects and backgrounds/context; in most of these images, the context has no semantic correlation with the object (namely not “misleading”), therefore, does not lead to a misclassification. As a comparison, in the context-shifted images of Waterbirds and Spawrious datasets, the contexts often have strong semantic correlation with opposite/non-target classes which strongly misleads the model’s predictions. Under the ImageNet/ImageNet-BG setting, we believe our method still provides a strong defense against malicious/adversarial context shifts, where the context is intentionally designed to fool the model.

S2: "It would also help to report training time and memory overhead more explicitly, since the paper claims CR-CE has only minor computational cost."
A: We report training time for all datasets and approaches in Appendix D, paragraph “Computational Resources”. We will also ensure to check and include the memory overheads for all approaches in our next revision.

S3: "For ImageNet-BG, the authors could add a short failure-case analysis to explain when CR-CE helps and when it does not"
A: We thank the reviewer for this suggestion. The authors of ImageNet-BG [2] consider the scenario of images that do not have clearly defined object-context regions. For example, in Figure 2 of [2], the authors identify such cases and preclude them from being assessed for context-robustness, since any given region is a priori causally connected to the prediction target. In this case, CR-CE cannot be used to improve the context-shift robustness of the model. We will ensure to include this detail in our next revision.

[2] Łukasz Piekarek and Kamil Szyc. Imagenet-bg: A toolkit and dataset for evaluating vision model robustness against background variations. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV) Workshops, pages 231–240, October 2025.

Authors · CommentOpenReview ↗

While the promised experiment of energy-based explanation guidance on the Waterbirds dataset is still running, we would like to politely follow up with the reviewer. We hope our rebuttal addresses your other concerns raised in the review. We remain active until the discussion deadline to address any remaining questions you may have. We believe any discussion will help strengthen this paper. Thank you very much!

Authors · CommentOpenReview ↗

We thank the reviewer for their patience while we prepared comparisons of our method with the energy-based method [1]. Specifically, we compare with their best setting which uses the energy-based loss with Eq. 1, Eq. 2 and Eq. 6. Our CR-CE framework outperforms the energy-based method; we report our findings below:

CAM Resolution Approach Waterbirds (No Context Shift) Waterbirds (Context Shifted)
7x7 CE 98.66 ± 0.10 41.74 ± 4.15
7x7 Energy-Based [1] 96.98 ± 0.61 61.73 ± 4.26
7x7 CR-CE (Ours) 93.81 ± 0.12 76.79 ± 0.18
14x14 CE 98.48 ± 0.09 38.4 ± 1.79
14x14 Energy-Based [1] 97.43 ± 0.3 59.09 ± 8.26
14x14 CR-CE (Ours) 93.9 ± 0.04 81.37 ± 0.39

We will add this comparison to our next revision.

[1] Sukrut Rao, Moritz Böhle, Amin Parchami-Araghi, and Bernt Schiele. Studying how to efficiently and effectively guide models with explanations. In Proceedings of the IEEE/CVF International Conference on Computer Vision, pages 1922–1933, 2023.

Reviewer amfB · CommentOpenReview ↗

The rebuttal is well responsive to the concerns I raised. I will take the other reviewers’ comments into consideration and adjust my score if appropriate.

Reviewer FYepOpenReview ↗
Rating
5/6
Confidence
4/5
Quality
3/4
Clarity
3/4
Significance
3/4
Originality
3/4
Contribution type
general
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

The paper looks at improving context robustness for image classifications using spatial feature attributions - specifically using the Class Activation Mappings (CAMs) - which has a limitation of the softmax being similar if each output logit is shifted by a similar amount. This limitation leads to the CAMs providing potentially incorrect assignments of importance of input pixels. The authors aim to correct this limitation using k-ContrastiveCAMs which subtracts the average of all CAMs from the current CAM - thus providing a class discriminative way of generating foreground attribution rather than the background contributions.

Strengths and weaknesses

Strengths -

  • The paper is very well written
  • The propositions are well formulated and they aid in the explainability of the paper
  • The properties of the ContrastiveCAMs to HiResCAMs is well explained

Weaknesses -

  • While the authors have dealt with image classification as the problem of choice, for classification, the CAMs are well defined and the object localization is not a problem. However, there needs to be a discussion about how ContrastiveCAMs can be used in the case of object detection, especially where the attention is completely on the background (example Fig. 3 of https://arxiv.org/pdf/2409.14679) rather than the foreground object. Will this method be able to still predict the correct class in the presence of such error?
  • Some important ablations are missing - how many CAMs are required and how much approximation about masking is tolerated?
  • How are the independence of the HiResCams captured?
Questions
  • How will this port over to object detection?
  • How much is it dependent on the value of 'k'?
  • This approach is dependent on SAM3 or MAE - how much approximation can be tolerated? Is there an approximation % vs accuracy which could be discussed.
Limitations

Yes

Final justification

Updated to accept.

Formatting concerns

None

4 comments
Authors · RebuttalOpenReview ↗
Rebuttal

We thank the reviewer for their constructive and comprehensive review.


W1: "... there needs to be a discussion about how ContrastiveCAMs can be used in the case of object detection, especially where the attention is completely on the background (example Fig. 3 of https://arxiv.org/pdf/2409.14679) rather than the foreground object. Will this method be able to still predict the correct class in the presence of such error?", & Q1: "How will this port over to object detection?"
A: This is an interesting direction, although object detection is out of the scope of our current work. We believe our method can help with object detection in such scenarios. Basically, our method suppresses contribution from background regions and encourages contribution of the foreground object. In the case where the attention is completely on the background (according to the attention map generated via standard CE training), the model trained by our method will be more likely to generate attention maps (i.e., the ContrastiveCAMs) that are more object-focused, thereby helping detect the object. In addition, the probability of obtaining the correct class prediction is further improved as a result of correctly detecting the objects.

W2: "Some important ablations are missing ... how much approximation about masking is tolerated?", & Q3: "This approach is dependent on SAM3 or MAE - how much approximation can be tolerated? Is there an approximation % vs accuracy which could be discussed."
A: Thank you and reviewer amfB for bringing up this point. We test the tolerance of mask imperfection by corrupting the object-context masks using random affine transformations. The corrupted masks share an mIoU of ~60% with the original masks. We report the results from training on these corrupted masks in the table below:

CAM Resolution Approach Waterbirds (No Context Shift) Waterbirds (Context Shifted) Spawrious (Many-to-Many Corr., Hard Subtask)
7x7 CE 98.66 ± 0.10 41.74 ± 4.15 77.63 ± 0.47
7x7 CR-CE 93.81 ± 0.12 76.79 ± 0.18 86.53 ± 0.87
7x7 CR-CE (Noisier Masks) 92.7 ± 0.46 74.34 ± 1.31 84.76 ± 2.6
14x14 CE 98.48 ± 0.09 38.4 ± 1.79 64.98 ± 0.86
14x14 CR-CE 93.9 ± 0.04 81.37 ± 0.39 86.13 ± 0.33
14x14 CR-CE (Noisier Masks) 93.26 ± 2.16 78.79 ± 3.64 85.34 ± 1.9

We note that despite the imperfect masks, CR-CE incurs only a minor drop in context-shifted accuracy. This is consistent with the statement in our paper that our method does not require precise segmentation masks. We will include this evidence in the next revision of our paper.

W2b: "how many CAMs are required", & Q2: "How much is it dependent on the value of 'k'?"
A: During training, we only use the ContrastiveCAM that is associated with the target class for a given sample. For a target class ktk_t, we use {C(kt,k’):k′∈[k]∖kt}\{\mathcal{C}_{(k_t, k’)}: k' \in [k] \setminus k_t\} to compute CR-CE.

W3: "How are the independence of the HiResCams captured?"
A: We apologize for not being able to understand this question. We kindly ask for elaboration on this question. We will respond as soon as we can.

Reviewer FYep · CommentOpenReview ↗

Different mIoU

While the first comment is satisfactory, I am concerned with the mIoU being capped at 60%. Essentially, that is greater than the nominal threshold of 0.5 used for classification. So I am still unsure whether this could be robust for cases where the overlap is minimal or non-existent. I am sorry I should have clarified the question further, I meant, there are two different ways that perturbation can be added - adding noise to the HiResCams (as done here) or adding noise to the inputs - both should yield the same output. What is the benefit in adding HiResCams as opposed to adding noise to input?

Authors · CommentOpenReview ↗

We thank the reviewer for considering our points and for their thoughtful response.


“I am concerned with the mIoU being capped at 60%. Essentially, that is greater than the nominal threshold of 0.5 used for classification. So I am still unsure whether this could be robust for cases where the overlap is minimal or non-existent.”

A: Thanks for the follow-up question. We rerun experiments using corrupted masks with mIoU at ~50%, and report the performance below:

CAM Resolution Approach Waterbirds (No Context Shift) Waterbirds (Context Shifted) Spawrious (Many-to-Many Corr., Hard Subtask)
7x7 CE 98.66 ± 0.10 41.74 ± 4.15 77.63 ± 0.47
7x7 CR-CE 93.81 ± 0.12 76.79 ± 0.18 86.53 ± 0.87
7x7 CR-CE (~60% mIoU) 92.7 ± 0.46 74.34 ± 1.31 84.76 ± 2.6
7x7 CR-CE (~50% mIoU) 93.75 ± 0.24 73.69 ± 5.35 82.2 ± 1.08
14x14 CE 98.48 ± 0.09 38.4 ± 1.79 64.98 ± 0.86
14x14 CR-CE 93.9 ± 0.04 81.37 ± 0.39 86.13 ± 0.33
14x14 CR-CE (~60% mIoU) 93.26 ± 2.16 78.79 ± 3.64 85.34 ± 1.9
14x14 CR-CE (~50% mIoU) 91.67 ± 0.48 78.59 ± 1.28 82.48 ± 4.37

We can see that our CR-CE training framework remains robust at such a level of mask imperfection.

In addition, we would like to point out that, for the Spawrious dataset where ground-truth object-context segmentation is not available, we use SAM3’s mask predictions, which are already approximations. In this case, we added additional noise to these approximations, and the mIoU is between the corrupted masks and the SAM3’s predictions. Therefore, the “true” mIoU between the corrupted masks and the unknown ground-truth masks should be even lower.

In the extreme cases where the mask-object overlap is minimal or non-existent and the context is shifted, we believe it is difficult for CR-CE (and more generally, mask-based methods) to make correct predictions, because they are supposed to focus on the mask region for prediction. Indeed, mask quality is a key assumption of our approach, we will clarify this in our next revision.

“there are two different ways that perturbation can be added - adding noise to the HiResCams (as done here) or adding noise to the inputs - both should yield the same output. What is the benefit in adding HiResCams as opposed to adding noise to input?”, & “How are the independence of the HiResCams captured?”

A: Thank you for the clarification and we think we understand your question now. We believe the "noise" you mentioned refers to the MM matrix in Theorem 3.2 and Figure 2.

We would like to point out that adding "noise" to the input does not necessarily yield the same output. Note that each output logit fkf_k, as a function of the feature embedding A=g(x)A = g(x), has its own parameters wkw_k: fk=hk(A)f_k = h_k(A). Consider adding noise ξ\xi to the input image xx. One gets a "noisy" feature embedding A~=g(x+ξ)\tilde{A} = g(x+\xi). Write the new logits as f~k:=hk(A~)=hk(A)+ck=:fk+ck\tilde{f}_k := h_k(\tilde{A}) = h_k(A) + c_k =: f_k+c_k. Due to the different logit functions hkh_k, the term ckc_k is logit-dependent in general. Therefore, the differences between logits fk−fk’f_{k} - f_{k’} are not maintained after adding input noise, i.e., fk−fk′≠f~k−f~k′,  k,k’∈[K]f_k - f_{k'} \neq \tilde{f}_k - \tilde{f}_{k'},~~k, k’ \in [K], resulting in a different post-softmax output after adding noise to input.

However, for the case of adding "noise" to HiResCAM, the "noise" MM is identical across all the KK output logits in Theorem 3.2 and Figure 2, thus fk−fk’=f~k−f~k’f_{k}-f_{k’} = \tilde{f}_{k}-\tilde{f}_{k’} is guaranteed, leading to the same post-softmax output.

Regarding the independence of the post-softmax outputs on MM: since softmax compares the differences between logits (c.f. Eq. 34-36), the final post-softmax predictions are invariant to a common shift MM across logits, as a consequence of Proposition 3.1.

Reviewer FYep · CommentOpenReview ↗

Thank you

Thanks for the clarification. I have no further comments.

Reviewer Fr6zOpenReview ↗
Rating
3/6
Confidence
3/5
Quality
2/4
Clarity
4/4
Significance
3/4
Originality
3/4
Contribution type
general
Ethical concerns
NO or VERY MINOR ethics concerns only
Read review
Summary

The paper proposes a training procedure aiming to improve CNN-based classifier robustness to context shift. The method uses modern segmentation models to generate object segments of the training samples, and proposes a loss function that regularizes the model to base the prediction on the object spatial region by enforcing the class activation map to align with the object region. Empirically, the paper shows their method is effective in improving context shift robustness on several datasets (Waterbirds-100, Spawrious, ImageNet-BG)

Strengths and weaknesses

Strengths

  1. The paper is generally clear and well-organized. It provides useful intuition for how both context and object features can contribute to the model prediction and motivates the proposed regularization technique.

  2. The method is intuitive and technically plausible. The paper provides empirical evidence that the proposed loss function makes the model rely more on object regions rather than on content regions.

  3. The paper employs modern, powerful zero-shot segmentation models and demonstrates substantial gains on several benchmarks compared to other methods.

Weaknesses

  1. The novelty of ContrastiveCAM seems limited compared to DiffGradCAM [1], which is also described in the paper as a contrastive attribution map.

  2. The experimental results do not isolate the benefits of the proposed CR-CE loss from the benefits of using object segmentations during training. To my understanding, none of the compared methods (ABN, GALS) use modern segmentation models such as SAM, and the paper does not compare against other relevant mask-based techniques (e.g. [2]), which could benefit from such modern segmentation models. Additionally, to better isolate the contribution of the loss function, the authors should compare against other simple mask-based baselines, e.g., training only on object regions, or using the segmentation models to augment the contexts during training. The compared baselines are relatively dated (ABN 2019 and GALS 2022). There may exist more recent relevant comparisons, e.g. [2,3].

  3. The ImageNet/ImageNet-BG (the largest evaluated dataset) results show a nontrivial trade-off between shifted and non-shifted accuracies. The gain in shifted-accuracy is modest and comparable to the decrease in non-shifted accuracy. This raises questions about the practical benefit of the method in settings where standard accuracy remains important.

  4. The empirical evaluation is limited, in terms of architecture diversity and scale, as the paper reports results only on ResNet50 variants. It remains unclear how well the method performs with other architectures and at other scales.

[1]Diffgradcam: A universal class activation map resistant to adversarial training. Piland et al., 2025

[2] Masking Strategies for Background Bias Removal in Computer Vision Models. Aniraj et al., 2023

[3] Causal Feature Alignment: Learning to Ignore Spurious Background Features. Venkataramani et al., 2024

Questions
  1. Can the authors clarify the precise novelty of ContrastiveCAM compared to DiffGradCAM?

  2. Can the authors compare the proposed method against mask-based baselines that use the same training set object segmentations (e.g., object-only training or swap-context augmentations)?

  3. Can the authors compare against CFA [3], or explain why it is not a relevant comparison?

  4. Can the authors evaluate the method on additional CNN architectures and other ResNet scales?

[3] Causal Feature Alignment: Learning to Ignore Spurious Background Features. Venkataramani et al., 2024

Limitations

Yes

Final justification

The rebuttal addresses most of my concerns regarding the relation to DiffGradCAM and the missing comparisons with more recent methods, specifically against other mask-based methods. However, two concerns were not addressed.

First, the requested augmentation-based baseline was not provided. Using the same segmentation masks to vary or swap the context seems like a particularly direct alternative, since it addresses the same problematic object–context correlation in the training set without introducing the proposed loss. As mentioned by the authors regarding the comparison with CFA, including context-shifted images in the training set can be beneficial, and context augmentation could provide a similar benefit.

Second, the stronger new baselines were not evaluated on ImageNet/ImageNet-BG. I believe this comparison is important as it better represents real-world task complexities, and the advantage of the proposed method seems more marginal there. However, I weigh this concern lower as I understand the limited time for the rebuttal.

Overall, I do not change my original recommendation.

Formatting concerns

N/A

4 comments
Authors · RebuttalOpenReview ↗
Rebuttal

We thank the reviewer for their constructive and comprehensive review.


W1: "The novelty of ContrastiveCAM seems limited compared to DiffGradCAM [1], which is also described in the paper as a contrastive attribution map.", & Q1: "Can the authors clarify the precise novelty of ContrastiveCAM compared to DiffGradCAM?"
A: Thanks for pointing this out. After a careful check of the paper [1], we noted a nontrivial similarity between ContrastiveCAM and DiffGradCAM which we should acknowledge in our paper, although key differences remain. Specifically, we note the following:

  • A similarity in their definition: Both methods use the same technique – subtracting the average logit-level CAM, to eliminate the redundancy of CAMs in explaining the network’s final (i.e., post-softmax) prediction. We apologize for the oversight and will clarify this and give credits to DiffGradCAM in our next revision.
  • Differences: While DiffGradCAM is based on GradCAM, our ContrastiveCAM is based on HiResCAM. The key difference is that HiResCAM has the property (c.f. Eq. (2) and Remark 2.1) that connect CAMs and class logits, while GradCAM does not. Consequently, a key result of ContrastiveCAM, Proposition 3.6, fails to hold for DiffGradCAM, and the loss functions (standard CE or CR-CE) cannot be expressed as a function of DiffGradCAMs. Therefore, our context-shift robustness technique does not extend to DiffGradCAMs.

Note that, in our paper, ContrastiveCAM is just an intermediate step of constructing the new loss function, CR-CE. Therefore, this similarity between the two methods does not affect the overall novelty and contributions of our paper, which are: (1) the theoretical connection between (CE-type) loss and CAMs (i.e., Proposition 3.6); and (2) the CR-CE training framework for context-shift robustness.

[1] Piland, Jacob, Chris Sweet, and Adam Czajka. "Diffgradcam: A universal class activation map resistant to adversarial training." arXiv preprint arXiv:2506.08514 (2025).

W2: "The experimental results do not isolate the benefits of the proposed CR-CE loss from the benefits of using object segmentations during training.", & Q2: "Can the authors compare the proposed method against mask-based baselines that use the same training set object segmentations (e.g., object-only training or swap-context augmentations)?"
A: We totally agree that a comparison with the mask-based baseline would clarify the benefits of the proposed CR-CE training framework.

Conceptually,

  • The standard CE training encourages the model to exploit correlations between the object and context, reducing robustness to context shift (especially adversarial context shift).
  • The mask-based methods try to avoid this correlation by neither encouraging nor penalizing contributions from context regions, in which case a spurious correlation may still sneak in.
  • Our method, instead, explicitly penalizes the contribution from the context, thereby suppressing the effect of adversarial context shift the most among the three methods.

Therefore, we expect that our method outperforms the mask-based methods in improving the robustness against context shift. This is numerically confirmed by the following experiments:

CAM Resolution Approach Waterbirds (No Context Shift) Waterbirds (Context Shifted) Spawrious (Many-to-Many Corr., Hard Subtask)
7x7 CE 98.66 ± 0.10 41.74 ± 4.15 77.63 ± 0.47
7x7 Mask-Based [2] 94.24 ± 3.14 63.96 ± 9.87 72.31 ± 7.25
7x7 CFA [3] 96.76 ± 0.19 73.51 ± 0.89 81.77 ± 1.73
7x7 CR-CE (Ours) 93.81 ± 0.12 76.79 ± 0.18 86.53 ± 0.87
14x14 CE 98.48 ± 0.09 38.4 ± 1.79 64.98 ± 0.86
14x14 Mask-Based [2] 93.25 ± 1.48 67.8 ± 3.74 80.56 ± 3.95
14x14 CFA [3] 96.99 ± 0.13 75.05 ± 0.44 75.88 ± 1.12
14x14 CR-CE (Ours) 93.9 ± 0.04 81.37 ± 0.39 86.13 ± 0.33

We will add this numerical comparison with the mask-based methods in the next revision.

Note: We used the “the early-masking strategy” of [2] for the mask-based method, which is shown to be the best-performing setting explored in [2]. This setting corresponds to training only on object regions.

[2] Aniraj, Ananthu, Cassio F. Dantas, Dino Ienco, and Diego Marcos. "Masking strategies for background bias removal in computer vision models." In Proceedings of the IEEE/CVF international conference on computer vision, pp. 4397-4405. 2023.

W3: "The ImageNet/ImageNet-BG (the largest evaluated dataset) results show a nontrivial trade-off between shifted and non-shifted accuracies. The gain in shifted-accuracy is modest and comparable to the decrease in non-shifted accuracy. This raises questions about the practical benefit of the method in settings where standard accuracy remains important."
A: It is very common to observe trade-offs between accuracy and robustness in methods of improving robustness. Particularly, for context-shift robustness, methods improve the robustness against “misleading” context by trying to rely more on the object regions. Consequently, due to the concentration of model attention, images with “supportive” context may suffer from lowered confidence, or even incorrect, prediction, compared to standard CE training.

As for the modest improvement on context-shifted ImageNet-BG, we hypothesize it is because of the following: images of ImageNet-BG are random combinations of objects and backgrounds/context; in most of these images, the context has no semantic correlation with the object (namely not “misleading”), therefore, does not lead to a misclassification. As a comparison, in the context-shifted images of Waterbirds and Spawrious datasets, the contexts often have strong semantic correlation with opposite/non-target classes which strongly misleads the model’s predictions. Under the ImageNet/ImageNet-BG setting, we believe our method still provides a strong defence against malicious/adversarial context shifts, where the context is intentionally designed to fool the model.

Q3: "Can the authors compare against CFA [3], or explain why it is not a relevant comparison?"
A: Please see an experimental comparison to CFA in the table above (within our response to W2 / Q2). We observe that our method outperforms CFA in improving robustness against context shifts.

Note: the accuracy of CFA on the Waterbirds dataset reported in the paper [3] looks higher, that is because their training dataset contains context-shifted images. In our case, the training dataset is free of context-shifted images, which we believe is a more practical setting in addressing the challenge of context-shift.

In addition, we view the CFA method as orthogonal to our method, achieving context-shift robustness in different ways. We believe a combination of the two methods (such as replacing the CE loss in their objective function Eq. 2 of [3] by our CR-CE) will further improve the robustness.

[3] Venkataramani, Rahul, Parag Dutta, Vikram Melapudi, and Ambedkar Dukkipati. "Causal feature alignment: Learning to ignore spurious background features." In Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision, pp. 4666-4674. 2024.

Q4: “Can the authors evaluate the method on additional CNN architectures and other ResNet scales?”
A: Regarding the additional CNN architectures, we evaluate CR-CE on EfficientNetv2 [4] on the Waterbirds and Spawrious (M2M-Hard subtask) datasets (see table below). We observe that context-robustness improvements by our method hold for EfficientNetv2:

CAM Resolution Approach Waterbirds (No Context Shift) Waterbirds (Context Shifted) Spawrious (Many-to-Many Corr., Hard Subtask)
7x7 CE 91.08 ± 0.05 39.31 ± 3.01 77.5 ± 0.91
7x7 CR-CE (Ours) 94.51 ± 2.21 77.64 ± 3.71 88.29 ± 0.22
14x14 CE 84.64 ± 0.14 38.88 ± 1.31 79.3 ± 1.17
14x14 CR-CE (Ours) 93.52 ± 1.13 81.87 ± 3.11 88.85 ± 0.55

We also evaluate our method with a ResNet-18 on the Spawrious dataset (see table below), where the experimental results exhibit an improved context-shift robustness of our method.

CAM Resolution Approach Easy Medium Hard Average
7x7 CE 80.89 ± 0.92 59.34 ± 0.73 52.16 ± 1.27 64.13
7x7 CR-CE (Ours) 90.55 ± 0.04 75.86 ± 0.62 69.07 ± 0.17 78.5
14x14 CE 68.23 ± 0.48 43.61 ± 0.44 34.28 ± 0.98 48.71
14x14 CR-CE (Ours) 91.9 ± 0.16 80.98 ± 0.33 69.19 ± 0.55 80.69

[4] Tan, Mingxing, and Quoc Le. "Efficientnetv2: Smaller models and faster training." In International conference on machine learning, pp. 10096-10106. PMLR, 2021.

Authors · CommentOpenReview ↗

We would like to politely follow up with the reviewer. We hope our rebuttal addresses your concerns raised in the review. We remain active until the discussion deadline to address any remaining questions you may have. We believe any discussion will help strengthen this paper. Thank you very much!

Reviewer Fr6z · CommentOpenReview ↗

I thank the authors for the detailed rebuttal and the additional experiments. Most of my concerns are addressed: the relation to DiffGradCAM is now clarified, the method is evaluated on additional backbones, and the new comparisons against the mask-based baseline [2] and CFA [3] do help isolate the contribution of the CR-CE loss. Two remaining points, both on W2/Q2:

  1. My question about augmentation-based training was not addressed. Beyond object-only training, I asked about using the segmentation masks to augment contexts during training (e.g., pasting objects onto varied or swapped backgrounds). This seems the most direct competitor to CR-CE, since it attacks the object–context correlation using exactly the same masks, and I would still like to see it.
  2. Which segmentation model was used to produce the masks for the mask-based baseline [2]? If these are the masks from the original setup of [2] rather than the modern segmentation tool used for CR-CE, it would weaken these results as a direct comparison of the methods. Could the authors confirm this, and if applicable report the baseline with the same mask model they use?

If time permits, I would also appreciate results for the new baselines [2,3] on ImageNet/ImageNet-BG. They appear considerably more competitive than ABN and GALS, which are relatively dated, so their behavior on the largest dataset is the more informative comparison.

[2] Masking Strategies for Background Bias Removal in Computer Vision Models. Aniraj et al., 2023

[3] Causal Feature Alignment: Learning to Ignore Spurious Background Features. Venkataramani et al., 2024

Authors · CommentOpenReview ↗

We are thankful to the reviewer for their response, and we are glad to see that most of the concerns are addressed. Our paper has become much stronger thanks to this discussion. In the following, we address your remaining concerns.

"Which segmentation model was used to produce the masks for the mask-based baseline [2]? If these are the masks from the original setup of [2] rather than the modern segmentation tool used for CR-CE, it would weaken these results as a direct comparison of the methods. Could the authors confirm this, and if applicable report the baseline with the same mask model they use?"

A: We used SAM3, the same model used for our CR-CE training framework, to produce masks for the mask-based baseline [2] on the Spawrious dataset. This is to ensure a fair comparison between the two methods. For the Waterbirds dataset, ground-truth masks are available, so neither the mask-based baseline [2] nor our CR-CE framework uses segmentation models for mask generation. For the promised ImageNet/ImageNet-BG experiment, we will use the same segmentation model for both methods.

[2] Aniraj, Ananthu, Cassio F. Dantas, Dino Ienco, and Diego Marcos. "Masking strategies for background bias removal in computer vision models." In Proceedings of the IEEE/CVF international conference on computer vision, pp. 4397-4405. 2023.

"My question about augmentation-based training was not addressed. Beyond object-only training, I asked about using the segmentation masks to augment contexts during training (e.g., pasting objects onto varied or swapped backgrounds). … and I would still like to see it."

A: We apologize for not being able to finish numerical comparison with augmentation-based training before the author-reviewer discussion deadline. Given the limited time and computational resources, we prioritized other experiments earlier, including comparing with object-only methods and CFA. As a result, this numerical comparison hasn’t finished at this time. We will include these evaluations in our next revision.

In general, augmentation-based training could improve context-shift robustness, as it augments the training dataset with additional, artificial object-context combinations. However, we conjecture that this improvement may be limited to the observed object-context combinations. It is theoretically unclear how augmentation-based training performs in out-of-distribution scenarios, where unseen context-shifts may appear during evaluation, especially when these shifts are adversarial. On the other hand, our explanation-guided training framework explicitly suppresses the contributions from context regions without seeing any artificial object-context combinations, thereby being more robust to out-of-distribution scenarios. We will also include such an out-of-distribution comparison between the two types of methods in our next revision.

Indeed, we view the augmentation-based training as an orthogonal technique for improving this robustness, as it augments the dataset while keeping the standard CE training procedure unchanged. We can readily combine context augmentation with the CR-CE training framework to further improve robustness.

"If time permits, I would also appreciate results for the new baselines [2,3] on ImageNet/ImageNet-BG."

A: We apologize, as we will not be able to finish this experiment by the author-reviewer discussion deadline, due to its high computation cost, considering the limited time, computational resources and the amount of experimentation necessitated during the rebuttal period. We will also include results on ImageNet/ImageNet-BG for a comprehensive comparison with these baselines in our next revision.

Comments on the paper

2 comments
Area Chair rR12 · CommentOpenReview ↗

for the reviewers

Dear reviewers, please review the authors’ responses carefully and determine whether there are any remaining concerns that need to be addressed. Please also provide your final feedback to the authors and indicate whether their rebuttal adequately addresses the raised issues.

Authors · CommentOpenReview ↗

Dear ACs and Reviewers,

As the author-reviewer discussion ends, we thank all reviewers and ACs for the constructive feedback and fruitful discussions. We are glad that all the concerns from Reviewer FYep and Reviewer amfB and most of the concerns from Reviewer Fr6z have been resolved, as the reviewers acknowledged.

The only remaining questions from Reviewer Fr6z are regarding additional experimental comparisons between our proposed method and additional baselines: specifically, comparison with augmentation-based training, and comparison with CFA and object-only training on the ImageNet/ImageNet-BG dataset. Given the amount of experimentations we have finished during the rebuttal period, the limited time and computation resources and the high computation costs, we were simply not able to finish those experiments in time, although we believe our method still outperforms these baselines.

We will include these additional comparisons in our next revision, thereby comprehensively benchmarking our proposed CR-CE framework.

We are grateful for the time and effort put in by the reviewers and AC in consideration of our submission.

Best,
Authors

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Missing a submission?

Loading the discussion…