{"id":22668441,"url":"https://github.com/lanl/adversarialtensors","last_synced_at":"2025-03-29T10:40:52.248Z","repository":{"id":194651741,"uuid":"691284002","full_name":"lanl/AdversarialTensors","owner":"lanl","description":"Tensors-based framework for adversarial robustness","archived":false,"fork":false,"pushed_at":"2023-09-13T23:35:02.000Z","size":4904,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-02-04T09:18:01.031Z","etag":null,"topics":["adversarial-attacks","adversarial-defense","adversarial-machine-learning","lowrankdenoising","tensorfactorization"],"latest_commit_sha":null,"homepage":"https://lanl.github.io/AdversarialTensors/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lanl.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":"2023-09-13T21:42:17.000Z","updated_at":"2024-11-20T16:19:13.000Z","dependencies_parsed_at":"2023-09-14T13:09:18.234Z","dependency_job_id":null,"html_url":"https://github.com/lanl/AdversarialTensors","commit_stats":null,"previous_names":["lanl/adversarialtensors"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2FAdversarialTensors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2FAdversarialTensors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2FAdversarialTensors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lanl%2FAdversarialTensors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lanl","download_url":"https://codeload.github.com/lanl/AdversarialTensors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246174472,"owners_count":20735409,"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","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-attacks","adversarial-defense","adversarial-machine-learning","lowrankdenoising","tensorfactorization"],"created_at":"2024-12-09T15:15:12.253Z","updated_at":"2025-03-29T10:40:52.221Z","avatar_url":"https://github.com/lanl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AdversarialTensors: Tensors-based framework for adversarial robustness\n\nThis library implements a variety of tensor factorization methods for defending Artificeal intelligence \n(AI) models against adversarial attacks. The library implements three main operations. First, tensor\nfactorization methods are implemented as a preprocessing stage for input data to AI models to reduce the\neffectiveness of adversarial noise.  In the second operation, tensor factorization methods are used to \nfind novel latent attack features by combining proposed attacks from a variety of methods. Since these \nattacks will inherently be a combination of attacks many algorithms against many models, they have the \npotential to threaten a wide variety of AI models simultanioulsy In the third operation, an unsupervised\ngenerative adversarial networks (GAN) is employed to  generate denoised data from many adversarial noises. \nThis generator provides robust defense against unseen attacks. \n\n## Capabilites:\n* Tensor factorizations with Tucker, non-negative Tucker, CPD, non-negative CPD, Tensor Train, NMF, \nNNSVD and NMF\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"500\" height=\"322\" src=\"docs/_images/denoising.png\"\u003e\n\u003c/p\u003e\n* Ability to denoise image single/batches/all.\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"500\" height=\"156\" src=\"docs/_images/inference.png\"\u003e\n\u003c/p\u003e\n* Employs attacks such as AutoAttack, FGSM, PGD, BIM, DeepFool. \n* Ability to perform white-box/black-box attacks.\n\n\u003cp float=\"center\"\u003e\n  \u003cimg width=\"400\" height=\"270\" src=\"docs/_images/white_box.png\"\u003e\n  \u003cimg width=\"400\" height=\"211\" src=\"docs/_images/black_box.png\"\u003e\n\u003c/p\u003e\n\n* Ability to perform adversarial training.\n\n\u003cp float=\"center\"\u003e\n  \u003cimg width=\"400\" height=\"270\" src=\"docs/_images/white_box_adv_train.png\"\u003e\n  \u003cimg width=\"400\" height=\"211\" src=\"docs/_images/black_box_adv_train.png\"\u003e\n\u003c/p\u003e\n\n* Works on Cifar10/Cifar100/Imagenet/Tiny-Imagenet/MNIST/Fashion-MNIST. \n\n\n\n# End-to-End Code Execution Guide\n\n## 1. Training Models\n\nFirst, set the environment variables specific to your experiment in `send_train_jobs.sh`.\n\n### Output:\n\n- Models will be stored in `my_checkpoints`. For example: `my_checkpoints/cifar10/resnet18_0_1.ckpt`\n- If using CSVLogger, log data will be saved in `log_{dataset_name}_{model_name}_test/{fold_ind}_{nfolds}`\n\n### To Run:\n\n```bash\nbash send_train_jobs.sh\n```\n\n## 2. Generating Attack Data\n\nSet the environment variables for the experiment in `send_attack_jobs.sh`.\n\n### Output:\n\n- Attack data and logs will be stored in `attack_log_{dataset_name}/{model_name}/{fold_ind}_{nfolds}_{attack_type}`\n\n### To Run:\n\n```bash\nbash send_attack_jobs.sh\n```\n\n## 3. Parameter Tuning\n\nSet the environment variables for the experiment in `send_tune_jobs.sh`.\n\n### Output:\n\n- The tuning results will be located at `parameter_search_{dataset_name}/{model_name}/{fold_ind}_{nfolds}_{attack_type}/search_results`\n\n### To Run:\n\n```bash\nbash send_tune_jobs.sh\n```\n\n## 4. Collecting Results\n\nAfter setting the environment variables:\n\n### Output:\n\n- The results will be stored as CSV files in `tune_csv_results`\n\n### To Run:\n\n```bash\nbash collect_results.sh\n```\n\n## 5. Final Evaluation on Test Set\n\n### Generating Attacks\n\n- Set `final_test_set` to `True` in `send_attack_jobs.sh`\n\n```bash\nbash send_attack_jobs.sh\n```\n\n### Evaluating Models\n\n- After setting specific environment variables (such as `eval_top_k`):\n\n### To Run:\n\n```bash\nbash send_final_eval_jobs.sh\n```\n\n## Authors\n\n* [Manish Bhattarai](mailto:ceodspspectrum@lanl.gov) - Los Alamos National Laboratory\n* [Mehmet Kaymak Cagri](mailto:mehmet@lanl.gov) - Los Alamos National Laboratory\n* [Ben Nebgen](mailto:bnebgen@lanl.gov) - Los Alamos National Laboratory\n* [Boian Alexandrov](mailto:boian@lanl.gov) - Los Alamos National Laboratory\n* [Kim Rasmussen](mailto:kor@lanl.gov) - Theoretical Division, Los Alamos National Laboratory\n\n## How to cite pyDNMFk?\n\n```latex\n  @article{bhattarai2023robust,\n  title={Robust Adversarial Defense by Tensor Factorization},\n  author={Bhattarai, Manish and Kaymak, Mehmet Cagri and Barron, Ryan and Nebgen, Ben and Rasmussen, Kim and Alexandrov, Boian},\n  journal={arXiv preprint arXiv:2309.01077},\n  year={2023}\n}\n```\n\n\n## Acknowledgments\nLos Alamos National Lab (LANL), T-1\n\n## Copyright Notice\n© (or copyright) 2023. Triad National Security, LLC. All rights reserved.\nThis program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos\nNational Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S.\nDepartment of Energy/National Nuclear Security Administration. All rights in the program are\nreserved by Triad National Security, LLC, and the U.S. Department of Energy/National Nuclear\nSecurity Administration. The Government is granted for itself and others acting on its behalf a\nnonexclusive, paid-up, irrevocable worldwide license in this material to reproduce, prepare\nderivative works, distribute copies to the public, perform publicly and display publicly, and to permit\nothers to do so.\n\n\n## License\n\nThis program is open source under the BSD-3 License.\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n\n1. Redistributions of source code must retain the above copyright notice, this\n   list of conditions and the following disclaimer.\n\n2. Redistributions in binary form must reproduce the above copyright notice,\n   this list of conditions and the following disclaimer in the documentation\n   and/or other materials provided with the distribution.\n\n3. Neither the name of the copyright holder nor the names of its\n   contributors may be used to endorse or promote products derived from\n   this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\nAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\nIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\nFOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\nDAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\nOR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\nOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flanl%2Fadversarialtensors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flanl%2Fadversarialtensors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flanl%2Fadversarialtensors/lists"}