Created
March 15, 2021 02:37
-
-
Save samyumobi/4a2c855d5f9e762f3b6f8ff60266a3c4 to your computer and use it in GitHub Desktop.
Dog_Classifier.ipynb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "nbformat": 4, | |
| "nbformat_minor": 0, | |
| "metadata": { | |
| "colab": { | |
| "name": "Dog_Classifier.ipynb", | |
| "provenance": [], | |
| "authorship_tag": "ABX9TyMJcIFLY77tMMg0lxC3z4kT", | |
| "include_colab_link": true | |
| }, | |
| "kernelspec": { | |
| "name": "python3", | |
| "display_name": "Python 3" | |
| } | |
| }, | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "metadata": { | |
| "id": "view-in-github", | |
| "colab_type": "text" | |
| }, | |
| "source": [ | |
| "<a href=\"https://colab.research.google.com/gist/samyumobi/4a2c855d5f9e762f3b6f8ff60266a3c4/dog_classifier.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "9r57X9-Jgkls" | |
| }, | |
| "source": [ | |
| "!pip install d2l==0.16.1\r\n", | |
| "!pip install -U mxnet-cu101==1.7.0\r\n" | |
| ], | |
| "execution_count": null, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "1-eTZvlpkhRB" | |
| }, | |
| "source": [ | |
| "from d2l import mxnet as d2l\r\n", | |
| "from mxnet import autograd, gluon, init, npx\r\n", | |
| "from mxnet.gluon import nn\r\n", | |
| "import os\r\n", | |
| "\r\n", | |
| "npx.set_np()" | |
| ], | |
| "execution_count": 2, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "SGcSbWVrklSv" | |
| }, | |
| "source": [ | |
| "d2l.DATA_HUB['dog_tiny'] = (d2l.DATA_URL + 'kaggle_dog_tiny.zip',\r\n", | |
| " '0cb91d09b814ecdc07b50f31f8dcad3e81d6a86d')\r\n", | |
| "\r\n", | |
| "# If you use the full dataset downloaded for the Kaggle competition, change\r\n", | |
| "# the variable below to False\r\n", | |
| "demo = True\r\n", | |
| "if demo:\r\n", | |
| " data_dir = d2l.download_extract('dog_tiny')\r\n", | |
| "else:\r\n", | |
| " data_dir = os.path.join('..', 'data', 'dog-breed-identification')" | |
| ], | |
| "execution_count": 4, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "yglqConPktUl" | |
| }, | |
| "source": [ | |
| "def reorg_dog_data(data_dir, valid_ratio):\r\n", | |
| " labels = d2l.read_csv_labels(os.path.join(data_dir, 'labels.csv'))\r\n", | |
| " d2l.reorg_train_valid(data_dir, labels, valid_ratio)\r\n", | |
| " d2l.reorg_test(data_dir)\r\n", | |
| "\r\n", | |
| " \r\n", | |
| "batch_size = 4 if demo else 128\r\n", | |
| "valid_ratio = 0.1\r\n", | |
| "reorg_dog_data(data_dir, valid_ratio)" | |
| ], | |
| "execution_count": 5, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "gOxSaL3rk1je" | |
| }, | |
| "source": [ | |
| "transform_train = gluon.data.vision.transforms.Compose([\r\n", | |
| " # Randomly crop the image to obtain an image with an area of 0.08 to 1 of\r\n", | |
| " # the original area and height to width ratio between 3/4 and 4/3. Then,\r\n", | |
| " # scale the image to create a new image with a height and width of 224\r\n", | |
| " # pixels each\r\n", | |
| " gluon.data.vision.transforms.RandomResizedCrop(224, scale=(0.08, 1.0),\r\n", | |
| " ratio=(3.0/4.0, 4.0/3.0)),\r\n", | |
| " gluon.data.vision.transforms.RandomFlipLeftRight(),\r\n", | |
| " # Randomly change the brightness, contrast, and saturation\r\n", | |
| " gluon.data.vision.transforms.RandomColorJitter(brightness=0.4,\r\n", | |
| " contrast=0.4,\r\n", | |
| " saturation=0.4),\r\n", | |
| " # Add random noise\r\n", | |
| " gluon.data.vision.transforms.RandomLighting(0.1),\r\n", | |
| " gluon.data.vision.transforms.ToTensor(),\r\n", | |
| " # Standardize each channel of the image\r\n", | |
| " gluon.data.vision.transforms.Normalize([0.485, 0.456, 0.406],\r\n", | |
| " [0.229, 0.224, 0.225])])" | |
| ], | |
| "execution_count": 6, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "Fd4ueeyEk5cN" | |
| }, | |
| "source": [ | |
| "transform_test = gluon.data.vision.transforms.Compose([\r\n", | |
| " gluon.data.vision.transforms.Resize(256),\r\n", | |
| " # Crop a square of 224 by 224 from the center of the image\r\n", | |
| " gluon.data.vision.transforms.CenterCrop(224),\r\n", | |
| " gluon.data.vision.transforms.ToTensor(),\r\n", | |
| " gluon.data.vision.transforms.Normalize([0.485, 0.456, 0.406],\r\n", | |
| " [0.229, 0.224, 0.225])])" | |
| ], | |
| "execution_count": 7, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "4AstW8NWk9WI" | |
| }, | |
| "source": [ | |
| "train_ds, valid_ds, train_valid_ds, test_ds = [\r\n", | |
| " gluon.data.vision.ImageFolderDataset(\r\n", | |
| " os.path.join(data_dir, 'train_valid_test', folder))\r\n", | |
| " for folder in ('train', 'valid', 'train_valid', 'test')]" | |
| ], | |
| "execution_count": 8, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "x9mJRjVRk-kE" | |
| }, | |
| "source": [ | |
| "train_iter, train_valid_iter = [gluon.data.DataLoader(\r\n", | |
| " dataset.transform_first(transform_train), batch_size, shuffle=True, \r\n", | |
| " last_batch='discard') for dataset in (train_ds, train_valid_ds)]\r\n", | |
| "\r\n", | |
| "valid_iter = gluon.data.DataLoader(\r\n", | |
| " valid_ds.transform_first(transform_test), batch_size, shuffle=False, \r\n", | |
| " last_batch='discard')\r\n", | |
| "\r\n", | |
| "test_iter = gluon.data.DataLoader(\r\n", | |
| " test_ds.transform_first(transform_test), batch_size, shuffle=False, \r\n", | |
| " last_batch='keep')" | |
| ], | |
| "execution_count": 9, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "WRwpU98flFDC" | |
| }, | |
| "source": [ | |
| "def get_net(devices):\r\n", | |
| " finetune_net = gluon.model_zoo.vision.resnet34_v2(pretrained=True)\r\n", | |
| " # Define a new output network\r\n", | |
| " finetune_net.output_new = nn.HybridSequential(prefix='')\r\n", | |
| " finetune_net.output_new.add(nn.Dense(256, activation='relu'))\r\n", | |
| " # There are 120 output categories\r\n", | |
| " finetune_net.output_new.add(nn.Dense(120))\r\n", | |
| " # Initialize the output network\r\n", | |
| " finetune_net.output_new.initialize(init.Xavier(), ctx=devices)\r\n", | |
| " # Distribute the model parameters to the CPUs or GPUs used for computation\r\n", | |
| " finetune_net.collect_params().reset_ctx(devices)\r\n", | |
| " return finetune_net" | |
| ], | |
| "execution_count": 10, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "jcdfaFgTlKgO" | |
| }, | |
| "source": [ | |
| "loss = gluon.loss.SoftmaxCrossEntropyLoss()\r\n", | |
| "\r\n", | |
| "def evaluate_loss(data_iter, net, devices):\r\n", | |
| " l_sum, n = 0.0, 0\r\n", | |
| " for features, labels in data_iter:\r\n", | |
| " X_shards, y_shards = d2l.split_batch(features, labels, devices)\r\n", | |
| " output_features = [net.features(X_shard) for X_shard in X_shards]\r\n", | |
| " outputs = [net.output_new(feature) for feature in output_features]\r\n", | |
| " ls = [loss(output, y_shard).sum() for output, y_shard\r\n", | |
| " in zip(outputs, y_shards)]\r\n", | |
| " l_sum += sum([float(l.sum()) for l in ls])\r\n", | |
| " n += labels.size\r\n", | |
| " return l_sum / n" | |
| ], | |
| "execution_count": 11, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "7pf9lirWlLVP" | |
| }, | |
| "source": [ | |
| "def train(net, train_iter, valid_iter, num_epochs, lr, wd, devices, lr_period,\r\n", | |
| " lr_decay):\r\n", | |
| " # Only train the small custom output network\r\n", | |
| " trainer = gluon.Trainer(net.output_new.collect_params(), 'sgd',\r\n", | |
| " {'learning_rate': lr, 'momentum': 0.9, 'wd': wd})\r\n", | |
| " num_batches, timer = len(train_iter), d2l.Timer()\r\n", | |
| " animator = d2l.Animator(xlabel='epoch', xlim=[1, num_epochs],\r\n", | |
| " legend=['train loss', 'valid loss'])\r\n", | |
| " for epoch in range(num_epochs):\r\n", | |
| " metric = d2l.Accumulator(2)\r\n", | |
| " if epoch > 0 and epoch % lr_period == 0:\r\n", | |
| " trainer.set_learning_rate(trainer.learning_rate * lr_decay)\r\n", | |
| " for i, (features, labels) in enumerate(train_iter):\r\n", | |
| " timer.start()\r\n", | |
| " X_shards, y_shards = d2l.split_batch(features, labels, devices)\r\n", | |
| " output_features = [net.features(X_shard) for X_shard in X_shards]\r\n", | |
| " with autograd.record():\r\n", | |
| " outputs = [net.output_new(feature)\r\n", | |
| " for feature in output_features]\r\n", | |
| " ls = [loss(output, y_shard).sum() for output, y_shard\r\n", | |
| " in zip(outputs, y_shards)]\r\n", | |
| " for l in ls:\r\n", | |
| " l.backward()\r\n", | |
| " trainer.step(batch_size)\r\n", | |
| " metric.add(sum([float(l.sum()) for l in ls]), labels.shape[0])\r\n", | |
| " timer.stop()\r\n", | |
| " if (i + 1) % (num_batches // 5) == 0 or i == num_batches - 1:\r\n", | |
| " animator.add(epoch + (i + 1) / num_batches, \r\n", | |
| " (metric[0] / metric[1], None))\r\n", | |
| " if valid_iter is not None:\r\n", | |
| " valid_loss = evaluate_loss(valid_iter, net, devices)\r\n", | |
| " animator.add(epoch + 1, (None, valid_loss))\r\n", | |
| " if valid_iter is not None:\r\n", | |
| " print(f'train loss {metric[0] / metric[1]:.3f}, '\r\n", | |
| " f'valid loss {valid_loss:.3f}')\r\n", | |
| " else:\r\n", | |
| " print(f'train loss {metric[0] / metric[1]:.3f}')\r\n", | |
| " print(f'{metric[1] * num_epochs / timer.sum():.1f} examples/sec '\r\n", | |
| " f'on {str(devices)}')" | |
| ], | |
| "execution_count": 12, | |
| "outputs": [] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 301 | |
| }, | |
| "id": "jNUBIRkqlN9T", | |
| "outputId": "a1e635d2-3a15-4879-c6aa-3990ccc6bdab" | |
| }, | |
| "source": [ | |
| "devices, num_epochs, lr, wd = d2l.try_all_gpus(), 5, 0.01, 1e-4\r\n", | |
| "lr_period, lr_decay, net = 10, 0.1, get_net(devices)\r\n", | |
| "net.hybridize()\r\n", | |
| "train(net, train_iter, valid_iter, num_epochs, lr, wd, devices, lr_period,\r\n", | |
| " lr_decay)" | |
| ], | |
| "execution_count": 13, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "text": [ | |
| "train loss 2.265, valid loss 3.017\n", | |
| "8.1 examples/sec on [cpu(0)]\n" | |
| ], | |
| "name": "stdout" | |
| }, | |
| { | |
| "output_type": "display_data", | |
| "data": { | |
| "text/plain": [ | |
| "<Figure size 252x180 with 1 Axes>" | |
| ], | |
| "image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Created with matplotlib (https://matplotlib.org/) -->\n<svg height=\"184.121387pt\" version=\"1.1\" viewBox=\"0 0 226.24375 184.121387\" width=\"226.24375pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <defs>\n <style type=\"text/css\">\n*{stroke-linecap:butt;stroke-linejoin:round;}\n </style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 184.121387 \nL 226.24375 184.121387 \nL 226.24375 0 \nL 0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 20.5625 146.565137 \nL 215.8625 146.565137 \nL 215.8625 10.665137 \nL 20.5625 10.665137 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g id=\"matplotlib.axis_1\">\n <g id=\"xtick_1\">\n <g id=\"line2d_1\">\n <path clip-path=\"url(#pf3336fa7c2)\" d=\"M 20.5625 146.565137 \nL 20.5625 10.665137 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_2\">\n <defs>\n <path d=\"M 0 0 \nL 0 3.5 \n\" id=\"mb391d0b18b\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n </defs>\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"20.5625\" xlink:href=\"#mb391d0b18b\" y=\"146.565137\"/>\n </g>\n </g>\n <g id=\"text_1\">\n <!-- 1 -->\n <defs>\n <path d=\"M 12.40625 8.296875 \nL 28.515625 8.296875 \nL 28.515625 63.921875 \nL 10.984375 60.40625 \nL 10.984375 69.390625 \nL 28.421875 72.90625 \nL 38.28125 72.90625 \nL 38.28125 8.296875 \nL 54.390625 8.296875 \nL 54.390625 0 \nL 12.40625 0 \nz\n\" id=\"DejaVuSans-49\"/>\n </defs>\n <g transform=\"translate(17.38125 161.163574)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-49\"/>\n </g>\n </g>\n </g>\n <g id=\"xtick_2\">\n <g id=\"line2d_3\">\n <path clip-path=\"url(#pf3336fa7c2)\" d=\"M 69.3875 146.565137 \nL 69.3875 10.665137 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_4\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"69.3875\" xlink:href=\"#mb391d0b18b\" y=\"146.565137\"/>\n </g>\n </g>\n <g id=\"text_2\">\n <!-- 2 -->\n <defs>\n <path d=\"M 19.1875 8.296875 \nL 53.609375 8.296875 \nL 53.609375 0 \nL 7.328125 0 \nL 7.328125 8.296875 \nQ 12.9375 14.109375 22.625 23.890625 \nQ 32.328125 33.6875 34.8125 36.53125 \nQ 39.546875 41.84375 41.421875 45.53125 \nQ 43.3125 49.21875 43.3125 52.78125 \nQ 43.3125 58.59375 39.234375 62.25 \nQ 35.15625 65.921875 28.609375 65.921875 \nQ 23.96875 65.921875 18.8125 64.3125 \nQ 13.671875 62.703125 7.8125 59.421875 \nL 7.8125 69.390625 \nQ 13.765625 71.78125 18.9375 73 \nQ 24.125 74.21875 28.421875 74.21875 \nQ 39.75 74.21875 46.484375 68.546875 \nQ 53.21875 62.890625 53.21875 53.421875 \nQ 53.21875 48.921875 51.53125 44.890625 \nQ 49.859375 40.875 45.40625 35.40625 \nQ 44.1875 33.984375 37.640625 27.21875 \nQ 31.109375 20.453125 19.1875 8.296875 \nz\n\" id=\"DejaVuSans-50\"/>\n </defs>\n <g transform=\"translate(66.20625 161.163574)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-50\"/>\n </g>\n </g>\n </g>\n <g id=\"xtick_3\">\n <g id=\"line2d_5\">\n <path clip-path=\"url(#pf3336fa7c2)\" d=\"M 118.2125 146.565137 \nL 118.2125 10.665137 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_6\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"118.2125\" xlink:href=\"#mb391d0b18b\" y=\"146.565137\"/>\n </g>\n </g>\n <g id=\"text_3\">\n <!-- 3 -->\n <defs>\n <path d=\"M 40.578125 39.3125 \nQ 47.65625 37.796875 51.625 33 \nQ 55.609375 28.21875 55.609375 21.1875 \nQ 55.609375 10.40625 48.1875 4.484375 \nQ 40.765625 -1.421875 27.09375 -1.421875 \nQ 22.515625 -1.421875 17.65625 -0.515625 \nQ 12.796875 0.390625 7.625 2.203125 \nL 7.625 11.71875 \nQ 11.71875 9.328125 16.59375 8.109375 \nQ 21.484375 6.890625 26.8125 6.890625 \nQ 36.078125 6.890625 40.9375 10.546875 \nQ 45.796875 14.203125 45.796875 21.1875 \nQ 45.796875 27.640625 41.28125 31.265625 \nQ 36.765625 34.90625 28.71875 34.90625 \nL 20.21875 34.90625 \nL 20.21875 43.015625 \nL 29.109375 43.015625 \nQ 36.375 43.015625 40.234375 45.921875 \nQ 44.09375 48.828125 44.09375 54.296875 \nQ 44.09375 59.90625 40.109375 62.90625 \nQ 36.140625 65.921875 28.71875 65.921875 \nQ 24.65625 65.921875 20.015625 65.03125 \nQ 15.375 64.15625 9.8125 62.3125 \nL 9.8125 71.09375 \nQ 15.4375 72.65625 20.34375 73.4375 \nQ 25.25 74.21875 29.59375 74.21875 \nQ 40.828125 74.21875 47.359375 69.109375 \nQ 53.90625 64.015625 53.90625 55.328125 \nQ 53.90625 49.265625 50.4375 45.09375 \nQ 46.96875 40.921875 40.578125 39.3125 \nz\n\" id=\"DejaVuSans-51\"/>\n </defs>\n <g transform=\"translate(115.03125 161.163574)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-51\"/>\n </g>\n </g>\n </g>\n <g id=\"xtick_4\">\n <g id=\"line2d_7\">\n <path clip-path=\"url(#pf3336fa7c2)\" d=\"M 167.0375 146.565137 \nL 167.0375 10.665137 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_8\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"167.0375\" xlink:href=\"#mb391d0b18b\" y=\"146.565137\"/>\n </g>\n </g>\n <g id=\"text_4\">\n <!-- 4 -->\n <defs>\n <path d=\"M 37.796875 64.3125 \nL 12.890625 25.390625 \nL 37.796875 25.390625 \nz\nM 35.203125 72.90625 \nL 47.609375 72.90625 \nL 47.609375 25.390625 \nL 58.015625 25.390625 \nL 58.015625 17.1875 \nL 47.609375 17.1875 \nL 47.609375 0 \nL 37.796875 0 \nL 37.796875 17.1875 \nL 4.890625 17.1875 \nL 4.890625 26.703125 \nz\n\" id=\"DejaVuSans-52\"/>\n </defs>\n <g transform=\"translate(163.85625 161.163574)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-52\"/>\n </g>\n </g>\n </g>\n <g id=\"xtick_5\">\n <g id=\"line2d_9\">\n <path clip-path=\"url(#pf3336fa7c2)\" d=\"M 215.8625 146.565137 \nL 215.8625 10.665137 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_10\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"215.8625\" xlink:href=\"#mb391d0b18b\" y=\"146.565137\"/>\n </g>\n </g>\n <g id=\"text_5\">\n <!-- 5 -->\n <defs>\n <path d=\"M 10.796875 72.90625 \nL 49.515625 72.90625 \nL 49.515625 64.59375 \nL 19.828125 64.59375 \nL 19.828125 46.734375 \nQ 21.96875 47.46875 24.109375 47.828125 \nQ 26.265625 48.1875 28.421875 48.1875 \nQ 40.625 48.1875 47.75 41.5 \nQ 54.890625 34.8125 54.890625 23.390625 \nQ 54.890625 11.625 47.5625 5.09375 \nQ 40.234375 -1.421875 26.90625 -1.421875 \nQ 22.3125 -1.421875 17.546875 -0.640625 \nQ 12.796875 0.140625 7.71875 1.703125 \nL 7.71875 11.625 \nQ 12.109375 9.234375 16.796875 8.0625 \nQ 21.484375 6.890625 26.703125 6.890625 \nQ 35.15625 6.890625 40.078125 11.328125 \nQ 45.015625 15.765625 45.015625 23.390625 \nQ 45.015625 31 40.078125 35.4375 \nQ 35.15625 39.890625 26.703125 39.890625 \nQ 22.75 39.890625 18.8125 39.015625 \nQ 14.890625 38.140625 10.796875 36.28125 \nz\n\" id=\"DejaVuSans-53\"/>\n </defs>\n <g transform=\"translate(212.68125 161.163574)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-53\"/>\n </g>\n </g>\n </g>\n <g id=\"text_6\">\n <!-- epoch -->\n <defs>\n <path d=\"M 56.203125 29.59375 \nL 56.203125 25.203125 \nL 14.890625 25.203125 \nQ 15.484375 15.921875 20.484375 11.0625 \nQ 25.484375 6.203125 34.421875 6.203125 \nQ 39.59375 6.203125 44.453125 7.46875 \nQ 49.3125 8.734375 54.109375 11.28125 \nL 54.109375 2.78125 \nQ 49.265625 0.734375 44.1875 -0.34375 \nQ 39.109375 -1.421875 33.890625 -1.421875 \nQ 20.796875 -1.421875 13.15625 6.1875 \nQ 5.515625 13.8125 5.515625 26.8125 \nQ 5.515625 40.234375 12.765625 48.109375 \nQ 20.015625 56 32.328125 56 \nQ 43.359375 56 49.78125 48.890625 \nQ 56.203125 41.796875 56.203125 29.59375 \nz\nM 47.21875 32.234375 \nQ 47.125 39.59375 43.09375 43.984375 \nQ 39.0625 48.390625 32.421875 48.390625 \nQ 24.90625 48.390625 20.390625 44.140625 \nQ 15.875 39.890625 15.1875 32.171875 \nz\n\" id=\"DejaVuSans-101\"/>\n <path d=\"M 18.109375 8.203125 \nL 18.109375 -20.796875 \nL 9.078125 -20.796875 \nL 9.078125 54.6875 \nL 18.109375 54.6875 \nL 18.109375 46.390625 \nQ 20.953125 51.265625 25.265625 53.625 \nQ 29.59375 56 35.59375 56 \nQ 45.5625 56 51.78125 48.09375 \nQ 58.015625 40.1875 58.015625 27.296875 \nQ 58.015625 14.40625 51.78125 6.484375 \nQ 45.5625 -1.421875 35.59375 -1.421875 \nQ 29.59375 -1.421875 25.265625 0.953125 \nQ 20.953125 3.328125 18.109375 8.203125 \nz\nM 48.6875 27.296875 \nQ 48.6875 37.203125 44.609375 42.84375 \nQ 40.53125 48.484375 33.40625 48.484375 \nQ 26.265625 48.484375 22.1875 42.84375 \nQ 18.109375 37.203125 18.109375 27.296875 \nQ 18.109375 17.390625 22.1875 11.75 \nQ 26.265625 6.109375 33.40625 6.109375 \nQ 40.53125 6.109375 44.609375 11.75 \nQ 48.6875 17.390625 48.6875 27.296875 \nz\n\" id=\"DejaVuSans-112\"/>\n <path d=\"M 30.609375 48.390625 \nQ 23.390625 48.390625 19.1875 42.75 \nQ 14.984375 37.109375 14.984375 27.296875 \nQ 14.984375 17.484375 19.15625 11.84375 \nQ 23.34375 6.203125 30.609375 6.203125 \nQ 37.796875 6.203125 41.984375 11.859375 \nQ 46.1875 17.53125 46.1875 27.296875 \nQ 46.1875 37.015625 41.984375 42.703125 \nQ 37.796875 48.390625 30.609375 48.390625 \nz\nM 30.609375 56 \nQ 42.328125 56 49.015625 48.375 \nQ 55.71875 40.765625 55.71875 27.296875 \nQ 55.71875 13.875 49.015625 6.21875 \nQ 42.328125 -1.421875 30.609375 -1.421875 \nQ 18.84375 -1.421875 12.171875 6.21875 \nQ 5.515625 13.875 5.515625 27.296875 \nQ 5.515625 40.765625 12.171875 48.375 \nQ 18.84375 56 30.609375 56 \nz\n\" id=\"DejaVuSans-111\"/>\n <path d=\"M 48.78125 52.59375 \nL 48.78125 44.1875 \nQ 44.96875 46.296875 41.140625 47.34375 \nQ 37.3125 48.390625 33.40625 48.390625 \nQ 24.65625 48.390625 19.8125 42.84375 \nQ 14.984375 37.3125 14.984375 27.296875 \nQ 14.984375 17.28125 19.8125 11.734375 \nQ 24.65625 6.203125 33.40625 6.203125 \nQ 37.3125 6.203125 41.140625 7.25 \nQ 44.96875 8.296875 48.78125 10.40625 \nL 48.78125 2.09375 \nQ 45.015625 0.34375 40.984375 -0.53125 \nQ 36.96875 -1.421875 32.421875 -1.421875 \nQ 20.0625 -1.421875 12.78125 6.34375 \nQ 5.515625 14.109375 5.515625 27.296875 \nQ 5.515625 40.671875 12.859375 48.328125 \nQ 20.21875 56 33.015625 56 \nQ 37.15625 56 41.109375 55.140625 \nQ 45.0625 54.296875 48.78125 52.59375 \nz\n\" id=\"DejaVuSans-99\"/>\n <path d=\"M 54.890625 33.015625 \nL 54.890625 0 \nL 45.90625 0 \nL 45.90625 32.71875 \nQ 45.90625 40.484375 42.875 44.328125 \nQ 39.84375 48.1875 33.796875 48.1875 \nQ 26.515625 48.1875 22.3125 43.546875 \nQ 18.109375 38.921875 18.109375 30.90625 \nL 18.109375 0 \nL 9.078125 0 \nL 9.078125 75.984375 \nL 18.109375 75.984375 \nL 18.109375 46.1875 \nQ 21.34375 51.125 25.703125 53.5625 \nQ 30.078125 56 35.796875 56 \nQ 45.21875 56 50.046875 50.171875 \nQ 54.890625 44.34375 54.890625 33.015625 \nz\n\" id=\"DejaVuSans-104\"/>\n </defs>\n <g transform=\"translate(102.984375 174.841699)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-101\"/>\n <use x=\"61.523438\" xlink:href=\"#DejaVuSans-112\"/>\n <use x=\"125\" xlink:href=\"#DejaVuSans-111\"/>\n <use x=\"186.181641\" xlink:href=\"#DejaVuSans-99\"/>\n <use x=\"241.162109\" xlink:href=\"#DejaVuSans-104\"/>\n </g>\n </g>\n </g>\n <g id=\"matplotlib.axis_2\">\n <g id=\"ytick_1\">\n <g id=\"line2d_11\">\n <path clip-path=\"url(#pf3336fa7c2)\" d=\"M 20.5625 140.253114 \nL 215.8625 140.253114 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_12\">\n <defs>\n <path d=\"M 0 0 \nL -3.5 0 \n\" id=\"m70e8333d13\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n </defs>\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"20.5625\" xlink:href=\"#m70e8333d13\" y=\"140.253114\"/>\n </g>\n </g>\n <g id=\"text_7\">\n <!-- 2 -->\n <g transform=\"translate(7.2 144.052333)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-50\"/>\n </g>\n </g>\n </g>\n <g id=\"ytick_2\">\n <g id=\"line2d_13\">\n <path clip-path=\"url(#pf3336fa7c2)\" d=\"M 20.5625 97.168482 \nL 215.8625 97.168482 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_14\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"20.5625\" xlink:href=\"#m70e8333d13\" y=\"97.168482\"/>\n </g>\n </g>\n <g id=\"text_8\">\n <!-- 3 -->\n <g transform=\"translate(7.2 100.967701)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-51\"/>\n </g>\n </g>\n </g>\n <g id=\"ytick_3\">\n <g id=\"line2d_15\">\n <path clip-path=\"url(#pf3336fa7c2)\" d=\"M 20.5625 54.08385 \nL 215.8625 54.08385 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_16\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"20.5625\" xlink:href=\"#m70e8333d13\" y=\"54.08385\"/>\n </g>\n </g>\n <g id=\"text_9\">\n <!-- 4 -->\n <g transform=\"translate(7.2 57.883069)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-52\"/>\n </g>\n </g>\n </g>\n <g id=\"ytick_4\">\n <g id=\"line2d_17\">\n <path clip-path=\"url(#pf3336fa7c2)\" d=\"M 20.5625 10.999219 \nL 215.8625 10.999219 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_18\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"20.5625\" xlink:href=\"#m70e8333d13\" y=\"10.999219\"/>\n </g>\n </g>\n <g id=\"text_10\">\n <!-- 5 -->\n <g transform=\"translate(7.2 14.798437)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-53\"/>\n </g>\n </g>\n </g>\n </g>\n <g id=\"line2d_19\">\n <path clip-path=\"url(#pf3336fa7c2)\" d=\"M -1 35.495426 \nL 1.0325 37.802483 \nL 10.7975 46.42226 \nL 20.5625 54.597765 \nL 30.3275 128.528131 \nL 40.0925 117.462655 \nL 49.8575 116.094223 \nL 59.6225 114.275356 \nL 69.3875 114.447852 \nL 79.1525 138.317303 \nL 88.9175 133.28851 \nL 98.6825 128.734297 \nL 108.4475 128.99821 \nL 118.2125 125.579312 \nL 127.9775 134.719126 \nL 137.7425 126.567505 \nL 147.5075 127.18268 \nL 157.2725 128.175879 \nL 167.0375 125.535659 \nL 176.8025 137.130013 \nL 186.5675 136.314978 \nL 196.3325 130.745075 \nL 206.0975 129.997862 \nL 215.8625 128.815463 \n\" style=\"fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;\"/>\n </g>\n <g id=\"line2d_20\">\n <path clip-path=\"url(#pf3336fa7c2)\" d=\"M 20.5625 108.741114 \nL 69.3875 131.953738 \nL 118.2125 140.387864 \nL 167.0375 126.347742 \nL 215.8625 96.449246 \n\" style=\"fill:none;stroke:#bf00bf;stroke-dasharray:5.55,2.4;stroke-dashoffset:0;stroke-width:1.5;\"/>\n </g>\n <g id=\"patch_3\">\n <path d=\"M 20.5625 146.565137 \nL 20.5625 10.665137 \n\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n </g>\n <g id=\"patch_4\">\n <path d=\"M 215.8625 146.565137 \nL 215.8625 10.665137 \n\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n </g>\n <g id=\"patch_5\">\n <path d=\"M 20.5625 146.565137 \nL 215.8625 146.565137 \n\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n </g>\n <g id=\"patch_6\">\n <path d=\"M 20.5625 10.665137 \nL 215.8625 10.665137 \n\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n </g>\n <g id=\"legend_1\">\n <g id=\"patch_7\">\n <path d=\"M 130.417188 48.021387 \nL 208.8625 48.021387 \nQ 210.8625 48.021387 210.8625 46.021387 \nL 210.8625 17.665137 \nQ 210.8625 15.665137 208.8625 15.665137 \nL 130.417188 15.665137 \nQ 128.417188 15.665137 128.417188 17.665137 \nL 128.417188 46.021387 \nQ 128.417188 48.021387 130.417188 48.021387 \nz\n\" style=\"fill:#ffffff;opacity:0.8;stroke:#cccccc;stroke-linejoin:miter;\"/>\n </g>\n <g id=\"line2d_21\">\n <path d=\"M 132.417188 23.763574 \nL 152.417188 23.763574 \n\" style=\"fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;\"/>\n </g>\n <g id=\"line2d_22\"/>\n <g id=\"text_11\">\n <!-- train loss -->\n <defs>\n <path d=\"M 18.3125 70.21875 \nL 18.3125 54.6875 \nL 36.8125 54.6875 \nL 36.8125 47.703125 \nL 18.3125 47.703125 \nL 18.3125 18.015625 \nQ 18.3125 11.328125 20.140625 9.421875 \nQ 21.96875 7.515625 27.59375 7.515625 \nL 36.8125 7.515625 \nL 36.8125 0 \nL 27.59375 0 \nQ 17.1875 0 13.234375 3.875 \nQ 9.28125 7.765625 9.28125 18.015625 \nL 9.28125 47.703125 \nL 2.6875 47.703125 \nL 2.6875 54.6875 \nL 9.28125 54.6875 \nL 9.28125 70.21875 \nz\n\" id=\"DejaVuSans-116\"/>\n <path d=\"M 41.109375 46.296875 \nQ 39.59375 47.171875 37.8125 47.578125 \nQ 36.03125 48 33.890625 48 \nQ 26.265625 48 22.1875 43.046875 \nQ 18.109375 38.09375 18.109375 28.8125 \nL 18.109375 0 \nL 9.078125 0 \nL 9.078125 54.6875 \nL 18.109375 54.6875 \nL 18.109375 46.1875 \nQ 20.953125 51.171875 25.484375 53.578125 \nQ 30.03125 56 36.53125 56 \nQ 37.453125 56 38.578125 55.875 \nQ 39.703125 55.765625 41.0625 55.515625 \nz\n\" id=\"DejaVuSans-114\"/>\n <path d=\"M 34.28125 27.484375 \nQ 23.390625 27.484375 19.1875 25 \nQ 14.984375 22.515625 14.984375 16.5 \nQ 14.984375 11.71875 18.140625 8.90625 \nQ 21.296875 6.109375 26.703125 6.109375 \nQ 34.1875 6.109375 38.703125 11.40625 \nQ 43.21875 16.703125 43.21875 25.484375 \nL 43.21875 27.484375 \nz\nM 52.203125 31.203125 \nL 52.203125 0 \nL 43.21875 0 \nL 43.21875 8.296875 \nQ 40.140625 3.328125 35.546875 0.953125 \nQ 30.953125 -1.421875 24.3125 -1.421875 \nQ 15.921875 -1.421875 10.953125 3.296875 \nQ 6 8.015625 6 15.921875 \nQ 6 25.140625 12.171875 29.828125 \nQ 18.359375 34.515625 30.609375 34.515625 \nL 43.21875 34.515625 \nL 43.21875 35.40625 \nQ 43.21875 41.609375 39.140625 45 \nQ 35.0625 48.390625 27.6875 48.390625 \nQ 23 48.390625 18.546875 47.265625 \nQ 14.109375 46.140625 10.015625 43.890625 \nL 10.015625 52.203125 \nQ 14.9375 54.109375 19.578125 55.046875 \nQ 24.21875 56 28.609375 56 \nQ 40.484375 56 46.34375 49.84375 \nQ 52.203125 43.703125 52.203125 31.203125 \nz\n\" id=\"DejaVuSans-97\"/>\n <path d=\"M 9.421875 54.6875 \nL 18.40625 54.6875 \nL 18.40625 0 \nL 9.421875 0 \nz\nM 9.421875 75.984375 \nL 18.40625 75.984375 \nL 18.40625 64.59375 \nL 9.421875 64.59375 \nz\n\" id=\"DejaVuSans-105\"/>\n <path d=\"M 54.890625 33.015625 \nL 54.890625 0 \nL 45.90625 0 \nL 45.90625 32.71875 \nQ 45.90625 40.484375 42.875 44.328125 \nQ 39.84375 48.1875 33.796875 48.1875 \nQ 26.515625 48.1875 22.3125 43.546875 \nQ 18.109375 38.921875 18.109375 30.90625 \nL 18.109375 0 \nL 9.078125 0 \nL 9.078125 54.6875 \nL 18.109375 54.6875 \nL 18.109375 46.1875 \nQ 21.34375 51.125 25.703125 53.5625 \nQ 30.078125 56 35.796875 56 \nQ 45.21875 56 50.046875 50.171875 \nQ 54.890625 44.34375 54.890625 33.015625 \nz\n\" id=\"DejaVuSans-110\"/>\n <path id=\"DejaVuSans-32\"/>\n <path d=\"M 9.421875 75.984375 \nL 18.40625 75.984375 \nL 18.40625 0 \nL 9.421875 0 \nz\n\" id=\"DejaVuSans-108\"/>\n <path d=\"M 44.28125 53.078125 \nL 44.28125 44.578125 \nQ 40.484375 46.53125 36.375 47.5 \nQ 32.28125 48.484375 27.875 48.484375 \nQ 21.1875 48.484375 17.84375 46.4375 \nQ 14.5 44.390625 14.5 40.28125 \nQ 14.5 37.15625 16.890625 35.375 \nQ 19.28125 33.59375 26.515625 31.984375 \nL 29.59375 31.296875 \nQ 39.15625 29.25 43.1875 25.515625 \nQ 47.21875 21.78125 47.21875 15.09375 \nQ 47.21875 7.46875 41.1875 3.015625 \nQ 35.15625 -1.421875 24.609375 -1.421875 \nQ 20.21875 -1.421875 15.453125 -0.5625 \nQ 10.6875 0.296875 5.421875 2 \nL 5.421875 11.28125 \nQ 10.40625 8.6875 15.234375 7.390625 \nQ 20.0625 6.109375 24.8125 6.109375 \nQ 31.15625 6.109375 34.5625 8.28125 \nQ 37.984375 10.453125 37.984375 14.40625 \nQ 37.984375 18.0625 35.515625 20.015625 \nQ 33.0625 21.96875 24.703125 23.78125 \nL 21.578125 24.515625 \nQ 13.234375 26.265625 9.515625 29.90625 \nQ 5.8125 33.546875 5.8125 39.890625 \nQ 5.8125 47.609375 11.28125 51.796875 \nQ 16.75 56 26.8125 56 \nQ 31.78125 56 36.171875 55.265625 \nQ 40.578125 54.546875 44.28125 53.078125 \nz\n\" id=\"DejaVuSans-115\"/>\n </defs>\n <g transform=\"translate(160.417188 27.263574)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-116\"/>\n <use x=\"39.208984\" xlink:href=\"#DejaVuSans-114\"/>\n <use x=\"80.322266\" xlink:href=\"#DejaVuSans-97\"/>\n <use x=\"141.601562\" xlink:href=\"#DejaVuSans-105\"/>\n <use x=\"169.384766\" xlink:href=\"#DejaVuSans-110\"/>\n <use x=\"232.763672\" xlink:href=\"#DejaVuSans-32\"/>\n <use x=\"264.550781\" xlink:href=\"#DejaVuSans-108\"/>\n <use x=\"292.333984\" xlink:href=\"#DejaVuSans-111\"/>\n <use x=\"353.515625\" xlink:href=\"#DejaVuSans-115\"/>\n <use x=\"405.615234\" xlink:href=\"#DejaVuSans-115\"/>\n </g>\n </g>\n <g id=\"line2d_23\">\n <path d=\"M 132.417188 38.441699 \nL 152.417188 38.441699 \n\" style=\"fill:none;stroke:#bf00bf;stroke-dasharray:5.55,2.4;stroke-dashoffset:0;stroke-width:1.5;\"/>\n </g>\n <g id=\"line2d_24\"/>\n <g id=\"text_12\">\n <!-- valid loss -->\n <defs>\n <path d=\"M 2.984375 54.6875 \nL 12.5 54.6875 \nL 29.59375 8.796875 \nL 46.6875 54.6875 \nL 56.203125 54.6875 \nL 35.6875 0 \nL 23.484375 0 \nz\n\" id=\"DejaVuSans-118\"/>\n <path d=\"M 45.40625 46.390625 \nL 45.40625 75.984375 \nL 54.390625 75.984375 \nL 54.390625 0 \nL 45.40625 0 \nL 45.40625 8.203125 \nQ 42.578125 3.328125 38.25 0.953125 \nQ 33.9375 -1.421875 27.875 -1.421875 \nQ 17.96875 -1.421875 11.734375 6.484375 \nQ 5.515625 14.40625 5.515625 27.296875 \nQ 5.515625 40.1875 11.734375 48.09375 \nQ 17.96875 56 27.875 56 \nQ 33.9375 56 38.25 53.625 \nQ 42.578125 51.265625 45.40625 46.390625 \nz\nM 14.796875 27.296875 \nQ 14.796875 17.390625 18.875 11.75 \nQ 22.953125 6.109375 30.078125 6.109375 \nQ 37.203125 6.109375 41.296875 11.75 \nQ 45.40625 17.390625 45.40625 27.296875 \nQ 45.40625 37.203125 41.296875 42.84375 \nQ 37.203125 48.484375 30.078125 48.484375 \nQ 22.953125 48.484375 18.875 42.84375 \nQ 14.796875 37.203125 14.796875 27.296875 \nz\n\" id=\"DejaVuSans-100\"/>\n </defs>\n <g transform=\"translate(160.417188 41.941699)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-118\"/>\n <use x=\"59.179688\" xlink:href=\"#DejaVuSans-97\"/>\n <use x=\"120.458984\" xlink:href=\"#DejaVuSans-108\"/>\n <use x=\"148.242188\" xlink:href=\"#DejaVuSans-105\"/>\n <use x=\"176.025391\" xlink:href=\"#DejaVuSans-100\"/>\n <use x=\"239.501953\" xlink:href=\"#DejaVuSans-32\"/>\n <use x=\"271.289062\" xlink:href=\"#DejaVuSans-108\"/>\n <use x=\"299.072266\" xlink:href=\"#DejaVuSans-111\"/>\n <use x=\"360.253906\" xlink:href=\"#DejaVuSans-115\"/>\n <use x=\"412.353516\" xlink:href=\"#DejaVuSans-115\"/>\n </g>\n </g>\n </g>\n </g>\n </g>\n <defs>\n <clipPath id=\"pf3336fa7c2\">\n <rect height=\"135.9\" width=\"195.3\" x=\"20.5625\" y=\"10.665137\"/>\n </clipPath>\n </defs>\n</svg>\n" | |
| }, | |
| "metadata": { | |
| "tags": [], | |
| "needs_background": "light" | |
| } | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "colab": { | |
| "base_uri": "https://localhost:8080/", | |
| "height": 297 | |
| }, | |
| "id": "uHvFXBYClQjJ", | |
| "outputId": "b1fd6273-2497-4f11-b8f3-3ba0c96f9ad1" | |
| }, | |
| "source": [ | |
| "net = get_net(devices)\r\n", | |
| "net.hybridize()\r\n", | |
| "train(net, train_valid_iter, None, num_epochs, lr, wd, devices, lr_period,\r\n", | |
| " lr_decay)\r\n", | |
| "\r\n", | |
| "preds = []\r\n", | |
| "for data, label in test_iter:\r\n", | |
| " output_features = net.features(data.as_in_ctx(devices[0]))\r\n", | |
| " output = npx.softmax(net.output_new(output_features))\r\n", | |
| " preds.extend(output.asnumpy())\r\n", | |
| "ids = sorted(os.listdir(\r\n", | |
| " os.path.join(data_dir, 'train_valid_test', 'test', 'unknown')))\r\n", | |
| "with open('submission.csv', 'w') as f:\r\n", | |
| " f.write('id,' + ','.join(train_valid_ds.synsets) + '\\n')\r\n", | |
| " for i, output in zip(ids, preds):\r\n", | |
| " f.write(i.split('.')[0] + ',' + ','.join(\r\n", | |
| " [str(num) for num in output]) + '\\n')" | |
| ], | |
| "execution_count": 14, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "text": [ | |
| "train loss 2.439\n", | |
| "8.1 examples/sec on [cpu(0)]\n" | |
| ], | |
| "name": "stdout" | |
| }, | |
| { | |
| "output_type": "display_data", | |
| "data": { | |
| "text/plain": [ | |
| "<Figure size 252x180 with 1 Axes>" | |
| ], | |
| "image/svg+xml": "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\"?>\n<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n<!-- Created with matplotlib (https://matplotlib.org/) -->\n<svg height=\"180.65625pt\" version=\"1.1\" viewBox=\"0 0 235.784375 180.65625\" width=\"235.784375pt\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n <defs>\n <style type=\"text/css\">\n*{stroke-linecap:butt;stroke-linejoin:round;}\n </style>\n </defs>\n <g id=\"figure_1\">\n <g id=\"patch_1\">\n <path d=\"M 0 180.65625 \nL 235.784375 180.65625 \nL 235.784375 0 \nL 0 0 \nz\n\" style=\"fill:none;\"/>\n </g>\n <g id=\"axes_1\">\n <g id=\"patch_2\">\n <path d=\"M 30.103125 143.1 \nL 225.403125 143.1 \nL 225.403125 7.2 \nL 30.103125 7.2 \nz\n\" style=\"fill:#ffffff;\"/>\n </g>\n <g id=\"matplotlib.axis_1\">\n <g id=\"xtick_1\">\n <g id=\"line2d_1\">\n <path clip-path=\"url(#pdd2e991f15)\" d=\"M 30.103125 143.1 \nL 30.103125 7.2 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_2\">\n <defs>\n <path d=\"M 0 0 \nL 0 3.5 \n\" id=\"m6a1128b8f0\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n </defs>\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"30.103125\" xlink:href=\"#m6a1128b8f0\" y=\"143.1\"/>\n </g>\n </g>\n <g id=\"text_1\">\n <!-- 1 -->\n <defs>\n <path d=\"M 12.40625 8.296875 \nL 28.515625 8.296875 \nL 28.515625 63.921875 \nL 10.984375 60.40625 \nL 10.984375 69.390625 \nL 28.421875 72.90625 \nL 38.28125 72.90625 \nL 38.28125 8.296875 \nL 54.390625 8.296875 \nL 54.390625 0 \nL 12.40625 0 \nz\n\" id=\"DejaVuSans-49\"/>\n </defs>\n <g transform=\"translate(26.921875 157.698438)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-49\"/>\n </g>\n </g>\n </g>\n <g id=\"xtick_2\">\n <g id=\"line2d_3\">\n <path clip-path=\"url(#pdd2e991f15)\" d=\"M 78.928125 143.1 \nL 78.928125 7.2 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_4\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"78.928125\" xlink:href=\"#m6a1128b8f0\" y=\"143.1\"/>\n </g>\n </g>\n <g id=\"text_2\">\n <!-- 2 -->\n <defs>\n <path d=\"M 19.1875 8.296875 \nL 53.609375 8.296875 \nL 53.609375 0 \nL 7.328125 0 \nL 7.328125 8.296875 \nQ 12.9375 14.109375 22.625 23.890625 \nQ 32.328125 33.6875 34.8125 36.53125 \nQ 39.546875 41.84375 41.421875 45.53125 \nQ 43.3125 49.21875 43.3125 52.78125 \nQ 43.3125 58.59375 39.234375 62.25 \nQ 35.15625 65.921875 28.609375 65.921875 \nQ 23.96875 65.921875 18.8125 64.3125 \nQ 13.671875 62.703125 7.8125 59.421875 \nL 7.8125 69.390625 \nQ 13.765625 71.78125 18.9375 73 \nQ 24.125 74.21875 28.421875 74.21875 \nQ 39.75 74.21875 46.484375 68.546875 \nQ 53.21875 62.890625 53.21875 53.421875 \nQ 53.21875 48.921875 51.53125 44.890625 \nQ 49.859375 40.875 45.40625 35.40625 \nQ 44.1875 33.984375 37.640625 27.21875 \nQ 31.109375 20.453125 19.1875 8.296875 \nz\n\" id=\"DejaVuSans-50\"/>\n </defs>\n <g transform=\"translate(75.746875 157.698438)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-50\"/>\n </g>\n </g>\n </g>\n <g id=\"xtick_3\">\n <g id=\"line2d_5\">\n <path clip-path=\"url(#pdd2e991f15)\" d=\"M 127.753125 143.1 \nL 127.753125 7.2 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_6\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"127.753125\" xlink:href=\"#m6a1128b8f0\" y=\"143.1\"/>\n </g>\n </g>\n <g id=\"text_3\">\n <!-- 3 -->\n <defs>\n <path d=\"M 40.578125 39.3125 \nQ 47.65625 37.796875 51.625 33 \nQ 55.609375 28.21875 55.609375 21.1875 \nQ 55.609375 10.40625 48.1875 4.484375 \nQ 40.765625 -1.421875 27.09375 -1.421875 \nQ 22.515625 -1.421875 17.65625 -0.515625 \nQ 12.796875 0.390625 7.625 2.203125 \nL 7.625 11.71875 \nQ 11.71875 9.328125 16.59375 8.109375 \nQ 21.484375 6.890625 26.8125 6.890625 \nQ 36.078125 6.890625 40.9375 10.546875 \nQ 45.796875 14.203125 45.796875 21.1875 \nQ 45.796875 27.640625 41.28125 31.265625 \nQ 36.765625 34.90625 28.71875 34.90625 \nL 20.21875 34.90625 \nL 20.21875 43.015625 \nL 29.109375 43.015625 \nQ 36.375 43.015625 40.234375 45.921875 \nQ 44.09375 48.828125 44.09375 54.296875 \nQ 44.09375 59.90625 40.109375 62.90625 \nQ 36.140625 65.921875 28.71875 65.921875 \nQ 24.65625 65.921875 20.015625 65.03125 \nQ 15.375 64.15625 9.8125 62.3125 \nL 9.8125 71.09375 \nQ 15.4375 72.65625 20.34375 73.4375 \nQ 25.25 74.21875 29.59375 74.21875 \nQ 40.828125 74.21875 47.359375 69.109375 \nQ 53.90625 64.015625 53.90625 55.328125 \nQ 53.90625 49.265625 50.4375 45.09375 \nQ 46.96875 40.921875 40.578125 39.3125 \nz\n\" id=\"DejaVuSans-51\"/>\n </defs>\n <g transform=\"translate(124.571875 157.698438)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-51\"/>\n </g>\n </g>\n </g>\n <g id=\"xtick_4\">\n <g id=\"line2d_7\">\n <path clip-path=\"url(#pdd2e991f15)\" d=\"M 176.578125 143.1 \nL 176.578125 7.2 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_8\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"176.578125\" xlink:href=\"#m6a1128b8f0\" y=\"143.1\"/>\n </g>\n </g>\n <g id=\"text_4\">\n <!-- 4 -->\n <defs>\n <path d=\"M 37.796875 64.3125 \nL 12.890625 25.390625 \nL 37.796875 25.390625 \nz\nM 35.203125 72.90625 \nL 47.609375 72.90625 \nL 47.609375 25.390625 \nL 58.015625 25.390625 \nL 58.015625 17.1875 \nL 47.609375 17.1875 \nL 47.609375 0 \nL 37.796875 0 \nL 37.796875 17.1875 \nL 4.890625 17.1875 \nL 4.890625 26.703125 \nz\n\" id=\"DejaVuSans-52\"/>\n </defs>\n <g transform=\"translate(173.396875 157.698438)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-52\"/>\n </g>\n </g>\n </g>\n <g id=\"xtick_5\">\n <g id=\"line2d_9\">\n <path clip-path=\"url(#pdd2e991f15)\" d=\"M 225.403125 143.1 \nL 225.403125 7.2 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_10\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"225.403125\" xlink:href=\"#m6a1128b8f0\" y=\"143.1\"/>\n </g>\n </g>\n <g id=\"text_5\">\n <!-- 5 -->\n <defs>\n <path d=\"M 10.796875 72.90625 \nL 49.515625 72.90625 \nL 49.515625 64.59375 \nL 19.828125 64.59375 \nL 19.828125 46.734375 \nQ 21.96875 47.46875 24.109375 47.828125 \nQ 26.265625 48.1875 28.421875 48.1875 \nQ 40.625 48.1875 47.75 41.5 \nQ 54.890625 34.8125 54.890625 23.390625 \nQ 54.890625 11.625 47.5625 5.09375 \nQ 40.234375 -1.421875 26.90625 -1.421875 \nQ 22.3125 -1.421875 17.546875 -0.640625 \nQ 12.796875 0.140625 7.71875 1.703125 \nL 7.71875 11.625 \nQ 12.109375 9.234375 16.796875 8.0625 \nQ 21.484375 6.890625 26.703125 6.890625 \nQ 35.15625 6.890625 40.078125 11.328125 \nQ 45.015625 15.765625 45.015625 23.390625 \nQ 45.015625 31 40.078125 35.4375 \nQ 35.15625 39.890625 26.703125 39.890625 \nQ 22.75 39.890625 18.8125 39.015625 \nQ 14.890625 38.140625 10.796875 36.28125 \nz\n\" id=\"DejaVuSans-53\"/>\n </defs>\n <g transform=\"translate(222.221875 157.698438)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-53\"/>\n </g>\n </g>\n </g>\n <g id=\"text_6\">\n <!-- epoch -->\n <defs>\n <path d=\"M 56.203125 29.59375 \nL 56.203125 25.203125 \nL 14.890625 25.203125 \nQ 15.484375 15.921875 20.484375 11.0625 \nQ 25.484375 6.203125 34.421875 6.203125 \nQ 39.59375 6.203125 44.453125 7.46875 \nQ 49.3125 8.734375 54.109375 11.28125 \nL 54.109375 2.78125 \nQ 49.265625 0.734375 44.1875 -0.34375 \nQ 39.109375 -1.421875 33.890625 -1.421875 \nQ 20.796875 -1.421875 13.15625 6.1875 \nQ 5.515625 13.8125 5.515625 26.8125 \nQ 5.515625 40.234375 12.765625 48.109375 \nQ 20.015625 56 32.328125 56 \nQ 43.359375 56 49.78125 48.890625 \nQ 56.203125 41.796875 56.203125 29.59375 \nz\nM 47.21875 32.234375 \nQ 47.125 39.59375 43.09375 43.984375 \nQ 39.0625 48.390625 32.421875 48.390625 \nQ 24.90625 48.390625 20.390625 44.140625 \nQ 15.875 39.890625 15.1875 32.171875 \nz\n\" id=\"DejaVuSans-101\"/>\n <path d=\"M 18.109375 8.203125 \nL 18.109375 -20.796875 \nL 9.078125 -20.796875 \nL 9.078125 54.6875 \nL 18.109375 54.6875 \nL 18.109375 46.390625 \nQ 20.953125 51.265625 25.265625 53.625 \nQ 29.59375 56 35.59375 56 \nQ 45.5625 56 51.78125 48.09375 \nQ 58.015625 40.1875 58.015625 27.296875 \nQ 58.015625 14.40625 51.78125 6.484375 \nQ 45.5625 -1.421875 35.59375 -1.421875 \nQ 29.59375 -1.421875 25.265625 0.953125 \nQ 20.953125 3.328125 18.109375 8.203125 \nz\nM 48.6875 27.296875 \nQ 48.6875 37.203125 44.609375 42.84375 \nQ 40.53125 48.484375 33.40625 48.484375 \nQ 26.265625 48.484375 22.1875 42.84375 \nQ 18.109375 37.203125 18.109375 27.296875 \nQ 18.109375 17.390625 22.1875 11.75 \nQ 26.265625 6.109375 33.40625 6.109375 \nQ 40.53125 6.109375 44.609375 11.75 \nQ 48.6875 17.390625 48.6875 27.296875 \nz\n\" id=\"DejaVuSans-112\"/>\n <path d=\"M 30.609375 48.390625 \nQ 23.390625 48.390625 19.1875 42.75 \nQ 14.984375 37.109375 14.984375 27.296875 \nQ 14.984375 17.484375 19.15625 11.84375 \nQ 23.34375 6.203125 30.609375 6.203125 \nQ 37.796875 6.203125 41.984375 11.859375 \nQ 46.1875 17.53125 46.1875 27.296875 \nQ 46.1875 37.015625 41.984375 42.703125 \nQ 37.796875 48.390625 30.609375 48.390625 \nz\nM 30.609375 56 \nQ 42.328125 56 49.015625 48.375 \nQ 55.71875 40.765625 55.71875 27.296875 \nQ 55.71875 13.875 49.015625 6.21875 \nQ 42.328125 -1.421875 30.609375 -1.421875 \nQ 18.84375 -1.421875 12.171875 6.21875 \nQ 5.515625 13.875 5.515625 27.296875 \nQ 5.515625 40.765625 12.171875 48.375 \nQ 18.84375 56 30.609375 56 \nz\n\" id=\"DejaVuSans-111\"/>\n <path d=\"M 48.78125 52.59375 \nL 48.78125 44.1875 \nQ 44.96875 46.296875 41.140625 47.34375 \nQ 37.3125 48.390625 33.40625 48.390625 \nQ 24.65625 48.390625 19.8125 42.84375 \nQ 14.984375 37.3125 14.984375 27.296875 \nQ 14.984375 17.28125 19.8125 11.734375 \nQ 24.65625 6.203125 33.40625 6.203125 \nQ 37.3125 6.203125 41.140625 7.25 \nQ 44.96875 8.296875 48.78125 10.40625 \nL 48.78125 2.09375 \nQ 45.015625 0.34375 40.984375 -0.53125 \nQ 36.96875 -1.421875 32.421875 -1.421875 \nQ 20.0625 -1.421875 12.78125 6.34375 \nQ 5.515625 14.109375 5.515625 27.296875 \nQ 5.515625 40.671875 12.859375 48.328125 \nQ 20.21875 56 33.015625 56 \nQ 37.15625 56 41.109375 55.140625 \nQ 45.0625 54.296875 48.78125 52.59375 \nz\n\" id=\"DejaVuSans-99\"/>\n <path d=\"M 54.890625 33.015625 \nL 54.890625 0 \nL 45.90625 0 \nL 45.90625 32.71875 \nQ 45.90625 40.484375 42.875 44.328125 \nQ 39.84375 48.1875 33.796875 48.1875 \nQ 26.515625 48.1875 22.3125 43.546875 \nQ 18.109375 38.921875 18.109375 30.90625 \nL 18.109375 0 \nL 9.078125 0 \nL 9.078125 75.984375 \nL 18.109375 75.984375 \nL 18.109375 46.1875 \nQ 21.34375 51.125 25.703125 53.5625 \nQ 30.078125 56 35.796875 56 \nQ 45.21875 56 50.046875 50.171875 \nQ 54.890625 44.34375 54.890625 33.015625 \nz\n\" id=\"DejaVuSans-104\"/>\n </defs>\n <g transform=\"translate(112.525 171.376563)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-101\"/>\n <use x=\"61.523438\" xlink:href=\"#DejaVuSans-112\"/>\n <use x=\"125\" xlink:href=\"#DejaVuSans-111\"/>\n <use x=\"186.181641\" xlink:href=\"#DejaVuSans-99\"/>\n <use x=\"241.162109\" xlink:href=\"#DejaVuSans-104\"/>\n </g>\n </g>\n </g>\n <g id=\"matplotlib.axis_2\">\n <g id=\"ytick_1\">\n <g id=\"line2d_11\">\n <path clip-path=\"url(#pdd2e991f15)\" d=\"M 30.103125 127.97247 \nL 225.403125 127.97247 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_12\">\n <defs>\n <path d=\"M 0 0 \nL -3.5 0 \n\" id=\"m9ea1c5b806\" style=\"stroke:#000000;stroke-width:0.8;\"/>\n </defs>\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"30.103125\" xlink:href=\"#m9ea1c5b806\" y=\"127.97247\"/>\n </g>\n </g>\n <g id=\"text_7\">\n <!-- 2.5 -->\n <defs>\n <path d=\"M 10.6875 12.40625 \nL 21 12.40625 \nL 21 0 \nL 10.6875 0 \nz\n\" id=\"DejaVuSans-46\"/>\n </defs>\n <g transform=\"translate(7.2 131.771689)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-50\"/>\n <use x=\"63.623047\" xlink:href=\"#DejaVuSans-46\"/>\n <use x=\"95.410156\" xlink:href=\"#DejaVuSans-53\"/>\n </g>\n </g>\n </g>\n <g id=\"ytick_2\">\n <g id=\"line2d_13\">\n <path clip-path=\"url(#pdd2e991f15)\" d=\"M 30.103125 103.549103 \nL 225.403125 103.549103 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_14\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"30.103125\" xlink:href=\"#m9ea1c5b806\" y=\"103.549103\"/>\n </g>\n </g>\n <g id=\"text_8\">\n <!-- 3.0 -->\n <defs>\n <path d=\"M 31.78125 66.40625 \nQ 24.171875 66.40625 20.328125 58.90625 \nQ 16.5 51.421875 16.5 36.375 \nQ 16.5 21.390625 20.328125 13.890625 \nQ 24.171875 6.390625 31.78125 6.390625 \nQ 39.453125 6.390625 43.28125 13.890625 \nQ 47.125 21.390625 47.125 36.375 \nQ 47.125 51.421875 43.28125 58.90625 \nQ 39.453125 66.40625 31.78125 66.40625 \nz\nM 31.78125 74.21875 \nQ 44.046875 74.21875 50.515625 64.515625 \nQ 56.984375 54.828125 56.984375 36.375 \nQ 56.984375 17.96875 50.515625 8.265625 \nQ 44.046875 -1.421875 31.78125 -1.421875 \nQ 19.53125 -1.421875 13.0625 8.265625 \nQ 6.59375 17.96875 6.59375 36.375 \nQ 6.59375 54.828125 13.0625 64.515625 \nQ 19.53125 74.21875 31.78125 74.21875 \nz\n\" id=\"DejaVuSans-48\"/>\n </defs>\n <g transform=\"translate(7.2 107.348322)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-51\"/>\n <use x=\"63.623047\" xlink:href=\"#DejaVuSans-46\"/>\n <use x=\"95.410156\" xlink:href=\"#DejaVuSans-48\"/>\n </g>\n </g>\n </g>\n <g id=\"ytick_3\">\n <g id=\"line2d_15\">\n <path clip-path=\"url(#pdd2e991f15)\" d=\"M 30.103125 79.125735 \nL 225.403125 79.125735 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_16\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"30.103125\" xlink:href=\"#m9ea1c5b806\" y=\"79.125735\"/>\n </g>\n </g>\n <g id=\"text_9\">\n <!-- 3.5 -->\n <g transform=\"translate(7.2 82.924954)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-51\"/>\n <use x=\"63.623047\" xlink:href=\"#DejaVuSans-46\"/>\n <use x=\"95.410156\" xlink:href=\"#DejaVuSans-53\"/>\n </g>\n </g>\n </g>\n <g id=\"ytick_4\">\n <g id=\"line2d_17\">\n <path clip-path=\"url(#pdd2e991f15)\" d=\"M 30.103125 54.702368 \nL 225.403125 54.702368 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_18\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"30.103125\" xlink:href=\"#m9ea1c5b806\" y=\"54.702368\"/>\n </g>\n </g>\n <g id=\"text_10\">\n <!-- 4.0 -->\n <g transform=\"translate(7.2 58.501587)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-52\"/>\n <use x=\"63.623047\" xlink:href=\"#DejaVuSans-46\"/>\n <use x=\"95.410156\" xlink:href=\"#DejaVuSans-48\"/>\n </g>\n </g>\n </g>\n <g id=\"ytick_5\">\n <g id=\"line2d_19\">\n <path clip-path=\"url(#pdd2e991f15)\" d=\"M 30.103125 30.279001 \nL 225.403125 30.279001 \n\" style=\"fill:none;stroke:#b0b0b0;stroke-linecap:square;stroke-width:0.8;\"/>\n </g>\n <g id=\"line2d_20\">\n <g>\n <use style=\"stroke:#000000;stroke-width:0.8;\" x=\"30.103125\" xlink:href=\"#m9ea1c5b806\" y=\"30.279001\"/>\n </g>\n </g>\n <g id=\"text_11\">\n <!-- 4.5 -->\n <g transform=\"translate(7.2 34.078219)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-52\"/>\n <use x=\"63.623047\" xlink:href=\"#DejaVuSans-46\"/>\n <use x=\"95.410156\" xlink:href=\"#DejaVuSans-53\"/>\n </g>\n </g>\n </g>\n </g>\n <g id=\"line2d_21\">\n <path clip-path=\"url(#pdd2e991f15)\" d=\"M -1 24.644507 \nL 0.808125 27.20488 \nL 10.573125 36.817004 \nL 20.338125 48.501859 \nL 30.103125 56.731617 \nL 39.868125 118.791405 \nL 49.633125 114.900257 \nL 59.398125 113.470452 \nL 69.163125 110.122233 \nL 78.928125 110.996554 \nL 88.693125 133.282988 \nL 98.458125 126.306374 \nL 108.223125 123.163929 \nL 117.988125 124.284545 \nL 127.753125 124.018583 \nL 137.518125 136.922727 \nL 147.283125 134.23068 \nL 157.048125 130.460427 \nL 166.813125 130.869286 \nL 176.578125 128.821976 \nL 186.343125 117.269278 \nL 196.108125 128.576796 \nL 205.873125 128.186736 \nL 215.638125 128.799093 \nL 225.403125 130.934685 \n\" style=\"fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;\"/>\n </g>\n <g id=\"line2d_22\"/>\n <g id=\"patch_3\">\n <path d=\"M 30.103125 143.1 \nL 30.103125 7.2 \n\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n </g>\n <g id=\"patch_4\">\n <path d=\"M 225.403125 143.1 \nL 225.403125 7.2 \n\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n </g>\n <g id=\"patch_5\">\n <path d=\"M 30.103125 143.1 \nL 225.403125 143.1 \n\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n </g>\n <g id=\"patch_6\">\n <path d=\"M 30.103125 7.2 \nL 225.403125 7.2 \n\" style=\"fill:none;stroke:#000000;stroke-linecap:square;stroke-linejoin:miter;stroke-width:0.8;\"/>\n </g>\n <g id=\"legend_1\">\n <g id=\"patch_7\">\n <path d=\"M 139.957813 44.55625 \nL 218.403125 44.55625 \nQ 220.403125 44.55625 220.403125 42.55625 \nL 220.403125 14.2 \nQ 220.403125 12.2 218.403125 12.2 \nL 139.957813 12.2 \nQ 137.957813 12.2 137.957813 14.2 \nL 137.957813 42.55625 \nQ 137.957813 44.55625 139.957813 44.55625 \nz\n\" style=\"fill:#ffffff;opacity:0.8;stroke:#cccccc;stroke-linejoin:miter;\"/>\n </g>\n <g id=\"line2d_23\">\n <path d=\"M 141.957813 20.298437 \nL 161.957813 20.298437 \n\" style=\"fill:none;stroke:#1f77b4;stroke-linecap:square;stroke-width:1.5;\"/>\n </g>\n <g id=\"line2d_24\"/>\n <g id=\"text_12\">\n <!-- train loss -->\n <defs>\n <path d=\"M 18.3125 70.21875 \nL 18.3125 54.6875 \nL 36.8125 54.6875 \nL 36.8125 47.703125 \nL 18.3125 47.703125 \nL 18.3125 18.015625 \nQ 18.3125 11.328125 20.140625 9.421875 \nQ 21.96875 7.515625 27.59375 7.515625 \nL 36.8125 7.515625 \nL 36.8125 0 \nL 27.59375 0 \nQ 17.1875 0 13.234375 3.875 \nQ 9.28125 7.765625 9.28125 18.015625 \nL 9.28125 47.703125 \nL 2.6875 47.703125 \nL 2.6875 54.6875 \nL 9.28125 54.6875 \nL 9.28125 70.21875 \nz\n\" id=\"DejaVuSans-116\"/>\n <path d=\"M 41.109375 46.296875 \nQ 39.59375 47.171875 37.8125 47.578125 \nQ 36.03125 48 33.890625 48 \nQ 26.265625 48 22.1875 43.046875 \nQ 18.109375 38.09375 18.109375 28.8125 \nL 18.109375 0 \nL 9.078125 0 \nL 9.078125 54.6875 \nL 18.109375 54.6875 \nL 18.109375 46.1875 \nQ 20.953125 51.171875 25.484375 53.578125 \nQ 30.03125 56 36.53125 56 \nQ 37.453125 56 38.578125 55.875 \nQ 39.703125 55.765625 41.0625 55.515625 \nz\n\" id=\"DejaVuSans-114\"/>\n <path d=\"M 34.28125 27.484375 \nQ 23.390625 27.484375 19.1875 25 \nQ 14.984375 22.515625 14.984375 16.5 \nQ 14.984375 11.71875 18.140625 8.90625 \nQ 21.296875 6.109375 26.703125 6.109375 \nQ 34.1875 6.109375 38.703125 11.40625 \nQ 43.21875 16.703125 43.21875 25.484375 \nL 43.21875 27.484375 \nz\nM 52.203125 31.203125 \nL 52.203125 0 \nL 43.21875 0 \nL 43.21875 8.296875 \nQ 40.140625 3.328125 35.546875 0.953125 \nQ 30.953125 -1.421875 24.3125 -1.421875 \nQ 15.921875 -1.421875 10.953125 3.296875 \nQ 6 8.015625 6 15.921875 \nQ 6 25.140625 12.171875 29.828125 \nQ 18.359375 34.515625 30.609375 34.515625 \nL 43.21875 34.515625 \nL 43.21875 35.40625 \nQ 43.21875 41.609375 39.140625 45 \nQ 35.0625 48.390625 27.6875 48.390625 \nQ 23 48.390625 18.546875 47.265625 \nQ 14.109375 46.140625 10.015625 43.890625 \nL 10.015625 52.203125 \nQ 14.9375 54.109375 19.578125 55.046875 \nQ 24.21875 56 28.609375 56 \nQ 40.484375 56 46.34375 49.84375 \nQ 52.203125 43.703125 52.203125 31.203125 \nz\n\" id=\"DejaVuSans-97\"/>\n <path d=\"M 9.421875 54.6875 \nL 18.40625 54.6875 \nL 18.40625 0 \nL 9.421875 0 \nz\nM 9.421875 75.984375 \nL 18.40625 75.984375 \nL 18.40625 64.59375 \nL 9.421875 64.59375 \nz\n\" id=\"DejaVuSans-105\"/>\n <path d=\"M 54.890625 33.015625 \nL 54.890625 0 \nL 45.90625 0 \nL 45.90625 32.71875 \nQ 45.90625 40.484375 42.875 44.328125 \nQ 39.84375 48.1875 33.796875 48.1875 \nQ 26.515625 48.1875 22.3125 43.546875 \nQ 18.109375 38.921875 18.109375 30.90625 \nL 18.109375 0 \nL 9.078125 0 \nL 9.078125 54.6875 \nL 18.109375 54.6875 \nL 18.109375 46.1875 \nQ 21.34375 51.125 25.703125 53.5625 \nQ 30.078125 56 35.796875 56 \nQ 45.21875 56 50.046875 50.171875 \nQ 54.890625 44.34375 54.890625 33.015625 \nz\n\" id=\"DejaVuSans-110\"/>\n <path id=\"DejaVuSans-32\"/>\n <path d=\"M 9.421875 75.984375 \nL 18.40625 75.984375 \nL 18.40625 0 \nL 9.421875 0 \nz\n\" id=\"DejaVuSans-108\"/>\n <path d=\"M 44.28125 53.078125 \nL 44.28125 44.578125 \nQ 40.484375 46.53125 36.375 47.5 \nQ 32.28125 48.484375 27.875 48.484375 \nQ 21.1875 48.484375 17.84375 46.4375 \nQ 14.5 44.390625 14.5 40.28125 \nQ 14.5 37.15625 16.890625 35.375 \nQ 19.28125 33.59375 26.515625 31.984375 \nL 29.59375 31.296875 \nQ 39.15625 29.25 43.1875 25.515625 \nQ 47.21875 21.78125 47.21875 15.09375 \nQ 47.21875 7.46875 41.1875 3.015625 \nQ 35.15625 -1.421875 24.609375 -1.421875 \nQ 20.21875 -1.421875 15.453125 -0.5625 \nQ 10.6875 0.296875 5.421875 2 \nL 5.421875 11.28125 \nQ 10.40625 8.6875 15.234375 7.390625 \nQ 20.0625 6.109375 24.8125 6.109375 \nQ 31.15625 6.109375 34.5625 8.28125 \nQ 37.984375 10.453125 37.984375 14.40625 \nQ 37.984375 18.0625 35.515625 20.015625 \nQ 33.0625 21.96875 24.703125 23.78125 \nL 21.578125 24.515625 \nQ 13.234375 26.265625 9.515625 29.90625 \nQ 5.8125 33.546875 5.8125 39.890625 \nQ 5.8125 47.609375 11.28125 51.796875 \nQ 16.75 56 26.8125 56 \nQ 31.78125 56 36.171875 55.265625 \nQ 40.578125 54.546875 44.28125 53.078125 \nz\n\" id=\"DejaVuSans-115\"/>\n </defs>\n <g transform=\"translate(169.957813 23.798437)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-116\"/>\n <use x=\"39.208984\" xlink:href=\"#DejaVuSans-114\"/>\n <use x=\"80.322266\" xlink:href=\"#DejaVuSans-97\"/>\n <use x=\"141.601562\" xlink:href=\"#DejaVuSans-105\"/>\n <use x=\"169.384766\" xlink:href=\"#DejaVuSans-110\"/>\n <use x=\"232.763672\" xlink:href=\"#DejaVuSans-32\"/>\n <use x=\"264.550781\" xlink:href=\"#DejaVuSans-108\"/>\n <use x=\"292.333984\" xlink:href=\"#DejaVuSans-111\"/>\n <use x=\"353.515625\" xlink:href=\"#DejaVuSans-115\"/>\n <use x=\"405.615234\" xlink:href=\"#DejaVuSans-115\"/>\n </g>\n </g>\n <g id=\"line2d_25\">\n <path d=\"M 141.957813 34.976562 \nL 161.957813 34.976562 \n\" style=\"fill:none;stroke:#bf00bf;stroke-dasharray:5.55,2.4;stroke-dashoffset:0;stroke-width:1.5;\"/>\n </g>\n <g id=\"line2d_26\"/>\n <g id=\"text_13\">\n <!-- valid loss -->\n <defs>\n <path d=\"M 2.984375 54.6875 \nL 12.5 54.6875 \nL 29.59375 8.796875 \nL 46.6875 54.6875 \nL 56.203125 54.6875 \nL 35.6875 0 \nL 23.484375 0 \nz\n\" id=\"DejaVuSans-118\"/>\n <path d=\"M 45.40625 46.390625 \nL 45.40625 75.984375 \nL 54.390625 75.984375 \nL 54.390625 0 \nL 45.40625 0 \nL 45.40625 8.203125 \nQ 42.578125 3.328125 38.25 0.953125 \nQ 33.9375 -1.421875 27.875 -1.421875 \nQ 17.96875 -1.421875 11.734375 6.484375 \nQ 5.515625 14.40625 5.515625 27.296875 \nQ 5.515625 40.1875 11.734375 48.09375 \nQ 17.96875 56 27.875 56 \nQ 33.9375 56 38.25 53.625 \nQ 42.578125 51.265625 45.40625 46.390625 \nz\nM 14.796875 27.296875 \nQ 14.796875 17.390625 18.875 11.75 \nQ 22.953125 6.109375 30.078125 6.109375 \nQ 37.203125 6.109375 41.296875 11.75 \nQ 45.40625 17.390625 45.40625 27.296875 \nQ 45.40625 37.203125 41.296875 42.84375 \nQ 37.203125 48.484375 30.078125 48.484375 \nQ 22.953125 48.484375 18.875 42.84375 \nQ 14.796875 37.203125 14.796875 27.296875 \nz\n\" id=\"DejaVuSans-100\"/>\n </defs>\n <g transform=\"translate(169.957813 38.476562)scale(0.1 -0.1)\">\n <use xlink:href=\"#DejaVuSans-118\"/>\n <use x=\"59.179688\" xlink:href=\"#DejaVuSans-97\"/>\n <use x=\"120.458984\" xlink:href=\"#DejaVuSans-108\"/>\n <use x=\"148.242188\" xlink:href=\"#DejaVuSans-105\"/>\n <use x=\"176.025391\" xlink:href=\"#DejaVuSans-100\"/>\n <use x=\"239.501953\" xlink:href=\"#DejaVuSans-32\"/>\n <use x=\"271.289062\" xlink:href=\"#DejaVuSans-108\"/>\n <use x=\"299.072266\" xlink:href=\"#DejaVuSans-111\"/>\n <use x=\"360.253906\" xlink:href=\"#DejaVuSans-115\"/>\n <use x=\"412.353516\" xlink:href=\"#DejaVuSans-115\"/>\n </g>\n </g>\n </g>\n </g>\n </g>\n <defs>\n <clipPath id=\"pdd2e991f15\">\n <rect height=\"135.9\" width=\"195.3\" x=\"30.103125\" y=\"7.2\"/>\n </clipPath>\n </defs>\n</svg>\n" | |
| }, | |
| "metadata": { | |
| "tags": [], | |
| "needs_background": "light" | |
| } | |
| } | |
| ] | |
| }, | |
| { | |
| "cell_type": "code", | |
| "metadata": { | |
| "id": "hbU98ZoalTmA" | |
| }, | |
| "source": [ | |
| "" | |
| ], | |
| "execution_count": 14, | |
| "outputs": [] | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment