{"id":13577924,"url":"https://github.com/google-research/adamatch","last_synced_at":"2025-10-12T02:05:55.189Z","repository":{"id":41465788,"uuid":"387904483","full_name":"google-research/adamatch","owner":"google-research","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-02T22:04:33.000Z","size":151,"stargazers_count":66,"open_issues_count":5,"forks_count":5,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-06-21T11:05:03.650Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/google-research.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-07-20T20:17:43.000Z","updated_at":"2024-11-20T05:50:58.000Z","dependencies_parsed_at":"2023-02-01T04:31:17.370Z","dependency_job_id":null,"html_url":"https://github.com/google-research/adamatch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/google-research/adamatch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-research%2Fadamatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-research%2Fadamatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-research%2Fadamatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-research%2Fadamatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google-research","download_url":"https://codeload.github.com/google-research/adamatch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google-research%2Fadamatch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279009915,"owners_count":26084666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-12T02:00:06.719Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T15:01:25.441Z","updated_at":"2025-10-12T02:05:55.174Z","avatar_url":"https://github.com/google-research.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# AdaMatch\n\nCode for the paper: \"[AdaMatch: A Unified Approach to Semi-Supervised Learning and Domain Adaptation](https://arxiv.org/abs/2106.04732)\" by\nDavid Berthelot, Rebecca Roelofs, Kihyuk Sohn, Nicholas Carlini, and Alex Kurakin.\n\nThis is not an officially supported Google product.\n\n\n![AdaMatch diagram](media/AdaMatch.png)\n\n## Setup\n\n```bash\nsudo apt install python3-dev python3-virtualenv python3-tk imagemagick\nvirtualenv -p python3 --system-site-packages ~/jax3\n. ~/jax3/bin/activate\n\n# Install dependencies (replace with your installed CUDA version)\nCUDA_VERSION=11.2\npip install --upgrade -r requirements.txt\npip install -f https://storage.googleapis.com/jax-releases/jax_releases.html jaxlib==`python3 -c 'import jaxlib; print(jaxlib.__version__)'`+cuda`echo $CUDA_VERSION | sed s:\\\\\\.::g`\n```\n\n### Required environment variables\n\n```bash\nexport ML_DATA=\"path to where you want the datasets saved\"\nexport PYTHONPATH=$PYTHONPATH:.\n```\n\n### Potentially useful environment variables\n\n```bash\n# Use this config if you won't want JAX to take the whole GPU memory\nexport XLA_PYTHON_CLIENT_PREALLOCATE=false\n```\n\n\n## Data preparation\n\n```bash\n# Download datasets and save them as TF records\nCUDA_VISIBLE_DEVICES= python scripts/create_datasets.py\n\n# Alternatively if your machine has many cores, this parallel version is much faster to run.\nbash ./runs/create_datasets.sh\n```\n\n## Training\n\n### Options\n\n- `--logdir` where the results are saved.\n- `--uratio` ratio of unlabeled data / label data.\n- `--augment` typically can take two values (weak,strong) augmentation and a prefix (Control-Theory Augment (CTA)\n  introduced in ReMixMatch or no prefix). Examples:\n  - `--augment=\\(sm,smc\\)` weak augmentation is shift and mirror, strong augmentation is shift, mirror and cutout.\n  - `--augment=CTA\\(sm,sm\\)` weak augmentation is shift and mirror, strong augmentation CTA on top of shift and mirror.\n\n#### Specific to Domain Adaptation (DA) and Semi-Supervised Domain Adaptation (SSDA)\n- `--dataset` dataset to use with desired size, example: `domainnet32` (32x32 images)\n- `--source` source subset (for example `clipart`)\n- `--target` target subset to which to adapt the source (for example `quickdraw`)\n\n**Note**: for **SSDA**, the target takes a different form.\n- `--target` target subset to which to adapt the source and how many label per class to use and what random seed to use\n  (for example `quickdraw(3,seed=2)` means use 3 labels per class picked at random using random seed 2)\n\n\n#### Specific to Semi-Supervised Learning (SSL)\n- `--dataset` combines both dataset and source from SSDA in a single option. For example:\n  `domainnet32_quickdraw(3,seed=2)`.\n\n### Fully supervised\n\n```bash\n# Baseline: source and target must be the same. Additionally, one can specify extra test sets.\npython fully_supervised/baseline.py --dataset=domainnet32 --source=clipart --target=clipart\\\n    --logdir experiments/2021/02.12-32 --augment=CTA\\(sm,sm\\)\\\n    --test_extra=clipart,infograph,quickdraw,real,sketch,painting\n```\n\n### Domain adaptation\n\n```bash\n# Baseline: does nothing for unlabeled except running it with labeled as a single batch through the network.\npython domain_adaptation/baseline.py --dataset=domainnet32 --source=clipart --target=quickdraw\\\n    --logdir experiments/2021/02.12-32 --uratio=3 --augment=CTA\\(sm,sm\\)\npython domain_adaptation/baseline.py --dataset=domainnet32 --source=clipart --target=quickdraw\\\n    --logdir experiments/2021/02.12-32 --uratio=1 --augment=\\(sm,smc\\)\n\n# FixMatch\npython domain_adaptation/fixmatch_da.py --dataset=domainnet32 --source=clipart --target=quickdraw\\\n    --logdir experiments/2021/02.12-32 --uratio=3 --augment=CTA\\(sm,sm\\)\npython domain_adaptation/fixmatch_da.py --dataset=domainnet32 --source=clipart --target=quickdraw\\\n    --logdir experiments/2021/02.12-32 --uratio=1 --augment=\\(sm,smc\\)\n\n# AdaMatch\npython domain_adaptation/adamatch.py --dataset=domainnet32 --source=clipart --target=quickdraw\\\n    --logdir experiments/2021/02.12-32 --uratio=3 --augment=CTA\\(sm,sm\\)\npython domain_adaptation/adamatch.py --dataset=domainnet32 --source=clipart --target=quickdraw\\\n    --logdir experiments/2021/02.12-32 --uratio=1 --augment=\\(sm,smc\\)\n\n# NoisyStudent\n## Teacher\npython domain_adaptation/noisy_student.py --dataset=domainnet32 --source=clipart --target=quickdraw\\\n    --logdir experiments/2021/02.12-32 --pseudo_label_th=0.9 --augment=CTA\\(sm,sm\\)\\\n    --id=0\n## Student\npython domain_adaptation/noisy_student.py --dataset=domainnet32 --source=clipart --target=quickdraw\\\n    --logdir experiments/2021/02.12-32 --pseudo_label_th=0.9 --augment=CTA\\(sm,sm\\) --id=1\\\n    --pseudo_label_file=experiments/2021/03.1-32/DA/domainnet32/clipart/quickdraw/CTA\\(sm,sm\\)/NoisyStudent/archwrn28-2_batch64_lr0.03_lr_decay0.25_wd0.001/0/predictions.npy\n\n# MCD\npython domain_adaptation/mcd.py --dataset=domainnet64 --source=clipart --target=quickdraw\\\n    --uratio=1 --arch=wrn28-2 --augment='CTA(sm,sm)' --train_mimg=8 --logdir experiments/2021/02.12-32 --lr_decay 0.25\n```\n\n#### Multi-source domain adaptation\n\nUse `no` in front of the subdomain to use all domains but the one concerned.\n\n```bash\npython domain_adaptation/adamatch.py --dataset=domainnet32 --source=no_quickdraw --target=quickdraw\\\n    --logdir experiments/2021/02.12-32 --uratio=3 --augment=CTA\\(sm,sm\\)\n````\n\n### Semi-Supervised Domain adaptation\n\n```bash\n# FixMatch\npython semi_supervised_domain_adaptation/fixmatch_da.py --dataset=domainnet32 --source=clipart\\\n    --target=quickdraw\\(10,seed=1\\)\\\n    --logdir experiments/2021/02.12-32 --uratio=3 --augment=CTA\\(sm,sm\\)\n\n# AdaMatch\npython semi_supervised_domain_adaptation/adamatch.py --dataset=domainnet32 --source=clipart\\\n    --target=quickdraw\\(10,seed=1\\)\\\n    --logdir experiments/2021/02.12-32 --uratio=3 --augment=CTA\\(sm,sm\\)\n```\n\n### Semi-Supervised Learning\n\n```bash\n# FixMatch\npython semi_supervised/fixmatch_da.py --dataset=domainnet32_quickdraw\\(10,seed=1\\)\\\n    --logdir experiments/2021/02.12-32 --uratio=3 --augment=CTA\\(sm,sm\\)\n\n# AdaMatch\npython semi_supervised/adamatch.py --dataset=domainnet32_quickdraw\\(10,seed=1\\)\\\n    --logdir experiments/2021/02.12-32 --uratio=3 --augment=CTA\\(sm,sm\\)\n```\n\n## Tensorboard\n\n```bash\ntensorboard --logdir experiments\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle-research%2Fadamatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle-research%2Fadamatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle-research%2Fadamatch/lists"}