projet-reseaux-profond/notebook.ipynb

584 lines
486 KiB
Plaintext
Raw Normal View History

{
"cells": [
{
"cell_type": "code",
2022-04-05 20:38:05 +00:00
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import PIL.Image\n",
"import glob\n",
"import os\n",
"\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline"
]
},
{
"cell_type": "code",
2022-04-05 20:38:05 +00:00
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2022-04-05 20:38:05 +00:00
"/tmp/deepl/dataset_rot\n",
"['octane', 'werewolf', 'breakout', 'aftershock']\n"
]
}
],
"source": [
"IMAGE_SIZE = (400, 150, 3)\n",
"RESIZED_SIZE = (100, 50, 3)\n",
"RESIZED_SIZE_PIL = (RESIZED_SIZE[1], RESIZED_SIZE[0], RESIZED_SIZE[2])\n",
2022-04-05 20:38:05 +00:00
"DATASET_PATH = \"./dataset_rot/\"\n",
"DATASET_PATH = os.path.abspath(DATASET_PATH)\n",
2022-04-05 20:38:05 +00:00
"CLASSES = next(os.walk(DATASET_PATH))[1]\n",
"\n",
"print(DATASET_PATH)\n",
"print(CLASSES)"
]
},
{
"cell_type": "code",
2022-04-05 20:38:05 +00:00
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"def load_data():\n",
" # Récupération des fichiers\n",
" files = glob.glob(f\"{DATASET_PATH}/**/*.jpg\", recursive = True)\n",
"\n",
" # Initialise les structures de données\n",
" x = np.zeros((len(files), *RESIZED_SIZE_PIL))\n",
" y = np.zeros((len(files), 1))\n",
"\n",
" # print(f\"x.shape = {x.shape}\")\n",
"\n",
" for i, path in enumerate(files):\n",
" # Lecture de l'image\n",
" img = PIL.Image.open(path)\n",
"\n",
" # print(f\"img.size = {img.size}\")\n",
"\n",
" # Redimensionnement de l'image\n",
" img = img.resize(RESIZED_SIZE[:-1], PIL.Image.ANTIALIAS)\n",
"\n",
" # print(f\"img.size = {img.size}\")\n",
"\n",
" test = np.asarray(img)\n",
"\n",
" # print(f\"test.shape = {test.shape}\")\n",
"\n",
" # Remplissage de la variable x\n",
" x[i] = test\n",
"\n",
" # On récupère l'index dans le path\n",
" class_label = path.split(\"/\")[-2]\n",
"\n",
" # On récupère le numéro de la classe à partir du string\n",
" class_label = CLASSES.index(class_label)\n",
" \n",
" # Remplissage de la variable y\n",
" y[i] = class_label\n",
"\n",
" return x, y"
]
},
{
"cell_type": "code",
2022-04-05 20:38:05 +00:00
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"x, y = load_data()\n",
"x = x / 255"
]
},
{
"cell_type": "code",
2022-04-05 20:38:05 +00:00
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
2022-04-05 20:38:05 +00:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAxoAAAGoCAYAAADB3ZMFAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAEAAElEQVR4nOz9eax165beB/3G28w5V7ObrznNPed2VbdaY5eNkWM7VnAMGOzg0EgQmUQODhIhEgQQCgEEf0CQA5GIFYIV5ARCmyiAgiAmloIhomK7ItsBO7arynbVvXXrNqf5uv3tvVczm/d9B3+Md661vu80rlt1z7lle42j7+y91l5rrrnmfJsxnvGMZ4iqcrazne1sZzvb2c52trOd7WzfT3M/6BM429nOdrazne1sZzvb2c72t5+dA42zne1sZzvb2c52trOd7WzfdzsHGmc729nOdrazne1sZzvb2b7vdg40zna2s53tbGc729nOdrazfd/tHGic7WxnO9vZzna2s53tbGf7vts50Djb2c52trOd7WxnO9vZzvZ9t3OgcbZftYnIHxaRP3Py+HeJyC+IyEZE/jM/wFM729nO9reRndeas53tbGf7W9POgcbZvp/2TwF/TFXXqvp/+0GfzNnOdra/be281pztbH+HmYh8VURURMIP+lzO9iu3c6Dxt6mJiP8BfOxXgJ/9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XcZ7aBqlCZ5HFws6X3jQbGh94arNFC30ZWQaRnabPbt94e4us99u2dzfsu+VXa/sd3v6/Z4hKWNWnHpQx5ghqbAPHdl5Vm4iUAh5Ijrl3QeBZRt4/OAhi+h4azWCwJA9gwZe5CX
"text/plain": [
"<Figure size 864x432 with 9 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Randomisation des indices et affichage de 9 images alétoires de la base d'apprentissage\n",
"indices = np.arange(x.shape[0])\n",
"np.random.shuffle(indices)\n",
"\n",
"plt.figure(figsize=(12, 6))\n",
"\n",
"for i in range(0, 3*3):\n",
" plt.subplot(3, 3, i+1)\n",
" plt.title(CLASSES[int(y[indices[i]])])\n",
" plt.imshow(x[indices[i]])\n",
"\n",
"plt.tight_layout()\n",
"plt.show()"
]
},
{
"cell_type": "code",
2022-04-05 20:38:05 +00:00
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"import tensorflow\n",
"from tensorflow.keras.models import Sequential\n",
"from tensorflow.keras.layers import InputLayer, Dense, Flatten, Conv2D, MaxPooling2D\n",
"from tensorflow.keras import optimizers"
]
},
{
"cell_type": "code",
2022-04-05 20:38:05 +00:00
"execution_count": 8,
"metadata": {},
"outputs": [
2022-04-05 20:38:05 +00:00
{
"name": "stderr",
"output_type": "stream",
"text": [
"2022-04-05 22:28:37.416102: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA\n",
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
"2022-04-05 22:28:40.750736: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1525] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 1538 MB memory: -> device: 0, name: Quadro K620, pci bus id: 0000:03:00.0, compute capability: 5.0\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Model: \"sequential\"\n",
"_________________________________________________________________\n",
" Layer (type) Output Shape Param # \n",
"=================================================================\n",
2022-04-05 20:38:05 +00:00
" conv2d (Conv2D) (None, 48, 98, 32) 896 \n",
" \n",
" max_pooling2d (MaxPooling2D (None, 24, 49, 32) 0 \n",
" ) \n",
" \n",
2022-04-05 20:38:05 +00:00
" conv2d_1 (Conv2D) (None, 22, 47, 64) 18496 \n",
" \n",
" max_pooling2d_1 (MaxPooling (None, 11, 23, 64) 0 \n",
" 2D) \n",
" \n",
" conv2d_2 (Conv2D) (None, 9, 21, 92) 53084 \n",
" \n",
2022-04-05 20:38:05 +00:00
" max_pooling2d_2 (MaxPooling (None, 4, 10, 92) 0 \n",
" 2D) \n",
" \n",
2022-04-05 20:38:05 +00:00
" flatten (Flatten) (None, 3680) 0 \n",
" \n",
2022-04-05 20:38:05 +00:00
" dense (Dense) (None, 250) 920250 \n",
" \n",
2022-04-05 20:38:05 +00:00
" dense_1 (Dense) (None, 4) 1004 \n",
" \n",
"=================================================================\n",
2022-04-05 20:38:05 +00:00
"Total params: 993,730\n",
"Trainable params: 993,730\n",
"Non-trainable params: 0\n",
2022-04-05 20:38:05 +00:00
"_________________________________________________________________\n",
"Epoch 1/10\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
2022-04-05 20:38:05 +00:00
"2022-04-05 22:28:44.035945: I tensorflow/stream_executor/cuda/cuda_dnn.cc:368] Loaded cuDNN version 8100\n",
"2022-04-05 22:28:44.502196: W tensorflow/stream_executor/gpu/asm_compiler.cc:111] *** WARNING *** You are using ptxas 10.1.243, which is older than 11.1. ptxas before 11.1 is known to miscompile XLA code, leading to incorrect results or invalid-address errors.\n",
"\n",
"You may not need to update to CUDA 11.1; cherry-picking the ptxas binary is often sufficient.\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
2022-04-05 20:38:05 +00:00
"136/136 [==============================] - 8s 38ms/step - loss: 1.3556 - accuracy: 0.3171 - val_loss: 1.8914 - val_accuracy: 0.0000e+00\n",
"Epoch 2/10\n",
"136/136 [==============================] - 5s 35ms/step - loss: 1.2893 - accuracy: 0.6168 - val_loss: 2.0711 - val_accuracy: 0.0000e+00\n",
"Epoch 3/10\n",
"136/136 [==============================] - 5s 35ms/step - loss: 1.2347 - accuracy: 0.7135 - val_loss: 2.0556 - val_accuracy: 0.0000e+00\n",
"Epoch 4/10\n",
"136/136 [==============================] - 5s 35ms/step - loss: 1.1550 - accuracy: 0.7450 - val_loss: 1.9452 - val_accuracy: 0.0000e+00\n",
"Epoch 5/10\n",
"136/136 [==============================] - 5s 35ms/step - loss: 1.0499 - accuracy: 0.7638 - val_loss: 1.9318 - val_accuracy: 0.0000e+00\n",
"Epoch 6/10\n",
"136/136 [==============================] - 5s 35ms/step - loss: 0.9393 - accuracy: 0.7618 - val_loss: 1.7806 - val_accuracy: 0.0000e+00\n",
"Epoch 7/10\n",
"136/136 [==============================] - 5s 35ms/step - loss: 0.8375 - accuracy: 0.7762 - val_loss: 1.5481 - val_accuracy: 0.0650\n",
"Epoch 8/10\n",
"136/136 [==============================] - 5s 35ms/step - loss: 0.7452 - accuracy: 0.7985 - val_loss: 1.5029 - val_accuracy: 0.0717\n",
"Epoch 9/10\n",
"136/136 [==============================] - 5s 35ms/step - loss: 0.6600 - accuracy: 0.8229 - val_loss: 1.3571 - val_accuracy: 0.2733\n",
"Epoch 10/10\n",
"136/136 [==============================] - 5s 35ms/step - loss: 0.5855 - accuracy: 0.8603 - val_loss: 1.1708 - val_accuracy: 0.4583\n"
]
2022-04-05 20:38:05 +00:00
}
],
"source": [
"model = Sequential()\n",
"\n",
"model.add(InputLayer(input_shape=RESIZED_SIZE_PIL))\n",
"\n",
"model.add(Conv2D(32, 3, activation=\"relu\"))\n",
"model.add(MaxPooling2D(pool_size=(2, 2)))\n",
"\n",
"model.add(Conv2D(64, 3, activation=\"relu\"))\n",
"model.add(MaxPooling2D(pool_size=(2, 2)))\n",
"\n",
"model.add(Conv2D(92, 3, activation=\"relu\"))\n",
"model.add(MaxPooling2D(pool_size=(2, 2)))\n",
"\n",
"model.add(Flatten())\n",
"\n",
"model.add(Dense(250, activation=\"relu\"))\n",
"\n",
"model.add(Dense(4, activation=\"softmax\"))\n",
"\n",
"model.summary()\n",
"\n",
"adam = optimizers.Adam(learning_rate=7e-6)\n",
"model.compile(optimizer=adam, loss='sparse_categorical_crossentropy', metrics=['accuracy'])\n",
"history = model.fit(x, y, validation_split=0.15, epochs=10, batch_size=25)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEICAYAAABPgw/pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAvEElEQVR4nO3dd3hU1dbA4d8iAUIIHelgohI6ARKpoiB4BUEQRapKLCAgKljQq4iI/YqCXAVFFBTRoDRRwYKC+omUSLsSipQooUknEAIp+/tjT8gQQjJAkjMzWe/zzDMzp645SVb2rHPO3mKMQSmllO8r4nQASiml8oYmdKWU8hOa0JVSyk9oQldKKT+hCV0ppfyEJnSllPITmtD9mIgsEpEBeb2sk0QkXkQ65sN2jYhc5Xr9jog848myF7Gf/iLy3cXGqVRORK9D9y4ictztbTBwCkhzvb/fGDOz4KPyHiISD9xnjFmcx9s1QG1jzNa8WlZEQoEdQFFjTGqeBKpUDgKdDkCdzRgTkvE6p+QlIoGaJJS30N9H76AlFx8hIu1EJEFEnhCRvcA0ESknIl+JyH4ROex6XcNtnaUicp/rdbSI/J+IjHMtu0NEOl/ksmEi8rOIJIrIYhF5W0Q+Pk/cnsT4vIj86tredyJS0W3+nSLyl4gcFJGnczg+LURkr4gEuE3rISLrXa+bi8hvInJERPaIyFsiUuw825ouIi+4vX/ctc5uEbkny7JdRGSNiBwTkZ0iMsZt9s+u5yMiclxEWmUcW7f1W4vIKhE56npu7emxucDjXF5Eprk+w2ERme82r7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3oVvP56+1DeIdeEboxJFZFhwLfYSxI/MMZsEJGxQKwxZgH
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
2022-04-05 20:38:05 +00:00
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEICAYAAABPgw/pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAA4bElEQVR4nO3deZxP1f/A8dfbzJgxZmwzKFv4xmgxaAYxiOSbrREpREgRJaS+JdFXi199o5IsJftSKEtkTcgua/YtWYZsI4x9xpzfH+eDodnMfGbuLO/n4zGP+dx7z+fe99zh/TlzzrnniDEGpZRSmV8OpwNQSinlHprQlVIqi9CErpRSWYQmdKWUyiI0oSulVBahCV0ppbIITegqXiIyT0Taubusk0TkgIg8lgbnNSJyr+v1VyLSNzllU3Cd1iKyMKVxJnLe2iIS4e7zqvTn6XQAyn1E5HycTV/gCnDNtf2SMWZScs9ljGmQFmWzOmNMZ3ecR0RKAn8CXsaYGNe5JwHJ/h2q7EcTehZijPG7/lpEDgAvGmMW3V5ORDyvJwmlVNahTS7ZwPU/qUXkLRE5BowRkfwi8pOInBSRv12vi8V5z1IRedH1ur2IrBCRga6yf4pIgxSWLSUiy0QkSkQWichQEZmYQNzJifEDEVnpOt9CEQmMc/w5ETkoIpEi8k4i96eqiBwTEY84+5qKyBbX6yoislpEzojIXyIyRERyJnCusSLyYZzt/7jec1REOtxWtpGIbBKRcyJyWET6xTm8zPX9jIicF5Fq1+9tnPdXF5F1InLW9b16cu9NYkTkPtf7z4jIdhEJj3OsoYjscJ3ziIi84dof6Pr9nBGR0yKyXEQ0v6QzveHZx11AAeAeoBP2dz/GtV0CuAQMSeT9VYHdQCDwCTBKRCQFZb8FfgMCgH7Ac4lcMzkxPgs8DxQCcgL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j3o1q0bAH5+fpw/f56lS5fSr18/AgMD2bZtGyEhIUycOBERYe7cufTs2ZPcuXMTFhbG/v37E62Jnz59mg4dOrB//358fX0ZMWIEwcHB/Prrr3Tv3h2wbd7Lli3j/PnztGjRgnPnzhETE8Pw4cOpWbNmutxLTehJiLoSRbf53Ri7eSxVilZhYtOJlAko45Zziwi+Xr74evlSxL9Iis4RfS2aefvm8cXaL+j1Sy/e+/U92lZoS7eq3bi/4P1uiVNlXbVr/3PfM8/Ayy/DxYvQsOE/j7dvb79OnYLmzW89tnRpyuKIiIhg1apVeHh4cO7cOZYvX46npyeLFi2id+/eTJs27R/v2bVrF0uWLCEqKoqgoCC6dOnyjzHbmzZtYvv27RQpUoSwsDBWrlxJaGgoL730EsuWLaNUqVK0atUqyfj++9//UqlSJWbOnMnixYtp27YtmzdvZuDAgQwdOpSwsDDOnz+Pj48PI0aM4PHHH+edd97h2rVrXLx4MWU3JQU0oSdi1eFVPDfjOQ6cOUDfWn3pW6svXh7JH+SfHrw8vAgPCic8KJwtx7cweO1gxm4ey9cbvqZe6Xp0r9qdBmUakEN0QJPKuJ5++mk8PDwAOHv2LO3atWPv3r2ICNHR0fG+p1GjRnh7e+Pt7U2hQoU4fvw4xYoVu6VMlSpVbuyrWLEiBw4cwM/Pj9KlS98Y392qVStGjBiRaHwrVqy48aHy6KOPEhkZyblz5wgLC6Nnz560bt2aZs2aUaxYMSpXrkyHDh2Ijo7mySefpGLFiqm5NXdEE3o8YmJj+ODXD/hw+YeUyFuCZe2XEVYizOmwkhRcOJiR4SP5+LGPGbFhBEPXDaXxd40pU6AM3ap2o12Fdvh7+zsdpspAEqtR+/omfjwwMOU18tvlzp37xuu+fftSp04dZsyYwYEDB6gd358RgLe3943XHh4exMT8sz8qOWVSo1evXjRq1Ii
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"def plot_training_analysis():\n",
" acc = history.history['accuracy']\n",
" val_acc = history.history['val_accuracy']\n",
" loss = history.history['loss']\n",
" val_loss = history.history['val_loss']\n",
"\n",
" epochs = range(len(acc))\n",
"\n",
" plt.plot(epochs, acc, 'b', linestyle=\"--\",label='Training acc')\n",
" plt.plot(epochs, val_acc, 'g', label='Validation acc')\n",
" plt.title('Training and validation accuracy')\n",
" plt.legend()\n",
"\n",
" plt.figure()\n",
"\n",
" plt.plot(epochs, loss, 'b', linestyle=\"--\",label='Training loss')\n",
" plt.plot(epochs, val_loss,'g', label='Validation loss')\n",
" plt.title('Training and validation loss')\n",
" plt.legend()\n",
"\n",
" plt.show()\n",
"\n",
"plot_training_analysis()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2022-04-05 20:38:05 +00:00
"/tmp/deepl/data\n",
"[]\n"
]
2022-04-05 20:38:05 +00:00
}
],
"source": [
"IMAGE_SIZE = (400, 150, 3)\n",
"RESIZED_SIZE = (100, 50, 3)\n",
"RESIZED_SIZE_PIL = (RESIZED_SIZE[1], RESIZED_SIZE[0], RESIZED_SIZE[2])\n",
"DATASET_PATH = \"./data/\"\n",
"DATASET_PATH = os.path.abspath(DATASET_PATH)\n",
"CLASSES = next(os.walk(DATASET_PATH))[1]\n",
"\n",
"print(DATASET_PATH)\n",
"print(CLASSES)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
2022-04-05 20:38:05 +00:00
"dataset_length = 380870\n",
"batch size = 16\n",
"number of batchs = 23804\n",
"\n",
"train_size = 304696\n",
"validation_size = 76174\n"
]
}
],
"source": [
2022-04-05 20:38:05 +00:00
"import tensorflow as tf\n",
"import tensorflow_addons as tfa\n",
"import sqlite3\n",
"\n",
2022-04-05 20:38:05 +00:00
"AUTOTUNE = tf.data.experimental.AUTOTUNE\n",
"BATCH_SIZE = 16\n",
"\n",
2022-04-05 20:38:05 +00:00
"def customGenerator():\n",
" data = sqlite3.connect(f\"{DATASET_PATH}/index.db\").execute(\"SELECT uuid, model from data LIMIT 10000\").fetchall()\n",
"\n",
2022-04-05 20:38:05 +00:00
" for uuid, model in data:\n",
" img = tf.io.read_file(f\"{DATASET_PATH}/{uuid}.jpg\")\n",
" img = tf.image.decode_jpeg(img, channels=IMAGE_SIZE[2])\n",
" img = tf.image.convert_image_dtype(img, tf.float32)\n",
" img = tf.image.resize(img, RESIZED_SIZE[:-1])\n",
" \n",
" label = tf.convert_to_tensor(model, dtype=tf.uint8)\n",
" \n",
" # img.set_shape(RESIZED_SIZE)\n",
" # label.set_shape([])\n",
" \n",
" yield img, label\n",
"\n",
2022-04-05 20:38:05 +00:00
"def cutout(image, label):\n",
" img = tfa.image.random_cutout(image, (6, 6), constant_values=1)\n",
" return (img, label)\n",
"\n",
2022-04-05 20:38:05 +00:00
"def rotate(image,label) :\n",
" img = tfa.image.rotate(image, tf.constant(np.pi)) \n",
" return (img, label)\n",
"\n",
2022-04-05 20:38:05 +00:00
"dataset = tf.data.Dataset.from_generator(\n",
" generator=customGenerator, \n",
" output_types=(tf.float32, tf.uint8)\n",
")\n",
"\n",
"(dataset_length,) = sqlite3.connect(f\"{DATASET_PATH}/index.db\").execute(\"SELECT count(uuid) from data\").fetchone()\n",
"print(f\"dataset_length = {dataset_length}\")\n",
"print(f\"batch size = {BATCH_SIZE}\")\n",
"print(f\"number of batchs = {dataset_length // BATCH_SIZE}\")\n",
"\n",
"print()\n",
"\n",
"train_size = int(0.8 * dataset_length)\n",
"print(f\"train_size = {train_size}\")\n",
"print(f\"validation_size = {dataset_length - train_size}\")\n",
"\n",
"dataset = (\n",
" dataset.batch(BATCH_SIZE)\n",
" .prefetch(AUTOTUNE)\n",
" # .map(cutout)\n",
")\n",
"\n",
"dataset_train = dataset.take(train_size)\n",
"dataset_validate = dataset.skip(train_size)\n",
"\n",
"dataset_train = dataset_train.shuffle(10)\n",
"\n",
"# print(RESIZED_SIZE)\n",
"# for boop in dataset_train.take(2):\n",
"# print(boop)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Model: \"sequential_1\"\n",
"_________________________________________________________________\n",
" Layer (type) Output Shape Param # \n",
"=================================================================\n",
" conv2d_3 (Conv2D) (None, 98, 48, 32) 896 \n",
" \n",
" max_pooling2d_3 (MaxPooling (None, 49, 24, 32) 0 \n",
" 2D) \n",
" \n",
" conv2d_4 (Conv2D) (None, 47, 22, 64) 18496 \n",
" \n",
" max_pooling2d_4 (MaxPooling (None, 23, 11, 64) 0 \n",
" 2D) \n",
" \n",
" conv2d_5 (Conv2D) (None, 21, 9, 92) 53084 \n",
" \n",
" max_pooling2d_5 (MaxPooling (None, 10, 4, 92) 0 \n",
" 2D) \n",
" \n",
" flatten_1 (Flatten) (None, 3680) 0 \n",
" \n",
" dense_2 (Dense) (None, 250) 920250 \n",
" \n",
" dense_3 (Dense) (None, 4) 1004 \n",
" \n",
"=================================================================\n",
"Total params: 993,730\n",
"Trainable params: 993,730\n",
"Non-trainable params: 0\n",
"_________________________________________________________________\n",
"Epoch 1/10\n",
"625/625 [==============================] - 89s 139ms/step - loss: 0.7095\n",
"Epoch 2/10\n",
"625/625 [==============================] - 37s 59ms/step - loss: 0.4486\n",
"Epoch 3/10\n",
"625/625 [==============================] - 37s 59ms/step - loss: 0.3915\n",
"Epoch 4/10\n",
"625/625 [==============================] - 37s 59ms/step - loss: 0.3414\n",
"Epoch 5/10\n",
"625/625 [==============================] - 37s 59ms/step - loss: 0.3116\n",
"Epoch 6/10\n",
"625/625 [==============================] - 37s 59ms/step - loss: 0.2882\n",
"Epoch 7/10\n",
"625/625 [==============================] - 37s 59ms/step - loss: 0.2601\n",
"Epoch 8/10\n",
"625/625 [==============================] - 37s 59ms/step - loss: 0.2375\n",
"Epoch 9/10\n",
"625/625 [==============================] - 37s 59ms/step - loss: 0.2176\n",
"Epoch 10/10\n",
"625/625 [==============================] - 37s 59ms/step - loss: 0.1952\n"
]
}
],
"source": [
"model = Sequential([\n",
" InputLayer(input_shape=RESIZED_SIZE),\n",
" \n",
" Conv2D(32, 3, activation=\"relu\"),\n",
" MaxPooling2D(pool_size=(2, 2)),\n",
" \n",
" Conv2D(64, 3, activation=\"relu\"),\n",
" MaxPooling2D(pool_size=(2, 2)),\n",
"\n",
" Conv2D(92, 3, activation=\"relu\"),\n",
" MaxPooling2D(pool_size=(2, 2)),\n",
"\n",
" Flatten(),\n",
"\n",
" Dense(250, activation=\"relu\"),\n",
" Dense(4, activation=\"softmax\")\n",
"])\n",
"\n",
"model.summary()\n",
"\n",
2022-04-05 20:38:05 +00:00
"adam = optimizers.Adam(learning_rate=7e-6)\n",
"# model.compile(optimizer=adam, loss='sparse_categorical_crossentropy', metrics=['accuracy']) # not currently working\n",
"model.compile(optimizer=adam, loss='sparse_categorical_crossentropy')\n",
"history = model.fit(dataset_train, validation_data=dataset_validate, epochs=10)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAEICAYAAABPgw/pAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAmeUlEQVR4nO3deXiU5dn38e9JCPviAogQFFAKIiJIBAERUKygiKiAqJVSH3ct1o2i1UrVvq2t9VHfYi1q1VoU3EsRRRFZ3AmIC5sigkaxRpRd9vP545qQIQQySSa5k5nf5zjmmLmXuefMHThzzbWauyMiIlVftagDEBGR5FBCFxFJEUroIiIpQgldRCRFKKGLiKQIJXQRkRShhC5FMrOXzOznyT43Sma2wsz6lcN13cwOj71+wMxuSeTcUnzO+Wb2Smnj3Md1+5hZbrKvKxWvetQBSPKY2Ya4zTrAFmBHbPtSd5+Q6LXcfUB5nJvq3P2yZFzHzFoCnwOZ7r49du0JQ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wgknMHv2bF588UVGjhzJtddey4gRI8r0OYmU0L8CWsRtZ8X2FWU4YeX0cve730ElaVgWkQisXbuW5s1DZcGjjz6a9Ou3bduW5cuXs2LFCgAmTZpU7Ht69erFhAkTgFA336hRIxo0aMBnn33GUUcdxa9//WuOPfZYlixZwsqVKznooIO4+OKLueiii5g/f36ZY04koc8F2phZKzOrQUjakwufZGbtgP2Bt8scVYJWroTZsyvq00SkMhk9ejQ33ngjnTt3TnqJGqB27drcf//99O/fny5dulC/fn0
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"def plot_training_analysis():\n",
"# acc = history.history['accuracy']\n",
"# val_acc = history.history['val_accuracy']\n",
" loss = history.history['loss']\n",
"# val_loss = history.history['val_loss']\n",
"\n",
" epochs = range(len(loss))\n",
"\n",
"# plt.plot(epochs, acc, 'b', linestyle=\"--\",label='Training acc')\n",
"# plt.plot(epochs, val_acc, 'g', label='Validation acc')\n",
"# plt.title('Training and validation accuracy')\n",
"# plt.legend()\n",
"\n",
"# plt.figure()\n",
"\n",
" plt.plot(epochs, loss, 'b', linestyle=\"--\",label='Training loss')\n",
"# plt.plot(epochs, val_loss,'g', label='Validation loss')\n",
" plt.title('Training and validation loss')\n",
" plt.legend()\n",
"\n",
" plt.show()\n",
"\n",
"plot_training_analysis()"
]
}
],
"metadata": {
2022-04-05 20:38:05 +00:00
"interpreter": {
"hash": "e55666fbbf217aa3df372b978577f47b6009e2f78e2ec76a584f49cd54a1e62c"
},
"kernelspec": {
"display_name": ".env",
"language": "python",
"name": ".env"
},
"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.8.10"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}