{ "cells": [ { "cell_type": "markdown", "id": "086b9495", "metadata": {}, "source": [ "
\n", "\n", "

Neural Networks: Convolutional Neural Networks (2)

\n", "

DSAI

\n", "

Jakob Eggl

\n", "\n", "
\n", " \"Logo\"\n", "
\n", " © 2025/26 Jakob Eggl. Nutzung oder Verbreitung nur mit ausdrücklicher Genehmigung des Autors.\n", "
\n", "
\n", "
" ] }, { "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 }