Skip to content

Commit d726d68

Browse files
committed
updated link to data folder
1 parent 153a8ec commit d726d68

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

1-fast-gradient-sign-method/FSGM-Attack.ipynb

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3201,7 +3201,16 @@
32013201
"from pathlib import Path\n",
32023202
"import os \n",
32033203
"\n",
3204-
"DATA_FOLDER = Path(os.path.join(os.path.abspath(os.path.curdir), \"..\", \"..\")) / \"data\""
3204+
"DATA_FOLDER = Path(os.path.join(os.path.abspath(os.path.curdir), \"..\")) / \"data\""
3205+
]
3206+
},
3207+
{
3208+
"cell_type": "code",
3209+
"execution_count": null,
3210+
"metadata": {},
3211+
"outputs": [],
3212+
"source": [
3213+
"print(DATA_FOLDER)"
32053214
]
32063215
},
32073216
{
@@ -3268,9 +3277,22 @@
32683277
"metadata": {},
32693278
"outputs": [],
32703279
"source": [
3271-
"PRETRAINED_MODEL_WEIGHTS = \"lenet_mnist_model.pth\"\n",
3280+
"if torch.cuda.is_available():\n",
3281+
" dev_name = \"cuda\"\n",
3282+
"else:\n",
3283+
" dev_name = \"cpu\"\n",
32723284
"\n",
3273-
"device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n",
3285+
"device = torch.device(dev_name)\n",
3286+
"print(f\"You will be using the {device} device\")"
3287+
]
3288+
},
3289+
{
3290+
"cell_type": "code",
3291+
"execution_count": null,
3292+
"metadata": {},
3293+
"outputs": [],
3294+
"source": [
3295+
"PRETRAINED_MODEL_WEIGHTS = \"lenet_mnist_model.pth\"\n",
32743296
"\n",
32753297
"# Initialize the network\n",
32763298
"model = Net().to(device)\n",
@@ -3519,7 +3541,9 @@
35193541
"\n",
35203542
"# Run test for each epsilon\n",
35213543
"for ε in EPSILONS[1:]:\n",
3522-
" # your code here"
3544+
" acc, adv_examples = test(model, device, test_loader, ε)\n",
3545+
" accuracies.append(acc)\n",
3546+
" adv_examples_map[ε] = adv_examples"
35233547
]
35243548
},
35253549
{
@@ -3605,7 +3629,7 @@
36053629
"name": "python",
36063630
"nbconvert_exporter": "python",
36073631
"pygments_lexer": "ipython3",
3608-
"version": "3.10.5"
3632+
"version": "3.9.16"
36093633
}
36103634
},
36113635
"nbformat": 4,

0 commit comments

Comments
 (0)