From 5bcb893326707eed75161a12646c44b0462b8feb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Duhalde?= <matias.duhalde@uc.cl> Date: Fri, 17 Nov 2023 17:18:27 +0100 Subject: [PATCH] feat: ex1 base --- TD2 Deep Learning.ipynb | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/TD2 Deep Learning.ipynb b/TD2 Deep Learning.ipynb index 2ecfce9..cda6a88 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": { -- GitLab