From b43f84d739cbf99e5f9a5f4655cba8192ceecad2 Mon Sep 17 00:00:00 2001
From: Jeanne Caty <jeanne.caty@ecl22.ec-lyon.fr>
Date: Thu, 5 Dec 2024 18:08:54 +0100
Subject: [PATCH] Update TD2 Deep Learning.ipynb

---
 TD2 Deep Learning.ipynb | 132 ++++++++++++++++++++++++++++++++++++----
 1 file changed, 120 insertions(+), 12 deletions(-)

diff --git a/TD2 Deep Learning.ipynb b/TD2 Deep Learning.ipynb
index 00e4fdc..65bffee 100644
--- a/TD2 Deep Learning.ipynb	
+++ b/TD2 Deep Learning.ipynb	
@@ -38,7 +38,7 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "%pip install torch torchvision"
+    "%pip install torch torchvision\n"
    ]
   },
   {
@@ -52,10 +52,72 @@
   },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 7,
    "id": "b1950f0a",
    "metadata": {},
-   "outputs": [],
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "tensor([[ 0.6418, -0.1700,  0.6304,  0.3113,  0.1379,  1.0753, -0.3344,  1.4741,\n",
+      "         -0.8532,  0.3268],\n",
+      "        [ 0.0866,  2.1869, -1.1434,  0.6156, -0.4647, -0.5759, -0.6658,  0.3761,\n",
+      "         -1.1228,  0.1785],\n",
+      "        [-0.4243, -1.0760,  0.3367,  1.0454,  0.4841,  0.8989,  0.4678, -0.1791,\n",
+      "          2.0395, -0.9181],\n",
+      "        [-0.8864,  0.1093, -0.5295,  0.4361,  0.7182,  0.2051,  0.0169, -0.8813,\n",
+      "          0.3688,  1.3760],\n",
+      "        [-0.5702, -0.1380,  1.2921,  1.0146,  0.1518,  1.2922,  0.6758, -0.1043,\n",
+      "          1.1502,  0.4387],\n",
+      "        [ 0.5554,  0.5230,  0.8402, -1.3635, -0.3173,  0.3087,  0.7613, -2.0258,\n",
+      "          0.1627,  0.9464],\n",
+      "        [ 0.7489, -0.2015,  0.8231,  1.2146,  0.9384,  0.6064,  0.6412,  0.0341,\n",
+      "          1.0204, -0.0650],\n",
+      "        [ 0.2682,  1.0076, -1.5576, -0.3533, -0.1235,  2.4824,  1.1433,  0.5006,\n",
+      "          0.0619,  0.2076],\n",
+      "        [ 1.1212,  1.7072, -0.4859,  0.3846, -0.6056,  1.4281,  0.5899,  0.1623,\n",
+      "          1.9957,  0.3370],\n",
+      "        [ 0.9890, -1.0958, -0.5957, -0.4671, -0.2902, -0.0344, -0.8092, -0.5606,\n",
+      "         -0.5501, -1.3897],\n",
+      "        [ 0.8188, -0.6413,  0.2777,  0.7005, -0.2147, -0.0083,  0.6479, -1.1746,\n",
+      "         -1.2938,  2.7529],\n",
+      "        [-0.2992,  1.4363,  0.4173,  2.1196,  0.1661, -0.6726,  1.1396, -0.0788,\n",
+      "         -0.9447,  0.5560],\n",
+      "        [ 1.8925, -1.7427, -1.7261, -0.3420,  1.3588, -0.4280, -0.2186, -0.1555,\n",
+      "         -0.4196, -0.6740],\n",
+      "        [-0.9354, -0.1141,  0.3492,  0.5924, -1.0574, -1.2510,  0.9382,  0.2804,\n",
+      "         -1.0396, -1.6244]])\n",
+      "AlexNet(\n",
+      "  (features): Sequential(\n",
+      "    (0): Conv2d(3, 64, kernel_size=(11, 11), stride=(4, 4), padding=(2, 2))\n",
+      "    (1): ReLU(inplace=True)\n",
+      "    (2): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
+      "    (3): Conv2d(64, 192, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2))\n",
+      "    (4): ReLU(inplace=True)\n",
+      "    (5): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
+      "    (6): Conv2d(192, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
+      "    (7): ReLU(inplace=True)\n",
+      "    (8): Conv2d(384, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
+      "    (9): ReLU(inplace=True)\n",
+      "    (10): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))\n",
+      "    (11): ReLU(inplace=True)\n",
+      "    (12): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
+      "  )\n",
+      "  (avgpool): AdaptiveAvgPool2d(output_size=(6, 6))\n",
+      "  (classifier): Sequential(\n",
+      "    (0): Dropout(p=0.5, inplace=False)\n",
+      "    (1): Linear(in_features=9216, out_features=4096, bias=True)\n",
+      "    (2): ReLU(inplace=True)\n",
+      "    (3): Dropout(p=0.5, inplace=False)\n",
+      "    (4): Linear(in_features=4096, out_features=4096, bias=True)\n",
+      "    (5): ReLU(inplace=True)\n",
+      "    (6): Linear(in_features=4096, out_features=1000, bias=True)\n",
+      "  )\n",
+      ")\n"
+     ]
+    }
+   ],
    "source": [
     "import torch\n",
     "\n",
@@ -95,10 +157,18 @@
   },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 8,
    "id": "6e18f2fd",
    "metadata": {},
-   "outputs": [],
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "CUDA is not available.  Training on CPU ...\n"
+     ]
+    }
+   ],
    "source": [
     "import torch\n",
     "\n",
@@ -121,10 +191,33 @@
   },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 9,
    "id": "462666a2",
    "metadata": {},
-   "outputs": [],
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Downloading https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz to data\\cifar-10-python.tar.gz\n"
+     ]
+    },
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "100%|██████████| 170M/170M [00:48<00:00, 3.52MB/s] \n"
+     ]
+    },
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Extracting data\\cifar-10-python.tar.gz to data\n",
+      "Files already downloaded and verified\n"
+     ]
+    }
+   ],
    "source": [
     "import numpy as np\n",
     "from torchvision import datasets, transforms\n",
@@ -193,10 +286,25 @@
   },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 10,
    "id": "317bf070",
    "metadata": {},
-   "outputs": [],
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Net(\n",
+      "  (conv1): Conv2d(3, 6, kernel_size=(5, 5), stride=(1, 1))\n",
+      "  (pool): MaxPool2d(kernel_size=2, stride=2, padding=0, dilation=1, ceil_mode=False)\n",
+      "  (conv2): Conv2d(6, 16, kernel_size=(5, 5), stride=(1, 1))\n",
+      "  (fc1): Linear(in_features=400, out_features=120, bias=True)\n",
+      "  (fc2): Linear(in_features=120, out_features=84, bias=True)\n",
+      "  (fc3): Linear(in_features=84, out_features=10, bias=True)\n",
+      ")\n"
+     ]
+    }
+   ],
    "source": [
     "import torch.nn as nn\n",
     "import torch.nn.functional as F\n",
@@ -883,7 +991,7 @@
   },
   {
    "cell_type": "markdown",
-   "id": "bbd48800",
+   "id": "ca7cda74",
    "metadata": {},
    "source": [
     "Experiments:\n",
@@ -926,7 +1034,7 @@
  ],
  "metadata": {
   "kernelspec": {
-   "display_name": "Python 3.8.5 ('base')",
+   "display_name": "Python 3 (ipykernel)",
    "language": "python",
    "name": "python3"
   },
@@ -940,7 +1048,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.8.5"
+   "version": "3.9.13"
   },
   "vscode": {
    "interpreter": {
-- 
GitLab