forked from pms/uczenie-maszynowe
Laboratoria - sieci neuronowe
This commit is contained in:
parent
277dd4a367
commit
afb21cb42c
237
lab/Sieci_neuronowe_Keras.ipynb
Normal file
237
lab/Sieci_neuronowe_Keras.ipynb
Normal file
@ -0,0 +1,237 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "-"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"### AITech — Uczenie maszynowe — laboratoria\n",
|
||||
"# 11. Sieci neuronowe (Keras)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Keras to napisany w języku Python interfejs do platformy TensorFlow, służącej do uczenia maszynowego.\n",
|
||||
"\n",
|
||||
"Aby z niego korzystać, trzeba zainstalować bibliotekę TensorFlow:\n",
|
||||
" * `pip`: https://www.tensorflow.org/install\n",
|
||||
" * `conda`: https://docs.anaconda.com/anaconda/user-guide/tasks/tensorflow"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Przykład implementacji sieci neuronowej do rozpoznawania cyfr ze zbioru MNIST, według https://keras.io/examples/vision/mnist_convnet"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Konieczne importy\n",
|
||||
"\n",
|
||||
"import numpy as np\n",
|
||||
"from tensorflow import keras\n",
|
||||
"from tensorflow.keras import layers"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz\n",
|
||||
"11493376/11490434 [==============================] - 1s 0us/step\n",
|
||||
"x_train shape: (60000, 28, 28, 1)\n",
|
||||
"60000 train samples\n",
|
||||
"10000 test samples\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Przygotowanie danych\n",
|
||||
"\n",
|
||||
"num_classes = 10\n",
|
||||
"input_shape = (28, 28, 1)\n",
|
||||
"\n",
|
||||
"# podział danych na zbiory uczący i testowy\n",
|
||||
"(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()\n",
|
||||
"\n",
|
||||
"# skalowanie obrazów do przedziału [0, 1]\n",
|
||||
"x_train = x_train.astype(\"float32\") / 255\n",
|
||||
"x_test = x_test.astype(\"float32\") / 255\n",
|
||||
"# upewnienie się, że obrazy mają wymiary (28, 28, 1)\n",
|
||||
"x_train = np.expand_dims(x_train, -1)\n",
|
||||
"x_test = np.expand_dims(x_test, -1)\n",
|
||||
"print(\"x_train shape:\", x_train.shape)\n",
|
||||
"print(x_train.shape[0], \"train samples\")\n",
|
||||
"print(x_test.shape[0], \"test samples\")\n",
|
||||
"\n",
|
||||
"# konwersja danych kategorycznych na binarne\n",
|
||||
"y_train = keras.utils.to_categorical(y_train, num_classes)\n",
|
||||
"y_test = keras.utils.to_categorical(y_test, num_classes)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Model: \"sequential\"\n",
|
||||
"_________________________________________________________________\n",
|
||||
"Layer (type) Output Shape Param # \n",
|
||||
"=================================================================\n",
|
||||
"conv2d (Conv2D) (None, 26, 26, 32) 320 \n",
|
||||
"_________________________________________________________________\n",
|
||||
"max_pooling2d (MaxPooling2D) (None, 13, 13, 32) 0 \n",
|
||||
"_________________________________________________________________\n",
|
||||
"conv2d_1 (Conv2D) (None, 11, 11, 64) 18496 \n",
|
||||
"_________________________________________________________________\n",
|
||||
"max_pooling2d_1 (MaxPooling2 (None, 5, 5, 64) 0 \n",
|
||||
"_________________________________________________________________\n",
|
||||
"flatten (Flatten) (None, 1600) 0 \n",
|
||||
"_________________________________________________________________\n",
|
||||
"dropout (Dropout) (None, 1600) 0 \n",
|
||||
"_________________________________________________________________\n",
|
||||
"dense (Dense) (None, 10) 16010 \n",
|
||||
"=================================================================\n",
|
||||
"Total params: 34,826\n",
|
||||
"Trainable params: 34,826\n",
|
||||
"Non-trainable params: 0\n",
|
||||
"_________________________________________________________________\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Stworzenie modelu\n",
|
||||
"\n",
|
||||
"model = keras.Sequential(\n",
|
||||
" [\n",
|
||||
" keras.Input(shape=input_shape),\n",
|
||||
" layers.Conv2D(32, kernel_size=(3, 3), activation=\"relu\"),\n",
|
||||
" layers.MaxPooling2D(pool_size=(2, 2)),\n",
|
||||
" layers.Conv2D(64, kernel_size=(3, 3), activation=\"relu\"),\n",
|
||||
" layers.MaxPooling2D(pool_size=(2, 2)),\n",
|
||||
" layers.Flatten(),\n",
|
||||
" layers.Dropout(0.5),\n",
|
||||
" layers.Dense(num_classes, activation=\"softmax\"),\n",
|
||||
" ]\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"model.summary()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"422/422 [==============================] - 38s 91ms/step - loss: 0.0556 - accuracy: 0.9826 - val_loss: 0.0412 - val_accuracy: 0.9893\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"text/plain": [
|
||||
"<tensorflow.python.keras.callbacks.History at 0x1a50b35a070>"
|
||||
]
|
||||
},
|
||||
"execution_count": 9,
|
||||
"metadata": {},
|
||||
"output_type": "execute_result"
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Uczenie modelu\n",
|
||||
"\n",
|
||||
"batch_size = 128\n",
|
||||
"epochs = 15\n",
|
||||
"\n",
|
||||
"model.compile(loss=\"categorical_crossentropy\", optimizer=\"adam\", metrics=[\"accuracy\"])\n",
|
||||
"\n",
|
||||
"model.fit(x_train, y_train, epochs=1, batch_size=batch_size, epochs=epochs, validation_split=0.1)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Test loss: 0.03675819933414459\n",
|
||||
"Test accuracy: 0.988099992275238\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"# Ewaluacja modelu\n",
|
||||
"\n",
|
||||
"score = model.evaluate(x_test, y_test, verbose=0)\n",
|
||||
"print(\"Test loss:\", score[0])\n",
|
||||
"print(\"Test accuracy:\", score[1])"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Zadanie 11 (6 punktów)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Zaimplementuj rozwiązanie wybranego problemu klasyfikacyjnego za pomocą prostej sieci neuronowej stworzonej przy użyciu biblioteki Keras."
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"celltoolbar": "Slideshow",
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"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.10.6"
|
||||
},
|
||||
"livereveal": {
|
||||
"start_slideshow_at": "selected",
|
||||
"theme": "amu"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
761
lab/Sieci_neuronowe_PyTorch.ipynb
Normal file
761
lab/Sieci_neuronowe_PyTorch.ipynb
Normal file
@ -0,0 +1,761 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {
|
||||
"slideshow": {
|
||||
"slide_type": "-"
|
||||
}
|
||||
},
|
||||
"source": [
|
||||
"### AITech — Uczenie maszynowe — laboratoria\n",
|
||||
"# 10. Sieci neuronowe (PyTorch)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Przykład implementacji sieci neuronowej do rozpoznawania cyfr ze [zbioru MNIST](https://en.wikipedia.org/wiki/MNIST_database), według https://github.com/pytorch/examples/tree/master/mnist"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import torch\n",
|
||||
"import torch.nn as nn\n",
|
||||
"import torch.nn.functional as F\n",
|
||||
"import torch.optim as optim\n",
|
||||
"from torchvision import datasets, transforms\n",
|
||||
"from torch.optim.lr_scheduler import StepLR\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"class Net(nn.Module):\n",
|
||||
" \"\"\"W PyTorchu tworzenie sieci neuronowej\n",
|
||||
" polega na zdefiniowaniu klasy, która dziedziczy z nn.Module.\n",
|
||||
" \"\"\"\n",
|
||||
" \n",
|
||||
" def __init__(self):\n",
|
||||
" super().__init__()\n",
|
||||
" \n",
|
||||
" # Warstwy splotowe\n",
|
||||
" self.conv1 = nn.Conv2d(1, 32, 3, 1)\n",
|
||||
" self.conv2 = nn.Conv2d(32, 64, 3, 1)\n",
|
||||
" \n",
|
||||
" # Warstwy dropout\n",
|
||||
" self.dropout1 = nn.Dropout(0.25)\n",
|
||||
" self.dropout2 = nn.Dropout(0.5)\n",
|
||||
" \n",
|
||||
" # Warstwy liniowe\n",
|
||||
" self.fc1 = nn.Linear(9216, 128)\n",
|
||||
" self.fc2 = nn.Linear(128, 10)\n",
|
||||
"\n",
|
||||
" def forward(self, x):\n",
|
||||
" \"\"\"Definiujemy przechodzenie \"do przodu\" jako kolejne przekształcenia wejścia x\"\"\"\n",
|
||||
" x = self.conv1(x)\n",
|
||||
" x = F.relu(x)\n",
|
||||
" x = self.conv2(x)\n",
|
||||
" x = F.relu(x)\n",
|
||||
" x = F.max_pool2d(x, 2)\n",
|
||||
" x = self.dropout1(x)\n",
|
||||
" x = torch.flatten(x, 1)\n",
|
||||
" x = self.fc1(x)\n",
|
||||
" x = F.relu(x)\n",
|
||||
" x = self.dropout2(x)\n",
|
||||
" x = self.fc2(x)\n",
|
||||
" output = F.log_softmax(x, dim=1)\n",
|
||||
" return output\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def train(model, device, train_loader, optimizer, epoch, log_interval, dry_run):\n",
|
||||
" \"\"\"Uczenie modelu\"\"\"\n",
|
||||
" model.train()\n",
|
||||
" for batch_idx, (data, target) in enumerate(train_loader):\n",
|
||||
" data, target = data.to(device), target.to(device) # wrzucenie danych na kartę graficzną (jeśli dotyczy)\n",
|
||||
" optimizer.zero_grad() # wyzerowanie gradientu\n",
|
||||
" output = model(data) # przejście \"do przodu\"\n",
|
||||
" loss = F.nll_loss(output, target) # obliczenie funkcji kosztu\n",
|
||||
" loss.backward() # propagacja wsteczna\n",
|
||||
" optimizer.step() # krok optymalizatora\n",
|
||||
" if batch_idx % log_interval == 0:\n",
|
||||
" print('Train Epoch: {} [{}/{} ({:.0f}%)]\\tLoss: {:.6f}'.format(\n",
|
||||
" epoch, batch_idx * len(data), len(train_loader.dataset),\n",
|
||||
" 100. * batch_idx / len(train_loader), loss.item()))\n",
|
||||
" if dry_run:\n",
|
||||
" break\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def test(model, device, test_loader):\n",
|
||||
" \"\"\"Testowanie modelu\"\"\"\n",
|
||||
" model.eval()\n",
|
||||
" test_loss = 0\n",
|
||||
" correct = 0\n",
|
||||
" with torch.no_grad():\n",
|
||||
" for data, target in test_loader:\n",
|
||||
" data, target = data.to(device), target.to(device) # wrzucenie danych na kartę graficzną (jeśli dotyczy)\n",
|
||||
" output = model(data) # przejście \"do przodu\"\n",
|
||||
" test_loss += F.nll_loss(output, target, reduction='sum').item() # suma kosztów z każdego batcha\n",
|
||||
" pred = output.argmax(dim=1, keepdim=True) # predykcja na podstawie maks. logarytmu prawdopodobieństwa\n",
|
||||
" correct += pred.eq(target.view_as(pred)).sum().item()\n",
|
||||
"\n",
|
||||
" test_loss /= len(test_loader.dataset) # obliczenie kosztu na zbiorze testowym\n",
|
||||
"\n",
|
||||
" print('\\nTest set: Average loss: {:.4f}, Accuracy: {}/{} ({:.0f}%)\\n'.format(\n",
|
||||
" test_loss, correct, len(test_loader.dataset),\n",
|
||||
" 100. * correct / len(test_loader.dataset)))\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def run(\n",
|
||||
" batch_size=64,\n",
|
||||
" test_batch_size=1000,\n",
|
||||
" epochs=14,\n",
|
||||
" lr=1.0,\n",
|
||||
" gamma=0.7,\n",
|
||||
" no_cuda=False,\n",
|
||||
" dry_run=False,\n",
|
||||
" seed=1,\n",
|
||||
" log_interval=10,\n",
|
||||
" save_model=False,\n",
|
||||
" ):\n",
|
||||
" \"\"\"Main training function.\n",
|
||||
" \n",
|
||||
" Arguments:\n",
|
||||
" batch_size - wielkość batcha podczas uczenia (default: 64),\n",
|
||||
" test_batch_size - wielkość batcha podczas testowania (default: 1000)\n",
|
||||
" epochs - liczba epok uczenia (default: 14)\n",
|
||||
" lr - współczynnik uczenia (learning rate) (default: 1.0)\n",
|
||||
" gamma - współczynnik gamma (dla optymalizatora) (default: 0.7)\n",
|
||||
" no_cuda - wyłącza uczenie na karcie graficznej (default: False)\n",
|
||||
" dry_run - szybko (\"na sucho\") sprawdza pojedyncze przejście (default: False)\n",
|
||||
" seed - ziarno generatora liczb pseudolosowych (default: 1)\n",
|
||||
" log_interval - interwał logowania stanu uczenia (default: 10)\n",
|
||||
" save_model - zapisuje bieżący model (default: False)\n",
|
||||
" \"\"\"\n",
|
||||
" use_cuda = no_cuda and torch.cuda.is_available()\n",
|
||||
"\n",
|
||||
" torch.manual_seed(seed)\n",
|
||||
"\n",
|
||||
" device = torch.device(\"cuda\" if use_cuda else \"cpu\")\n",
|
||||
"\n",
|
||||
" train_kwargs = {'batch_size': batch_size}\n",
|
||||
" test_kwargs = {'batch_size': test_batch_size}\n",
|
||||
" if use_cuda:\n",
|
||||
" cuda_kwargs = {'num_workers': 1,\n",
|
||||
" 'pin_memory': True,\n",
|
||||
" 'shuffle': True}\n",
|
||||
" train_kwargs.update(cuda_kwargs)\n",
|
||||
" test_kwargs.update(cuda_kwargs)\n",
|
||||
"\n",
|
||||
" transform=transforms.Compose([\n",
|
||||
" transforms.ToTensor(),\n",
|
||||
" transforms.Normalize((0.1307,), (0.3081,))\n",
|
||||
" ])\n",
|
||||
" dataset1 = datasets.MNIST('../data', train=True, download=True,\n",
|
||||
" transform=transform)\n",
|
||||
" dataset2 = datasets.MNIST('../data', train=False,\n",
|
||||
" transform=transform)\n",
|
||||
" train_loader = torch.utils.data.DataLoader(dataset1,**train_kwargs)\n",
|
||||
" test_loader = torch.utils.data.DataLoader(dataset2, **test_kwargs)\n",
|
||||
"\n",
|
||||
" model = Net().to(device)\n",
|
||||
" optimizer = optim.Adadelta(model.parameters(), lr=lr)\n",
|
||||
"\n",
|
||||
" scheduler = StepLR(optimizer, step_size=1, gamma=gamma)\n",
|
||||
" for epoch in range(1, epochs + 1):\n",
|
||||
" train(model, device, train_loader, optimizer, epoch, log_interval, dry_run)\n",
|
||||
" test(model, device, test_loader)\n",
|
||||
" scheduler.step()\n",
|
||||
"\n",
|
||||
" if save_model:\n",
|
||||
" torch.save(model.state_dict(), \"mnist_cnn.pt\")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"**Uwaga**: uruchomienie tego przykładu długo trwa. Żeby trwało krócej, można zmniejszyć liczbę epok."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stderr",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"C:\\Users\\pawel\\anaconda3\\lib\\site-packages\\torch\\autograd\\__init__.py:130: UserWarning: CUDA initialization: The NVIDIA driver on your system is too old (found version 9020). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx Alternatively, go to: https://pytorch.org to install a PyTorch version that has been compiled with your version of the CUDA driver. (Triggered internally at ..\\c10\\cuda\\CUDAFunctions.cpp:100.)\n",
|
||||
" Variable._execution_engine.run_backward(\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Train Epoch: 1 [0/60000 (0%)]\tLoss: 2.305400\n",
|
||||
"Train Epoch: 1 [640/60000 (1%)]\tLoss: 1.359776\n",
|
||||
"Train Epoch: 1 [1280/60000 (2%)]\tLoss: 0.842885\n",
|
||||
"Train Epoch: 1 [1920/60000 (3%)]\tLoss: 0.587047\n",
|
||||
"Train Epoch: 1 [2560/60000 (4%)]\tLoss: 0.368678\n",
|
||||
"Train Epoch: 1 [3200/60000 (5%)]\tLoss: 0.468111\n",
|
||||
"Train Epoch: 1 [3840/60000 (6%)]\tLoss: 0.264335\n",
|
||||
"Train Epoch: 1 [4480/60000 (7%)]\tLoss: 0.288264\n",
|
||||
"Train Epoch: 1 [5120/60000 (9%)]\tLoss: 0.579878\n",
|
||||
"Train Epoch: 1 [5760/60000 (10%)]\tLoss: 0.225971\n",
|
||||
"Train Epoch: 1 [6400/60000 (11%)]\tLoss: 0.235435\n",
|
||||
"Train Epoch: 1 [7040/60000 (12%)]\tLoss: 0.334189\n",
|
||||
"Train Epoch: 1 [7680/60000 (13%)]\tLoss: 0.205391\n",
|
||||
"Train Epoch: 1 [8320/60000 (14%)]\tLoss: 0.224400\n",
|
||||
"Train Epoch: 1 [8960/60000 (15%)]\tLoss: 0.265982\n",
|
||||
"Train Epoch: 1 [9600/60000 (16%)]\tLoss: 0.110670\n",
|
||||
"Train Epoch: 1 [10240/60000 (17%)]\tLoss: 0.266168\n",
|
||||
"Train Epoch: 1 [10880/60000 (18%)]\tLoss: 0.086807\n",
|
||||
"Train Epoch: 1 [11520/60000 (19%)]\tLoss: 0.417719\n",
|
||||
"Train Epoch: 1 [12160/60000 (20%)]\tLoss: 0.276456\n",
|
||||
"Train Epoch: 1 [12800/60000 (21%)]\tLoss: 0.242908\n",
|
||||
"Train Epoch: 1 [13440/60000 (22%)]\tLoss: 0.221252\n",
|
||||
"Train Epoch: 1 [14080/60000 (23%)]\tLoss: 0.130435\n",
|
||||
"Train Epoch: 1 [14720/60000 (25%)]\tLoss: 0.371944\n",
|
||||
"Train Epoch: 1 [15360/60000 (26%)]\tLoss: 0.143184\n",
|
||||
"Train Epoch: 1 [16000/60000 (27%)]\tLoss: 0.132785\n",
|
||||
"Train Epoch: 1 [16640/60000 (28%)]\tLoss: 0.167957\n",
|
||||
"Train Epoch: 1 [17280/60000 (29%)]\tLoss: 0.075128\n",
|
||||
"Train Epoch: 1 [17920/60000 (30%)]\tLoss: 0.200841\n",
|
||||
"Train Epoch: 1 [18560/60000 (31%)]\tLoss: 0.176965\n",
|
||||
"Train Epoch: 1 [19200/60000 (32%)]\tLoss: 0.277037\n",
|
||||
"Train Epoch: 1 [19840/60000 (33%)]\tLoss: 0.068315\n",
|
||||
"Train Epoch: 1 [20480/60000 (34%)]\tLoss: 0.035655\n",
|
||||
"Train Epoch: 1 [21120/60000 (35%)]\tLoss: 0.225525\n",
|
||||
"Train Epoch: 1 [21760/60000 (36%)]\tLoss: 0.012368\n",
|
||||
"Train Epoch: 1 [22400/60000 (37%)]\tLoss: 0.077660\n",
|
||||
"Train Epoch: 1 [23040/60000 (38%)]\tLoss: 0.235851\n",
|
||||
"Train Epoch: 1 [23680/60000 (39%)]\tLoss: 0.140474\n",
|
||||
"Train Epoch: 1 [24320/60000 (41%)]\tLoss: 0.014417\n",
|
||||
"Train Epoch: 1 [24960/60000 (42%)]\tLoss: 0.090741\n",
|
||||
"Train Epoch: 1 [25600/60000 (43%)]\tLoss: 0.058374\n",
|
||||
"Train Epoch: 1 [26240/60000 (44%)]\tLoss: 0.073511\n",
|
||||
"Train Epoch: 1 [26880/60000 (45%)]\tLoss: 0.284830\n",
|
||||
"Train Epoch: 1 [27520/60000 (46%)]\tLoss: 0.242107\n",
|
||||
"Train Epoch: 1 [28160/60000 (47%)]\tLoss: 0.106403\n",
|
||||
"Train Epoch: 1 [28800/60000 (48%)]\tLoss: 0.126598\n",
|
||||
"Train Epoch: 1 [29440/60000 (49%)]\tLoss: 0.048677\n",
|
||||
"Train Epoch: 1 [30080/60000 (50%)]\tLoss: 0.170355\n",
|
||||
"Train Epoch: 1 [30720/60000 (51%)]\tLoss: 0.048502\n",
|
||||
"Train Epoch: 1 [31360/60000 (52%)]\tLoss: 0.110658\n",
|
||||
"Train Epoch: 1 [32000/60000 (53%)]\tLoss: 0.209499\n",
|
||||
"Train Epoch: 1 [32640/60000 (54%)]\tLoss: 0.129011\n",
|
||||
"Train Epoch: 1 [33280/60000 (55%)]\tLoss: 0.054514\n",
|
||||
"Train Epoch: 1 [33920/60000 (57%)]\tLoss: 0.022598\n",
|
||||
"Train Epoch: 1 [34560/60000 (58%)]\tLoss: 0.013603\n",
|
||||
"Train Epoch: 1 [35200/60000 (59%)]\tLoss: 0.234786\n",
|
||||
"Train Epoch: 1 [35840/60000 (60%)]\tLoss: 0.159701\n",
|
||||
"Train Epoch: 1 [36480/60000 (61%)]\tLoss: 0.046117\n",
|
||||
"Train Epoch: 1 [37120/60000 (62%)]\tLoss: 0.116941\n",
|
||||
"Train Epoch: 1 [37760/60000 (63%)]\tLoss: 0.135829\n",
|
||||
"Train Epoch: 1 [38400/60000 (64%)]\tLoss: 0.148995\n",
|
||||
"Train Epoch: 1 [39040/60000 (65%)]\tLoss: 0.065900\n",
|
||||
"Train Epoch: 1 [39680/60000 (66%)]\tLoss: 0.025586\n",
|
||||
"Train Epoch: 1 [40320/60000 (67%)]\tLoss: 0.063601\n",
|
||||
"Train Epoch: 1 [40960/60000 (68%)]\tLoss: 0.102640\n",
|
||||
"Train Epoch: 1 [41600/60000 (69%)]\tLoss: 0.105056\n",
|
||||
"Train Epoch: 1 [42240/60000 (70%)]\tLoss: 0.086704\n",
|
||||
"Train Epoch: 1 [42880/60000 (71%)]\tLoss: 0.107370\n",
|
||||
"Train Epoch: 1 [43520/60000 (72%)]\tLoss: 0.253792\n",
|
||||
"Train Epoch: 1 [44160/60000 (74%)]\tLoss: 0.062311\n",
|
||||
"Train Epoch: 1 [44800/60000 (75%)]\tLoss: 0.162836\n",
|
||||
"Train Epoch: 1 [45440/60000 (76%)]\tLoss: 0.199484\n",
|
||||
"Train Epoch: 1 [46080/60000 (77%)]\tLoss: 0.153846\n",
|
||||
"Train Epoch: 1 [46720/60000 (78%)]\tLoss: 0.180161\n",
|
||||
"Train Epoch: 1 [47360/60000 (79%)]\tLoss: 0.136180\n",
|
||||
"Train Epoch: 1 [48000/60000 (80%)]\tLoss: 0.115283\n",
|
||||
"Train Epoch: 1 [48640/60000 (81%)]\tLoss: 0.027290\n",
|
||||
"Train Epoch: 1 [49280/60000 (82%)]\tLoss: 0.042729\n",
|
||||
"Train Epoch: 1 [49920/60000 (83%)]\tLoss: 0.075887\n",
|
||||
"Train Epoch: 1 [50560/60000 (84%)]\tLoss: 0.063403\n",
|
||||
"Train Epoch: 1 [51200/60000 (85%)]\tLoss: 0.313571\n",
|
||||
"Train Epoch: 1 [51840/60000 (86%)]\tLoss: 0.013781\n",
|
||||
"Train Epoch: 1 [52480/60000 (87%)]\tLoss: 0.033717\n",
|
||||
"Train Epoch: 1 [53120/60000 (88%)]\tLoss: 0.182661\n",
|
||||
"Train Epoch: 1 [53760/60000 (90%)]\tLoss: 0.039041\n",
|
||||
"Train Epoch: 1 [54400/60000 (91%)]\tLoss: 0.099427\n",
|
||||
"Train Epoch: 1 [55040/60000 (92%)]\tLoss: 0.016252\n",
|
||||
"Train Epoch: 1 [55680/60000 (93%)]\tLoss: 0.077332\n",
|
||||
"Train Epoch: 1 [56320/60000 (94%)]\tLoss: 0.057406\n",
|
||||
"Train Epoch: 1 [56960/60000 (95%)]\tLoss: 0.107130\n",
|
||||
"Train Epoch: 1 [57600/60000 (96%)]\tLoss: 0.126342\n",
|
||||
"Train Epoch: 1 [58240/60000 (97%)]\tLoss: 0.031756\n",
|
||||
"Train Epoch: 1 [58880/60000 (98%)]\tLoss: 0.009388\n",
|
||||
"Train Epoch: 1 [59520/60000 (99%)]\tLoss: 0.001617\n",
|
||||
"\n",
|
||||
"Test set: Average loss: 0.0452, Accuracy: 9848/10000 (98%)\n",
|
||||
"\n",
|
||||
"Train Epoch: 2 [0/60000 (0%)]\tLoss: 0.128514\n",
|
||||
"Train Epoch: 2 [640/60000 (1%)]\tLoss: 0.056695\n",
|
||||
"Train Epoch: 2 [1280/60000 (2%)]\tLoss: 0.034919\n",
|
||||
"Train Epoch: 2 [1920/60000 (3%)]\tLoss: 0.125458\n",
|
||||
"Train Epoch: 2 [2560/60000 (4%)]\tLoss: 0.052010\n",
|
||||
"Train Epoch: 2 [3200/60000 (5%)]\tLoss: 0.043915\n",
|
||||
"Train Epoch: 2 [3840/60000 (6%)]\tLoss: 0.015439\n",
|
||||
"Train Epoch: 2 [4480/60000 (7%)]\tLoss: 0.063102\n",
|
||||
"Train Epoch: 2 [5120/60000 (9%)]\tLoss: 0.121400\n",
|
||||
"Train Epoch: 2 [5760/60000 (10%)]\tLoss: 0.114424\n",
|
||||
"Train Epoch: 2 [6400/60000 (11%)]\tLoss: 0.212067\n",
|
||||
"Train Epoch: 2 [7040/60000 (12%)]\tLoss: 0.195634\n",
|
||||
"Train Epoch: 2 [7680/60000 (13%)]\tLoss: 0.075988\n",
|
||||
"Train Epoch: 2 [8320/60000 (14%)]\tLoss: 0.032679\n",
|
||||
"Train Epoch: 2 [8960/60000 (15%)]\tLoss: 0.111834\n",
|
||||
"Train Epoch: 2 [9600/60000 (16%)]\tLoss: 0.027801\n",
|
||||
"Train Epoch: 2 [10240/60000 (17%)]\tLoss: 0.073348\n",
|
||||
"Train Epoch: 2 [10880/60000 (18%)]\tLoss: 0.033118\n",
|
||||
"Train Epoch: 2 [11520/60000 (19%)]\tLoss: 0.172008\n",
|
||||
"Train Epoch: 2 [12160/60000 (20%)]\tLoss: 0.057611\n",
|
||||
"Train Epoch: 2 [12800/60000 (21%)]\tLoss: 0.064679\n",
|
||||
"Train Epoch: 2 [13440/60000 (22%)]\tLoss: 0.006825\n",
|
||||
"Train Epoch: 2 [14080/60000 (23%)]\tLoss: 0.019145\n",
|
||||
"Train Epoch: 2 [14720/60000 (25%)]\tLoss: 0.094843\n",
|
||||
"Train Epoch: 2 [15360/60000 (26%)]\tLoss: 0.047758\n",
|
||||
"Train Epoch: 2 [16000/60000 (27%)]\tLoss: 0.179497\n",
|
||||
"Train Epoch: 2 [16640/60000 (28%)]\tLoss: 0.076738\n",
|
||||
"Train Epoch: 2 [17280/60000 (29%)]\tLoss: 0.006352\n",
|
||||
"Train Epoch: 2 [17920/60000 (30%)]\tLoss: 0.051825\n",
|
||||
"Train Epoch: 2 [18560/60000 (31%)]\tLoss: 0.110851\n",
|
||||
"Train Epoch: 2 [19200/60000 (32%)]\tLoss: 0.065105\n",
|
||||
"Train Epoch: 2 [19840/60000 (33%)]\tLoss: 0.135653\n",
|
||||
"Train Epoch: 2 [20480/60000 (34%)]\tLoss: 0.021735\n",
|
||||
"Train Epoch: 2 [21120/60000 (35%)]\tLoss: 0.071245\n",
|
||||
"Train Epoch: 2 [21760/60000 (36%)]\tLoss: 0.003421\n",
|
||||
"Train Epoch: 2 [22400/60000 (37%)]\tLoss: 0.014809\n",
|
||||
"Train Epoch: 2 [23040/60000 (38%)]\tLoss: 0.053631\n",
|
||||
"Train Epoch: 2 [23680/60000 (39%)]\tLoss: 0.082716\n",
|
||||
"Train Epoch: 2 [24320/60000 (41%)]\tLoss: 0.001589\n",
|
||||
"Train Epoch: 2 [24960/60000 (42%)]\tLoss: 0.006215\n",
|
||||
"Train Epoch: 2 [25600/60000 (43%)]\tLoss: 0.042557\n",
|
||||
"Train Epoch: 2 [26240/60000 (44%)]\tLoss: 0.014680\n",
|
||||
"Train Epoch: 2 [26880/60000 (45%)]\tLoss: 0.124249\n",
|
||||
"Train Epoch: 2 [27520/60000 (46%)]\tLoss: 0.029917\n",
|
||||
"Train Epoch: 2 [28160/60000 (47%)]\tLoss: 0.100452\n",
|
||||
"Train Epoch: 2 [28800/60000 (48%)]\tLoss: 0.009274\n",
|
||||
"Train Epoch: 2 [29440/60000 (49%)]\tLoss: 0.076723\n",
|
||||
"Train Epoch: 2 [30080/60000 (50%)]\tLoss: 0.036926\n",
|
||||
"Train Epoch: 2 [30720/60000 (51%)]\tLoss: 0.097355\n",
|
||||
"Train Epoch: 2 [31360/60000 (52%)]\tLoss: 0.113212\n",
|
||||
"Train Epoch: 2 [32000/60000 (53%)]\tLoss: 0.126080\n",
|
||||
"Train Epoch: 2 [32640/60000 (54%)]\tLoss: 0.116121\n",
|
||||
"Train Epoch: 2 [33280/60000 (55%)]\tLoss: 0.053296\n",
|
||||
"Train Epoch: 2 [33920/60000 (57%)]\tLoss: 0.004935\n",
|
||||
"Train Epoch: 2 [34560/60000 (58%)]\tLoss: 0.018139\n",
|
||||
"Train Epoch: 2 [35200/60000 (59%)]\tLoss: 0.083827\n",
|
||||
"Train Epoch: 2 [35840/60000 (60%)]\tLoss: 0.064212\n",
|
||||
"Train Epoch: 2 [36480/60000 (61%)]\tLoss: 0.042852\n",
|
||||
"Train Epoch: 2 [37120/60000 (62%)]\tLoss: 0.053815\n",
|
||||
"Train Epoch: 2 [37760/60000 (63%)]\tLoss: 0.064109\n",
|
||||
"Train Epoch: 2 [38400/60000 (64%)]\tLoss: 0.082490\n",
|
||||
"Train Epoch: 2 [39040/60000 (65%)]\tLoss: 0.001922\n",
|
||||
"Train Epoch: 2 [39680/60000 (66%)]\tLoss: 0.021783\n",
|
||||
"Train Epoch: 2 [40320/60000 (67%)]\tLoss: 0.041218\n",
|
||||
"Train Epoch: 2 [40960/60000 (68%)]\tLoss: 0.037719\n",
|
||||
"Train Epoch: 2 [41600/60000 (69%)]\tLoss: 0.040485\n",
|
||||
"Train Epoch: 2 [42240/60000 (70%)]\tLoss: 0.025866\n",
|
||||
"Train Epoch: 2 [42880/60000 (71%)]\tLoss: 0.079971\n",
|
||||
"Train Epoch: 2 [43520/60000 (72%)]\tLoss: 0.051924\n",
|
||||
"Train Epoch: 2 [44160/60000 (74%)]\tLoss: 0.003454\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Train Epoch: 2 [44800/60000 (75%)]\tLoss: 0.059499\n",
|
||||
"Train Epoch: 2 [45440/60000 (76%)]\tLoss: 0.109399\n",
|
||||
"Train Epoch: 2 [46080/60000 (77%)]\tLoss: 0.078003\n",
|
||||
"Train Epoch: 2 [46720/60000 (78%)]\tLoss: 0.111255\n",
|
||||
"Train Epoch: 2 [47360/60000 (79%)]\tLoss: 0.061806\n",
|
||||
"Train Epoch: 2 [48000/60000 (80%)]\tLoss: 0.039426\n",
|
||||
"Train Epoch: 2 [48640/60000 (81%)]\tLoss: 0.035167\n",
|
||||
"Train Epoch: 2 [49280/60000 (82%)]\tLoss: 0.027696\n",
|
||||
"Train Epoch: 2 [49920/60000 (83%)]\tLoss: 0.021057\n",
|
||||
"Train Epoch: 2 [50560/60000 (84%)]\tLoss: 0.040626\n",
|
||||
"Train Epoch: 2 [51200/60000 (85%)]\tLoss: 0.150808\n",
|
||||
"Train Epoch: 2 [51840/60000 (86%)]\tLoss: 0.026038\n",
|
||||
"Train Epoch: 2 [52480/60000 (87%)]\tLoss: 0.014357\n",
|
||||
"Train Epoch: 2 [53120/60000 (88%)]\tLoss: 0.030147\n",
|
||||
"Train Epoch: 2 [53760/60000 (90%)]\tLoss: 0.085780\n",
|
||||
"Train Epoch: 2 [54400/60000 (91%)]\tLoss: 0.028594\n",
|
||||
"Train Epoch: 2 [55040/60000 (92%)]\tLoss: 0.037993\n",
|
||||
"Train Epoch: 2 [55680/60000 (93%)]\tLoss: 0.070294\n",
|
||||
"Train Epoch: 2 [56320/60000 (94%)]\tLoss: 0.035509\n",
|
||||
"Train Epoch: 2 [56960/60000 (95%)]\tLoss: 0.022443\n",
|
||||
"Train Epoch: 2 [57600/60000 (96%)]\tLoss: 0.034794\n",
|
||||
"Train Epoch: 2 [58240/60000 (97%)]\tLoss: 0.017368\n",
|
||||
"Train Epoch: 2 [58880/60000 (98%)]\tLoss: 0.016261\n",
|
||||
"Train Epoch: 2 [59520/60000 (99%)]\tLoss: 0.009625\n",
|
||||
"\n",
|
||||
"Test set: Average loss: 0.0345, Accuracy: 9876/10000 (99%)\n",
|
||||
"\n",
|
||||
"Train Epoch: 3 [0/60000 (0%)]\tLoss: 0.017473\n",
|
||||
"Train Epoch: 3 [640/60000 (1%)]\tLoss: 0.018726\n",
|
||||
"Train Epoch: 3 [1280/60000 (2%)]\tLoss: 0.012606\n",
|
||||
"Train Epoch: 3 [1920/60000 (3%)]\tLoss: 0.078804\n",
|
||||
"Train Epoch: 3 [2560/60000 (4%)]\tLoss: 0.044306\n",
|
||||
"Train Epoch: 3 [3200/60000 (5%)]\tLoss: 0.054774\n",
|
||||
"Train Epoch: 3 [3840/60000 (6%)]\tLoss: 0.028103\n",
|
||||
"Train Epoch: 3 [4480/60000 (7%)]\tLoss: 0.017842\n",
|
||||
"Train Epoch: 3 [5120/60000 (9%)]\tLoss: 0.051417\n",
|
||||
"Train Epoch: 3 [5760/60000 (10%)]\tLoss: 0.021005\n",
|
||||
"Train Epoch: 3 [6400/60000 (11%)]\tLoss: 0.079213\n",
|
||||
"Train Epoch: 3 [7040/60000 (12%)]\tLoss: 0.249057\n",
|
||||
"Train Epoch: 3 [7680/60000 (13%)]\tLoss: 0.021483\n",
|
||||
"Train Epoch: 3 [8320/60000 (14%)]\tLoss: 0.049537\n",
|
||||
"Train Epoch: 3 [8960/60000 (15%)]\tLoss: 0.064109\n",
|
||||
"Train Epoch: 3 [9600/60000 (16%)]\tLoss: 0.121206\n",
|
||||
"Train Epoch: 3 [10240/60000 (17%)]\tLoss: 0.272828\n",
|
||||
"Train Epoch: 3 [10880/60000 (18%)]\tLoss: 0.011667\n",
|
||||
"Train Epoch: 3 [11520/60000 (19%)]\tLoss: 0.074186\n",
|
||||
"Train Epoch: 3 [12160/60000 (20%)]\tLoss: 0.020923\n",
|
||||
"Train Epoch: 3 [12800/60000 (21%)]\tLoss: 0.071615\n",
|
||||
"Train Epoch: 3 [13440/60000 (22%)]\tLoss: 0.032925\n",
|
||||
"Train Epoch: 3 [14080/60000 (23%)]\tLoss: 0.020151\n",
|
||||
"Train Epoch: 3 [14720/60000 (25%)]\tLoss: 0.137694\n",
|
||||
"Train Epoch: 3 [15360/60000 (26%)]\tLoss: 0.014524\n",
|
||||
"Train Epoch: 3 [16000/60000 (27%)]\tLoss: 0.018904\n",
|
||||
"Train Epoch: 3 [16640/60000 (28%)]\tLoss: 0.115159\n",
|
||||
"Train Epoch: 3 [17280/60000 (29%)]\tLoss: 0.001221\n",
|
||||
"Train Epoch: 3 [17920/60000 (30%)]\tLoss: 0.039947\n",
|
||||
"Train Epoch: 3 [18560/60000 (31%)]\tLoss: 0.027275\n",
|
||||
"Train Epoch: 3 [19200/60000 (32%)]\tLoss: 0.115719\n",
|
||||
"Train Epoch: 3 [19840/60000 (33%)]\tLoss: 0.056799\n",
|
||||
"Train Epoch: 3 [20480/60000 (34%)]\tLoss: 0.003543\n",
|
||||
"Train Epoch: 3 [21120/60000 (35%)]\tLoss: 0.093628\n",
|
||||
"Train Epoch: 3 [21760/60000 (36%)]\tLoss: 0.041564\n",
|
||||
"Train Epoch: 3 [22400/60000 (37%)]\tLoss: 0.001555\n",
|
||||
"Train Epoch: 3 [23040/60000 (38%)]\tLoss: 0.047547\n",
|
||||
"Train Epoch: 3 [23680/60000 (39%)]\tLoss: 0.028232\n",
|
||||
"Train Epoch: 3 [24320/60000 (41%)]\tLoss: 0.002724\n",
|
||||
"Train Epoch: 3 [24960/60000 (42%)]\tLoss: 0.014905\n",
|
||||
"Train Epoch: 3 [25600/60000 (43%)]\tLoss: 0.077347\n",
|
||||
"Train Epoch: 3 [26240/60000 (44%)]\tLoss: 0.055335\n",
|
||||
"Train Epoch: 3 [26880/60000 (45%)]\tLoss: 0.034777\n",
|
||||
"Train Epoch: 3 [27520/60000 (46%)]\tLoss: 0.137610\n",
|
||||
"Train Epoch: 3 [28160/60000 (47%)]\tLoss: 0.087771\n",
|
||||
"Train Epoch: 3 [28800/60000 (48%)]\tLoss: 0.031867\n",
|
||||
"Train Epoch: 3 [29440/60000 (49%)]\tLoss: 0.024958\n",
|
||||
"Train Epoch: 3 [30080/60000 (50%)]\tLoss: 0.047101\n",
|
||||
"Train Epoch: 3 [30720/60000 (51%)]\tLoss: 0.094225\n",
|
||||
"Train Epoch: 3 [31360/60000 (52%)]\tLoss: 0.076411\n",
|
||||
"Train Epoch: 3 [32000/60000 (53%)]\tLoss: 0.029375\n",
|
||||
"Train Epoch: 3 [32640/60000 (54%)]\tLoss: 0.003572\n",
|
||||
"Train Epoch: 3 [33280/60000 (55%)]\tLoss: 0.081241\n",
|
||||
"Train Epoch: 3 [33920/60000 (57%)]\tLoss: 0.001588\n",
|
||||
"Train Epoch: 3 [34560/60000 (58%)]\tLoss: 0.002668\n",
|
||||
"Train Epoch: 3 [35200/60000 (59%)]\tLoss: 0.061726\n",
|
||||
"Train Epoch: 3 [35840/60000 (60%)]\tLoss: 0.061300\n",
|
||||
"Train Epoch: 3 [36480/60000 (61%)]\tLoss: 0.012152\n",
|
||||
"Train Epoch: 3 [37120/60000 (62%)]\tLoss: 0.042971\n",
|
||||
"Train Epoch: 3 [37760/60000 (63%)]\tLoss: 0.053396\n",
|
||||
"Train Epoch: 3 [38400/60000 (64%)]\tLoss: 0.072361\n",
|
||||
"Train Epoch: 3 [39040/60000 (65%)]\tLoss: 0.001462\n",
|
||||
"Train Epoch: 3 [39680/60000 (66%)]\tLoss: 0.027137\n",
|
||||
"Train Epoch: 3 [40320/60000 (67%)]\tLoss: 0.054929\n",
|
||||
"Train Epoch: 3 [40960/60000 (68%)]\tLoss: 0.052149\n",
|
||||
"Train Epoch: 3 [41600/60000 (69%)]\tLoss: 0.042770\n",
|
||||
"Train Epoch: 3 [42240/60000 (70%)]\tLoss: 0.022091\n",
|
||||
"Train Epoch: 3 [42880/60000 (71%)]\tLoss: 0.040765\n",
|
||||
"Train Epoch: 3 [43520/60000 (72%)]\tLoss: 0.065408\n",
|
||||
"Train Epoch: 3 [44160/60000 (74%)]\tLoss: 0.002670\n",
|
||||
"Train Epoch: 3 [44800/60000 (75%)]\tLoss: 0.020735\n",
|
||||
"Train Epoch: 3 [45440/60000 (76%)]\tLoss: 0.035558\n",
|
||||
"Train Epoch: 3 [46080/60000 (77%)]\tLoss: 0.086752\n",
|
||||
"Train Epoch: 3 [46720/60000 (78%)]\tLoss: 0.063626\n",
|
||||
"Train Epoch: 3 [47360/60000 (79%)]\tLoss: 0.066880\n",
|
||||
"Train Epoch: 3 [48000/60000 (80%)]\tLoss: 0.028604\n",
|
||||
"Train Epoch: 3 [48640/60000 (81%)]\tLoss: 0.012193\n",
|
||||
"Train Epoch: 3 [49280/60000 (82%)]\tLoss: 0.002023\n",
|
||||
"Train Epoch: 3 [49920/60000 (83%)]\tLoss: 0.005326\n",
|
||||
"Train Epoch: 3 [50560/60000 (84%)]\tLoss: 0.028037\n",
|
||||
"Train Epoch: 3 [51200/60000 (85%)]\tLoss: 0.041471\n",
|
||||
"Train Epoch: 3 [51840/60000 (86%)]\tLoss: 0.034811\n",
|
||||
"Train Epoch: 3 [52480/60000 (87%)]\tLoss: 0.005038\n",
|
||||
"Train Epoch: 3 [53120/60000 (88%)]\tLoss: 0.037799\n",
|
||||
"Train Epoch: 3 [53760/60000 (90%)]\tLoss: 0.159812\n",
|
||||
"Train Epoch: 3 [54400/60000 (91%)]\tLoss: 0.021355\n",
|
||||
"Train Epoch: 3 [55040/60000 (92%)]\tLoss: 0.006514\n",
|
||||
"Train Epoch: 3 [55680/60000 (93%)]\tLoss: 0.058171\n",
|
||||
"Train Epoch: 3 [56320/60000 (94%)]\tLoss: 0.011602\n",
|
||||
"Train Epoch: 3 [56960/60000 (95%)]\tLoss: 0.008109\n",
|
||||
"Train Epoch: 3 [57600/60000 (96%)]\tLoss: 0.068050\n",
|
||||
"Train Epoch: 3 [58240/60000 (97%)]\tLoss: 0.010048\n",
|
||||
"Train Epoch: 3 [58880/60000 (98%)]\tLoss: 0.004794\n",
|
||||
"Train Epoch: 3 [59520/60000 (99%)]\tLoss: 0.000842\n",
|
||||
"\n",
|
||||
"Test set: Average loss: 0.0319, Accuracy: 9889/10000 (99%)\n",
|
||||
"\n",
|
||||
"Train Epoch: 4 [0/60000 (0%)]\tLoss: 0.011954\n",
|
||||
"Train Epoch: 4 [640/60000 (1%)]\tLoss: 0.011093\n",
|
||||
"Train Epoch: 4 [1280/60000 (2%)]\tLoss: 0.022356\n",
|
||||
"Train Epoch: 4 [1920/60000 (3%)]\tLoss: 0.066412\n",
|
||||
"Train Epoch: 4 [2560/60000 (4%)]\tLoss: 0.008823\n",
|
||||
"Train Epoch: 4 [3200/60000 (5%)]\tLoss: 0.006209\n",
|
||||
"Train Epoch: 4 [3840/60000 (6%)]\tLoss: 0.016633\n",
|
||||
"Train Epoch: 4 [4480/60000 (7%)]\tLoss: 0.046557\n",
|
||||
"Train Epoch: 4 [5120/60000 (9%)]\tLoss: 0.236557\n",
|
||||
"Train Epoch: 4 [5760/60000 (10%)]\tLoss: 0.016318\n",
|
||||
"Train Epoch: 4 [6400/60000 (11%)]\tLoss: 0.095599\n",
|
||||
"Train Epoch: 4 [7040/60000 (12%)]\tLoss: 0.109512\n",
|
||||
"Train Epoch: 4 [7680/60000 (13%)]\tLoss: 0.025031\n",
|
||||
"Train Epoch: 4 [8320/60000 (14%)]\tLoss: 0.022703\n",
|
||||
"Train Epoch: 4 [8960/60000 (15%)]\tLoss: 0.072901\n",
|
||||
"Train Epoch: 4 [9600/60000 (16%)]\tLoss: 0.027679\n",
|
||||
"Train Epoch: 4 [10240/60000 (17%)]\tLoss: 0.100027\n",
|
||||
"Train Epoch: 4 [10880/60000 (18%)]\tLoss: 0.022117\n",
|
||||
"Train Epoch: 4 [11520/60000 (19%)]\tLoss: 0.058990\n",
|
||||
"Train Epoch: 4 [12160/60000 (20%)]\tLoss: 0.022886\n",
|
||||
"Train Epoch: 4 [12800/60000 (21%)]\tLoss: 0.014279\n",
|
||||
"Train Epoch: 4 [13440/60000 (22%)]\tLoss: 0.009374\n",
|
||||
"Train Epoch: 4 [14080/60000 (23%)]\tLoss: 0.004224\n",
|
||||
"Train Epoch: 4 [14720/60000 (25%)]\tLoss: 0.128787\n",
|
||||
"Train Epoch: 4 [15360/60000 (26%)]\tLoss: 0.006627\n",
|
||||
"Train Epoch: 4 [16000/60000 (27%)]\tLoss: 0.045232\n",
|
||||
"Train Epoch: 4 [16640/60000 (28%)]\tLoss: 0.126329\n",
|
||||
"Train Epoch: 4 [17280/60000 (29%)]\tLoss: 0.002526\n",
|
||||
"Train Epoch: 4 [17920/60000 (30%)]\tLoss: 0.062796\n",
|
||||
"Train Epoch: 4 [18560/60000 (31%)]\tLoss: 0.006109\n",
|
||||
"Train Epoch: 4 [19200/60000 (32%)]\tLoss: 0.032889\n",
|
||||
"Train Epoch: 4 [19840/60000 (33%)]\tLoss: 0.053419\n",
|
||||
"Train Epoch: 4 [20480/60000 (34%)]\tLoss: 0.003135\n",
|
||||
"Train Epoch: 4 [21120/60000 (35%)]\tLoss: 0.087492\n",
|
||||
"Train Epoch: 4 [21760/60000 (36%)]\tLoss: 0.005437\n",
|
||||
"Train Epoch: 4 [22400/60000 (37%)]\tLoss: 0.001357\n",
|
||||
"Train Epoch: 4 [23040/60000 (38%)]\tLoss: 0.199949\n",
|
||||
"Train Epoch: 4 [23680/60000 (39%)]\tLoss: 0.018877\n",
|
||||
"Train Epoch: 4 [24320/60000 (41%)]\tLoss: 0.016835\n",
|
||||
"Train Epoch: 4 [24960/60000 (42%)]\tLoss: 0.007058\n",
|
||||
"Train Epoch: 4 [25600/60000 (43%)]\tLoss: 0.036731\n",
|
||||
"Train Epoch: 4 [26240/60000 (44%)]\tLoss: 0.013287\n",
|
||||
"Train Epoch: 4 [26880/60000 (45%)]\tLoss: 0.090547\n",
|
||||
"Train Epoch: 4 [27520/60000 (46%)]\tLoss: 0.068249\n",
|
||||
"Train Epoch: 4 [28160/60000 (47%)]\tLoss: 0.065214\n"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"Train Epoch: 4 [28800/60000 (48%)]\tLoss: 0.005579\n",
|
||||
"Train Epoch: 4 [29440/60000 (49%)]\tLoss: 0.010757\n",
|
||||
"Train Epoch: 4 [30080/60000 (50%)]\tLoss: 0.013080\n",
|
||||
"Train Epoch: 4 [30720/60000 (51%)]\tLoss: 0.004695\n",
|
||||
"Train Epoch: 4 [31360/60000 (52%)]\tLoss: 0.009816\n",
|
||||
"Train Epoch: 4 [32000/60000 (53%)]\tLoss: 0.097901\n",
|
||||
"Train Epoch: 4 [32640/60000 (54%)]\tLoss: 0.008036\n",
|
||||
"Train Epoch: 4 [33280/60000 (55%)]\tLoss: 0.025720\n",
|
||||
"Train Epoch: 4 [33920/60000 (57%)]\tLoss: 0.007743\n",
|
||||
"Train Epoch: 4 [34560/60000 (58%)]\tLoss: 0.010240\n",
|
||||
"Train Epoch: 4 [35200/60000 (59%)]\tLoss: 0.040739\n",
|
||||
"Train Epoch: 4 [35840/60000 (60%)]\tLoss: 0.046888\n",
|
||||
"Train Epoch: 4 [36480/60000 (61%)]\tLoss: 0.002148\n",
|
||||
"Train Epoch: 4 [37120/60000 (62%)]\tLoss: 0.018123\n",
|
||||
"Train Epoch: 4 [37760/60000 (63%)]\tLoss: 0.138039\n",
|
||||
"Train Epoch: 4 [38400/60000 (64%)]\tLoss: 0.092445\n",
|
||||
"Train Epoch: 4 [39040/60000 (65%)]\tLoss: 0.004439\n",
|
||||
"Train Epoch: 4 [39680/60000 (66%)]\tLoss: 0.059561\n",
|
||||
"Train Epoch: 4 [40320/60000 (67%)]\tLoss: 0.016702\n",
|
||||
"Train Epoch: 4 [40960/60000 (68%)]\tLoss: 0.048608\n",
|
||||
"Train Epoch: 4 [41600/60000 (69%)]\tLoss: 0.043941\n",
|
||||
"Train Epoch: 4 [42240/60000 (70%)]\tLoss: 0.028248\n",
|
||||
"Train Epoch: 4 [42880/60000 (71%)]\tLoss: 0.004207\n",
|
||||
"Train Epoch: 4 [43520/60000 (72%)]\tLoss: 0.050349\n",
|
||||
"Train Epoch: 4 [44160/60000 (74%)]\tLoss: 0.004836\n",
|
||||
"Train Epoch: 4 [44800/60000 (75%)]\tLoss: 0.039172\n",
|
||||
"Train Epoch: 4 [45440/60000 (76%)]\tLoss: 0.060112\n",
|
||||
"Train Epoch: 4 [46080/60000 (77%)]\tLoss: 0.038748\n",
|
||||
"Train Epoch: 4 [46720/60000 (78%)]\tLoss: 0.027801\n",
|
||||
"Train Epoch: 4 [47360/60000 (79%)]\tLoss: 0.043409\n",
|
||||
"Train Epoch: 4 [48000/60000 (80%)]\tLoss: 0.023842\n",
|
||||
"Train Epoch: 4 [48640/60000 (81%)]\tLoss: 0.043613\n",
|
||||
"Train Epoch: 4 [49280/60000 (82%)]\tLoss: 0.005819\n",
|
||||
"Train Epoch: 4 [49920/60000 (83%)]\tLoss: 0.013224\n",
|
||||
"Train Epoch: 4 [50560/60000 (84%)]\tLoss: 0.008549\n",
|
||||
"Train Epoch: 4 [51200/60000 (85%)]\tLoss: 0.115843\n",
|
||||
"Train Epoch: 4 [51840/60000 (86%)]\tLoss: 0.012308\n",
|
||||
"Train Epoch: 4 [52480/60000 (87%)]\tLoss: 0.024157\n",
|
||||
"Train Epoch: 4 [53120/60000 (88%)]\tLoss: 0.003395\n",
|
||||
"Train Epoch: 4 [53760/60000 (90%)]\tLoss: 0.084941\n",
|
||||
"Train Epoch: 4 [54400/60000 (91%)]\tLoss: 0.057644\n",
|
||||
"Train Epoch: 4 [55040/60000 (92%)]\tLoss: 0.002062\n",
|
||||
"Train Epoch: 4 [55680/60000 (93%)]\tLoss: 0.038266\n",
|
||||
"Train Epoch: 4 [56320/60000 (94%)]\tLoss: 0.006398\n",
|
||||
"Train Epoch: 4 [56960/60000 (95%)]\tLoss: 0.007706\n",
|
||||
"Train Epoch: 4 [57600/60000 (96%)]\tLoss: 0.027255\n",
|
||||
"Train Epoch: 4 [58240/60000 (97%)]\tLoss: 0.044076\n",
|
||||
"Train Epoch: 4 [58880/60000 (98%)]\tLoss: 0.000889\n",
|
||||
"Train Epoch: 4 [59520/60000 (99%)]\tLoss: 0.001196\n",
|
||||
"\n",
|
||||
"Test set: Average loss: 0.0311, Accuracy: 9886/10000 (99%)\n",
|
||||
"\n",
|
||||
"Train Epoch: 5 [0/60000 (0%)]\tLoss: 0.015992\n",
|
||||
"Train Epoch: 5 [640/60000 (1%)]\tLoss: 0.012034\n",
|
||||
"Train Epoch: 5 [1280/60000 (2%)]\tLoss: 0.012463\n",
|
||||
"Train Epoch: 5 [1920/60000 (3%)]\tLoss: 0.053295\n",
|
||||
"Train Epoch: 5 [2560/60000 (4%)]\tLoss: 0.013971\n",
|
||||
"Train Epoch: 5 [3200/60000 (5%)]\tLoss: 0.008351\n",
|
||||
"Train Epoch: 5 [3840/60000 (6%)]\tLoss: 0.000522\n",
|
||||
"Train Epoch: 5 [4480/60000 (7%)]\tLoss: 0.056046\n",
|
||||
"Train Epoch: 5 [5120/60000 (9%)]\tLoss: 0.226117\n",
|
||||
"Train Epoch: 5 [5760/60000 (10%)]\tLoss: 0.024622\n",
|
||||
"Train Epoch: 5 [6400/60000 (11%)]\tLoss: 0.114540\n",
|
||||
"Train Epoch: 5 [7040/60000 (12%)]\tLoss: 0.164275\n",
|
||||
"Train Epoch: 5 [7680/60000 (13%)]\tLoss: 0.015020\n",
|
||||
"Train Epoch: 5 [8320/60000 (14%)]\tLoss: 0.009615\n",
|
||||
"Train Epoch: 5 [8960/60000 (15%)]\tLoss: 0.060808\n",
|
||||
"Train Epoch: 5 [9600/60000 (16%)]\tLoss: 0.021185\n",
|
||||
"Train Epoch: 5 [10240/60000 (17%)]\tLoss: 0.071090\n",
|
||||
"Train Epoch: 5 [10880/60000 (18%)]\tLoss: 0.004819\n",
|
||||
"Train Epoch: 5 [11520/60000 (19%)]\tLoss: 0.044744\n",
|
||||
"Train Epoch: 5 [12160/60000 (20%)]\tLoss: 0.036432\n",
|
||||
"Train Epoch: 5 [12800/60000 (21%)]\tLoss: 0.007292\n",
|
||||
"Train Epoch: 5 [13440/60000 (22%)]\tLoss: 0.005680\n",
|
||||
"Train Epoch: 5 [14080/60000 (23%)]\tLoss: 0.003425\n",
|
||||
"Train Epoch: 5 [14720/60000 (25%)]\tLoss: 0.055383\n",
|
||||
"Train Epoch: 5 [15360/60000 (26%)]\tLoss: 0.007300\n",
|
||||
"Train Epoch: 5 [16000/60000 (27%)]\tLoss: 0.034897\n",
|
||||
"Train Epoch: 5 [16640/60000 (28%)]\tLoss: 0.126585\n",
|
||||
"Train Epoch: 5 [17280/60000 (29%)]\tLoss: 0.001609\n",
|
||||
"Train Epoch: 5 [17920/60000 (30%)]\tLoss: 0.011380\n",
|
||||
"Train Epoch: 5 [18560/60000 (31%)]\tLoss: 0.031130\n",
|
||||
"Train Epoch: 5 [19200/60000 (32%)]\tLoss: 0.030126\n",
|
||||
"Train Epoch: 5 [19840/60000 (33%)]\tLoss: 0.111376\n",
|
||||
"Train Epoch: 5 [20480/60000 (34%)]\tLoss: 0.005547\n",
|
||||
"Train Epoch: 5 [21120/60000 (35%)]\tLoss: 0.123237\n",
|
||||
"Train Epoch: 5 [21760/60000 (36%)]\tLoss: 0.023191\n",
|
||||
"Train Epoch: 5 [22400/60000 (37%)]\tLoss: 0.001363\n",
|
||||
"Train Epoch: 5 [23040/60000 (38%)]\tLoss: 0.057234\n",
|
||||
"Train Epoch: 5 [23680/60000 (39%)]\tLoss: 0.015569\n",
|
||||
"Train Epoch: 5 [24320/60000 (41%)]\tLoss: 0.000795\n",
|
||||
"Train Epoch: 5 [24960/60000 (42%)]\tLoss: 0.000723\n",
|
||||
"Train Epoch: 5 [25600/60000 (43%)]\tLoss: 0.014871\n",
|
||||
"Train Epoch: 5 [26240/60000 (44%)]\tLoss: 0.007171\n",
|
||||
"Train Epoch: 5 [26880/60000 (45%)]\tLoss: 0.117038\n",
|
||||
"Train Epoch: 5 [27520/60000 (46%)]\tLoss: 0.111855\n",
|
||||
"Train Epoch: 5 [28160/60000 (47%)]\tLoss: 0.018824\n",
|
||||
"Train Epoch: 5 [28800/60000 (48%)]\tLoss: 0.012503\n",
|
||||
"Train Epoch: 5 [29440/60000 (49%)]\tLoss: 0.056160\n",
|
||||
"Train Epoch: 5 [30080/60000 (50%)]\tLoss: 0.043957\n",
|
||||
"Train Epoch: 5 [30720/60000 (51%)]\tLoss: 0.001754\n",
|
||||
"Train Epoch: 5 [31360/60000 (52%)]\tLoss: 0.091498\n",
|
||||
"Train Epoch: 5 [32000/60000 (53%)]\tLoss: 0.018654\n",
|
||||
"Train Epoch: 5 [32640/60000 (54%)]\tLoss: 0.023146\n",
|
||||
"Train Epoch: 5 [33280/60000 (55%)]\tLoss: 0.036612\n",
|
||||
"Train Epoch: 5 [33920/60000 (57%)]\tLoss: 0.002565\n",
|
||||
"Train Epoch: 5 [34560/60000 (58%)]\tLoss: 0.003447\n",
|
||||
"Train Epoch: 5 [35200/60000 (59%)]\tLoss: 0.110711\n",
|
||||
"Train Epoch: 5 [35840/60000 (60%)]\tLoss: 0.031876\n",
|
||||
"Train Epoch: 5 [36480/60000 (61%)]\tLoss: 0.009661\n",
|
||||
"Train Epoch: 5 [37120/60000 (62%)]\tLoss: 0.053748\n",
|
||||
"Train Epoch: 5 [37760/60000 (63%)]\tLoss: 0.079816\n",
|
||||
"Train Epoch: 5 [38400/60000 (64%)]\tLoss: 0.052890\n",
|
||||
"Train Epoch: 5 [39040/60000 (65%)]\tLoss: 0.001838\n",
|
||||
"Train Epoch: 5 [39680/60000 (66%)]\tLoss: 0.032443\n",
|
||||
"Train Epoch: 5 [40320/60000 (67%)]\tLoss: 0.016371\n",
|
||||
"Train Epoch: 5 [40960/60000 (68%)]\tLoss: 0.032993\n",
|
||||
"Train Epoch: 5 [41600/60000 (69%)]\tLoss: 0.009191\n",
|
||||
"Train Epoch: 5 [42240/60000 (70%)]\tLoss: 0.012432\n",
|
||||
"Train Epoch: 5 [42880/60000 (71%)]\tLoss: 0.021050\n",
|
||||
"Train Epoch: 5 [43520/60000 (72%)]\tLoss: 0.014490\n",
|
||||
"Train Epoch: 5 [44160/60000 (74%)]\tLoss: 0.003937\n",
|
||||
"Train Epoch: 5 [44800/60000 (75%)]\tLoss: 0.023810\n",
|
||||
"Train Epoch: 5 [45440/60000 (76%)]\tLoss: 0.024212\n",
|
||||
"Train Epoch: 5 [46080/60000 (77%)]\tLoss: 0.032333\n",
|
||||
"Train Epoch: 5 [46720/60000 (78%)]\tLoss: 0.081611\n",
|
||||
"Train Epoch: 5 [47360/60000 (79%)]\tLoss: 0.055151\n",
|
||||
"Train Epoch: 5 [48000/60000 (80%)]\tLoss: 0.046237\n",
|
||||
"Train Epoch: 5 [48640/60000 (81%)]\tLoss: 0.007069\n",
|
||||
"Train Epoch: 5 [49280/60000 (82%)]\tLoss: 0.004486\n",
|
||||
"Train Epoch: 5 [49920/60000 (83%)]\tLoss: 0.021935\n",
|
||||
"Train Epoch: 5 [50560/60000 (84%)]\tLoss: 0.009369\n",
|
||||
"Train Epoch: 5 [51200/60000 (85%)]\tLoss: 0.133733\n",
|
||||
"Train Epoch: 5 [51840/60000 (86%)]\tLoss: 0.004490\n",
|
||||
"Train Epoch: 5 [52480/60000 (87%)]\tLoss: 0.004431\n",
|
||||
"Train Epoch: 5 [53120/60000 (88%)]\tLoss: 0.022499\n",
|
||||
"Train Epoch: 5 [53760/60000 (90%)]\tLoss: 0.111768\n",
|
||||
"Train Epoch: 5 [54400/60000 (91%)]\tLoss: 0.021636\n",
|
||||
"Train Epoch: 5 [55040/60000 (92%)]\tLoss: 0.002808\n",
|
||||
"Train Epoch: 5 [55680/60000 (93%)]\tLoss: 0.007162\n",
|
||||
"Train Epoch: 5 [56320/60000 (94%)]\tLoss: 0.012326\n",
|
||||
"Train Epoch: 5 [56960/60000 (95%)]\tLoss: 0.002056\n",
|
||||
"Train Epoch: 5 [57600/60000 (96%)]\tLoss: 0.003829\n",
|
||||
"Train Epoch: 5 [58240/60000 (97%)]\tLoss: 0.013328\n",
|
||||
"Train Epoch: 5 [58880/60000 (98%)]\tLoss: 0.000146\n",
|
||||
"Train Epoch: 5 [59520/60000 (99%)]\tLoss: 0.000575\n",
|
||||
"\n",
|
||||
"Test set: Average loss: 0.0299, Accuracy: 9903/10000 (99%)\n",
|
||||
"\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"run(epochs=5)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Polecam również bibliotekę [PyTorch-Lightning](https://www.pytorchlightning.ai), dzięki któej kod PyTorcha staje się trochę bardziej \"uporządkowany\"."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Tutaj artykuł o tym, jak stworzyć dataloader dla danych z własnego pliku CSV: https://androidkt.com/load-pandas-dataframe-using-dataset-and-dataloader-in-pytorch"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Zadanie 10 (6 punktów)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Zaimplementuj rozwiązanie wybranego problemu klasyfikacyjnego za pomocą prostej sieci neuronowej stworzonej przy użyciu biblioteki PyTorch."
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"celltoolbar": "Slideshow",
|
||||
"kernelspec": {
|
||||
"display_name": "Python 3 (ipykernel)",
|
||||
"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.10.6"
|
||||
},
|
||||
"livereveal": {
|
||||
"start_slideshow_at": "selected",
|
||||
"theme": "amu"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 4
|
||||
}
|
Loading…
Reference in New Issue
Block a user