diff options
author | aktersnurra <gustaf.rydholm@gmail.com> | 2020-09-09 23:31:31 +0200 |
---|---|---|
committer | aktersnurra <gustaf.rydholm@gmail.com> | 2020-09-09 23:31:31 +0200 |
commit | 2b63fd952bdc9c7c72edd501cbcdbf3231e98f00 (patch) | |
tree | 1c0e0898cb8b66faff9e5d410aa1f82d13542f68 /src/notebooks/01-look-at-emnist.ipynb | |
parent | e1b504bca41a9793ed7e88ef14f2e2cbd85724f2 (diff) |
Created an abstract Dataset class for common methods.
Diffstat (limited to 'src/notebooks/01-look-at-emnist.ipynb')
-rw-r--r-- | src/notebooks/01-look-at-emnist.ipynb | 134 |
1 files changed, 107 insertions, 27 deletions
diff --git a/src/notebooks/01-look-at-emnist.ipynb b/src/notebooks/01-look-at-emnist.ipynb index 93083a5..564d14e 100644 --- a/src/notebooks/01-look-at-emnist.ipynb +++ b/src/notebooks/01-look-at-emnist.ipynb @@ -2,9 +2,18 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 18, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The autoreload extension is already loaded. To reload it, use:\n", + " %reload_ext autoreload\n" + ] + } + ], "source": [ "%load_ext autoreload\n", "%autoreload 2\n", @@ -22,7 +31,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -31,7 +40,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 35, "metadata": {}, "outputs": [], "source": [ @@ -40,7 +49,16 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 36, + "metadata": {}, + "outputs": [], + "source": [ + "dataset.load_or_generate_data()" + ] + }, + { + "cell_type": "code", + "execution_count": 37, "metadata": {}, "outputs": [], "source": [ @@ -49,7 +67,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 38, "metadata": {}, "outputs": [], "source": [ @@ -58,7 +76,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 39, "metadata": {}, "outputs": [ { @@ -67,7 +85,7 @@ "55898" ] }, - "execution_count": 10, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -78,7 +96,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 40, "metadata": {}, "outputs": [], "source": [ @@ -87,7 +105,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 41, "metadata": {}, "outputs": [ { @@ -96,7 +114,7 @@ "3494" ] }, - "execution_count": 19, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } @@ -107,19 +125,74 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 42, "metadata": {}, "outputs": [ { - "ename": "ValueError", - "evalue": "only one element tensors can be converted to Python scalars", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m<ipython-input-14-69c3b5027f10>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0md1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdataset\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitem\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[0;31mValueError\u001b[0m: only one element tensors can be converted to Python scalars" - ] + "data": { + "text/plain": [ + "tensor([[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n", + " 0, 0, 0, 0, 4, 4, 4, 4, 4, 2, 0, 0, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n", + " 0, 2, 4, 9, 32, 37, 37, 37, 32, 20, 1, 0, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n", + " 3, 65, 109, 140, 204, 215, 217, 217, 201, 154, 22, 0, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3,\n", + " 12, 122, 190, 222, 245, 249, 250, 250, 242, 206, 46, 0, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 8, 79,\n", + " 127, 222, 247, 253, 235, 228, 249, 254, 254, 245, 114, 4, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 35, 91, 219,\n", + " 244, 252, 247, 207, 100, 84, 223, 251, 254, 250, 127, 4, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 91, 163, 246,\n", + " 252, 244, 220, 127, 39, 48, 218, 250, 255, 250, 127, 4, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 0, 0, 5, 20, 95, 219, 246, 246,\n", + " 221, 127, 79, 10, 5, 37, 217, 250, 254, 249, 125, 4, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 0, 0, 20, 67, 175, 246, 252, 219,\n", + " 164, 47, 22, 1, 5, 39, 218, 250, 254, 245, 114, 4, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 1, 9, 95, 175, 250, 246, 219, 91,\n", + " 35, 1, 0, 0, 22, 84, 234, 252, 250, 220, 50, 0, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 9, 35, 164, 221, 252, 219, 163, 35,\n", + " 9, 0, 0, 0, 46, 127, 246, 254, 245, 204, 34, 0, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 7, 91, 163, 246, 252, 219, 91, 35, 1,\n", + " 0, 0, 0, 10, 128, 209, 254, 254, 220, 139, 9, 0, 0, 0],\n", + " [ 0, 0, 0, 0, 3, 22, 159, 219, 252, 247, 164, 35, 9, 0,\n", + " 0, 0, 1, 36, 175, 233, 254, 254, 204, 115, 4, 0, 0, 0],\n", + " [ 0, 0, 0, 1, 36, 95, 232, 251, 232, 195, 47, 1, 0, 0,\n", + " 0, 9, 35, 163, 246, 253, 249, 232, 122, 45, 0, 0, 0, 0],\n", + " [ 0, 0, 0, 7, 91, 164, 247, 251, 187, 127, 20, 0, 0, 0,\n", + " 1, 35, 91, 219, 253, 254, 234, 187, 67, 20, 0, 0, 0, 0],\n", + " [ 0, 0, 0, 46, 207, 244, 247, 220, 80, 24, 1, 3, 8, 34,\n", + " 52, 164, 219, 253, 249, 234, 155, 79, 4, 0, 0, 0, 0, 0],\n", + " [ 0, 0, 2, 81, 232, 251, 235, 179, 39, 12, 5, 22, 46, 115,\n", + " 139, 221, 246, 254, 234, 188, 79, 32, 0, 0, 0, 0, 0, 0],\n", + " [ 0, 0, 3, 112, 244, 254, 236, 193, 130, 127, 129, 173, 209, 245,\n", + " 250, 254, 253, 232, 154, 79, 4, 0, 0, 0, 0, 0, 0, 0],\n", + " [ 0, 0, 0, 46, 206, 242, 249, 248, 249, 250, 250, 250, 250, 250,\n", + " 250, 243, 219, 95, 22, 7, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [ 0, 0, 0, 22, 154, 201, 217, 222, 245, 249, 249, 233, 222, 217,\n", + " 217, 202, 158, 36, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [ 0, 0, 0, 1, 20, 32, 39, 51, 114, 125, 125, 82, 51, 37,\n", + " 37, 32, 20, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [ 0, 0, 0, 0, 2, 4, 5, 9, 32, 37, 37, 21, 9, 4,\n", + " 4, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],\n", + " [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n", + " 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]],\n", + " dtype=torch.uint8)" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ @@ -128,7 +201,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 43, "metadata": {}, "outputs": [ { @@ -137,7 +210,7 @@ "torch.Tensor" ] }, - "execution_count": 4, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } @@ -148,7 +221,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 44, "metadata": {}, "outputs": [ { @@ -169,7 +242,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 45, "metadata": {}, "outputs": [], "source": [ @@ -187,7 +260,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 46, "metadata": {}, "outputs": [ { @@ -207,7 +280,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 47, "metadata": {}, "outputs": [ { @@ -238,6 +311,13 @@ "metadata": {}, "outputs": [], "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { |