diff --git a/TD2 Deep Learning.ipynb b/TD2 Deep Learning.ipynb index 2ecfce959ae6b947b633a758433f9bea0bf6992e..2130dd52d4e9bf32a3fa4d3428ea996ca6c8d479 100644 --- a/TD2 Deep Learning.ipynb +++ b/TD2 Deep Learning.ipynb @@ -33,12 +33,64 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "330a42f5", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Looking in indexes: https://download.pytorch.org/whl/cu121\n", + "Requirement already satisfied: torch in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (2.1.0+cu121)\n", + "Requirement already satisfied: torchvision in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (0.16.0)\n", + "Collecting torchaudio\n", + " Downloading https://download.pytorch.org/whl/cu121/torchaudio-2.1.1%2Bcu121-cp311-cp311-win_amd64.whl (4.0 MB)\n", + " ---------------------------------------- 0.0/4.0 MB ? eta -:--:--\n", + " --- ------------------------------------ 0.3/4.0 MB 7.2 MB/s eta 0:00:01\n", + " --------- ------------------------------ 1.0/4.0 MB 12.2 MB/s eta 0:00:01\n", + " ---------------- ----------------------- 1.6/4.0 MB 11.4 MB/s eta 0:00:01\n", + " ---------------------- ----------------- 2.3/4.0 MB 12.2 MB/s eta 0:00:01\n", + " -------------------------- ------------- 2.7/4.0 MB 11.4 MB/s eta 0:00:01\n", + " ------------------------------- -------- 3.1/4.0 MB 11.7 MB/s eta 0:00:01\n", + " ----------------------------------- ---- 3.6/4.0 MB 11.5 MB/s eta 0:00:01\n", + " ---------------------------------------- 4.0/4.0 MB 11.2 MB/s eta 0:00:00\n", + "Requirement already satisfied: filelock in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from torch) (3.13.1)\n", + "Requirement already satisfied: typing-extensions in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from torch) (4.8.0)\n", + "Requirement already satisfied: sympy in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from torch) (1.12)\n", + "Requirement already satisfied: networkx in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from torch) (3.2.1)\n", + "Requirement already satisfied: jinja2 in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from torch) (3.1.2)\n", + "Requirement already satisfied: fsspec in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from torch) (2023.10.0)\n", + "Requirement already satisfied: numpy in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from torchvision) (1.26.1)\n", + "Requirement already satisfied: requests in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from torchvision) (2.31.0)\n", + "Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from torchvision) (10.1.0)\n", + "INFO: pip is looking at multiple versions of torchaudio to determine which version is compatible with other requirements. This could take a while.\n", + " Using cached https://download.pytorch.org/whl/cu121/torchaudio-2.1.0%2Bcu121-cp311-cp311-win_amd64.whl (4.0 MB)\n", + "Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from jinja2->torch) (2.1.3)\n", + "Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from requests->torchvision) (3.3.2)\n", + "Requirement already satisfied: idna<4,>=2.5 in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from requests->torchvision) (3.4)\n", + "Requirement already satisfied: urllib3<3,>=1.21.1 in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from requests->torchvision) (2.0.7)\n", + "Requirement already satisfied: certifi>=2017.4.17 in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from requests->torchvision) (2023.7.22)\n", + "Requirement already satisfied: mpmath>=0.19 in c:\\users\\33778\\appdata\\local\\programs\\python\\python311\\lib\\site-packages (from sympy->torch) (1.3.0)\n", + "Installing collected packages: torchaudio\n", + "Successfully installed torchaudio-2.1.0+cu121\n", + "Note: you may need to restart the kernel to use updated packages.\n" + ] + }, + { + "name": "stderr", + "output_type": "stream", + "text": [ + "\n", + "[notice] A new release of pip is available: 23.2.1 -> 23.3.1\n", + "[notice] To update, run: python.exe -m pip install --upgrade pip\n" + ] + } + ], "source": [ - "%pip install torch torchvision" + "#%pip install torch torchvision\n", + "\n", + "%pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121" ] }, { @@ -47,15 +99,82 @@ "metadata": {}, "source": [ "\n", - "To test run the following code" + "To test run the following code\n", + "\n", + "Problème installation : ERROR: Could not install packages due to an OSError: [WinError 5] Accès refusé: 'C:\\\\Users\\\\33778\\\\AppData\\\\Local\\\\Programs\\\\Python\\\\Python311\\\\Lib\\\\site-packages\\\\~orch\\\\lib\\\\asmjit.dll'\n", + "Consider using the `--user` option or check the permissions.\n", + "\n", + "Séance 2 : pas d'erreur" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "b1950f0a", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "tensor([[-0.7268, -0.9474, -0.4714, -0.5032, -0.3566, 0.4072, -0.9652, -0.7066,\n", + " 1.3821, 0.5538],\n", + " [-1.1476, -0.1094, 0.9014, 2.3755, 0.2455, 0.8722, -0.2439, 1.2159,\n", + " 1.0185, 0.3590],\n", + " [-0.2150, -1.2410, 1.0992, -0.3079, 1.1391, -2.3063, -2.6116, 1.0540,\n", + " 0.1137, 0.7353],\n", + " [ 0.6713, -0.2484, 1.2865, -0.5164, -1.8983, 0.7056, 0.9285, 1.9441,\n", + " -0.3082, 0.9140],\n", + " [-0.2300, 0.6187, -0.7009, -0.8670, 0.9484, 0.0046, -1.6886, 0.4338,\n", + " 0.1176, 1.5366],\n", + " [-0.8439, -0.9951, 2.5313, 0.8563, -0.7508, 0.2469, 1.3054, 0.0328,\n", + " 0.5426, -0.2663],\n", + " [-0.9856, 0.5830, -1.1859, -0.7185, -1.1805, -0.3797, -0.8455, -0.1063,\n", + " 0.7098, 1.2478],\n", + " [-0.1530, -0.6071, 0.1492, 0.3094, -0.2197, 1.0157, 0.6586, 0.8388,\n", + " 0.7922, 1.3881],\n", + " [ 1.3397, -0.6168, -0.2699, -0.1470, 1.2906, 0.1153, 1.6731, -0.4478,\n", + " 0.3191, -0.6825],\n", + " [-1.2811, -0.8204, -0.0694, 1.0330, 2.3910, 0.1229, -0.2334, -0.7737,\n", + " 0.1272, 0.3935],\n", + " [-0.0233, 1.3477, 0.5933, -0.3373, 0.9051, 0.4029, -0.3025, 2.0969,\n", + " -0.1556, 0.6069],\n", + " [ 1.3300, -0.1632, 1.0080, -1.2555, -1.0411, -0.8801, -0.2668, -0.4731,\n", + " 0.0452, 2.0444],\n", + " [-0.0622, 0.8369, -1.7677, 0.1155, -0.8125, 1.5975, -0.1849, 1.7574,\n", + " -0.1292, 0.1241],\n", + " [ 0.4523, 0.7312, 0.4790, -1.4902, -1.2559, 1.3601, -0.6822, -0.7848,\n", + " -0.0340, 0.1907]])\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 +214,18 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "id": "6e18f2fd", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CUDA is available! Training on GPU ...\n" + ] + } + ], "source": [ "import torch\n", "\n", @@ -121,10 +248,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, "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.0%\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", @@ -940,7 +1090,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.11.6" }, "vscode": { "interpreter": {