diff --git a/TD2 Deep Learning.ipynb b/TD2 Deep Learning.ipynb index 2ecfce959ae6b947b633a758433f9bea0bf6992e..cda6a88551ad751997cd0ea8a063772e93255414 100644 --- a/TD2 Deep Learning.ipynb +++ b/TD2 Deep Learning.ipynb @@ -434,6 +434,42 @@ "Compare the results obtained with this new network to those obtained previously." ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Build the new network\n", + "\n", + "class NewNet(nn.Module):\n", + " def __init__(self):\n", + " super(NewNet, self).__init__()\n", + " # First convolutional layer (kernel size = 3, padding = 1, output = 16)\n", + " self.conv1 = nn.Conv2d(3, 16, 3, padding=1)\n", + " # Second convolutional layer (kernel size = 3, padding = 1, output = 32)\n", + " self.conv2 = nn.Conv2d(16, 32, 3, padding=1)\n", + " # Third convolutional layer (kernel size = 3, padding = 1, output = 64)\n", + " self.conv3 = nn.Conv2d(32, 64, 3, padding=1)\n", + "\n", + " def forward(self, x):\n", + " x = self.pool(F.relu(self.conv1(x)))\n", + " x = self.pool(F.relu(self.conv2(x)))\n", + " x = x.view(-1, 16 * 5 * 5)\n", + " x = F.relu(self.fc1(x))\n", + " x = F.relu(self.fc2(x))\n", + " x = self.fc3(x)\n", + " return x\n", + "\n", + "\n", + "# create a complete CNN\n", + "new_model = NewNet()\n", + "print(new_model)\n", + "# move tensors to GPU if CUDA is available\n", + "if train_on_gpu:\n", + " new_model.cuda()\n" + ] + }, { "cell_type": "markdown", "id": "bc381cf4", @@ -940,7 +976,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.5" + "version": "3.11.2" }, "vscode": { "interpreter": {