1907 lines
1.4 MiB
Plaintext
1907 lines
1.4 MiB
Plaintext
|
{
|
||
|
"cells": [
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "6Y8E0lw5eYWm"
|
||
|
},
|
||
|
"source": [
|
||
|
"# Post-training integer quantization"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "BTC1rDAuei_1"
|
||
|
},
|
||
|
"source": [
|
||
|
"## Overview\n",
|
||
|
"\n",
|
||
|
"Integer quantization is an optimization strategy that converts 32-bit floating-point numbers (such as weights and activation outputs) to the nearest 8-bit fixed-point numbers. This results in a smaller model and increased inferencing speed, which is valuable for low-power devices such as the [OpenMV](https://openmv.io) camera"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "dDqqUIZjZjac"
|
||
|
},
|
||
|
"source": [
|
||
|
"## Setup"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "I0nR5AMEWq0H"
|
||
|
},
|
||
|
"source": [
|
||
|
"In order to quantize both the input and output tensors, we need to use APIs added in TensorFlow 2.3:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 1,
|
||
|
"metadata": {
|
||
|
"id": "WsN6s5L1ieNl"
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import os\n",
|
||
|
"import logging\n",
|
||
|
"\n",
|
||
|
"os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'\n",
|
||
|
"logging.getLogger('tensorflow').setLevel(logging.ERROR)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"import matplotlib.pyplot as plt\n",
|
||
|
"import numpy as np\n",
|
||
|
"import tensorflow as tf\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"from tensorflow import keras\n",
|
||
|
"from tensorflow.keras import layers\n",
|
||
|
"from tensorflow.keras.models import Sequential"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "2XsEP17Zelz9"
|
||
|
},
|
||
|
"source": [
|
||
|
"## Generate a TensorFlow Model"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "5NMaNZQCkW9X"
|
||
|
},
|
||
|
"source": [
|
||
|
"We'll build a simple model to classify a few playing cards."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 2,
|
||
|
"metadata": {
|
||
|
"id": "eMsw_6HujaqM"
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Found 97 files belonging to 5 classes.\n",
|
||
|
"Using 78 files for training.\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n",
|
||
|
"I0000 00:00:1726357209.971252 177727 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1726357210.016076 177727 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1726357210.016287 177727 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1726357210.017355 177727 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1726357210.017543 177727 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1726357210.017701 177727 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1726357210.082813 177727 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1726357210.083011 177727 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n",
|
||
|
"I0000 00:00:1726357210.083177 177727 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Found 97 files belonging to 5 classes.\n",
|
||
|
"Using 19 files for validation.\n",
|
||
|
"number of classes: 5\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "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
|
||
|
"text/plain": [
|
||
|
"<Figure size 1000x1000 with 9 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 479/1875\u001b[0m \u001b[32m━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9829 - loss: 0.0583"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 516/1875\u001b[0m \u001b[32m━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9828 - loss: 0.0585"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 553/1875\u001b[0m \u001b[32m━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9827 - loss: 0.0587"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 590/1875\u001b[0m \u001b[32m━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9827 - loss: 0.0589"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 627/1875\u001b[0m \u001b[32m━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9826 - loss: 0.0591"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 664/1875\u001b[0m \u001b[32m━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9826 - loss: 0.0593"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 700/1875\u001b[0m \u001b[32m━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9825 - loss: 0.0594"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 736/1875\u001b[0m \u001b[32m━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9825 - loss: 0.0596"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 772/1875\u001b[0m \u001b[32m━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9825 - loss: 0.0597"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 808/1875\u001b[0m \u001b[32m━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9824 - loss: 0.0598"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 844/1875\u001b[0m \u001b[32m━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9824 - loss: 0.0599"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 881/1875\u001b[0m \u001b[32m━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9824 - loss: 0.0600"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 918/1875\u001b[0m \u001b[32m━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9824 - loss: 0.0600"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 956/1875\u001b[0m \u001b[32m━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9823 - loss: 0.0601"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m 993/1875\u001b[0m \u001b[32m━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9823 - loss: 0.0602"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1030/1875\u001b[0m \u001b[32m━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9823 - loss: 0.0603"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1067/1875\u001b[0m \u001b[32m━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9823 - loss: 0.0604"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1105/1875\u001b[0m \u001b[32m━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9823 - loss: 0.0605"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1143/1875\u001b[0m \u001b[32m━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━\u001b[0m \u001b[1m1s\u001b[0m 1ms/step - accuracy: 0.9822 - loss: 0.0606"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1181/1875\u001b[0m \u001b[32m━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9822 - loss: 0.0606"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1218/1875\u001b[0m \u001b[32m━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9822 - loss: 0.0607"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1256/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9822 - loss: 0.0608"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1295/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9822 - loss: 0.0608"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1334/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9822 - loss: 0.0609"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1373/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9822 - loss: 0.0609"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1412/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9822 - loss: 0.0610"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1451/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9822 - loss: 0.0610"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1489/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9821 - loss: 0.0611"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1528/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9821 - loss: 0.0611"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1566/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━━━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9821 - loss: 0.0612"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1603/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9821 - loss: 0.0612"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1641/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9821 - loss: 0.0613"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1679/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9821 - loss: 0.0613"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1718/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9821 - loss: 0.0614"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1756/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9821 - loss: 0.0614"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1795/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9821 - loss: 0.0614"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1833/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9820 - loss: 0.0615"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1870/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m━\u001b[0m \u001b[1m0s\u001b[0m 1ms/step - accuracy: 0.9820 - loss: 0.0615"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\r",
|
||
|
"\u001b[1m1875/1875\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m3s\u001b[0m 2ms/step - accuracy: 0.9820 - loss: 0.0615 - val_accuracy: 0.9797 - val_loss: 0.0668\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"<keras.src.callbacks.history.History at 0x7f0f06a4f5b0>"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"batch_size = 58\n",
|
||
|
"img_height = 120\n",
|
||
|
"img_width = 120\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"train_ds = tf.keras.utils.image_dataset_from_directory(\n",
|
||
|
" \"images/\",\n",
|
||
|
" #color_mode='grayscale',\n",
|
||
|
" validation_split=0.2,\n",
|
||
|
" subset=\"training\",\n",
|
||
|
" seed=123,\n",
|
||
|
" image_size=(img_height, img_width),\n",
|
||
|
" batch_size=batch_size)\n",
|
||
|
"\n",
|
||
|
"val_ds = tf.keras.utils.image_dataset_from_directory(\n",
|
||
|
" \"images/\",\n",
|
||
|
" #color_mode='grayscale',\n",
|
||
|
" validation_split=0.2,\n",
|
||
|
" subset=\"validation\",\n",
|
||
|
" seed=123,\n",
|
||
|
" image_size=(img_height, img_width),\n",
|
||
|
" batch_size=batch_size)\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"# print info on the classes in the dataset\n",
|
||
|
"class_names = train_ds.class_names\n",
|
||
|
"num_classes = len(class_names)\n",
|
||
|
"print(\"number of classes:\", num_classes)\n",
|
||
|
"\n",
|
||
|
"plt.figure(figsize=(10, 10))\n",
|
||
|
"for images, labels in train_ds.take(3):\n",
|
||
|
" for i in range(9):\n",
|
||
|
" ax = plt.subplot(3, 3, i + 1)\n",
|
||
|
" plt.imshow(images[i].numpy().astype(\"uint8\"))\n",
|
||
|
" plt.title(class_names[labels[i]])\n",
|
||
|
" plt.axis(\"off\")\n",
|
||
|
"\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 3,
|
||
|
"metadata": {},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"image_list = [] # Initialize an empty list to store the images\n",
|
||
|
"label_list = [] # Initialize an empty list to store the labels\n",
|
||
|
"\n",
|
||
|
"for images, labels in val_ds: # Take the first batch\n",
|
||
|
"\n",
|
||
|
" for i in range(len(images)):\n",
|
||
|
" image_list.append(images[i].numpy()) # Convert to NumPy and store in the list\n",
|
||
|
" label_list.append(labels[i].numpy()) # Convert to NumPy and store in the list\n",
|
||
|
"\n",
|
||
|
"# Convert the list of NumPy arrays into a single NumPy array\n",
|
||
|
"\n",
|
||
|
"image_array = np.array(image_list)\n",
|
||
|
"test_labels = np.array(label_list)\n",
|
||
|
"\n",
|
||
|
"# Now apply astype and normalization\n",
|
||
|
"test_images = image_array.astype(np.float32) / 255.0\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"image_list = [] # Initialize an empty list to store the images\n",
|
||
|
"label_list = [] # Initialize an empty list to store the labels\n",
|
||
|
"\n",
|
||
|
"for images, labels in train_ds: # Take the first batch\n",
|
||
|
" for i in range(len(images)):\n",
|
||
|
" image_list.append(images[i].numpy()) # Convert to NumPy and store in the list\n",
|
||
|
" label_list.append(labels[i].numpy()) # Convert to NumPy and store in the list\n",
|
||
|
"\n",
|
||
|
"# Convert the list of NumPy arrays into a single NumPy array\n",
|
||
|
"\n",
|
||
|
"image_array = np.array(image_list)\n",
|
||
|
"train_labels = np.array(label_list)\n",
|
||
|
"\n",
|
||
|
"# Now apply astype and normalization\n",
|
||
|
"train_images = image_array.astype(np.float32) / 255.0"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 4,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"0.2882355 0.99411756\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"image_list = [] # Initialize an empty list to store the images\n",
|
||
|
"label_list = [] # Initialize an empty list to store the labels\n",
|
||
|
"\n",
|
||
|
"for images, labels in train_ds: # Take the first batch\n",
|
||
|
" for i in range(len(images)):\n",
|
||
|
" image_list.append(images[i].numpy()) # Convert to NumPy and store in the list\n",
|
||
|
" label_list.append(labels[i].numpy()) # Convert to NumPy and store in the list\n",
|
||
|
"\n",
|
||
|
"# Convert the list of NumPy arrays into a single NumPy array\n",
|
||
|
"\n",
|
||
|
"image_array = np.array(image_list)\n",
|
||
|
"train_labels = np.array(label_list)\n",
|
||
|
"\n",
|
||
|
"# Now apply astype and normalization\n",
|
||
|
"train_images = image_array.astype(np.float32) / 255.0\n",
|
||
|
"\n",
|
||
|
"first_image = train_images[0]\n",
|
||
|
"print(np.min(first_image), np.max(first_image))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"In this step we will do a little data augmentation so that the model does not overfit"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 5,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"/home/brickman/miniconda3/envs/openmv_train/lib/python3.10/site-packages/keras/src/layers/preprocessing/tf_data_layer.py:19: UserWarning: Do not pass an `input_shape`/`input_dim` argument to a layer. When using Sequential models, prefer using an `Input(shape)` object as the first layer in the model instead.\n",
|
||
|
" super().__init__(**kwargs)\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "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
|
||
|
"text/plain": [
|
||
|
"<Figure size 1000x1000 with 9 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"# Augment training data\n",
|
||
|
"\n",
|
||
|
"data_augmentation = keras.Sequential(\n",
|
||
|
" [\n",
|
||
|
" layers.RandomFlip(\"horizontal\", input_shape=(img_height, img_width, 3)),\n",
|
||
|
" layers.RandomRotation(0.4),\n",
|
||
|
" layers.RandomZoom(0.1),\n",
|
||
|
" ]\n",
|
||
|
")\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"# Visualize Change\n",
|
||
|
"plt.figure(figsize=(10, 10))\n",
|
||
|
"for images, _ in train_ds.take(1):\n",
|
||
|
" for i in range(9):\n",
|
||
|
" augmented_images = data_augmentation(images)\n",
|
||
|
" ax = plt.subplot(3, 3, i + 1)\n",
|
||
|
" plt.imshow(augmented_images[0].numpy().astype(\"uint8\"))\n",
|
||
|
" plt.axis(\"off\")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Let's set up our model architecture and decide whether we want to use transfer learning or build the model from scratch. Transfer learning may include more overhead for the edge device but is better with less data, making it faster to build and train."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Choose whether you want to use transfer learning by setting the `transfer_learning` parameter to `True` or `False`."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 6,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"/tmp/ipykernel_177727/819969002.py:5: UserWarning: `input_shape` is undefined or non-square, or `rows` is not in [96, 128, 160, 192, 224]. Weights for input shape (224, 224) will be loaded as the default.\n",
|
||
|
" base_model = tf.keras.applications.MobileNetV2(input_shape=(img_height, img_width, 3),\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\">Model: \"sequential_1\"</span>\n",
|
||
|
"</pre>\n"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"\u001b[1mModel: \"sequential_1\"\u001b[0m\n"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓\n",
|
||
|
"┃<span style=\"font-weight: bold\"> Layer (type) </span>┃<span style=\"font-weight: bold\"> Output Shape </span>┃<span style=\"font-weight: bold\"> Param # </span>┃\n",
|
||
|
"┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩\n",
|
||
|
"│ sequential (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Sequential</span>) │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">120</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">120</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">3</span>) │ <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ mobilenetv2_1.00_224 │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">4</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">4</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">1280</span>) │ <span style=\"color: #00af00; text-decoration-color: #00af00\">2,257,984</span> │\n",
|
||
|
"│ (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Functional</span>) │ │ │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ global_average_pooling2d │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">1280</span>) │ <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
|
||
|
"│ (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">GlobalAveragePooling2D</span>) │ │ │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ dense (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dense</span>) │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">128</span>) │ <span style=\"color: #00af00; text-decoration-color: #00af00\">163,968</span> │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ dropout (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dropout</span>) │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">128</span>) │ <span style=\"color: #00af00; text-decoration-color: #00af00\">0</span> │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ outputs (<span style=\"color: #0087ff; text-decoration-color: #0087ff\">Dense</span>) │ (<span style=\"color: #00d7ff; text-decoration-color: #00d7ff\">None</span>, <span style=\"color: #00af00; text-decoration-color: #00af00\">5</span>) │ <span style=\"color: #00af00; text-decoration-color: #00af00\">645</span> │\n",
|
||
|
"└─────────────────────────────────┴────────────────────────┴───────────────┘\n",
|
||
|
"</pre>\n"
|
||
|
],
|
||
|
"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",
|
||
|
"│ sequential (\u001b[38;5;33mSequential\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m120\u001b[0m, \u001b[38;5;34m120\u001b[0m, \u001b[38;5;34m3\u001b[0m) │ \u001b[38;5;34m0\u001b[0m │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ mobilenetv2_1.00_224 │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m4\u001b[0m, \u001b[38;5;34m4\u001b[0m, \u001b[38;5;34m1280\u001b[0m) │ \u001b[38;5;34m2,257,984\u001b[0m │\n",
|
||
|
"│ (\u001b[38;5;33mFunctional\u001b[0m) │ │ │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ global_average_pooling2d │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m1280\u001b[0m) │ \u001b[38;5;34m0\u001b[0m │\n",
|
||
|
"│ (\u001b[38;5;33mGlobalAveragePooling2D\u001b[0m) │ │ │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ dense (\u001b[38;5;33mDense\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m128\u001b[0m) │ \u001b[38;5;34m163,968\u001b[0m │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ dropout (\u001b[38;5;33mDropout\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m128\u001b[0m) │ \u001b[38;5;34m0\u001b[0m │\n",
|
||
|
"├─────────────────────────────────┼────────────────────────┼───────────────┤\n",
|
||
|
"│ outputs (\u001b[38;5;33mDense\u001b[0m) │ (\u001b[38;5;45mNone\u001b[0m, \u001b[38;5;34m5\u001b[0m) │ \u001b[38;5;34m645\u001b[0m │\n",
|
||
|
"└─────────────────────────────────┴────────────────────────┴───────────────┘\n"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\"> Total params: </span><span style=\"color: #00af00; text-decoration-color: #00af00\">2,422,597</span> (9.24 MB)\n",
|
||
|
"</pre>\n"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"\u001b[1m Total params: \u001b[0m\u001b[38;5;34m2,422,597\u001b[0m (9.24 MB)\n"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\"> Trainable params: </span><span style=\"color: #00af00; text-decoration-color: #00af00\">164,613</span> (643.02 KB)\n",
|
||
|
"</pre>\n"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"\u001b[1m Trainable params: \u001b[0m\u001b[38;5;34m164,613\u001b[0m (643.02 KB)\n"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"text/html": [
|
||
|
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"font-weight: bold\"> Non-trainable params: </span><span style=\"color: #00af00; text-decoration-color: #00af00\">2,257,984</span> (8.61 MB)\n",
|
||
|
"</pre>\n"
|
||
|
],
|
||
|
"text/plain": [
|
||
|
"\u001b[1m Non-trainable params: \u001b[0m\u001b[38;5;34m2,257,984\u001b[0m (8.61 MB)\n"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"\n",
|
||
|
"transfer_learning = True\n",
|
||
|
"\n",
|
||
|
"if transfer_learning:\n",
|
||
|
" # Load the pre-trained MobileNetV2 model (excluding the top classification layer)\n",
|
||
|
" base_model = tf.keras.applications.MobileNetV2(input_shape=(img_height, img_width, 3),\n",
|
||
|
" include_top=False, # Do not include the final classification layer\n",
|
||
|
" weights='imagenet') # Use weights pre-trained on ImageNet\n",
|
||
|
" \n",
|
||
|
" base_model.trainable = False # Freeze the base model so its weights won't be updated during training\n",
|
||
|
" \n",
|
||
|
" # Create the model\n",
|
||
|
" model = Sequential([\n",
|
||
|
" data_augmentation,\n",
|
||
|
" base_model, # Add the pre-trained MobileNetV2\n",
|
||
|
" layers.GlobalAveragePooling2D(), # Use global average pooling instead of flattening\n",
|
||
|
" layers.Dense(128, activation='relu'), # Add a fully connected layer\n",
|
||
|
" layers.Dropout(0.2), # Dropout to reduce overfitting\n",
|
||
|
" layers.Dense(num_classes, name=\"outputs\", activation='softmax') # Final classification layer (for 10 classes)\n",
|
||
|
" ])\n",
|
||
|
"\n",
|
||
|
"else:\n",
|
||
|
" model = Sequential([\n",
|
||
|
" layers.InputLayer(input_shape(img_height, img_width, 3), batch_size=1), # Proper InputLayer with batch_size=1\n",
|
||
|
" data_augmentation,\n",
|
||
|
" layers.Conv2D(32, 3, padding='same', activation='relu'),\n",
|
||
|
" layers.MaxPooling2D(),\n",
|
||
|
" layers.Conv2D(64, 3, padding='same', activation='relu'),\n",
|
||
|
" layers.MaxPooling2D(),\n",
|
||
|
" layers.Conv2D(128, 3, padding='same', activation='relu'),\n",
|
||
|
" layers.MaxPooling2D(),\n",
|
||
|
" layers.Dropout(0.2),\n",
|
||
|
" layers.Flatten(),\n",
|
||
|
" layers.Dense(24, activation='relu'),\n",
|
||
|
" layers.Dense(48, activation='relu'),\n",
|
||
|
" layers.Dense(num_classes, name=\"outputs\", activation='softmax')\n",
|
||
|
" ])\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"# compile the model\n",
|
||
|
"model.compile(optimizer='adam',\n",
|
||
|
" loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),\n",
|
||
|
" metrics=['accuracy'])\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
"# give a nice summary of the model architecture\n",
|
||
|
"model.summary()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"# Training Model"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"Now that we have setup are model's architecture lets train our model"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 7,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Epoch 1/100\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"/home/brickman/miniconda3/envs/openmv_train/lib/python3.10/site-packages/keras/src/backend/tensorflow/nn.py:635: UserWarning: \"`sparse_categorical_crossentropy` received `from_logits=True`, but the `output` argument was produced by a Softmax activation and thus does not represent logits. Was this intended?\n",
|
||
|
" output, from_logits = _get_logits(\n",
|
||
|
"W0000 00:00:1726357216.800337 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.819953 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.821099 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.828785 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.830769 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.832719 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.834030 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.836192 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.837501 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.855066 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.962140 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.963683 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.966329 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.968056 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.989936 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.991655 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.993431 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.996330 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357216.999003 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.002068 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.005231 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.008253 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.011157 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.013318 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.015547 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.018033 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.021012 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.023248 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.026339 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.029253 177813 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 47ms/step - accuracy: 0.2181 - loss: 2.0655"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"W0000 00:00:1726357217.334963 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.336193 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.337305 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.338814 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.340084 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.341282 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.342461 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.343583 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.344710 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.345837 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.346965 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.348335 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.349593 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.350913 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.352279 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.353686 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.355036 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.356617 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.357905 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.359370 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.360732 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.362069 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.363444 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.364888 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.366474 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.367893 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.369443 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357217.370858 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m4s\u001b[0m 398ms/step - accuracy: 0.2373 - loss: 2.0153 - val_accuracy: 0.4737 - val_loss: 1.2687\n",
|
||
|
"Epoch 2/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.7404 - loss: 0.6928 - val_accuracy: 0.6316 - val_loss: 0.8260\n",
|
||
|
"Epoch 3/100\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"W0000 00:00:1726357218.034327 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.035458 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.036568 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.038225 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.039556 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.040762 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.041962 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.043101 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.044236 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.045447 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.046593 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.048033 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.049332 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.050737 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.052219 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.053743 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.055201 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.056975 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.058376 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.059985 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.061481 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.062938 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.064427 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.066005 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.067798 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.069361 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.071101 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n",
|
||
|
"W0000 00:00:1726357218.072682 177812 gpu_timer.cc:114] Skipping the delay kernel, measurement accuracy will be reduced\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.8503 - loss: 0.4061 - val_accuracy: 0.5789 - val_loss: 0.6591\n",
|
||
|
"Epoch 4/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.8076 - loss: 0.4528 - val_accuracy: 0.6842 - val_loss: 0.7452\n",
|
||
|
"Epoch 5/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9445 - loss: 0.2263 - val_accuracy: 0.7895 - val_loss: 0.5651\n",
|
||
|
"Epoch 6/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 38ms/step - accuracy: 0.8965 - loss: 0.2498 - val_accuracy: 0.8421 - val_loss: 0.4142\n",
|
||
|
"Epoch 7/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 33ms/step - accuracy: 0.8848 - loss: 0.2633 - val_accuracy: 0.8421 - val_loss: 0.4038\n",
|
||
|
"Epoch 8/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 31ms/step - accuracy: 0.9509 - loss: 0.2042 - val_accuracy: 0.8421 - val_loss: 0.3523\n",
|
||
|
"Epoch 9/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 29ms/step - accuracy: 0.8798 - loss: 0.2198 - val_accuracy: 0.8421 - val_loss: 0.3389\n",
|
||
|
"Epoch 10/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 32ms/step - accuracy: 0.9534 - loss: 0.1349 - val_accuracy: 0.8421 - val_loss: 0.3604\n",
|
||
|
"Epoch 11/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9716 - loss: 0.0719 - val_accuracy: 0.7895 - val_loss: 0.3791\n",
|
||
|
"Epoch 12/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9186 - loss: 0.1475 - val_accuracy: 0.8947 - val_loss: 0.3160\n",
|
||
|
"Epoch 13/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 33ms/step - accuracy: 0.9250 - loss: 0.1747 - val_accuracy: 0.8947 - val_loss: 0.2067\n",
|
||
|
"Epoch 14/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9406 - loss: 0.1366 - val_accuracy: 0.9474 - val_loss: 0.1961\n",
|
||
|
"Epoch 15/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 29ms/step - accuracy: 0.9445 - loss: 0.1685 - val_accuracy: 0.8947 - val_loss: 0.2783\n",
|
||
|
"Epoch 16/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9534 - loss: 0.1124 - val_accuracy: 0.8947 - val_loss: 0.2823\n",
|
||
|
"Epoch 17/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9819 - loss: 0.1058 - val_accuracy: 0.8947 - val_loss: 0.2889\n",
|
||
|
"Epoch 18/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 34ms/step - accuracy: 0.9897 - loss: 0.0564 - val_accuracy: 0.8947 - val_loss: 0.3029\n",
|
||
|
"Epoch 19/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 33ms/step - accuracy: 0.9264 - loss: 0.1349 - val_accuracy: 0.8947 - val_loss: 0.2102\n",
|
||
|
"Epoch 20/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 34ms/step - accuracy: 0.9637 - loss: 0.0832 - val_accuracy: 0.9474 - val_loss: 0.1600\n",
|
||
|
"Epoch 21/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 1.0000 - loss: 0.0557 - val_accuracy: 0.9474 - val_loss: 0.1391\n",
|
||
|
"Epoch 22/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9431 - loss: 0.1461 - val_accuracy: 0.8947 - val_loss: 0.1811\n",
|
||
|
"Epoch 23/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9665 - loss: 0.0685 - val_accuracy: 0.9474 - val_loss: 0.1729\n",
|
||
|
"Epoch 24/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 32ms/step - accuracy: 0.9612 - loss: 0.0803 - val_accuracy: 0.9474 - val_loss: 0.1309\n",
|
||
|
"Epoch 25/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 32ms/step - accuracy: 0.9716 - loss: 0.0867 - val_accuracy: 0.9474 - val_loss: 0.1322\n",
|
||
|
"Epoch 26/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 34ms/step - accuracy: 1.0000 - loss: 0.0355 - val_accuracy: 0.9474 - val_loss: 0.1303\n",
|
||
|
"Epoch 27/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9367 - loss: 0.1395 - val_accuracy: 0.9474 - val_loss: 0.1509\n",
|
||
|
"Epoch 28/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 38ms/step - accuracy: 0.9794 - loss: 0.0619 - val_accuracy: 0.8421 - val_loss: 0.2339\n",
|
||
|
"Epoch 29/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9651 - loss: 0.0518 - val_accuracy: 0.8421 - val_loss: 0.2864\n",
|
||
|
"Epoch 30/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 34ms/step - accuracy: 0.9534 - loss: 0.1049 - val_accuracy: 0.8947 - val_loss: 0.2026\n",
|
||
|
"Epoch 31/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 1.0000 - loss: 0.0255 - val_accuracy: 0.9474 - val_loss: 0.1675\n",
|
||
|
"Epoch 32/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 30ms/step - accuracy: 0.9637 - loss: 0.0935 - val_accuracy: 0.9474 - val_loss: 0.1276\n",
|
||
|
"Epoch 33/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 31ms/step - accuracy: 0.9819 - loss: 0.0436 - val_accuracy: 0.9474 - val_loss: 0.1064\n",
|
||
|
"Epoch 34/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 31ms/step - accuracy: 0.9794 - loss: 0.0587 - val_accuracy: 0.9474 - val_loss: 0.1186\n",
|
||
|
"Epoch 35/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 31ms/step - accuracy: 1.0000 - loss: 0.0234 - val_accuracy: 0.9474 - val_loss: 0.1543\n",
|
||
|
"Epoch 36/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 31ms/step - accuracy: 0.9897 - loss: 0.0388 - val_accuracy: 0.8421 - val_loss: 0.2616\n",
|
||
|
"Epoch 37/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9716 - loss: 0.0450 - val_accuracy: 0.8421 - val_loss: 0.3819\n",
|
||
|
"Epoch 38/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 32ms/step - accuracy: 0.9716 - loss: 0.0580 - val_accuracy: 0.8421 - val_loss: 0.2887\n",
|
||
|
"Epoch 39/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 31ms/step - accuracy: 1.0000 - loss: 0.0327 - val_accuracy: 0.9474 - val_loss: 0.1340\n",
|
||
|
"Epoch 40/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9819 - loss: 0.0443 - val_accuracy: 1.0000 - val_loss: 0.1000\n",
|
||
|
"Epoch 41/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9819 - loss: 0.0453 - val_accuracy: 1.0000 - val_loss: 0.0908\n",
|
||
|
"Epoch 42/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9936 - loss: 0.0317 - val_accuracy: 0.9474 - val_loss: 0.1173\n",
|
||
|
"Epoch 43/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 33ms/step - accuracy: 1.0000 - loss: 0.0393 - val_accuracy: 0.8947 - val_loss: 0.2235\n",
|
||
|
"Epoch 44/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9897 - loss: 0.0439 - val_accuracy: 0.8947 - val_loss: 0.2219\n",
|
||
|
"Epoch 45/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9819 - loss: 0.0424 - val_accuracy: 0.9474 - val_loss: 0.1414\n",
|
||
|
"Epoch 46/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 29ms/step - accuracy: 0.9819 - loss: 0.0419 - val_accuracy: 0.8947 - val_loss: 0.1344\n",
|
||
|
"Epoch 47/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 1.0000 - loss: 0.0116 - val_accuracy: 0.9474 - val_loss: 0.1197\n",
|
||
|
"Epoch 48/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9872 - loss: 0.0355 - val_accuracy: 1.0000 - val_loss: 0.0458\n",
|
||
|
"Epoch 49/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 31ms/step - accuracy: 1.0000 - loss: 0.0174 - val_accuracy: 1.0000 - val_loss: 0.0609\n",
|
||
|
"Epoch 50/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9897 - loss: 0.0796 - val_accuracy: 1.0000 - val_loss: 0.0605\n",
|
||
|
"Epoch 51/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9637 - loss: 0.1125 - val_accuracy: 1.0000 - val_loss: 0.0857\n",
|
||
|
"Epoch 52/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 34ms/step - accuracy: 1.0000 - loss: 0.0073 - val_accuracy: 0.8421 - val_loss: 0.2956\n",
|
||
|
"Epoch 53/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 1.0000 - loss: 0.0133 - val_accuracy: 0.8421 - val_loss: 0.5120\n",
|
||
|
"Epoch 54/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 1.0000 - loss: 0.0175 - val_accuracy: 0.8421 - val_loss: 0.5815\n",
|
||
|
"Epoch 55/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9794 - loss: 0.0523 - val_accuracy: 0.8421 - val_loss: 0.2835\n",
|
||
|
"Epoch 56/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 28ms/step - accuracy: 0.9819 - loss: 0.0399 - val_accuracy: 0.9474 - val_loss: 0.0811\n",
|
||
|
"Epoch 57/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9936 - loss: 0.0282 - val_accuracy: 1.0000 - val_loss: 0.0485\n",
|
||
|
"Epoch 58/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9819 - loss: 0.0518 - val_accuracy: 0.9474 - val_loss: 0.0833\n",
|
||
|
"Epoch 59/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 1.0000 - loss: 0.0224 - val_accuracy: 0.8947 - val_loss: 0.1869\n",
|
||
|
"Epoch 60/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 34ms/step - accuracy: 0.9819 - loss: 0.0641 - val_accuracy: 0.8947 - val_loss: 0.1960\n",
|
||
|
"Epoch 61/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9936 - loss: 0.0185 - val_accuracy: 0.8947 - val_loss: 0.2296\n",
|
||
|
"Epoch 62/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 1.0000 - loss: 0.0176 - val_accuracy: 0.8947 - val_loss: 0.2455\n",
|
||
|
"Epoch 63/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 31ms/step - accuracy: 0.9897 - loss: 0.0347 - val_accuracy: 0.9474 - val_loss: 0.1655\n",
|
||
|
"Epoch 64/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 37ms/step - accuracy: 1.0000 - loss: 0.0240 - val_accuracy: 0.9474 - val_loss: 0.0992\n",
|
||
|
"Epoch 65/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 30ms/step - accuracy: 0.9819 - loss: 0.0640 - val_accuracy: 0.8947 - val_loss: 0.1745\n",
|
||
|
"Epoch 66/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 32ms/step - accuracy: 0.9936 - loss: 0.0290 - val_accuracy: 0.8947 - val_loss: 0.1984\n",
|
||
|
"Epoch 67/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9716 - loss: 0.0526 - val_accuracy: 0.8947 - val_loss: 0.1530\n",
|
||
|
"Epoch 68/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 31ms/step - accuracy: 1.0000 - loss: 0.0082 - val_accuracy: 0.8947 - val_loss: 0.1839\n",
|
||
|
"Epoch 69/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 31ms/step - accuracy: 0.9936 - loss: 0.0211 - val_accuracy: 0.8947 - val_loss: 0.1748\n",
|
||
|
"Epoch 70/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 32ms/step - accuracy: 0.9819 - loss: 0.0434 - val_accuracy: 1.0000 - val_loss: 0.0406\n",
|
||
|
"Epoch 71/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 34ms/step - accuracy: 0.9936 - loss: 0.0144 - val_accuracy: 1.0000 - val_loss: 0.0327\n",
|
||
|
"Epoch 72/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 34ms/step - accuracy: 0.9819 - loss: 0.0381 - val_accuracy: 1.0000 - val_loss: 0.0354\n",
|
||
|
"Epoch 73/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 31ms/step - accuracy: 1.0000 - loss: 0.0129 - val_accuracy: 1.0000 - val_loss: 0.0431\n",
|
||
|
"Epoch 74/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 32ms/step - accuracy: 0.9819 - loss: 0.0261 - val_accuracy: 0.9474 - val_loss: 0.0838\n",
|
||
|
"Epoch 75/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 32ms/step - accuracy: 0.9936 - loss: 0.0191 - val_accuracy: 0.9474 - val_loss: 0.0921\n",
|
||
|
"Epoch 76/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 33ms/step - accuracy: 1.0000 - loss: 0.0163 - val_accuracy: 0.9474 - val_loss: 0.0705\n",
|
||
|
"Epoch 77/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9819 - loss: 0.0398 - val_accuracy: 1.0000 - val_loss: 0.0305\n",
|
||
|
"Epoch 78/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 1.0000 - loss: 0.0062 - val_accuracy: 1.0000 - val_loss: 0.0220\n",
|
||
|
"Epoch 79/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 30ms/step - accuracy: 1.0000 - loss: 0.0081 - val_accuracy: 1.0000 - val_loss: 0.0310\n",
|
||
|
"Epoch 80/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9897 - loss: 0.0317 - val_accuracy: 1.0000 - val_loss: 0.0296\n",
|
||
|
"Epoch 81/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 1.0000 - loss: 0.0135 - val_accuracy: 1.0000 - val_loss: 0.0430\n",
|
||
|
"Epoch 82/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9819 - loss: 0.0453 - val_accuracy: 1.0000 - val_loss: 0.0502\n",
|
||
|
"Epoch 83/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 32ms/step - accuracy: 1.0000 - loss: 0.0103 - val_accuracy: 1.0000 - val_loss: 0.0567\n",
|
||
|
"Epoch 84/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 33ms/step - accuracy: 1.0000 - loss: 0.0137 - val_accuracy: 0.9474 - val_loss: 0.0686\n",
|
||
|
"Epoch 85/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 31ms/step - accuracy: 1.0000 - loss: 0.0110 - val_accuracy: 0.9474 - val_loss: 0.0707\n",
|
||
|
"Epoch 86/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 30ms/step - accuracy: 0.9534 - loss: 0.0879 - val_accuracy: 1.0000 - val_loss: 0.0606\n",
|
||
|
"Epoch 87/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 29ms/step - accuracy: 1.0000 - loss: 0.0065 - val_accuracy: 1.0000 - val_loss: 0.0367\n",
|
||
|
"Epoch 88/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 32ms/step - accuracy: 1.0000 - loss: 0.0108 - val_accuracy: 1.0000 - val_loss: 0.0265\n",
|
||
|
"Epoch 89/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 30ms/step - accuracy: 1.0000 - loss: 0.0051 - val_accuracy: 1.0000 - val_loss: 0.0277\n",
|
||
|
"Epoch 90/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 34ms/step - accuracy: 0.9897 - loss: 0.0246 - val_accuracy: 1.0000 - val_loss: 0.0157\n",
|
||
|
"Epoch 91/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 32ms/step - accuracy: 1.0000 - loss: 0.0144 - val_accuracy: 1.0000 - val_loss: 0.0152\n",
|
||
|
"Epoch 92/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 34ms/step - accuracy: 1.0000 - loss: 0.0042 - val_accuracy: 1.0000 - val_loss: 0.0228\n",
|
||
|
"Epoch 93/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 34ms/step - accuracy: 0.9897 - loss: 0.0215 - val_accuracy: 1.0000 - val_loss: 0.0461\n",
|
||
|
"Epoch 94/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 34ms/step - accuracy: 1.0000 - loss: 0.0045 - val_accuracy: 0.9474 - val_loss: 0.0861\n",
|
||
|
"Epoch 95/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 31ms/step - accuracy: 1.0000 - loss: 0.0142 - val_accuracy: 0.8947 - val_loss: 0.1580\n",
|
||
|
"Epoch 96/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 29ms/step - accuracy: 1.0000 - loss: 0.0039 - val_accuracy: 0.8947 - val_loss: 0.1995\n",
|
||
|
"Epoch 97/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9819 - loss: 0.0465 - val_accuracy: 0.8947 - val_loss: 0.1079\n",
|
||
|
"Epoch 98/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 36ms/step - accuracy: 0.9936 - loss: 0.0257 - val_accuracy: 0.9474 - val_loss: 0.1108\n",
|
||
|
"Epoch 99/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 0.9936 - loss: 0.0122 - val_accuracy: 0.8947 - val_loss: 0.2087\n",
|
||
|
"Epoch 100/100\n",
|
||
|
"\u001b[1m3/3\u001b[0m \u001b[32m━━━━━━━━━━━━━━━━━━━━\u001b[0m\u001b[37m\u001b[0m \u001b[1m0s\u001b[0m 35ms/step - accuracy: 1.0000 - loss: 0.0078 - val_accuracy: 0.8947 - val_loss: 0.2261\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"epochs = 100\n",
|
||
|
"history = model.fit(\n",
|
||
|
" train_images,\n",
|
||
|
" train_labels,\n",
|
||
|
" epochs=epochs,\n",
|
||
|
" validation_data=(test_images, test_labels)\n",
|
||
|
")"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {},
|
||
|
"source": [
|
||
|
"## Visualize training results\n",
|
||
|
"Create plots of the loss and accuracy on the training and validation sets:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 8,
|
||
|
"metadata": {},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABL4AAAKqCAYAAAA0dZe7AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdeXwTdfoH8M8kadP7bimlhUK575sFlWMX5VBW1PVk5VBcL3QVXV2PRXF35bfrqux6rxfrfYPueiAgiALKfSigFAqFUlp6n0maZH5/TGaSNHcy6ZXP+/XqqzSZJJN0WjKfPs/zFURRFEFERERERERERNTFaNp7B4iIiIiIiIiIiMKBwRcREREREREREXVJDL6IiIiIiIiIiKhLYvBFRERERERERERdEoMvIiIiIiIiIiLqkhh8ERERERERERFRl8Tgi4iIiIiIiIiIuiQGX0RERERERERE1CUx+CIiIiIiIiIioi6JwRdRKwsXLkR+fn5Qt3344YchCIK6O9TBHD9+HIIgYNWqVW3+2IIg4OGHH1a+XrVqFQRBwPHjx33eNj8/HwsXLlR1f0I5VoiIiKjz4/tG7/i+0Y7vG4naD4Mv6jQEQfDrY9OmTe29qxHv9ttvhyAIKCws9LjNAw88AEEQsH///jbcs8CdPn0aDz/8MPbu3dveu+LWoUOHIAgCYmJiUFNT0967Q0RE1CHwfWPnwfeN4SWHj//4xz/ae1eI2o2uvXeAyF+vv/6609evvfYa1q1b53L5oEGDQnqcF198EVarNajbPvjgg/jjH/8Y0uN3BfPmzcNTTz2Ft956C8uWLXO7zdtvv41hw4Zh+PDhQT/Otddei6uuugp6vT7o+/Dl9OnTWL58OfLz8zFy5Ein60I5VtTyxhtvIDs7G9XV1fjggw+wePHidt0fIiKijoDvGzsPvm8konBj8EWdxm9/+1unr7/77jusW7fO5fLWmpqaEBcX5/fjREVFBbV/AKDT6aDT8cdqwoQJ6Nu3L95++223b2C2bduGoqIi/N///V9Ij6PVaqHVakO6j1CEcqyoQRRFvPXWW7jmmmtQVFSEN998s8MGX42NjYiPj2/v3SAiogjB942dB983ElG4sdWRupSpU6di6NCh2LVrFyZPnoy4uDjcf//9AICPP/4YF154IXJycqDX61FQUIA///nPsFgsTvfRuv/esTz43//+NwoKCqDX6zFu3Djs2LHD6bbuZjUIgoAlS5ZgzZo1GDp0KPR6PYYMGYIvvvjCZf83bdqEsWPHIiYmBgUFBXjhhRf8nv/wzTff4PLLL0fPnj2h1+uRl5eHO++8E83NzS7PLyEhASUlJZg7dy4SEhKQmZmJu+++2+W1qKmpwcKFC5GcnIyUlBQsWLDA73a6efPm4fDhw9i9e7fLdW+99RYEQcDVV18Nk8mEZcuWYcyYMUhOTkZ8fDzOO+88bNy40edjuJvVIIoi/vKXvyA3NxdxcXGYNm0afvzxR5fbVlVV4e6778awYcOQkJCApKQkzJo1C/v27VO22bRpE8aNGwcAWLRokdIWIc+pcDerobGxEXfddRfy8vKg1+sxYMAA/OMf/4Aoik7bBXJceLJlyxYcP34cV111Fa666ips3rwZp06dctnOarXin//8J4YNG4aYmBhkZmZi5syZ2Llzp9N2b7zxBsaPH4+4uDikpqZi8uTJ+PLLL5322XFWhqz1HAz5+/L111/jlltuQVZWFnJzcwEAJ06cwC233IIBAwYgNjYW6enpuPzyy93O26ipqcGdd96J/Px86PV65ObmYv78+aioqEBDQwPi4+Px+9//3uV2p06dglarxYoVK/x8JYmIKBLxfSPfN0bS+0ZfysvLcf3116Nbt26IiYnBiBEj8J///Mdlu3feeQdjxoxBYmIikpKSMGzYMPzzn/9Urm9pacHy5cvRr18/xMTEID09Heeeey7WrVun2r4SBYp/YqAup7KyErNmzcJVV12F3/72t+jWrRsA6T+7hIQELF26FAkJCfjqq6+wbNky1NXV4bHHHvN5v2+99Rbq6+tx4403QhAE/P3vf8ell16KY8eO+fwLzrfffouPPvoIt9xyCxITE/Gvf/0Ll112GYqLi5Geng4A2LNnD2bOnInu3btj+fLlsFgseOSRR5CZmenX837//ffR1NSEm2++Genp6di+fTueeuopnDp1Cu+//77TthaLBTNmzMCECRPwj3/8A+vXr8fjjz+OgoIC3HzzzQCkNwIXX3wxvv32W9x0000YNGgQVq9ejQULFvi1P/PmzcPy5cvx1ltvYfTo0U6P/d577+G8885Dz549UVFRgZdeeglXX301brjhBtTX1+Pll1/GjBkzsH37dpcycV+WLVuGv/zlL5g9ezZmz56N3bt344ILLoDJZHLa7tixY1izZg0uv/xy9O7dG2VlZXjhhRcwZcoUHDx4EDk5ORg0aBAeeeQRLFu2DL/73e9w3nnnAQAmTZrk9rFFUcSvf/1rbNy4Eddffz1GjhyJtWvX4g9/+ANKSkrw5JNPOm3vz3HhzZtvvomCggKMGzcOQ4cORVxcHN5++2384Q9/cNru+uuvx6pVqzBr1iwsXrwYZrMZ33zzDb777juMHTsWALB8+XI8/PDDmDRpEh555BFER0fj+++/x1dffYULLrjA79ff0S233ILMzEwsW7YMjY2NAIAdO3Zg69atuOqqq5Cbm4vjx4/jueeew9SpU3Hw4EHlr+wNDQ0477zzcOjQIVx33XUYPXo0Kioq8Mknn+DUqVMYOXIkLrnkErz77rt44oknnP6C+/bbb0MURcybNy+o/SYiosjB94183xgp7xu9aW5uxtSpU1FYWIglS5agd+/eeP/997Fw4ULU1NQof2hct24drr76avzqV7/C3/72NwDSvNktW7Yo2zz88MNYsWIFFi9ejPHjx6Ourg47d+7E7t27cf7554e0n0RBE4k6qVtvvVVsfQhPmTJFBCA+//zzLts3NTW5XHbjjTeKcXFxosFgUC5bsGCB2KtXL+XroqIiEYCYnp4uVlVVKZd//PHHIgDxv//9r3LZQw895LJPAMTo6GixsLBQuWzfvn0iAPGpp55SLpszZ44YFxcnlpSUKJcdOXJE1Ol0Lvfpjrvnt2LFClEQBPHEiRNOzw+A+MgjjzhtO2rUKHHMmDHK12vWrBEBiH//+9+Vy8xms3jeeeeJAMRXX33V5z6NGzdOzM3NFS0Wi3LZF198IQIQX3jhBeU+jUaj0+2qq6vFbt26idddd53T5QDEhx56SPn61VdfFQGIRUVFoiiKYnl5uRgdHS1eeOGFotVqVba7//77RQDiggULlMsMBoPTfomi9L3W6/VOr82OHTs8Pt/Wx4r8mv3lL39x2u43v/mNKAiC0zHg73HhiclkEtPT08UHHnhAueyaa64RR4wY4bTdV199JQIQb7/9dpf7kF+jI0eOiBqNRrzkkktcXhPH17H16y/r1auX02srf1/OPfdc0Ww2O23r7jjdtm2bCEB87bXXlMuWLVsmAhA/+ugjj/u9du1aEYD4+eefO10/fPhwccqUKS63IyKiyMX3jb6fH983Srra+0b5mHzsscc8brNy5UoRgPjGG28ol5lMJnHixIliQkKCWFdXJ4qiKP7+978Xk5KSXN7fORoxYoR44YUXet0norbGVkfqcvR6PRYtWuRyeWxsrPLv+vp6VFRU4LzzzkNTUxMOHz7s836vvPJKpKamKl/Lf8U5duyYz9tOnz4dBQUFytfDhw9HUlKScluLxYL169dj7ty5yMnJUbbr27cvZs2a5fP+Aefn19jYiIqKCkyaNAmiKGLPnj0u2990001OX5933nlOz+Wzzz6DTqdT/pIHSLMRbrvtNr/2B5Dma5w6dQqbN29WLnvrrbcQHR2Nyy+/XLnP6OhoAFJLXlVVFcxmM8aOHeu23N2b9evXw2Qy4bbbbnMq87/jjjtcttXr9dBopF+BFosFlZWVSEhIwIABAwJ+XNlnn30GrVaL22+/3enyu+66C6Io4vPPP3e63Ndx4c3nn3+OyspKXH311cplV199Nfbt2+d
|
||
|
"text/plain": [
|
||
|
"<Figure size 1500x800 with 2 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"acc = history.history['accuracy']\n",
|
||
|
"val_acc = history.history['val_accuracy']\n",
|
||
|
"\n",
|
||
|
"loss = history.history['loss']\n",
|
||
|
"val_loss = history.history['val_loss']\n",
|
||
|
"\n",
|
||
|
"epochs_range = range(epochs)\n",
|
||
|
"\n",
|
||
|
"plt.figure(figsize=(15, 8))\n",
|
||
|
"plt.subplot(1, 2, 1)\n",
|
||
|
"plt.plot(epochs_range, acc, label='Training Accuracy')\n",
|
||
|
"plt.plot(epochs_range, val_acc, label='Validation Accuracy')\n",
|
||
|
"plt.legend(loc='lower right')\n",
|
||
|
"plt.title('Training and Validation Accuracy')\n",
|
||
|
"\n",
|
||
|
"plt.subplot(1, 2, 2)\n",
|
||
|
"plt.plot(epochs_range, loss, label='Training Loss')\n",
|
||
|
"plt.plot(epochs_range, val_loss, label='Validation Loss')\n",
|
||
|
"plt.legend(loc='upper right')\n",
|
||
|
"plt.title('Training and Validation Loss')\n",
|
||
|
"plt.show()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "KuTEoGFYd8aM"
|
||
|
},
|
||
|
"source": [
|
||
|
"## Convert to a TensorFlow Lite model"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "FQgTqbvPvxGJ"
|
||
|
},
|
||
|
"source": [
|
||
|
"### Convert using integer-only quantization"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "rTe8avZJHMDO"
|
||
|
},
|
||
|
"source": [
|
||
|
"To quantize the variable data (such as model input/output and intermediates between layers), you need to provide a [`RepresentativeDataset`](https://www.tensorflow.org/api_docs/python/tf/lite/RepresentativeDataset). This is a generator function that provides a set of input data that's large enough to represent typical values. It allows the converter to estimate a dynamic range for all the variable data. (The dataset does not need to be unique compared to the training or evaluation dataset.)\n",
|
||
|
"To support multiple inputs, each representative data point is a list and elements in the list are fed to the model according to their indices.\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "mwR9keYAwArA"
|
||
|
},
|
||
|
"source": [
|
||
|
"To quantize the input and output tensors, and make the converter throw an error if it encounters an operation it cannot quantize, convert the model again with some additional parameters:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 9,
|
||
|
"metadata": {
|
||
|
"id": "kzjEjcDs3BHa"
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"INFO:tensorflow:Assets written to: /tmp/tmpurjcrmlo/assets\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"INFO:tensorflow:Assets written to: /tmp/tmpurjcrmlo/assets\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Saved artifact at '/tmp/tmpurjcrmlo'. The following endpoints are available:\n",
|
||
|
"\n",
|
||
|
"* Endpoint 'serve'\n",
|
||
|
" args_0 (POSITIONAL_ONLY): TensorSpec(shape=(None, 120, 120, 3), dtype=tf.float32, name='keras_tensor_158')\n",
|
||
|
"Output Type:\n",
|
||
|
" TensorSpec(shape=(None, 5), dtype=tf.float32, name=None)\n",
|
||
|
"Captures:\n",
|
||
|
" 131556059225376: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556070830352: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556070832640: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556070827712: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556070831936: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556070830176: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061018800: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061017744: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061014400: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061009472: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061012288: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061010704: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061005248: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061009296: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061013520: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061005952: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061284832: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061282896: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061282544: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061285008: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061293104: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061292048: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061294688: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061284480: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061292576: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061297680: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061121168: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061119232: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061121520: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061121344: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061126976: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061125920: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061128384: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061124512: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061127152: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061134368: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061130848: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061130496: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061131552: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061130320: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061129968: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556060929664: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556060930720: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556060926848: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556060929488: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556060936704: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556060935648: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556060932128: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556060934240: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556060936880: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556060934592: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059257088: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059259728: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059255680: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059257616: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059265888: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059264832: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059261312: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059253744: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059266064: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061130144: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059321744: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059322800: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059318928: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059321568: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059328784: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059327728: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059330368: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059319280: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059328256: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059324384: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059353456: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059353104: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059350640: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059353280: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059360672: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059359616: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059362080: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059358208: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059360848: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059364896: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061775472: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061775296: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061776704: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061777232: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061784448: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061783392: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061785856: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061781984: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556059364016: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061781632: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061907248: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061905312: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061787968: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061907424: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061915696: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061914640: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061917280: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061907776: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061915168: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061920272: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061743760: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061741824: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061744112: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061743936: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061749568: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061748512: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061750976: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061747104: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061749744: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061756960: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061753440: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061753088: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061754144: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061752912: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061752560: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556062486144: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556062487200: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556062483328: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556062485968: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556062493360: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556062492304: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556062488784: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556062490896: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556062493536: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556062491248: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061631888: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061633648: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061631536: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061632064: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061640336: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061639280: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061641744: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061629424: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061640512: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061628192: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061484608: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061485664: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061481792: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061484432: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061491648: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061490592: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061493232: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061482144: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061491120: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556061487248: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066710048: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066709696: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066707232: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066709872: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066717264: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066716208: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066718672: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066714800: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066717440: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066721488: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066182944: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066185056: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066181184: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066184704: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066191920: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066190864: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066193328: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066189456: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066192096: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066189104: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556065756256: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066190688: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066195968: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556065755200: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066196496: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556065762240: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556065764880: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556065760832: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556065762768: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556065771040: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556065761184: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556065766464: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556065768224: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556065766992: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066720432: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066615264: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066616144: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066617728: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066615616: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066611920: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066610160: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066612800: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066616496: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066614560: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066613504: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066531760: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066532816: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066528944: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066531584: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066538976: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066537920: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066540384: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066536512: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066539152: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066536864: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066268384: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066271024: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066266976: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066268912: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066277184: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066276128: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066278592: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066265040: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066277360: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066611216: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066365808: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066365456: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066362992: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066365632: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066372848: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066371792: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066374432: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066363344: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066372320: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556066377424: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057320784: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057318320: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057317440: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057320960: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057328000: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057326944: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057329408: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057325536: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057328176: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057332224: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057367120: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057366768: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057331344: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057368880: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057376096: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057375040: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057377504: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057373632: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057376272: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057373280: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057384208: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057384560: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057381552: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057382976: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057379616: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057390192: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057392832: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057388784: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057390720: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057398992: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057389136: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057394416: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057396176: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057449040: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057331168: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057455024: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057456080: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057452208: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057454848: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057463648: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057679648: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057678944: TensorSpec(shape=(), dtype=tf.resource, name=None)\n",
|
||
|
" 131556057682464: TensorSpec(shape=(), dtype=tf.resource, name=None)\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"/home/brickman/miniconda3/envs/openmv_train/lib/python3.10/site-packages/tensorflow/lite/python/convert.py:983: UserWarning: Statistics for quantized inputs were expected, but not specified; continuing anyway.\n",
|
||
|
" warnings.warn(\n",
|
||
|
"WARNING: All log messages before absl::InitializeLog() is called are written to STDERR\n",
|
||
|
"W0000 00:00:1726357234.059892 177727 tf_tfl_flatbuffer_helpers.cc:392] Ignored output_format.\n",
|
||
|
"W0000 00:00:1726357234.059913 177727 tf_tfl_flatbuffer_helpers.cc:395] Ignored drop_control_dependency.\n",
|
||
|
"fully_quantize: 0, inference_type: 6, input_inference_type: UINT8, output_inference_type: UINT8\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"def representative_data_gen():\n",
|
||
|
" for input_value in tf.data.Dataset.from_tensor_slices(train_images).batch(1).take(100):\n",
|
||
|
" yield [input_value]\n",
|
||
|
"\n",
|
||
|
"converter = tf.lite.TFLiteConverter.from_keras_model(model)\n",
|
||
|
"\n",
|
||
|
"converter._experimental_disable_per_channel_quantization_for_dense_layers = True\n",
|
||
|
"\n",
|
||
|
"converter.optimizations = [tf.lite.Optimize.DEFAULT]\n",
|
||
|
"converter.representative_dataset = representative_data_gen\n",
|
||
|
"converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS_INT8]\n",
|
||
|
"converter.target_spec.supported_types = [tf.int8]\n",
|
||
|
"converter.inference_input_type = tf.uint8\n",
|
||
|
"converter.inference_output_type = tf.uint8\n",
|
||
|
"tflite_model_quant = converter.convert()"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "wYd6NxD03yjB"
|
||
|
},
|
||
|
"source": [
|
||
|
"The internal quantization remains the same as above, but you can see the input and output tensors are now integer format:\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 10,
|
||
|
"metadata": {
|
||
|
"id": "PaNkOS-twz4k"
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"input: <class 'numpy.uint8'>\n",
|
||
|
"output: <class 'numpy.uint8'>\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"interpreter = tf.lite.Interpreter(model_content=tflite_model_quant)\n",
|
||
|
"input_type = interpreter.get_input_details()[0]['dtype']\n",
|
||
|
"print('input: ', input_type)\n",
|
||
|
"output_type = interpreter.get_output_details()[0]['dtype']\n",
|
||
|
"print('output: ', output_type)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "TO17AP84wzBb"
|
||
|
},
|
||
|
"source": [
|
||
|
"Now you have an integer quantized model that uses integer data for the model's input and output tensors, so it's compatible with integer-only hardware such as the [Edge TPU](https://coral.ai)."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "sse224YJ4KMm"
|
||
|
},
|
||
|
"source": [
|
||
|
"### Save the models as files"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "4_9nZ4nv4b9P"
|
||
|
},
|
||
|
"source": [
|
||
|
"You'll need a `.tflite` file to deploy your model on other devices. So let's save the converted model to a file and then load it when we run inferences below."
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 11,
|
||
|
"metadata": {
|
||
|
"id": "BEY59dC14uRv"
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"data": {
|
||
|
"text/plain": [
|
||
|
"2876048"
|
||
|
]
|
||
|
},
|
||
|
"execution_count": 11,
|
||
|
"metadata": {},
|
||
|
"output_type": "execute_result"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"import pathlib\n",
|
||
|
"\n",
|
||
|
"tflite_models_dir = pathlib.Path(\"models/\")\n",
|
||
|
"tflite_models_dir.mkdir(exist_ok=True, parents=True)\n",
|
||
|
"\n",
|
||
|
"# Save the quantized model:\n",
|
||
|
"tflite_model_quant_file = tflite_models_dir/\"model_quant.tflite\"\n",
|
||
|
"tflite_model_quant_file.write_bytes(tflite_model_quant)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "9t9yaTeF9fyM"
|
||
|
},
|
||
|
"source": [
|
||
|
"## Run the TensorFlow Lite model"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "L8lQHMp_asCq"
|
||
|
},
|
||
|
"source": [
|
||
|
"Now we'll run inferences using the TensorFlow Lite [`Interpreter`](https://www.tensorflow.org/api_docs/python/tf/lite/Interpreter) to confirm our model's accuracy.\n",
|
||
|
"\n",
|
||
|
"First, we need a function that runs inference with the model and images, and then return the predictions:\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 12,
|
||
|
"metadata": {
|
||
|
"id": "X092SbeWfd1A"
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Helper function to run inference on a TFLite model\n",
|
||
|
"def run_tflite_model(tflite_file, test_image_indices):\n",
|
||
|
" global test_images\n",
|
||
|
"\n",
|
||
|
" # Initialize the interpreter\n",
|
||
|
" interpreter = tf.lite.Interpreter(model_path=str(tflite_file))\n",
|
||
|
" interpreter.allocate_tensors()\n",
|
||
|
"\n",
|
||
|
" input_details = interpreter.get_input_details()[0]\n",
|
||
|
" output_details = interpreter.get_output_details()[0]\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
" predictions = np.zeros((len(test_image_indices),), dtype=int)\n",
|
||
|
" for i, test_image_index in enumerate(test_image_indices):\n",
|
||
|
" test_image = test_images[test_image_index]\n",
|
||
|
"\n",
|
||
|
" # Check if the input type is quantized, then rescale input data to uint8\n",
|
||
|
" if input_details['dtype'] == np.uint8:\n",
|
||
|
" input_scale, input_zero_point = input_details[\"quantization\"]\n",
|
||
|
" test_image = test_image / input_scale + input_zero_point\n",
|
||
|
"\n",
|
||
|
" test_image = np.expand_dims(test_image, axis=0).astype(input_details[\"dtype\"])\n",
|
||
|
" \n",
|
||
|
" interpreter.set_tensor(input_details[\"index\"], test_image)\n",
|
||
|
" interpreter.invoke()\n",
|
||
|
" output = interpreter.get_tensor(output_details[\"index\"])[0]\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
" predictions[i] = output.argmax()\n",
|
||
|
"\n",
|
||
|
" return predictions\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "2opUt_JTdyEu"
|
||
|
},
|
||
|
"source": [
|
||
|
"### Testing the model on one image\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "QpPpFPaz7eEM"
|
||
|
},
|
||
|
"source": [
|
||
|
"Now we'll test the performance of the model.\n",
|
||
|
"\n",
|
||
|
"Let's create another function to print our predictions:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 13,
|
||
|
"metadata": {
|
||
|
"id": "zR2cHRUcUZ6e"
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"import matplotlib.pylab as plt\n",
|
||
|
"\n",
|
||
|
"# Change this to test a different image\n",
|
||
|
"test_image_index = 18\n",
|
||
|
"\n",
|
||
|
"## Helper function to test the models on one image\n",
|
||
|
"def test_model(tflite_file, test_image_index):\n",
|
||
|
" global test_labels\n",
|
||
|
"\n",
|
||
|
" predictions = run_tflite_model(tflite_file, [test_image_index])\n",
|
||
|
"\n",
|
||
|
"\n",
|
||
|
" plt.imshow(test_images[test_image_index])\n",
|
||
|
" template = \" Model \\n True: {true}, Predicted: {predict}\"\n",
|
||
|
" _ = plt.title(template.format(true= str(class_names[test_labels[test_image_index]]), predict=str(class_names[predictions[0]])))\n",
|
||
|
" plt.grid(False)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "o3N6-UGl1dfE"
|
||
|
},
|
||
|
"source": [
|
||
|
"And test the model on an image:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 14,
|
||
|
"metadata": {
|
||
|
"id": "rc1i9umMcp0t"
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stderr",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"INFO: Created TensorFlow Lite XNNPACK delegate for CPU.\n"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"data": {
|
||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAakAAAHICAYAAAD0hBWkAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACtjklEQVR4nO2deZweVZX3T9Wz975vSWeDaMIiIJsRRlAjUXBBGVSG0aC8gAoq8I6OzAwgDBLFGWVABPWdAR1hGBkFlxlRRMBl2DeFQAgQsvfeT6/PWnXfPyB1fre67tP19JI8Hc7388knt6urbt3au371O+dYSilFgiAIglCB2Pt6AIIgCIJgQh5SgiAIQsUiDylBEAShYpGHlCAIglCxyENKEARBqFjkISUIgiBULPKQEgRBECoWeUgJgiAIFYs8pARBEISKRR5SgrAAOfHEE+nEE0+c0bLLli2js846a07HIwjzhTykBGGGvPLKK2RZFlmWRVdddVXgPGeeeSZZlkU1NTV7eXSCsH8gDylBmCXJZJL+4z/+Y8r0iYkJ+ulPf0rJZHIfjEoQ9g/kISUIs+Tkk0+mjRs30tNPP61N/+lPf0r5fJ7e9a537aORCcLCRx5SgjBL1qxZQ8uXL6fbbrtNm37rrbfSu9/9bmpqagpc7tvf/jYdfPDBlEgkqKuri84//3xKp9NT5vvud79LBxxwAKVSKTrmmGPo97//fWB/uVyOLr/8cjrwwAMpkUhQd3c3ffGLX6RcLjfrbRSEfYU8pARhDjjjjDPo9ttvpz2VbwYGBujXv/41/dVf/VXg/F/+8pfp/PPPp66uLvrnf/5nOu200+g73/kOnXTSSVQoFLz5/vVf/5XOO+886ujooGuuuYaOO+44ev/730/bt2/X+nNdl97//vfTP/3TP9H73vc+uv766+nUU0+lb37zm/SRj3xk/jZcEOYbJQjCjNiyZYsiIvX1r39dPfPMM4qI1O9//3ullFI33HCDqqmpURMTE2r9+vWqurraW66vr0/F43F10kknKcdxvOnf+ta3FBGpf/u3f1NKKZXP51VbW5s6/PDDVS6X8+b77ne/q4hInXDCCd60f//3f1e2bXvr38NNN92kiEj98Y9/9KYtXbpUrV+/fi53hSDMG/ImJQhzwMEHH0xvetObPAPFbbfdRh/4wAeoqqpqyry/+c1vKJ/P04UXXki2zZfgOeecQ3V1dfTf//3fRET02GOPUV9fH33qU5+ieDzuzXfWWWdRfX291ucdd9xBq1evplWrVtHAwID37x3veAcREd13331zvs2CsDeQh5QgzBF/9Vd/RXfccQe9+OKL9L//+79GqW/r1q1ERPTGN75Rmx6Px2nFihXe7/f8v3LlSm2+WCxGK1as0KZt3ryZnn32WWptbdX+veENbyAior6+vtlvoCDsA6L7egCCsL9wxhln0CWXXELnnHMONTc300knnbTX1u26Lh166KH0jW98I/D33d3de20sgjCXyENKEOaIJUuW0HHHHUf3338/ffrTn6ZoNPjyWrp0KRERbdq0SXsjyufztGXLFlq7dq023+bNmz3ZjoioUCjQli1b6LDDDvOmHXDAAfT000/TO9/5TrIsa863TRD2FSL3CcIcctVVV9Hll19On/3sZ43zrF27luLxOF133XWeG5DoVSffyMgInXLKKUREdNRRR1FrayvddNNNlM/nvfluueWWKVb1D3/4w7Rz50763ve+N2V9mUyGJiYmZrllgrBvkDcpQZhDTjjhBDrhhBNKztPa2kqXXHIJXXHFFfTud7+b3v/+99OmTZvo29/+Nh199NH013/910T06renq666is477zx6xzveQR/5yEdoy5YtdPPNN0/5JvWxj32MfvSjH9GnPvUpuu++++i4444jx3Ho+eefpx/96Ef0q1/9io466qh5225BmC/kISUI+4Avf/nL1NraSt/61rfooosuoqamJjr33HPp6quvplgs5s137rnnkuM49PWvf52+8IUv0KGHHko/+9nP6NJLL9X6s22b7rrrLvrmN79JP/jBD+jOO++kqqoqWrFiBX3+85/3DBSCsNCwFOoNgiAIglBByDcpQRAEoWKRh5QgCIJQschDShAEQahY5CElCIIgVCzykBIEQRAqFnlICYIgCBWLPKQEQfA466yzaNmyZdo0y7Loy1/+8j4ZTxBBYwzLK6+8QpZl0T/90z+VnO/+++8ny7Lo/vvvn9F6hLlDHlL7ISeeeCJZljXtv0q68Qh8A93zLxKJ0JIlS+iDH/wgPfXUU/t6eGWxceNG+vKXv0yvvPLKvh6KsMCRjBP7IX//939P/+f//B/v50cffZSuu+46+ru/+ztavXq1N/1Nb3rTvhieMA1nnHEGnXzyyeQ4Dj333HN044030i9/+Ut66KGH6PDDD9/r48lkMsZkuSY2btxIV1xxBZ144okzfuvZl7ztbW+jTCaj1fES9g3ykNoPede73qX9nEwm6brrrqN3vetddOKJJxqXm5iYoOrq6nkenTAdb37zm738fUTklYy/8cYb6Tvf+U7gMvN57JLJ5Lz0W8nYtv263O5KROS+1ylf/vKXybIs2rhxI/3VX/0VNTY20vHHH09Er8qFQQ+zoG8BruvStddeSwcffDAlk0lqb2+n8847j4aHh7X5RkZG6Pnnn6eRkZFpx6aUoquuuooWL15MVVVV9Pa3v52effZZWrZsGZ111llTtsHPLbfcQpZlTZGafvnLX9Jf/MVfUHV1NdXW1tIpp5xCzz777JTln3/+efrLv/xLampqomQySUcddRT97Gc/C1zHH//4R7r44ouptbWVqqur6YMf/CD19/dPu43lsKdMx5YtW7R1P/DAA/SZz3yG2traaPHixWVv51133UWHHHIIJZNJOuSQQ+jOO+8MXH+QNLxz5046++yzqaurixKJBC1fvpw+/elPUz6fp1tuuYVOP/10IiJ6+9vf7smX+H1nrse4e/duev7556lQKJh3pAGlFJ177rkUj8fpJz/5CREFf5M68cQT6ZBDDqGNGzfS29/+dqqqqqJFixbRNddcM6XPrVu30vvf/36qrq6mtrY2uuiii+hXv/qVfOeaAfIm9Trn9NNPp5UrV9LVV19NM0njeN5559Ett9xCn/jEJ+hzn/scbdmyhb71rW/Rk08+SX/84x+9ZKl33nknfeITn6Cbb75Ze9AEcdlll9FVV11FJ598Mp188sn0xBNP0EknnaSVqyiXf//3f6f169fTunXr6Gtf+xpNTk7SjTfeSMcffzw9+eST3sP32WefpeOOO44WLVpEX/rSl6i6upp+9KMf0amnnko//vGP6YMf/KDW72c/+1lqbGykyy+/nF555RW69tpr6YILLqD//M//nPFY/bz00ktERNTc3KxN/8xnPkOtra102WWXeaU4wm7nr3/9azrttNPooIMOog0bNtDg4CB94hOf0B52Jnbt2kXHHHMMpdNpOvfcc2nVqlW0c+dO+q//+i+anJykt73tbfS5z31uisS85//5GOMll1xC3//+92nLli1lyYuO49AnP/lJ+s///E+68847vTIpJoaHh+nd7343fehDH6IPf/jD9F//9V/0t3/7t3TooYfSe97zHiJ69a32He94B+3evZs+//nPU0dHB91222103333hR6XAChhv+eOO+5QRKTuu+8+b9rll1+uiEidccYZU+Y/4YQT1AknnDBl+vr169XSpUu9n3//+98rIlK33nqrNt/dd989ZfrNN9+siEjdfPPNJcfa19en4vG4OuWUU5Trut70v/u7v1NEpNavXz9lG/zsWdeWLVuUUkqNjY2phoYGdc4552jz9fT0qPr6em36O9/5TnXooYeqbDbrTXNdV731rW9VK1eunLKOtWvXauO86KKLVCQSUel0uuR2BrFlyxZFROqKK65Q/f39qqenR91///3qiCOOUESkfvzjH2vrPv7441WxWPSWL2c7Dz/8cNXZ2amN89e//rUiIu0YK6UUEanLL7/c+/njH/+4sm1bPfroo1O2Yc++CDrn5nOM69ev1465iT37+Otf/7oqFAr
|
||
|
"text/plain": [
|
||
|
"<Figure size 640x480 with 1 Axes>"
|
||
|
]
|
||
|
},
|
||
|
"metadata": {},
|
||
|
"output_type": "display_data"
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"test_model(tflite_model_quant_file, test_image_index)"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "LwN7uIdCd8Gw"
|
||
|
},
|
||
|
"source": [
|
||
|
"### Evaluate the model on all images"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "RFKOD4DG8XmU"
|
||
|
},
|
||
|
"source": [
|
||
|
"Now let's run the model using all the test images we loaded at the beginning:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 15,
|
||
|
"metadata": {
|
||
|
"id": "05aeAuWjvjPx"
|
||
|
},
|
||
|
"outputs": [],
|
||
|
"source": [
|
||
|
"# Helper function to evaluate a TFLite model on all images\n",
|
||
|
"def evaluate_model(tflite_file, model_type):\n",
|
||
|
" global test_images\n",
|
||
|
" global test_labels\n",
|
||
|
"\n",
|
||
|
" test_image_indices = range(test_images.shape[0])\n",
|
||
|
" predictions = run_tflite_model(tflite_file, test_image_indices)\n",
|
||
|
"\n",
|
||
|
" accuracy = (np.sum(test_labels== predictions) * 100) / len(test_images)\n",
|
||
|
"\n",
|
||
|
" print('%s model accuracy is %.4f%% (Number of test samples=%d)' % (\n",
|
||
|
" model_type, accuracy, len(test_images)))"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "markdown",
|
||
|
"metadata": {
|
||
|
"id": "Km3cY9ry8ZlG"
|
||
|
},
|
||
|
"source": [
|
||
|
"Evaluate the model:"
|
||
|
]
|
||
|
},
|
||
|
{
|
||
|
"cell_type": "code",
|
||
|
"execution_count": 16,
|
||
|
"metadata": {
|
||
|
"id": "-9cnwiPp6EGm"
|
||
|
},
|
||
|
"outputs": [
|
||
|
{
|
||
|
"name": "stdout",
|
||
|
"output_type": "stream",
|
||
|
"text": [
|
||
|
"Quantized model accuracy is 84.2105% (Number of test samples=19)\n"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"source": [
|
||
|
"evaluate_model(tflite_model_quant_file, model_type=\"Quantized\")"
|
||
|
]
|
||
|
}
|
||
|
],
|
||
|
"metadata": {
|
||
|
"colab": {
|
||
|
"collapsed_sections": [],
|
||
|
"name": "post_training_integer_quant.ipynb",
|
||
|
"provenance": [],
|
||
|
"toc_visible": true
|
||
|
},
|
||
|
"kernelspec": {
|
||
|
"display_name": "Python 3 (ipykernel)",
|
||
|
"language": "python",
|
||
|
"name": "python3"
|
||
|
},
|
||
|
"language_info": {
|
||
|
"codemirror_mode": {
|
||
|
"name": "ipython",
|
||
|
"version": 3
|
||
|
},
|
||
|
"file_extension": ".py",
|
||
|
"mimetype": "text/x-python",
|
||
|
"name": "python",
|
||
|
"nbconvert_exporter": "python",
|
||
|
"pygments_lexer": "ipython3",
|
||
|
"version": "3.10.14"
|
||
|
}
|
||
|
},
|
||
|
"nbformat": 4,
|
||
|
"nbformat_minor": 4
|
||
|
}
|