Papers › Sharpness-Aware Gradient Matching for Domain Generalization

Sharpness-Aware Gradient Matching for Domain Generalization

18 Mar 2023CVPR 2023 1arXiv:2303.10353archive 2025-07-28

Pengfei Wang, Zhaoxiang Zhang, Zhen Lei, Lei Zhang

The goal of domain generalization (DG) is to enhance the generalization capability of the model learned from a source domain to other unseen domains. The recently developed Sharpness-Aware Minimization (SAM) method aims to achieve this goal by minimizing the sharpness measure of the loss landscape. Though SAM and its variants have demonstrated impressive DG performance, they may not always converge to the desired flat region with a small loss value. In this paper, we present two conditions to ensure that the model could converge to a flat minimum with a small loss, and present an algorithm, named Sharpness-Aware Gradient Matching (SAGM), to meet the two conditions for improving model generalization capability. Specifically, the optimization objective of SAGM will simultaneously minimize the empirical risk, the perturbed loss (i.e., the maximum loss within a neighborhood in the parameter space), and the gap between them. By implicitly aligning the gradient directions between the empirical risk and the perturbed loss, SAGM improves the generalization capability over SAM and its variants without increasing the computational cost. Extensive experimental results show that our proposed SAGM method consistently outperforms the state-of-the-art methods on five DG benchmarks, including PACS, VLCS, OfficeHome, TerraIncognita, and DomainNet. Codes are available at https://github.com/Wang-pengfei/SAGM.

PaperPDFConference PDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2303.10353")

Code

Syntology Ran 10 of 15 code samples harvested from 1 repository linked to this paper; 5 have no recorded run. Of those that ran: 2 ran · our draft was wrong; 8 ran with no contract checked.

By repository: official repository: 14 samples from 1 repository, 9 ran; 1 identical to code first harvested elsewhere. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

wang-pengfei/sagm officialmentioned in papermentioned on GitHubpytorch report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

15 samples harvested; 10 ran; 0 honoured the contract we drafted; 5 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

2ran · our draft was wrong
8ran
5unverified

Licence: 1 of the 15 samples is pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from wang-pengfei/sagm. Some samples are identical code Syntology first harvested from another repository; for those, this paper's copy is not located and its licence is not recorded. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

Algorithm wang-pengfei/sagm/domainbed/algorithms/algorithms.py official repository ran · metamorphic tier: deterministic MIT (permissive) · d67127a3c5e535a0 · report
Identity wang-pengfei/sagm/domainbed/algorithms/algorithms.py official repository ran fingerprinted MIT (permissive) · c090fe2ca8acedb3 · report
MLP wang-pengfei/sagm/domainbed/algorithms/algorithms.py official repository ran · metamorphic tier: deterministic fingerprinted MIT (permissive) · bacc92fd6ae22e2c · report
MNIST_CNN wang-pengfei/sagm/domainbed/algorithms/algorithms.py official repository ran · metamorphic tier: deterministic MIT (permissive) · c998f65811a9d80f · report
ResNet wang-pengfei/sagm/domainbed/algorithms/algorithms.py official repository ran · metamorphic tier: deterministic fingerprinted MIT (permissive) · 73d7253036166f22 · report
SqueezeLastTwo wang-pengfei/sagm/domainbed/algorithms/algorithms.py official repository ran · metamorphic tier: deterministic fingerprinted MIT (permissive) · 01b81ca81d7a2e60 · report
Wide_ResNet wang-pengfei/sagm/domainbed/algorithms/algorithms.py official repository ran · metamorphic tier: deterministic MIT (permissive) · 6a63af402870932f · report
get_optimizer wang-pengfei/sagm/domainbed/algorithms/algorithms.py official repository ran · our draft was wrong MIT (permissive) · 5a8d4d0e1bf66cd4 · report
wide_basic wang-pengfei/sagm/domainbed/algorithms/algorithms.py official repository ran · metamorphic tier: deterministic fingerprinted MIT (permissive) · a47120fe8df1b363 · report
Featurizer wang-pengfei/sagm/domainbed/algorithms/algorithms.py official repository unverified MIT (permissive) · 467b3583a59f952e · report
SAGM wang-pengfei/sagm/domainbed/algorithms/algorithms.py official repository unverified MIT (permissive) · 9da593320c9aef89 · report
SAGM_DG wang-pengfei/sagm/domainbed/algorithms/algorithms.py official repository unverified MIT (permissive) · 7686c49c58187b1d · report
disable_running_stats wang-pengfei/sagm/domainbed/algorithms/algorithms.py official repository unverified MIT (permissive) · 957cadb71fb37e35 · report
enable_running_stats wang-pengfei/sagm/domainbed/algorithms/algorithms.py official repository unverified MIT (permissive) · 5ad5be23a3cf2d30 · report
conv3x3 identical code first harvested elsewhere ran · our draft was wrong licence of this copy not recorded · 00e569acd6b45ef0 · report

Tasks

Domain Generalization

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Methods

Sharpness-Aware Minimization

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections