-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Logan Engstrom
committed
Jun 6, 2018
1 parent
66d5114
commit 6eecf71
Showing
26 changed files
with
1,613,693 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# ResNet ImageNet Code | ||
|
||
This repository provides code for both training and using the restricted robust resnet models from the paper: | ||
|
||
**There Is No Free Lunch In Adversarial Robustness (But There Are Unexpected Benefits)** | ||
*Dimitris Tsipras\*, Shibani Santurkar\*, Logan Engstrom\*, Alexander Turner, Aleksander Madry* | ||
https://arxiv.org/abs/1805.12152 | ||
|
||
We show that adversarial robustness often inevitablely results in accuracy loss. The silver lining: adversarial training induces more semantically meaningful gradients and gives adversarial examples with GAN-like trajectories: | ||
|
||
<img src = 'https://pbs.twimg.com/media/DengXkCWAAADnUN.jpg:large' width='800px' /> | ||
|
||
### General overview ### | ||
|
||
Before trying to run anything: | ||
|
||
- Run `./setup.sh`. | ||
- Get a downloaded version of the ImageNet training set. By default the code looks for this directory in the environmental variable `INET_DIR`. For example, run `export INET_DIR=/scratch/datasets/imagenet/`. | ||
|
||
The code is organized so that you can: | ||
|
||
- Train your own robust restricted ImageNet models (via `ez_train.sh`) | ||
- Produce adversarial examples and visualize gradients, with example code in `example_use.ipynb` | ||
- Reproduce the ImageNet examples seen in the paper (via `make_viz.sh`). | ||
|
||
### Pretrained models | ||
This repository comes with (after following the instructions) three restricted ImageNet pretrained models: | ||
|
||
- `data/train_224_nat_slim` corresponds to a naturally trained model | ||
- `data/train_224_robust_eps_0.005_lp_inf_slim` corresponds to an linf adv trained model with eps 0.005 | ||
- `data/train_224_robust_eps_1.0_lp_2_slim` corresponds to an l2 adv trained model with eps 1.0 | ||
|
||
You will need to set the model ckpt directory in the various scripts/ipynb files where appropriate if you want to complete any nontrivial tasks. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
134 | ||
130 | ||
0 | ||
101 | ||
104 | ||
106 | ||
11 | ||
13 | ||
131 | ||
132 | ||
133 | ||
138 | ||
14 | ||
141 | ||
13 | ||
142 | ||
143 | ||
155 | ||
160 | ||
167 | ||
18 | ||
1013 | ||
1017 | ||
1052 | ||
1065 | ||
1068 | ||
1069 | ||
1019 | ||
1077 | ||
1079 | ||
1080 | ||
1096 | ||
1102 | ||
1105 | ||
1108 | ||
1119 | ||
230 | ||
1225 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# example usage: ./ez_train.sh 0.10 inf out_dir | ||
|
||
export CUDA_VISIBLE_DEVICES="0,1,2,3,4,5,6,7" | ||
set -e | ||
|
||
eps=$1 # eps for attack | ||
lp=$2 # lp norm for attack, either of: ['2', 'inf'] | ||
ckpt_dir=$3 # out dir to save model in | ||
|
||
./imagenet_resnet.py --gpu 0,1,2,3,4,5,6,7 --checkpoint-dir $ckpt_dir --image-size 224 --eps $eps --lp $lp | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
n02672831 accordion | ||
n02691156 airplane | ||
n02219486 ant | ||
n02419796 antelope | ||
n07739125 apple | ||
n02454379 armadillo | ||
n07718747 artichoke | ||
n02764044 axe | ||
n02766320 baby bed | ||
n02769748 backpack | ||
n07693725 bagel | ||
n02777292 balance beam | ||
n07753592 banana | ||
n02786058 band aid | ||
n02787622 banjo | ||
n02799071 baseball | ||
n02802426 basketball | ||
n02807133 bathing cap | ||
n02815834 beaker | ||
n02131653 bear | ||
n02206856 bee | ||
n07720875 bell pepper | ||
n02828884 bench | ||
n02834778 bicycle | ||
n02840245 binder | ||
n01503061 bird | ||
n02870880 bookshelf | ||
n02883205 bow tie | ||
n02879718 bow | ||
n02880940 bowl | ||
n02892767 brassiere | ||
n07880968 burrito | ||
n02924116 bus | ||
n02274259 butterfly | ||
n02437136 camel | ||
n02951585 can opener | ||
n02958343 car | ||
n02970849 cart | ||
n02402425 cattle | ||
n02992211 cello | ||
n01784675 centipede | ||
n03000684 chain saw | ||
n03001627 chair | ||
n03017168 chime | ||
n03062245 cocktail shaker | ||
n03063338 coffee maker | ||
n03085013 computer keyboard | ||
n03793489 computer mouse | ||
n03109150 corkscrew | ||
n03128519 cream | ||
n03134739 croquet ball | ||
n03141823 crutch | ||
n07718472 cucumber | ||
n03797390 cup or mug | ||
n03188531 diaper | ||
n03196217 digital clock | ||
n03207941 dishwasher | ||
n02084071 dog | ||
n02121808 domestic cat | ||
n02268443 dragonfly | ||
n03249569 drum | ||
n03255030 dumbbell | ||
n03271574 electric fan | ||
n02503517 elephant | ||
n03314780 face powder | ||
n07753113 fig | ||
n03337140 filing cabinet | ||
n03991062 flower pot | ||
n03372029 flute | ||
n02118333 fox | ||
n03394916 french horn | ||
n01639765 frog | ||
n03400231 frying pan | ||
n02510455 giant panda | ||
n01443537 goldfish | ||
n03445777 golf ball | ||
n03445924 golfcart | ||
n07583066 guacamole | ||
n03467517 guitar | ||
n03483316 hair dryer | ||
n03476991 hair spray | ||
n07697100 hamburger | ||
n03481172 hammer | ||
n02342885 hamster | ||
n03494278 harmonica | ||
n03495258 harp | ||
n03124170 hat with a wide brim | ||
n07714571 head cabbage | ||
n03513137 helmet | ||
n02398521 hippopotamus | ||
n03535780 horizontal bar | ||
n02374451 horse | ||
n07697537 hotdog | ||
n03584254 iPod | ||
n01990800 isopod | ||
n01910747 jellyfish | ||
n01882714 koala bear | ||
n03633091 ladle | ||
n02165456 ladybug | ||
n03636649 lamp | ||
n03642806 laptop | ||
n07749582 lemon | ||
n02129165 lion | ||
n03676483 lipstick | ||
n01674464 lizard | ||
n01982650 lobster | ||
n03710721 maillot | ||
n03720891 maraca | ||
n03759954 microphone | ||
n03761084 microwave | ||
n03764736 milk can | ||
n03770439 miniskirt | ||
n02484322 monkey | ||
n03790512 motorcycle | ||
n07734744 mushroom | ||
n03804744 nail | ||
n03814639 neck brace | ||
n03838899 oboe | ||
n07747607 orange | ||
n02444819 otter | ||
n03908618 pencil box | ||
n03908714 pencil sharpener | ||
n03916031 perfume | ||
n00007846 person | ||
n03928116 piano | ||
n07753275 pineapple | ||
n03942813 ping-pong ball | ||
n03950228 pitcher | ||
n07873807 pizza | ||
n03958227 plastic bag | ||
n03961711 plate rack | ||
n07768694 pomegranate | ||
n07615774 popsicle | ||
n02346627 porcupine | ||
n03995372 power drill | ||
n07695742 pretzel | ||
n04004767 printer | ||
n04019541 puck | ||
n04023962 punching bag | ||
n04026417 purse | ||
n02324045 rabbit | ||
n04039381 racket | ||
n01495701 ray | ||
n02509815 red panda | ||
n04070727 refrigerator | ||
n04074963 remote control | ||
n04116512 rubber eraser | ||
n04118538 rugby ball | ||
n04118776 ruler | ||
n04131690 salt or pepper shaker | ||
n04141076 saxophone | ||
n01770393 scorpion | ||
n04154565 screwdriver | ||
n02076196 seal | ||
n02411705 sheep | ||
n04228054 ski | ||
n02445715 skunk | ||
n01944390 snail | ||
n01726692 snake | ||
n04252077 snowmobile | ||
n04252225 snowplow | ||
n04254120 soap dispenser | ||
n04254680 soccer ball | ||
n04256520 sofa | ||
n04270147 spatula | ||
n02355227 squirrel | ||
n02317335 starfish | ||
n04317175 stethoscope | ||
n04330267 stove | ||
n04332243 strainer | ||
n07745940 strawberry | ||
n04336792 stretcher | ||
n04356056 sunglasses | ||
n04371430 swimming trunks | ||
n02395003 swine | ||
n04376876 syringe | ||
n04379243 table | ||
n04392985 tape player | ||
n04409515 tennis ball | ||
n01776313 tick | ||
n04591157 tie | ||
n02129604 tiger | ||
n04442312 toaster | ||
n06874185 traffic light | ||
n04468005 train | ||
n04487394 trombone | ||
n03110669 trumpet | ||
n01662784 turtle | ||
n03211117 tv or monitor | ||
n04509417 unicycle | ||
n04517823 vacuum | ||
n04536866 violin | ||
n04540053 volleyball | ||
n04542943 waffle iron | ||
n04554684 washer | ||
n04557648 water bottle | ||
n04530566 watercraft | ||
n02062744 whale | ||
n04591713 wine bottle | ||
n02391049 zebra |
Binary file not shown.
Binary file not shown.
Oops, something went wrong.