{ "metadata": { "kernelspec": { "language": "python", "display_name": "Python 3", "name": "python3" }, "language_info": { "name": "python", "version": "3.11.13", "mimetype": "text/x-python", "codemirror_mode": { "name": "ipython", "version": 3 }, "pygments_lexer": "ipython3", "nbconvert_exporter": "python", "file_extension": ".py" }, "kaggle": { "accelerator": "none", "dataSources": [ { "sourceId": 10705, "sourceType": "datasetVersion", "datasetId": 7160 } ], "dockerImageVersionId": 31089, "isInternetEnabled": false, "language": "python", "sourceType": "notebook", "isGpuEnabled": false }, "colab": { "provenance": [] } }, "nbformat_minor": 0, "nbformat": 4, "cells": [ { "cell_type": "code", "source": [ "# This Python 3 environment comes with many helpful analytics libraries installed\n", "# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n", "# For example, here's several helpful packages to load\n", "\n", "import numpy as np # linear algebra\n", "import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n", "\n", "# Input data files are available in the read-only \"../input/\" directory\n", "# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n", "\n", "import os\n", "for dirname, _, filenames in os.walk('/kaggle/input'):\n", " for filename in filenames:\n", " print(os.path.join(dirname, filename))\n", "\n", "# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\"\n", "# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session\n", "\n", "import kagglehub\n", "crawford_emnist_path = kagglehub.dataset_download('crawford/emnist')" ], "metadata": { "id": "txyCPT09KCiA" }, "execution_count": null, "outputs": [] }, { "cell_type": "code", "source": [ "# This Python 3 environment comes with many helpful analytics libraries installed\n", "# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n", "# For example, here's several helpful packages to load\n", "\n", "import numpy as np # linear algebra\n", "import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n", "\n", "# Input data files are available in the read-only \"../input/\" directory\n", "# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n", "\n", "import os\n", "for dirname, _, filenames in os.walk('/kaggle/input'):\n", " for filename in filenames:\n", " print(os.path.join(dirname, filename))\n", "\n", "# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\"\n", "# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session" ], "metadata": { "_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5", "_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", "trusted": true, "execution": { "iopub.status.busy": "2025-08-03T20:11:05.927699Z", "iopub.execute_input": "2025-08-03T20:11:05.928096Z", "iopub.status.idle": "2025-08-03T20:11:05.969546Z", "shell.execute_reply.started": "2025-08-03T20:11:05.928068Z", "shell.execute_reply": "2025-08-03T20:11:05.968625Z" }, "collapsed": true, "jupyter": { "outputs_hidden": true }, "colab": { "base_uri": "https://localhost:8080/" }, "id": "IE6KnyyiqzVu", "outputId": "bb6a5dc1-6fb5-4daa-f1df-1166c1ea6d38" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "/kaggle/input/emnist/emnist-letters-mapping.txt\n", "/kaggle/input/emnist/emnist-letters-test.csv\n", "/kaggle/input/emnist/emnist-mnist-mapping.txt\n", "/kaggle/input/emnist/emnist-digits-train.csv\n", "/kaggle/input/emnist/emnist-bymerge-mapping.txt\n", "/kaggle/input/emnist/emnist-balanced-train.csv\n", "/kaggle/input/emnist/emnist-digits-test.csv\n", "/kaggle/input/emnist/emnist-balanced-test.csv\n", "/kaggle/input/emnist/emnist-mnist-test.csv\n", "/kaggle/input/emnist/emnist-letters-train.csv\n", "/kaggle/input/emnist/emnist-byclass-train.csv\n", "/kaggle/input/emnist/emnist-bymerge-test.csv\n", "/kaggle/input/emnist/emnist-balanced-mapping.txt\n", "/kaggle/input/emnist/emnist-mnist-train.csv\n", "/kaggle/input/emnist/emnist-digits-mapping.txt\n", "/kaggle/input/emnist/emnist-bymerge-train.csv\n", "/kaggle/input/emnist/emnist-byclass-test.csv\n", "/kaggle/input/emnist/emnist-byclass-mapping.txt\n", "/kaggle/input/emnist/emnist_source_files/emnist-digits-test-labels-idx1-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-bymerge-train-labels-idx1-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-letters-test-labels-idx1-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-byclass-train-images-idx3-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-byclass-test-images-idx3-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-mnist-train-images-idx3-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-digits-train-labels-idx1-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-bymerge-test-images-idx3-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-bymerge-test-labels-idx1-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-mnist-test-labels-idx1-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-balanced-test-labels-idx1-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-balanced-test-images-idx3-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-mnist-test-images-idx3-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-bymerge-train-images-idx3-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-letters-train-labels-idx1-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-digits-train-images-idx3-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-byclass-train-labels-idx1-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-balanced-train-images-idx3-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-balanced-train-labels-idx1-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-letters-test-images-idx3-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-byclass-test-labels-idx1-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-letters-train-images-idx3-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-mnist-train-labels-idx1-ubyte\n", "/kaggle/input/emnist/emnist_source_files/emnist-digits-test-images-idx3-ubyte\n" ] } ], "execution_count": null }, { "cell_type": "code", "source": [ "import tensorflow as tf\n", "from tensorflow import keras\n", "from tensorflow.keras import Sequential\n", "from tensorflow.keras.layers import Flatten,Dense,Conv2D,MaxPooling2D,ZeroPadding2D,Dropout\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from tensorflow.keras.preprocessing.image import ImageDataGenerator\n", "print(tf.__version__)" ], "metadata": { "trusted": true, "execution": { "iopub.status.busy": "2025-08-03T20:11:05.971067Z", "iopub.execute_input": "2025-08-03T20:11:05.971396Z", "iopub.status.idle": "2025-08-03T20:11:05.978259Z", "shell.execute_reply.started": "2025-08-03T20:11:05.971374Z", "shell.execute_reply": "2025-08-03T20:11:05.976659Z" }, "colab": { "base_uri": "https://localhost:8080/" }, "id": "HKENR4l-qzVu", "outputId": "d1419725-89a1-430d-b368-7401f0af8658" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "2.18.0\n" ] } ], "execution_count": null }, { "cell_type": "code", "source": [ "img_width=28\n", "img_height=28" ], "metadata": { "trusted": true, "execution": { "iopub.status.busy": "2025-08-03T20:11:05.979231Z", "iopub.execute_input": "2025-08-03T20:11:05.979554Z", "iopub.status.idle": "2025-08-03T20:11:05.996388Z", "shell.execute_reply.started": "2025-08-03T20:11:05.979532Z", "shell.execute_reply": "2025-08-03T20:11:05.99529Z" }, "id": "T48UCCnhqzVv" }, "outputs": [], "execution_count": null }, { "cell_type": "code", "source": [ "datagen=ImageDataGenerator(1/255.0,validation_split=0.2)" ], "metadata": { "trusted": true, "execution": { "iopub.status.busy": "2025-08-03T20:11:05.998784Z", "iopub.execute_input": "2025-08-03T20:11:05.999162Z", "iopub.status.idle": "2025-08-03T20:11:06.016479Z", "shell.execute_reply.started": "2025-08-03T20:11:05.999132Z", "shell.execute_reply": "2025-08-03T20:11:06.015236Z" }, "id": "PEOMsQTbqzVv" }, "outputs": [], "execution_count": null }, { "cell_type": "code", "source": [ "# data = pd.read_csv(\"/kaggle/input/emnist/emnist-digits-train.csv\") # Original code\n", "data = pd.read_csv(crawford_emnist_path + \"/emnist-digits-train.csv\") # Corrected path" ], "metadata": { "trusted": true, "execution": { "iopub.status.busy": "2025-08-03T20:11:06.017695Z", "iopub.execute_input": "2025-08-03T20:11:06.018051Z", "iopub.status.idle": "2025-08-03T20:11:22.149542Z", "shell.execute_reply.started": "2025-08-03T20:11:06.018021Z", "shell.execute_reply": "2025-08-03T20:11:22.148551Z" }, "id": "liRgnVVoqzVv" }, "outputs": [], "execution_count": null }, { "cell_type": "code", "source": [ "data.head()" ], "metadata": { "trusted": true, "execution": { "iopub.status.busy": "2025-08-03T20:11:22.150575Z", "iopub.execute_input": "2025-08-03T20:11:22.150942Z", "iopub.status.idle": "2025-08-03T20:11:22.166806Z", "shell.execute_reply.started": "2025-08-03T20:11:22.150917Z", "shell.execute_reply": "2025-08-03T20:11:22.165799Z" }, "colab": { "base_uri": "https://localhost:8080/", "height": 235 }, "id": "2XuHBxa_qzVw", "outputId": "6767cbd7-b174-4574-d052-54b3dfd5ecfe" }, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " 8 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 ... 0.511 0.512 0.513 \\\n", "0 9 0 0 0 0 0 0 0 0 0 ... 0 0 0 \n", "1 6 0 0 0 0 0 0 0 0 0 ... 0 0 0 \n", "2 3 0 0 0 0 0 0 0 0 0 ... 0 0 0 \n", "3 6 0 0 0 0 0 0 0 0 0 ... 0 0 0 \n", "4 6 0 0 0 0 0 0 0 0 0 ... 0 0 0 \n", "\n", " 0.514 0.515 0.516 0.517 0.518 0.519 0.520 \n", "0 0 0 0 0 0 0 0 \n", "1 0 0 0 0 0 0 0 \n", "2 0 0 0 0 0 0 0 \n", "3 0 0 0 0 0 0 0 \n", "4 0 0 0 0 0 0 0 \n", "\n", "[5 rows x 785 columns]" ], "text/html": [ "\n", "
| \n", " | 8 | \n", "0 | \n", "0.1 | \n", "0.2 | \n", "0.3 | \n", "0.4 | \n", "0.5 | \n", "0.6 | \n", "0.7 | \n", "0.8 | \n", "... | \n", "0.511 | \n", "0.512 | \n", "0.513 | \n", "0.514 | \n", "0.515 | \n", "0.516 | \n", "0.517 | \n", "0.518 | \n", "0.519 | \n", "0.520 | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "9 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 1 | \n", "6 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 2 | \n", "3 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 3 | \n", "6 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 4 | \n", "6 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
5 rows × 785 columns
\n", "pandas.core.frame.DataFrame.info
def info(verbose: bool | None=None, buf: WriteBuffer[str] | None=None, max_cols: int | None=None, memory_usage: bool | str | None=None, show_counts: bool | None=None) -> None
Print a concise summary of a DataFrame.\n", "\n", "This method prints information about a DataFrame including\n", "the index dtype and columns, non-null values and memory usage.\n", "\n", "Parameters\n", "----------\n", "verbose : bool, optional\n", " Whether to print the full summary. By default, the setting in\n", " ``pandas.options.display.max_info_columns`` is followed.\n", "buf : writable buffer, defaults to sys.stdout\n", " Where to send the output. By default, the output is printed to\n", " sys.stdout. Pass a writable buffer if you need to further process\n", " the output.\n", "max_cols : int, optional\n", " When to switch from the verbose to the truncated output. If the\n", " DataFrame has more than `max_cols` columns, the truncated output\n", " is used. By default, the setting in\n", " ``pandas.options.display.max_info_columns`` is used.\n", "memory_usage : bool, str, optional\n", " Specifies whether total memory usage of the DataFrame\n", " elements (including the index) should be displayed. By default,\n", " this follows the ``pandas.options.display.memory_usage`` setting.\n", "\n", " True always show memory usage. False never shows memory usage.\n", " A value of 'deep' is equivalent to "True with deep introspection".\n", " Memory usage is shown in human-readable units (base-2\n", " representation). Without deep introspection a memory estimation is\n", " made based in column dtype and number of rows assuming values\n", " consume the same memory amount for corresponding dtypes. With deep\n", " memory introspection, a real memory usage calculation is performed\n", " at the cost of computational resources. See the\n", " :ref:`Frequently Asked Questions <df-memory-usage>` for more\n", " details.\n", "show_counts : bool, optional\n", " Whether to show the non-null counts. By default, this is shown\n", " only if the DataFrame is smaller than\n", " ``pandas.options.display.max_info_rows`` and\n", " ``pandas.options.display.max_info_columns``. A value of True always\n", " shows the counts, and False never shows the counts.\n", "\n", "Returns\n", "-------\n", "None\n", " This method prints a summary of a DataFrame and returns None.\n", "\n", "See Also\n", "--------\n", "DataFrame.describe: Generate descriptive statistics of DataFrame\n", " columns.\n", "DataFrame.memory_usage: Memory usage of DataFrame columns.\n", "\n", "Examples\n", "--------\n", ">>> int_values = [1, 2, 3, 4, 5]\n", ">>> text_values = ['alpha', 'beta', 'gamma', 'delta', 'epsilon']\n", ">>> float_values = [0.0, 0.25, 0.5, 0.75, 1.0]\n", ">>> df = pd.DataFrame({"int_col": int_values, "text_col": text_values,\n", "... "float_col": float_values})\n", ">>> df\n", " int_col text_col float_col\n", "0 1 alpha 0.00\n", "1 2 beta 0.25\n", "2 3 gamma 0.50\n", "3 4 delta 0.75\n", "4 5 epsilon 1.00\n", "\n", "Prints information of all columns:\n", "\n", ">>> df.info(verbose=True)\n", "<class 'pandas.core.frame.DataFrame'>\n", "RangeIndex: 5 entries, 0 to 4\n", "Data columns (total 3 columns):\n", " # Column Non-Null Count Dtype\n", "--- ------ -------------- -----\n", " 0 int_col 5 non-null int64\n", " 1 text_col 5 non-null object\n", " 2 float_col 5 non-null float64\n", "dtypes: float64(1), int64(1), object(1)\n", "memory usage: 248.0+ bytes\n", "\n", "Prints a summary of columns count and its dtypes but not per column\n", "information:\n", "\n", ">>> df.info(verbose=False)\n", "<class 'pandas.core.frame.DataFrame'>\n", "RangeIndex: 5 entries, 0 to 4\n", "Columns: 3 entries, int_col to float_col\n", "dtypes: float64(1), int64(1), object(1)\n", "memory usage: 248.0+ bytes\n", "\n", "Pipe output of DataFrame.info to buffer instead of sys.stdout, get\n", "buffer content and writes to a text file:\n", "\n", ">>> import io\n", ">>> buffer = io.StringIO()\n", ">>> df.info(buf=buffer)\n", ">>> s = buffer.getvalue()\n", ">>> with open("df_info.txt", "w",\n", "... encoding="utf-8") as f: # doctest: +SKIP\n", "... f.write(s)\n", "260\n", "\n", "The `memory_usage` parameter allows deep introspection mode, specially\n", "useful for big DataFrames and fine-tune memory optimization:\n", "\n", ">>> random_strings_array = np.random.choice(['a', 'b', 'c'], 10 ** 6)\n", ">>> df = pd.DataFrame({\n", "... 'column_1': np.random.choice(['a', 'b', 'c'], 10 ** 6),\n", "... 'column_2': np.random.choice(['a', 'b', 'c'], 10 ** 6),\n", "... 'column_3': np.random.choice(['a', 'b', 'c'], 10 ** 6)\n", "... })\n", ">>> df.info()\n", "<class 'pandas.core.frame.DataFrame'>\n", "RangeIndex: 1000000 entries, 0 to 999999\n", "Data columns (total 3 columns):\n", " # Column Non-Null Count Dtype\n", "--- ------ -------------- -----\n", " 0 column_1 1000000 non-null object\n", " 1 column_2 1000000 non-null object\n", " 2 column_3 1000000 non-null object\n", "dtypes: object(3)\n", "memory usage: 22.9+ MB\n", "\n", ">>> df.info(memory_usage='deep')\n", "<class 'pandas.core.frame.DataFrame'>\n", "RangeIndex: 1000000 entries, 0 to 999999\n", "Data columns (total 3 columns):\n", " # Column Non-Null Count Dtype\n", "--- ------ -------------- -----\n", " 0 column_1 1000000 non-null object\n", " 1 column_2 1000000 non-null object\n", " 2 column_3 1000000 non-null object\n", "dtypes: object(3)\n", "memory usage: 165.9 MB\n", " \n", "
| \n", " | 0 | \n", "0.1 | \n", "0.2 | \n", "0.3 | \n", "0.4 | \n", "0.5 | \n", "0.6 | \n", "0.7 | \n", "0.8 | \n", "0.9 | \n", "... | \n", "0.511 | \n", "0.512 | \n", "0.513 | \n", "0.514 | \n", "0.515 | \n", "0.516 | \n", "0.517 | \n", "0.518 | \n", "0.519 | \n", "0.520 | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 1 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 2 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 3 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 4 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
5 rows × 784 columns
\n", "| \n", " | 8 | \n", "
|---|---|
| 0 | \n", "9 | \n", "
| 1 | \n", "6 | \n", "
| 2 | \n", "3 | \n", "
| 3 | \n", "6 | \n", "
| 4 | \n", "6 | \n", "
Model: \"sequential\"\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓\n",
"┃\u001b[1m \u001b[0m\u001b[1mLayer (type) \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1mOutput Shape \u001b[0m\u001b[1m \u001b[0m┃\u001b[1m \u001b[0m\u001b[1m Param #\u001b[0m\u001b[1m \u001b[0m┃\n",
"┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩\n",
"│ conv2d (\u001b[38;5;33mConv2D\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m26\u001b[0m, \u001b[38;5;34m26\u001b[0m, \u001b[38;5;34m30\u001b[0m) │ \u001b[38;5;34m300\u001b[0m │\n",
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
"│ max_pooling2d (\u001b[38;5;33mMaxPooling2D\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m13\u001b[0m, \u001b[38;5;34m13\u001b[0m, \u001b[38;5;34m30\u001b[0m) │ \u001b[38;5;34m0\u001b[0m │\n",
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
"│ conv2d_1 (\u001b[38;5;33mConv2D\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m11\u001b[0m, \u001b[38;5;34m11\u001b[0m, \u001b[38;5;34m30\u001b[0m) │ \u001b[38;5;34m8,130\u001b[0m │\n",
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
"│ max_pooling2d_1 (\u001b[38;5;33mMaxPooling2D\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m5\u001b[0m, \u001b[38;5;34m5\u001b[0m, \u001b[38;5;34m30\u001b[0m) │ \u001b[38;5;34m0\u001b[0m │\n",
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
"│ flatten (\u001b[38;5;33mFlatten\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m750\u001b[0m) │ \u001b[38;5;34m0\u001b[0m │\n",
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
"│ dense (\u001b[38;5;33mDense\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m64\u001b[0m) │ \u001b[38;5;34m48,064\u001b[0m │\n",
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
"│ dropout (\u001b[38;5;33mDropout\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m64\u001b[0m) │ \u001b[38;5;34m0\u001b[0m │\n",
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
"│ dense_1 (\u001b[38;5;33mDense\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m10\u001b[0m) │ \u001b[38;5;34m650\u001b[0m │\n",
"└─────────────────────────────────┴────────────────────────┴───────────────┘\n"
],
"text/html": [
"┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓\n",
"┃ Layer (type) ┃ Output Shape ┃ Param # ┃\n",
"┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩\n",
"│ conv2d (Conv2D) │ (None, 26, 26, 30) │ 300 │\n",
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
"│ max_pooling2d (MaxPooling2D) │ (None, 13, 13, 30) │ 0 │\n",
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
"│ conv2d_1 (Conv2D) │ (None, 11, 11, 30) │ 8,130 │\n",
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
"│ max_pooling2d_1 (MaxPooling2D) │ (None, 5, 5, 30) │ 0 │\n",
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
"│ flatten (Flatten) │ (None, 750) │ 0 │\n",
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
"│ dense (Dense) │ (None, 64) │ 48,064 │\n",
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
"│ dropout (Dropout) │ (None, 64) │ 0 │\n",
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
"│ dense_1 (Dense) │ (None, 10) │ 650 │\n",
"└─────────────────────────────────┴────────────────────────┴───────────────┘\n",
"\n"
]
},
"metadata": {}
},
{
"output_type": "display_data",
"data": {
"text/plain": [
"\u001b[1m Total params: \u001b[0m\u001b[38;5;34m57,144\u001b[0m (223.22 KB)\n"
],
"text/html": [
"Total params: 57,144 (223.22 KB)\n", "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "\u001b[1m Trainable params: \u001b[0m\u001b[38;5;34m57,144\u001b[0m (223.22 KB)\n" ], "text/html": [ "
Trainable params: 57,144 (223.22 KB)\n", "\n" ] }, "metadata": {} }, { "output_type": "display_data", "data": { "text/plain": [ "\u001b[1m Non-trainable params: \u001b[0m\u001b[38;5;34m0\u001b[0m (0.00 B)\n" ], "text/html": [ "
Non-trainable params: 0 (0.00 B)\n", "\n" ] }, "metadata": {} } ], "execution_count": null }, { "cell_type": "code", "source": [ "print(\"y_train shape:\", y_train.shape) # should be (60000,)\n", "print(\"y_train example:\", y_train[0])" ], "metadata": { "trusted": true, "execution": { "iopub.status.busy": "2025-08-03T20:11:29.636742Z", "iopub.execute_input": "2025-08-03T20:11:29.636981Z", "iopub.status.idle": "2025-08-03T20:11:29.64244Z", "shell.execute_reply.started": "2025-08-03T20:11:29.636963Z", "shell.execute_reply": "2025-08-03T20:11:29.641251Z" }, "colab": { "base_uri": "https://localhost:8080/" }, "id": "r-37iAkzqzVz", "outputId": "168b16b1-543a-4f2f-e4c9-ee2263075f69" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "y_train shape: (239999, 10)\n", "y_train example: [0. 0. 0. 0. 0. 0. 0. 0. 0. 1.]\n" ] } ], "execution_count": null }, { "cell_type": "code", "source": [ "from tensorflow.keras.losses import CategoricalCrossentropy\n", "model.compile(loss=\"categorical_crossentropy\",optimizer=\"Adam\", metrics=['accuracy'])" ], "metadata": { "trusted": true, "execution": { "iopub.status.busy": "2025-08-03T20:11:29.643517Z", "iopub.execute_input": "2025-08-03T20:11:29.644664Z", "iopub.status.idle": "2025-08-03T20:11:29.667774Z", "shell.execute_reply.started": "2025-08-03T20:11:29.64463Z", "shell.execute_reply": "2025-08-03T20:11:29.666572Z" }, "id": "BPdA8FiKqzVz" }, "outputs": [], "execution_count": null }, { "cell_type": "code", "source": [ "history = model.fit(x_train, y_train,epochs=10)" ], "metadata": { "trusted": true, "execution": { "iopub.status.busy": "2025-08-03T20:11:29.669022Z", "iopub.execute_input": "2025-08-03T20:11:29.669286Z", "iopub.status.idle": "2025-08-03T20:31:27.646378Z", "shell.execute_reply.started": "2025-08-03T20:11:29.669265Z", "shell.execute_reply": "2025-08-03T20:31:27.645154Z" }, "colab": { "base_uri": "https://localhost:8080/" }, "id": "7zJ8urxrqzVz", "outputId": "3d2a2cb1-90fb-43e0-acda-9f7e3e72151f" }, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Epoch 1/10\n", "\u001b[1m7500/7500\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m181s\u001b[0m 24ms/step - accuracy: 0.9526 - loss: 0.1568\n", "Epoch 2/10\n", "\u001b[1m7500/7500\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m199s\u001b[0m 23ms/step - accuracy: 0.9899 - loss: 0.0348\n", "Epoch 3/10\n", "\u001b[1m7500/7500\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m201s\u001b[0m 23ms/step - accuracy: 0.9922 - loss: 0.0270\n", "Epoch 4/10\n", "\u001b[1m7500/7500\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m204s\u001b[0m 24ms/step - accuracy: 0.9933 - loss: 0.0240\n", "Epoch 5/10\n", "\u001b[1m7500/7500\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m171s\u001b[0m 23ms/step - accuracy: 0.9938 - loss: 0.0214\n", "Epoch 6/10\n", "\u001b[1m7500/7500\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m204s\u001b[0m 23ms/step - accuracy: 0.9944 - loss: 0.0194\n", "Epoch 7/10\n", "\u001b[1m7500/7500\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m201s\u001b[0m 23ms/step - accuracy: 0.9945 - loss: 0.0191\n", "Epoch 8/10\n", "\u001b[1m7500/7500\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m202s\u001b[0m 23ms/step - accuracy: 0.9950 - loss: 0.0170\n", "Epoch 9/10\n", "\u001b[1m7500/7500\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m199s\u001b[0m 23ms/step - accuracy: 0.9956 - loss: 0.0148\n", "Epoch 10/10\n", "\u001b[1m7500/7500\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m170s\u001b[0m 23ms/step - accuracy: 0.9953 - loss: 0.0155\n" ] } ], "execution_count": null }, { "cell_type": "code", "source": [ "data_test = pd.read_csv(crawford_emnist_path + \"/emnist-digits-test.csv\")" ], "metadata": { "trusted": true, "execution": { "iopub.status.busy": "2025-08-03T20:33:39.501746Z", "iopub.execute_input": "2025-08-03T20:33:39.502747Z", "iopub.status.idle": "2025-08-03T20:33:41.693985Z", "shell.execute_reply.started": "2025-08-03T20:33:39.502709Z", "shell.execute_reply": "2025-08-03T20:33:41.692861Z" }, "id": "YkP0FYK4qzVz" }, "outputs": [], "execution_count": null }, { "cell_type": "code", "source": [ "x_test = data_test.drop(columns=\"0\")\n", "y_test = data_test[\"0\"]" ], "metadata": { "trusted": true, "execution": { "iopub.status.busy": "2025-08-03T20:35:20.444957Z", "iopub.execute_input": "2025-08-03T20:35:20.445269Z", "iopub.status.idle": "2025-08-03T20:35:20.558185Z", "shell.execute_reply.started": "2025-08-03T20:35:20.445246Z", "shell.execute_reply": "2025-08-03T20:35:20.557264Z" }, "id": "sfJNYYQdqzVz" }, "outputs": [], "execution_count": null }, { "cell_type": "code", "source": [ "data_test.head()" ], "metadata": { "trusted": true, "execution": { "iopub.status.busy": "2025-08-03T20:35:20.559206Z", "iopub.execute_input": "2025-08-03T20:35:20.559491Z", "iopub.status.idle": "2025-08-03T20:35:20.576181Z", "shell.execute_reply.started": "2025-08-03T20:35:20.559469Z", "shell.execute_reply": "2025-08-03T20:35:20.575128Z" }, "colab": { "base_uri": "https://localhost:8080/", "height": 235 }, "id": "F0yT0P0dqzVz", "outputId": "451228f0-5da7-428d-dcb9-6268a571fa34" }, "outputs": [ { "output_type": "execute_result", "data": { "text/plain": [ " 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 ... 0.472 0.473 0.474 \\\n", "0 9 0 0 0 0 0 0 0 0 0 ... 0 0 0 \n", "1 7 0 0 0 0 0 0 0 0 0 ... 0 0 0 \n", "2 9 0 0 0 0 0 0 0 0 0 ... 0 0 0 \n", "3 2 0 0 0 0 0 0 0 0 0 ... 0 0 0 \n", "4 2 0 0 0 0 0 0 0 0 0 ... 0 0 0 \n", "\n", " 0.475 0.476 0.477 0.478 0.479 0.480 0.481 \n", "0 0 0 0 0 0 0 0 \n", "1 0 0 0 0 0 0 0 \n", "2 0 0 0 0 0 0 0 \n", "3 0 0 0 0 0 0 0 \n", "4 0 0 0 0 0 0 0 \n", "\n", "[5 rows x 785 columns]" ], "text/html": [ "\n", "
| \n", " | 0 | \n", "0.1 | \n", "0.2 | \n", "0.3 | \n", "0.4 | \n", "0.5 | \n", "0.6 | \n", "0.7 | \n", "0.8 | \n", "0.9 | \n", "... | \n", "0.472 | \n", "0.473 | \n", "0.474 | \n", "0.475 | \n", "0.476 | \n", "0.477 | \n", "0.478 | \n", "0.479 | \n", "0.480 | \n", "0.481 | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "9 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 1 | \n", "7 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 2 | \n", "9 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 3 | \n", "2 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
| 4 | \n", "2 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "... | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "0 | \n", "
5 rows × 785 columns
\n", "