Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
50683c9
Creato con Colab
Marcusrem Apr 9, 2025
b8a3b97
Creato con Colab
Marcusrem Jul 4, 2025
e233983
Creato con Colab
Marcusrem Jul 25, 2025
eee2ea9
Creato con Colab
Marcusrem Jul 27, 2025
60d7061
Create My images
Marcusrem Oct 7, 2025
5a8101e
Add files via upload
Marcusrem Oct 7, 2025
8516a5a
Creato con Colab
Marcusrem Oct 7, 2025
7e2b1b8
Creato con Colab
Marcusrem Oct 16, 2025
747f990
Add pizza_steak_sushi_40_percent.zip dataset
Marcusrem Nov 12, 2025
34ed6b1
Creato con Colab
Marcusrem Nov 16, 2025
38ab964
Creato con Colab
Marcusrem Nov 17, 2025
c38e557
Creato con Colab
Marcusrem Nov 17, 2025
d876fe7
Creato con Colab
Marcusrem Nov 17, 2025
7685a85
Creato con Colab
Marcusrem Nov 17, 2025
4474ac8
Creato con Colab
Marcusrem Nov 17, 2025
b1ef4d7
Creato con Colab
Marcusrem Nov 17, 2025
356be73
Creato con Colab
Marcusrem Nov 17, 2025
7a3566f
Delete extras/exercises/07_pytorch_experiment_tracking_exercise_solve…
Marcusrem Nov 17, 2025
941f74d
Creato con Colab
Marcusrem Nov 18, 2025
39d1aa0
Delete extras/exercises/07_pytorch_experiment_tracking_exercise_sols.…
Marcusrem Nov 18, 2025
5bd04cf
Delete extras/exercises/07_pytorch_experiment_tracking_exercise_solve…
Marcusrem Nov 18, 2025
c64f605
Creato con Colab
Marcusrem Nov 18, 2025
50d6d0f
Delete extras/exercises/07_pytorch_experiment_tracking_exercise_sols.…
Marcusrem Nov 18, 2025
02e50dc
Creato con Colab
Marcusrem Nov 18, 2025
128a9c5
Aggiornamenti in going_modular: helper_functions.py integrated inside…
Marcusrem Dec 5, 2025
73b5b51
Aggiornamenti in going_modular: helper_functions.py integrated inside…
Marcusrem Dec 5, 2025
1e1708e
Aggiornamenti in going_modular: helper_functions.py integrated inside…
Marcusrem Dec 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions My images
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Binary file added braised-steak-recipe-2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/pizza_steak_sushi_40_percent.zip
Binary file not shown.
277 changes: 229 additions & 48 deletions extras/exercises/00_pytorch_fundamentals_exercises.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"colab": {
"name": "00_pytorch_fundamentals_exercises.ipynb",
"provenance": [],
"collapsed_sections": []
"gpuType": "T4"
},
"kernelspec": {
"name": "python3",
Expand All @@ -22,7 +22,7 @@
"source": [
"# 00. PyTorch Fundamentals Exercises\n",
"\n",
"### 1. Documentation reading \n",
"### 1. Documentation reading\n",
"\n",
"A big part of deep learning (and learning to code in general) is getting familiar with the documentation of a certain framework you're using. We'll be using the PyTorch documentation a lot throughout the rest of this course. So I'd recommend spending 10-minutes reading the following (it's okay if you don't get some things for now, the focus is not yet full understanding, it's awareness):\n",
" * The documentation on [`torch.Tensor`](https://pytorch.org/docs/stable/tensors.html#torch-tensor).\n",
Expand All @@ -41,7 +41,7 @@
"metadata": {
"id": "bGD0oD8Kizak"
},
"execution_count": 1,
"execution_count": null,
"outputs": []
},
{
Expand All @@ -57,15 +57,38 @@
"cell_type": "code",
"source": [
"# Import torch\n",
"import torch\n",
"\n",
"\n",
"# Create random tensor\n"
"# Create random tensor\n",
"tensor = torch.rand(7,7)\n",
"tensor"
],
"metadata": {
"id": "6pUq9Dc8i2L7"
"id": "6pUq9Dc8i2L7",
"outputId": "a6081379-f7dd-4b2f-9809-eebec0ea5d42",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 2,
"outputs": []
"execution_count": 1,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"tensor([[0.9473, 0.4796, 0.8238, 0.2162, 0.4292, 0.2930, 0.4013],\n",
" [0.0909, 0.9036, 0.1976, 0.7709, 0.3027, 0.3923, 0.5768],\n",
" [0.2172, 0.4720, 0.0324, 0.1137, 0.2709, 0.5308, 0.0708],\n",
" [0.4380, 0.2407, 0.6845, 0.4044, 0.4465, 0.0734, 0.6406],\n",
" [0.6649, 0.3130, 0.4927, 0.1371, 0.5819, 0.9410, 0.6062],\n",
" [0.3131, 0.9110, 0.0606, 0.9862, 0.9770, 0.1302, 0.8300],\n",
" [0.3633, 0.5432, 0.0048, 0.7753, 0.5374, 0.2534, 0.7470]])"
]
},
"metadata": {},
"execution_count": 1
}
]
},
{
"cell_type": "markdown",
Expand All @@ -80,14 +103,30 @@
"cell_type": "code",
"source": [
"# Create another random tensor\n",
"\n",
"# Perform matrix multiplication \n"
"tensor2= torch.rand(1,7)\n",
"# Perform matrix multiplication\n",
"torch.mm(tensor2, tensor)"
],
"metadata": {
"id": "NcLqR0Sbi_vT"
"id": "NcLqR0Sbi_vT",
"outputId": "1ca6c5b2-d54e-4847-8ae8-b4171ee48654",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 3,
"outputs": []
"execution_count": 10,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"tensor([[1.5162, 1.4619, 1.2879, 0.9661, 1.1961, 1.2263, 1.2790]])"
]
},
"metadata": {},
"execution_count": 10
}
]
},
{
"cell_type": "markdown",
Expand All @@ -113,18 +152,44 @@
"cell_type": "code",
"source": [
"# Set manual seed\n",
"\n",
"\n",
"random_seed=0\n",
"# Create two random tensors\n",
"torch.manual_seed(random_seed)\n",
"tensor_a=torch.rand(7,7)\n",
"torch.manual_seed(random_seed)\n",
"tensor_b=torch.rand(1,7)\n",
"\n",
"\n",
"# Matrix multiply tensors\n"
"# Matrix multiply tensors\n",
"mul= torch.mm(tensor_a,tensor_b.T)\n",
"mul, mul.shape"
],
"metadata": {
"id": "D-lOWI_1jRMm"
"id": "D-lOWI_1jRMm",
"outputId": "d563b732-f901-40af-ab64-e34849ca543c",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 4,
"outputs": []
"execution_count": 49,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"(tensor([[1.5985],\n",
" [1.1173],\n",
" [1.2741],\n",
" [1.6838],\n",
" [0.8279],\n",
" [1.0347],\n",
" [1.2498]]),\n",
" torch.Size([7, 1]))"
]
},
"metadata": {},
"execution_count": 49
}
]
},
{
"cell_type": "markdown",
Expand All @@ -144,7 +209,7 @@
"metadata": {
"id": "_LKWcfSTjp00"
},
"execution_count": 5,
"execution_count": null,
"outputs": []
},
{
Expand All @@ -169,17 +234,48 @@
"cell_type": "code",
"source": [
"# Set random seed\n",
"\n",
"\n",
"torch.cuda.manual_seed(1234)\n",
"torch.cuda.set_device(0)\n",
"# Check for access to GPU\n",
"\n",
"# Create two random tensors on GPU\n"
"device= \"cuda\" if torch.cuda.is_available() else \"cpu\"\n",
"print(f\"Device: {device}\")\n",
"# Create two random tensors on GPU\n",
"torch.cuda.manual_seed(1234)\n",
"tensor_c = torch.rand(2,3).to(device)\n",
"torch.cuda.manual_seed(1234)\n",
"tensor_d = torch.rand(2,3).to(device)\n",
"tensor_c, tensor_d\n"
],
"metadata": {
"id": "azXExiFZj5nm"
"id": "azXExiFZj5nm",
"outputId": "a2f6555a-d7be-4c8d-a4c5-e296f5a753aa",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 6,
"outputs": []
"execution_count": 58,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"Device: cuda\n"
]
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
"(tensor([[0.7529, 0.8579, 0.6870],\n",
" [0.0051, 0.1757, 0.7497]], device='cuda:0'),\n",
" tensor([[0.6047, 0.1100, 0.2121],\n",
" [0.9704, 0.8369, 0.2820]], device='cuda:0'))"
]
},
"metadata": {},
"execution_count": 58
}
]
},
{
"cell_type": "markdown",
Expand All @@ -200,13 +296,32 @@
{
"cell_type": "code",
"source": [
"# Perform matmul on tensor_A and tensor_B\n"
"# Perform matmul on tensor_A and tensor_B\n",
"mul2=torch.mm(tensor_c,tensor_d.T)\n",
"mul2,mul2.shape"
],
"metadata": {
"id": "fAeG7ox0lHEO"
"id": "fAeG7ox0lHEO",
"outputId": "b8f0cf80-35bb-41d4-b94b-cf822b384024",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 7,
"outputs": []
"execution_count": 47,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"(tensor([[1.1941, 0.6911],\n",
" [0.3175, 0.2087]], device='cuda:0'),\n",
" torch.Size([2, 2]))"
]
},
"metadata": {},
"execution_count": 47
}
]
},
{
"cell_type": "markdown",
Expand All @@ -221,14 +336,31 @@
"cell_type": "code",
"source": [
"# Find max\n",
"\n",
"# Find min\n"
"max= torch.max(mul2)\n",
"# Find min\n",
"min= torch.min(mul2)\n",
"max,min"
],
"metadata": {
"id": "Fu8_3mZpllOd"
"id": "Fu8_3mZpllOd",
"outputId": "479d6132-727d-4980-a819-82d0466ab10e",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 8,
"outputs": []
"execution_count": 60,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"(tensor(1.1941, device='cuda:0'), tensor(0.2087, device='cuda:0'))"
]
},
"metadata": {},
"execution_count": 60
}
]
},
{
"cell_type": "markdown",
Expand All @@ -243,15 +375,34 @@
"cell_type": "code",
"source": [
"# Find arg max\n",
"max2= torch.argmax(mul2)\n",
"\n",
"\n",
"# Find arg min\n"
"# Find arg min\n",
"min2=torch.argmin(mul2)\n",
"max2,min2"
],
"metadata": {
"id": "CCEKt4K2lsfQ"
"id": "CCEKt4K2lsfQ",
"outputId": "c8fb459d-2b91-4b80-a210-b46275657147",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 9,
"outputs": []
"execution_count": 66,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"(tensor(0, device='cuda:0'),\n",
" tensor(3, device='cuda:0'),\n",
" tensor(0.2087, device='cuda:0'))"
]
},
"metadata": {},
"execution_count": 66
}
]
},
{
"cell_type": "markdown",
Expand All @@ -276,20 +427,50 @@
"cell_type": "code",
"source": [
"# Set seed\n",
"\n",
"torch.cuda.manual_seed(7)\n",
"\n",
"# Create random tensor\n",
"\n",
"tensor_f = torch.rand(1,1,1,10)\n",
"\n",
"# Remove single dimensions\n",
"tensor_g=tensor_f.squeeze()\n",
"\n",
"\n",
"# Print out tensors and their shapes\n"
"# Print out tensors and their shapes\n",
"print(f\"tensor_f: {tensor_f}\")\n",
"print(f\"tensfor_f_shape: {tensor_f.shape}\")\n",
"print(f\"tensor_g:{tensor_g}\")\n",
"print(f\"tensor_g_shape: {tensor_g.shape}\")"
],
"metadata": {
"id": "TQ9zbRzVl1jV"
"id": "TQ9zbRzVl1jV",
"outputId": "a7ee7640-b73a-4874-8682-5b4e86b0c5c4",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"execution_count": 10,
"execution_count": 69,
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"tensor_f: tensor([[[[0.9537, 0.8426, 0.0784, 0.3756, 0.5226, 0.5730, 0.6186, 0.6962,\n",
" 0.5300, 0.2560]]]])\n",
"tensfor_f_shape: torch.Size([1, 1, 1, 10])\n",
"tensor_g:tensor([0.9537, 0.8426, 0.0784, 0.3756, 0.5226, 0.5730, 0.6186, 0.6962, 0.5300,\n",
" 0.2560])\n",
"tensor_g_shape: torch.Size([10])\n"
]
}
]
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "0HaL7IBHbRVU"
},
"execution_count": null,
"outputs": []
}
]
Expand Down
Loading