Files
DSAI/06_NN/code/nn_10_cnn_2.ipynb
2026-01-16 16:53:19 +01:00

127 lines
3.1 KiB
Plaintext

{
"cells": [
{
"cell_type": "markdown",
"id": "086b9495",
"metadata": {},
"source": [
"<div style=\"\n",
" border: 2px solid #4CAF50; \n",
" padding: 15px; \n",
" background-color: #f4f4f4; \n",
" border-radius: 10px; \n",
" align-items: center;\">\n",
"\n",
"<h1 style=\"margin: 0; color: #4CAF50;\">Neural Networks: Convolutional Neural Networks (2)</h1>\n",
"<h2 style=\"margin: 5px 0; color: #555;\">DSAI</h2>\n",
"<h3 style=\"margin: 5px 0; color: #555;\">Jakob Eggl</h3>\n",
"\n",
"<div style=\"flex-shrink: 0;\">\n",
" <img src=\"https://www.htl-grieskirchen.at/wp/wp-content/uploads/2022/11/logo_bildschirm-1024x503.png\" alt=\"Logo\" style=\"width: 250px; height: auto;\"/>\n",
"</div>\n",
"<p1> © 2025/26 Jakob Eggl. Nutzung oder Verbreitung nur mit ausdrücklicher Genehmigung des Autors.</p1>\n",
"</div>\n",
"<div style=\"flex: 1;\">\n",
"</div> "
]
},
{
"cell_type": "markdown",
"id": "640a7aba",
"metadata": {},
"source": [
"Nachdem wir jetzt wissen, wie ein *Convolutional Neuronal Network* (**CNN**) funktioniert, wollen wir nun nochmal die Datasets **MNIST** und **Fashion-MNIST** ausprobieren."
]
},
{
"cell_type": "markdown",
"id": "8d8125aa",
"metadata": {},
"source": [
"Erstelle somit ein Neuronales Netzwerk, welches auf der CNN Architektur basiert und auf den Datasets **MNIST** und **Fashion-MNIST** trainiert wird."
]
},
{
"cell_type": "markdown",
"id": "2b5f313f",
"metadata": {},
"source": [
"# Lösung"
]
},
{
"cell_type": "markdown",
"id": "6c231b6a",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": 2,
"id": "2a0a6fdf",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"import torch\n",
"import torch.nn as nn\n",
"import torch.optim as optim\n",
"from torch.utils.data import DataLoader, Dataset, random_split\n",
"from torchvision import datasets, transforms\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"from sklearn.metrics import confusion_matrix\n",
"import seaborn as sns"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "e942400c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cpu\n"
]
}
],
"source": [
"device = torch.device('cuda') if torch.cuda.is_available() else torch.device('mps') if torch.backends.mps.is_available() else torch.device('cpu')\n",
"print(device)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "86c04c79",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "dsai",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.23"
}
},
"nbformat": 4,
"nbformat_minor": 5
}