{"id":14286477,"url":"https://github.com/jh-jeong/smoothmix","last_synced_at":"2025-08-15T07:31:24.360Z","repository":{"id":89400160,"uuid":"421290936","full_name":"jh-jeong/smoothmix","owner":"jh-jeong","description":"Code for the paper \"SmoothMix: Training Confidence-calibrated Smoothed Classifiers for Certified Robustness\" (NeurIPS 2021)","archived":false,"fork":false,"pushed_at":"2022-09-27T02:20:10.000Z","size":17590,"stargazers_count":21,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-16T02:34:22.445Z","etag":null,"topics":["adversarial-defense","deep-learning","machine-learning","neurips-2021","paper","randomized-smoothing","robustness"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2111.09277","language":"Roff","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jh-jeong.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-10-26T05:22:58.000Z","updated_at":"2023-11-13T14:11:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"46c96cbc-cb78-4e8d-ad53-7efedb48d9a7","html_url":"https://github.com/jh-jeong/smoothmix","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jh-jeong/smoothmix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jh-jeong%2Fsmoothmix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jh-jeong%2Fsmoothmix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jh-jeong%2Fsmoothmix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jh-jeong%2Fsmoothmix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jh-jeong","download_url":"https://codeload.github.com/jh-jeong/smoothmix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jh-jeong%2Fsmoothmix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270539521,"owners_count":24603182,"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-08-15T02:00:12.559Z","response_time":110,"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":["adversarial-defense","deep-learning","machine-learning","neurips-2021","paper","randomized-smoothing","robustness"],"created_at":"2024-08-23T17:00:52.227Z","updated_at":"2025-08-15T07:31:21.048Z","avatar_url":"https://github.com/jh-jeong.png","language":"Roff","funding_links":[],"categories":["Table of Contents"],"sub_categories":["**Optimizing Calibration**"],"readme":"# SmoothMix: Training Confidence-calibrated Smoothed Classifiers for Certified Robustness (NeurIPS2021)\n\nThis repository contains code for the paper\n**\"SmoothMix: Training Confidence-calibrated Smoothed Classifiers for Certified Robustness\"**\nby [Jongheon Jeong](https://sites.google.com/view/jongheonj), [Sejun Park](https://sites.google.com/site/sejunparksite/), Minkyu Kim, Heung-Chang Lee, Doguk Kim and [Jinwoo Shin](http://alinlab.kaist.ac.kr/shin.html). \n\n## Dependencies\n```\nconda create -n smoothmix python=3.7\nconda activate smoothmix\n\n# Below is for linux, with CUDA 11.1; see https://pytorch.org/ for the correct command for your system\nconda install pytorch torchvision cudatoolkit=11.1 -c pytorch -c nvidia\n\nconda install scipy pandas statsmodels matplotlib seaborn\npip install tensorboardX\n```\n\n## Scripts\n\n### Training Scripts\n\nOur code is built upon a previous codebase from several baselines considered in the paper \n([Cohen et al (2019)](https://github.com/locuslab/smoothing); \n[Salman et al (2019)](https://github.com/Hadisalman/smoothing-adversarial); \n[Jeong and Shin (2020)](https://github.com/jh-jeong/smoothing-consistency)).\nThe main script is `code/train.py`, and the sample scripts below demonstrate how to run `code/train.py`.\nOne can modify `CUDA_VISIBLE_DEVICES` to further specify GPU number(s) to work on.\n\n```\n# SmoothMix (Ours): MNIST, w/ one-step adversary, eta=5.0 \nCUDA_VISIBLE_DEVICES=0 python code/train.py mnist lenet --lr 0.01 --lr_step_size 30 --epochs 90  --noise 1.0 \\\n--num-noise-vec 4 --eta 5.0 --num-steps 8 --alpha 1.0 --mix_step 1 --id 0\n```\n\nFor a more detailed instruction to reproduce our experiments, see [`EXPERIMENTS.MD`](EXPERIMENTS.MD).\n\n### Testing Scripts\n\nAll the testing scripts is originally from https://github.com/locuslab/smoothing:\n\n* The script [certify.py](code/certify.py) certifies the robustness of a smoothed classifier.  For example,\n\n```python code/certify.py mnist model_output_dir/checkpoint.pth.tar 0.50 certification_output --alpha 0.001 --N0 100 --N 100000```\n\nwill load the base classifier saved at `model_output_dir/checkpoint.pth.tar`, smooth it using noise level \u0026sigma;=0.50,\nand certify the MNIST test set with parameters `N0=100`, `N=100000`, and `alpha=0.001`.\n\n* The script [predict.py](code/predict.py) makes predictions using a smoothed classifier.  For example,\n\n```python code/predict.py mnist model_output_dir/checkpoint.pth.tar 0.50 prediction_outupt --alpha 0.001 --N 1000```\n\nwill load the base classifier saved at `model_output_dir/checkpoint.pth.tar`, smooth it using noise level \u0026sigma;=0.50,\nand classify the MNIST test set with parameters `N=1000` and `alpha=0.001`.\n\n* The script [analyze.py](code/analyze.py) contains some useful classes and functions to analyze the result data \nfrom [certify.py](code/certify.py) or [predict.py](code/predict.py).\n\n### Pre-trained models\n\nWe release our ImageNet models trained with SmoothMix in the following GDrive link: [ImageNet](https://drive.google.com/drive/folders/1M6Garbgg201tjxPosGIATZ7kLeB8HJQO?usp=sharing)\n\n### Citation\n\n```\n@inproceedings{jeong2021smoothmix,\n author = {Jeong, Jongheon and Park, Sejun and Kim, Minkyu and Lee, Heung-Chang and Kim, Do-Guk and Shin, Jinwoo},\n booktitle = {Advances in Neural Information Processing Systems},\n editor = {M. Ranzato and A. Beygelzimer and Y. Dauphin and P.S. Liang and J. Wortman Vaughan},\n pages = {30153--30168},\n publisher = {Curran Associates, Inc.},\n title = {SmoothMix: Training Confidence-calibrated Smoothed Classifiers for Certified Robustness},\n url = {https://proceedings.neurips.cc/paper/2021/file/fd45ebc1e1d76bc1fe0ba933e60e9957-Paper.pdf},\n volume = {34},\n year = {2021}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjh-jeong%2Fsmoothmix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjh-jeong%2Fsmoothmix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjh-jeong%2Fsmoothmix/lists"}