Browse Source

Minor adjustments and cleaning of FinePruning notebooks.

bart 11 months ago
parent
commit
6a494fdc91

File diff suppressed because it is too large
+ 44 - 747
Notebooks/Defences/FinePruningFTT/Finetune.ipynb


File diff suppressed because it is too large
+ 30 - 655
Notebooks/Defences/FinePruningFTT/Prune.ipynb


+ 8 - 224
Notebooks/Defences/FinePruningFTT/Train.ipynb

@@ -2,19 +2,10 @@
  "cells": [
   {
    "cell_type": "code",
-   "execution_count": 1,
+   "execution_count": null,
    "id": "ddde10d5",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "/home/bart/Documents/School/MasterThesis/Development/tabular-backdoors/tabularbackdoor/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
-      "  from .autonotebook import tqdm as notebook_tqdm\n"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "import numpy as np\n",
     "import pandas as pd\n",
@@ -55,22 +46,13 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
+   "execution_count": null,
    "id": "640f00b9",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "File already exists.\n"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "# Experiment settings\n",
     "EPOCHS = 50\n",
-    "RERUNS = 5 # How many times to redo the same setting\n",
     "\n",
     "# Backdoor settings\n",
     "target=[\"Covertype\"]\n",
@@ -224,7 +206,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": null,
    "id": "a3466db3",
    "metadata": {},
    "outputs": [],
@@ -273,19 +255,10 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": null,
    "id": "60f8c561",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Using device: cuda:0\n",
-      "self.category_embeddings.weight.shape=torch.Size([88, 424])\n"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "\n",
     "zero.set_randomness(config['seed'])\n",
@@ -452,196 +425,7 @@
    "execution_count": null,
    "id": "ad5e4ccb",
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "\r",
-      "  0%|                                                                         | 0/18200 [00:00<?, ?it/s]"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "\n",
-      ">>> Epoch 1 | 0:00:00\n"
-     ]
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "  2%|█▏                                                           | 364/18200 [01:20<1:04:40,  4.60it/s]"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "[train] loss = 0.757\n"
-     ]
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "\r",
-      "  2%|█▏                                                          | 365/18200 [01:34<21:50:29,  4.41s/it]"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "[val  ] Accuracy = 0.748\n",
-      "[test ] Accuracy = 0.751\n",
-      "New best epoch!\n",
-      "\n",
-      ">>> Epoch 2 | 0:00:00\n"
-     ]
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "  4%|██▍                                                          | 728/18200 [02:54<1:03:36,  4.58it/s]"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "[train] loss = 0.569\n"
-     ]
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "\r",
-      "  4%|██▍                                                         | 729/18200 [03:08<21:19:36,  4.39s/it]"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "[val  ] Accuracy = 0.786\n",
-      "[test ] Accuracy = 0.790\n",
-      "New best epoch!\n",
-      "\n",
-      ">>> Epoch 3 | 0:00:00\n"
-     ]
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "  6%|███▌                                                        | 1092/18200 [04:27<1:02:35,  4.56it/s]"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "[train] loss = 0.501\n"
-     ]
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "\r",
-      "  6%|███▌                                                       | 1093/18200 [04:41<20:46:26,  4.37s/it]"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "[val  ] Accuracy = 0.816\n",
-      "[test ] Accuracy = 0.819\n",
-      "New best epoch!\n",
-      "\n",
-      ">>> Epoch 4 | 0:00:00\n"
-     ]
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "  8%|████▊                                                       | 1456/18200 [06:01<1:01:44,  4.52it/s]"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "[train] loss = 0.451\n"
-     ]
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "\r",
-      "  8%|████▋                                                      | 1457/18200 [06:15<20:18:31,  4.37s/it]"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "[val  ] Accuracy = 0.836\n",
-      "[test ] Accuracy = 0.840\n",
-      "New best epoch!\n",
-      "\n",
-      ">>> Epoch 5 | 0:00:00\n"
-     ]
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      " 10%|██████▏                                                       | 1820/18200 [07:35<59:21,  4.60it/s]"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "[train] loss = 0.413\n"
-     ]
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "\r",
-      " 10%|█████▉                                                     | 1821/18200 [07:49<19:50:46,  4.36s/it]"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "[val  ] Accuracy = 0.856\n",
-      "[test ] Accuracy = 0.858\n",
-      "New best epoch!\n",
-      "\n",
-      ">>> Epoch 6 | 0:00:00\n"
-     ]
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      " 10%|██████                                                      | 1826/18200 [07:50<4:09:46,  1.09it/s]"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "zero.set_randomness(config['seed'])\n",
     "\n",

Some files were not shown because too many files changed in this diff