{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "b108498a", "metadata": {}, "outputs": [], "source": [ "from test_atks import test_atks_on_cifar10\n", "from test_import import test_import_version" ] }, { "cell_type": "code", "execution_count": 2, "id": "3d08de15", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "3.4.1\n" ] } ], "source": [ "test_import_version()" ] }, { "cell_type": "code", "execution_count": 3, "id": "2fd7a267", "metadata": {}, "outputs": [], "source": [ "import torchattacks" ] }, { "cell_type": "code", "execution_count": 4, "id": "aea26465", "metadata": { "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Files already downloaded and verified\n", "VANILA : clean_acc=1.00 robust_acc=1.00 sec=0.00\n", "GN : clean_acc=1.00 robust_acc=0.20 sec=0.00\n", "FGSM : clean_acc=1.00 robust_acc=0.40 sec=0.02\n", "- targeted : clean_acc=1.00 robust_acc=0.40 sec=0.02\n", "BIM : clean_acc=1.00 robust_acc=0.00 sec=0.07\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=0.07\n", "RFGSM : clean_acc=1.00 robust_acc=0.00 sec=0.06\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=0.06\n", "PGD : clean_acc=1.00 robust_acc=0.00 sec=0.06\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=0.06\n", "EOTPGD : clean_acc=1.00 robust_acc=0.00 sec=0.22\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=0.22\n", "FFGSM : clean_acc=1.00 robust_acc=0.20 sec=0.01\n", "- targeted : clean_acc=1.00 robust_acc=0.20 sec=0.01\n", "TPGD : clean_acc=1.00 robust_acc=0.00 sec=0.06\n", "MIFGSM : clean_acc=1.00 robust_acc=0.00 sec=0.06\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=0.06\n", "UPGD : clean_acc=1.00 robust_acc=0.00 sec=0.07\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=0.07\n", "APGD : clean_acc=1.00 robust_acc=0.00 sec=0.30\n", "APGDT : clean_acc=1.00 robust_acc=0.00 sec=0.33\n", "DIFGSM : clean_acc=1.00 robust_acc=0.00 sec=0.07\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=0.07\n", "TIFGSM : clean_acc=1.00 robust_acc=0.20 sec=0.07\n", "- targeted : clean_acc=1.00 robust_acc=0.20 sec=0.07\n", "Jitter : clean_acc=1.00 robust_acc=0.00 sec=0.25\n", "- targeted : clean_acc=1.00 robust_acc=0.40 sec=0.25\n", "NIFGSM : clean_acc=1.00 robust_acc=0.00 sec=0.06\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=0.06\n", "PGDRS : clean_acc=1.00 robust_acc=0.80 sec=0.11\n", "- targeted : clean_acc=1.00 robust_acc=0.80 sec=0.11\n", "SINIFGSM : clean_acc=1.00 robust_acc=0.00 sec=0.91\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=0.91\n", "VMIFGSM : clean_acc=1.00 robust_acc=0.00 sec=1.15\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=1.15\n", "VNIFGSM : clean_acc=1.00 robust_acc=0.00 sec=1.17\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=1.17\n", "SPSA : clean_acc=1.00 robust_acc=0.40 sec=1.44\n", "- targeted : clean_acc=1.00 robust_acc=1.00 sec=1.44\n", "JSMA : clean_acc=1.00 robust_acc=0.00 sec=19.91\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=19.91\n", "EADL1 : clean_acc=1.00 robust_acc=0.00 sec=8.07\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=8.07\n", "EADEN : clean_acc=1.00 robust_acc=0.00 sec=7.04\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=7.04\n", "PIFGSM : clean_acc=1.00 robust_acc=0.00 sec=0.07\n", "PIFGSMPP : clean_acc=1.00 robust_acc=0.00 sec=0.07\n", "- targeted : clean_acc=1.00 robust_acc=1.00 sec=0.07\n", "CW : clean_acc=1.00 robust_acc=0.00 sec=0.30\n", "- targeted : clean_acc=1.00 robust_acc=0.20 sec=0.30\n", "PGDL2 : clean_acc=1.00 robust_acc=0.00 sec=0.07\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=0.07\n", "DeepFool : clean_acc=1.00 robust_acc=0.20 sec=1.75\n", "PGDRSL2 : clean_acc=1.00 robust_acc=0.80 sec=0.13\n", "- targeted : clean_acc=1.00 robust_acc=1.00 sec=0.13\n", "SparseFool : clean_acc=1.00 robust_acc=0.60 sec=16.86\n", "OnePixel : clean_acc=1.00 robust_acc=0.60 sec=0.83\n", "- targeted : clean_acc=1.00 robust_acc=1.00 sec=0.83\n", "Pixle : clean_acc=1.00 robust_acc=0.00 sec=1.15\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=1.15\n", "FAB : clean_acc=1.00 robust_acc=0.00 sec=1.98\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=1.98\n", "AutoAttack : clean_acc=1.00 robust_acc=0.00 sec=0.30\n", "Square : clean_acc=1.00 robust_acc=0.00 sec=6.29\n", "- targeted : clean_acc=1.00 robust_acc=0.00 sec=6.29\n" ] } ], "source": [ "for atk_class in [atk_class for atk_class in torchattacks.__all__ if atk_class not in torchattacks.__wrapper__]:\n", " test_atks_on_cifar10(atk_class=atk_class,\n", " device='cuda',\n", " model_dir='../demo/models/',\n", " data_dir='../demo/data/')" ] }, { "cell_type": "code", "execution_count": null, "id": "086977ef", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.8" } }, "nbformat": 4, "nbformat_minor": 5 }