├── README.md ├── LICENSE ├── .gitignore └── TinyImageNet_Network_2.ipynb /README.md: -------------------------------------------------------------------------------- 1 | # DenseNet Models for Tiny ImageNet Classification 2 | [![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/densenet-models-for-tiny-imagenet/image-classification-on-tiny-imagenet-1)](https://paperswithcode.com/sota/image-classification-on-tiny-imagenet-1?p=densenet-models-for-tiny-imagenet) 3 | 4 | 5 | ## Abstract 6 | 7 | In this paper, we present two image classification models on the Tiny ImageNet dataset. We built two very different networks from scratch based on the idea of Densely Connected Convolution Networks. The architecture of the networks is designed based on the image resolution of this specific dataset and by calculating the Receptive Field of the convolution layers. We also used some non- conventional techniques related to image augmentation and Cyclical Learning Rate to improve the accuracy of our models. The networks are trained under high constraints and low computation resources. We aimed to achieve top-1 validation accuracy of 60%; the results and error analysis are also presented. 8 | 9 | **Complete paper can be found here: [arXiv:1904.10429](https://arxiv.org/abs/1904.10429)** 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Zoheb Abai 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /TinyImageNet_Network_2.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "nbformat": 4, 3 | "nbformat_minor": 0, 4 | "metadata": { 5 | "colab": { 6 | "name": "Assignment_4.ipynb", 7 | "version": "0.3.2", 8 | "provenance": [], 9 | "collapsed_sections": [], 10 | "include_colab_link": true 11 | }, 12 | "kernelspec": { 13 | "name": "python3", 14 | "display_name": "Python 3" 15 | }, 16 | "accelerator": "GPU" 17 | }, 18 | "cells": [ 19 | { 20 | "cell_type": "markdown", 21 | "metadata": { 22 | "id": "view-in-github", 23 | "colab_type": "text" 24 | }, 25 | "source": [ 26 | "\"Open" 27 | ] 28 | }, 29 | { 30 | "metadata": { 31 | "id": "Tyav-Kv4Cluk", 32 | "colab_type": "text" 33 | }, 34 | "cell_type": "markdown", 35 | "source": [ 36 | "# Installing libraries and Downloading Dataset" 37 | ] 38 | }, 39 | { 40 | "metadata": { 41 | "id": "aMf7Mem__-f8", 42 | "colab_type": "code", 43 | "outputId": "d9ed3350-9fde-481a-b1c2-8789a0852d50", 44 | "colab": { 45 | "base_uri": "https://localhost:8080/", 46 | "height": 34 47 | } 48 | }, 49 | "cell_type": "code", 50 | "source": [ 51 | "!pip install -q keras\n", 52 | "import keras" 53 | ], 54 | "execution_count": 0, 55 | "outputs": [ 56 | { 57 | "output_type": "stream", 58 | "text": [ 59 | "Using TensorFlow backend.\n" 60 | ], 61 | "name": "stderr" 62 | } 63 | ] 64 | }, 65 | { 66 | "metadata": { 67 | "id": "JNaPivQDFCVu", 68 | "colab_type": "code", 69 | "outputId": "4817e63f-6576-4221-e379-38e2e923b8eb", 70 | "colab": { 71 | "base_uri": "https://localhost:8080/", 72 | "height": 208 73 | } 74 | }, 75 | "cell_type": "code", 76 | "source": [ 77 | "## Download the dataset and unzip it \n", 78 | "!wget http://cs231n.stanford.edu/tiny-imagenet-200.zip" 79 | ], 80 | "execution_count": 0, 81 | "outputs": [ 82 | { 83 | "output_type": "stream", 84 | "text": [ 85 | "--2019-04-14 22:31:46-- http://cs231n.stanford.edu/tiny-imagenet-200.zip\n", 86 | "Resolving cs231n.stanford.edu (cs231n.stanford.edu)... 171.64.68.10\n", 87 | "Connecting to cs231n.stanford.edu (cs231n.stanford.edu)|171.64.68.10|:80... connected.\n", 88 | "HTTP request sent, awaiting response... 200 OK\n", 89 | "Length: 248100043 (237M) [application/zip]\n", 90 | "Saving to: ‘tiny-imagenet-200.zip’\n", 91 | "\n", 92 | "tiny-imagenet-200.z 100%[===================>] 236.61M 66.7MB/s in 4.8s \n", 93 | "\n", 94 | "2019-04-14 22:31:51 (49.4 MB/s) - ‘tiny-imagenet-200.zip’ saved [248100043/248100043]\n", 95 | "\n" 96 | ], 97 | "name": "stdout" 98 | } 99 | ] 100 | }, 101 | { 102 | "metadata": { 103 | "id": "anb0832EAX1P", 104 | "colab_type": "code", 105 | "outputId": "1eb5749b-3b2f-4adc-feb2-31c8bc909b91", 106 | "colab": { 107 | "base_uri": "https://localhost:8080/", 108 | "height": 34 109 | } 110 | }, 111 | "cell_type": "code", 112 | "source": [ 113 | "!unzip -qq 'tiny-imagenet-200.zip'\n", 114 | "!ls" 115 | ], 116 | "execution_count": 0, 117 | "outputs": [ 118 | { 119 | "output_type": "stream", 120 | "text": [ 121 | "sample_data tiny-imagenet-200\ttiny-imagenet-200.zip\n" 122 | ], 123 | "name": "stdout" 124 | } 125 | ] 126 | }, 127 | { 128 | "metadata": { 129 | "id": "hQaK0yk7Aa5q", 130 | "colab_type": "code", 131 | "outputId": "1104a0f0-e34b-479b-c06e-f85fdcf78e03", 132 | "colab": { 133 | "base_uri": "https://localhost:8080/", 134 | "height": 124 135 | } 136 | }, 137 | "cell_type": "code", 138 | "source": [ 139 | "from google.colab import drive\n", 140 | "drive.mount('/content/drive')" 141 | ], 142 | "execution_count": 0, 143 | "outputs": [ 144 | { 145 | "output_type": "stream", 146 | "text": [ 147 | "Go to this URL in a browser: https://accounts.google.com/o/oauth2/auth?client_id=947318989803-6bn6qk8qdgf4n4g3pfee6491hc0brc4i.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=email%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdocs.test%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.photos.readonly%20https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fpeopleapi.readonly&response_type=code\n", 148 | "\n", 149 | "Enter your authorization code:\n", 150 | "··········\n", 151 | "Mounted at /content/drive\n" 152 | ], 153 | "name": "stdout" 154 | } 155 | ] 156 | }, 157 | { 158 | "metadata": { 159 | "id": "OE5XWyuzaj7X", 160 | "colab_type": "code", 161 | "outputId": "949ac5b2-d923-4f5a-a059-ede636050558", 162 | "colab": { 163 | "base_uri": "https://localhost:8080/", 164 | "height": 295 165 | } 166 | }, 167 | "cell_type": "code", 168 | "source": [ 169 | "!pip install git+https://github.com/keras-team/keras-contrib.git" 170 | ], 171 | "execution_count": 0, 172 | "outputs": [ 173 | { 174 | "output_type": "stream", 175 | "text": [ 176 | "Collecting git+https://github.com/keras-team/keras-contrib.git\n", 177 | " Cloning https://github.com/keras-team/keras-contrib.git to /tmp/pip-req-build-p9bsdlvh\n", 178 | "Requirement already satisfied: keras in /usr/local/lib/python3.6/dist-packages (from keras-contrib==2.0.8) (2.2.4)\n", 179 | "Requirement already satisfied: scipy>=0.14 in /usr/local/lib/python3.6/dist-packages (from keras->keras-contrib==2.0.8) (1.2.1)\n", 180 | "Requirement already satisfied: pyyaml in /usr/local/lib/python3.6/dist-packages (from keras->keras-contrib==2.0.8) (3.13)\n", 181 | "Requirement already satisfied: h5py in /usr/local/lib/python3.6/dist-packages (from keras->keras-contrib==2.0.8) (2.8.0)\n", 182 | "Requirement already satisfied: keras-applications>=1.0.6 in /usr/local/lib/python3.6/dist-packages (from keras->keras-contrib==2.0.8) (1.0.7)\n", 183 | "Requirement already satisfied: numpy>=1.9.1 in /usr/local/lib/python3.6/dist-packages (from keras->keras-contrib==2.0.8) (1.16.2)\n", 184 | "Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.6/dist-packages (from keras->keras-contrib==2.0.8) (1.11.0)\n", 185 | "Requirement already satisfied: keras-preprocessing>=1.0.5 in /usr/local/lib/python3.6/dist-packages (from keras->keras-contrib==2.0.8) (1.0.9)\n", 186 | "Building wheels for collected packages: keras-contrib\n", 187 | " Building wheel for keras-contrib (setup.py) ... \u001b[?25ldone\n", 188 | "\u001b[?25h Stored in directory: /tmp/pip-ephem-wheel-cache-kyhxk74g/wheels/eb/42/ea/ef324c6958836b1a3d4c0659214b0bae1c0a9bf151254dc93f\n", 189 | "Successfully built keras-contrib\n", 190 | "Installing collected packages: keras-contrib\n", 191 | "Successfully installed keras-contrib-2.0.8\n" 192 | ], 193 | "name": "stdout" 194 | } 195 | ] 196 | }, 197 | { 198 | "metadata": { 199 | "id": "g7LJSXVKAgPn", 200 | "colab_type": "code", 201 | "colab": {} 202 | }, 203 | "cell_type": "code", 204 | "source": [ 205 | "# Importing important libraries\n", 206 | "import numpy as np\n", 207 | "import pandas as pd\n", 208 | "from keras.models import Model, Sequential\n", 209 | "from keras.layers import Dense, Dropout, Flatten, Input, AveragePooling2D, merge, Activation, GlobalAveragePooling2D\n", 210 | "from keras.layers import Conv2D, MaxPooling2D, BatchNormalization, SeparableConv2D\n", 211 | "from keras.optimizers import Adam, RMSprop, SGD\n", 212 | "from keras.layers import Reshape, Activation, Conv2D, Input, MaxPooling2D, BatchNormalization, Flatten, Dense, Lambda\n", 213 | "from keras.layers.merge import concatenate\n", 214 | "from keras.regularizers import l2\n", 215 | "from keras.preprocessing.image import ImageDataGenerator\n", 216 | "from keras.callbacks import ReduceLROnPlateau, ModelCheckpoint\n", 217 | "from keras_contrib.callbacks import CyclicLR\n", 218 | "import imgaug as ia\n", 219 | "from imgaug import augmenters as iaa\n", 220 | "\n", 221 | "# random seed\n", 222 | "np.random.seed(seed=101)\n", 223 | "ia.seed(101)\n", 224 | "\n", 225 | "# this part will prevent tensorflow to allocate all the avaliable GPU Memory\n", 226 | "# backend\n", 227 | "import tensorflow as tf\n", 228 | "from keras import backend as k\n", 229 | "\n", 230 | "# Don't pre-allocate memory; allocate as-needed\n", 231 | "config = tf.ConfigProto()\n", 232 | "config.gpu_options.allow_growth = True\n", 233 | "\n", 234 | "# Create a session with the above options specified.\n", 235 | "k.tensorflow_backend.set_session(tf.Session(config=config))\n", 236 | "\n", 237 | "# input image dimensions\n", 238 | "img_height = 64\n", 239 | "img_width = 64\n", 240 | "channels = 3\n", 241 | "\n", 242 | "# Hyperparameters\n", 243 | "batch_size = 128\n", 244 | "num_classes = 200\n", 245 | "epochs = 24\n", 246 | "num_train = 100000\n", 247 | "num_validation = 10000" 248 | ], 249 | "execution_count": 0, 250 | "outputs": [] 251 | }, 252 | { 253 | "metadata": { 254 | "id": "Uk0y7CZXAqvq", 255 | "colab_type": "code", 256 | "outputId": "95b7130c-4d06-46b2-d7e5-f50e65f711ea", 257 | "colab": { 258 | "base_uri": "https://localhost:8080/", 259 | "height": 143 260 | } 261 | }, 262 | "cell_type": "code", 263 | "source": [ 264 | "val_data = pd.read_csv('./tiny-imagenet-200/val/val_annotations.txt', sep='\\t', header=None, \n", 265 | " names=['File', 'Class', 'X', 'Y', 'H', 'W'])\n", 266 | "val_data.drop(['X', 'Y', 'H', 'W'], axis=1, inplace=True)\n", 267 | "val_data.head(3)" 268 | ], 269 | "execution_count": 0, 270 | "outputs": [ 271 | { 272 | "output_type": "execute_result", 273 | "data": { 274 | "text/html": [ 275 | "
\n", 276 | "\n", 289 | "\n", 290 | " \n", 291 | " \n", 292 | " \n", 293 | " \n", 294 | " \n", 295 | " \n", 296 | " \n", 297 | " \n", 298 | " \n", 299 | " \n", 300 | " \n", 301 | " \n", 302 | " \n", 303 | " \n", 304 | " \n", 305 | " \n", 306 | " \n", 307 | " \n", 308 | " \n", 309 | " \n", 310 | " \n", 311 | " \n", 312 | " \n", 313 | " \n", 314 | "
FileClass
0val_0.JPEGn03444034
1val_1.JPEGn04067472
2val_2.JPEGn04070727
\n", 315 | "
" 316 | ], 317 | "text/plain": [ 318 | " File Class\n", 319 | "0 val_0.JPEG n03444034\n", 320 | "1 val_1.JPEG n04067472\n", 321 | "2 val_2.JPEG n04070727" 322 | ] 323 | }, 324 | "metadata": { 325 | "tags": [] 326 | }, 327 | "execution_count": 7 328 | } 329 | ] 330 | }, 331 | { 332 | "metadata": { 333 | "id": "IfwTLY9ZCt6p", 334 | "colab_type": "text" 335 | }, 336 | "cell_type": "markdown", 337 | "source": [ 338 | "# Image Augmentation" 339 | ] 340 | }, 341 | { 342 | "metadata": { 343 | "id": "DrMP7ZvMAt0q", 344 | "colab_type": "code", 345 | "colab": {} 346 | }, 347 | "cell_type": "code", 348 | "source": [ 349 | "# Defining Customized Imagedatagenerator using imgaug library\n", 350 | "def CustomImageDataGen(input_img):\n", 351 | " # Sometimes(0.5, ...) applies the given augmenter in 50% of all cases,\n", 352 | " # e.g. Sometimes(0.5, GaussianBlur(0.3)) would blur roughly every second\n", 353 | " # image.\n", 354 | " sometimes = lambda aug: iaa.Sometimes(0.5, aug)\n", 355 | " \n", 356 | " seq = iaa.Sequential([\n", 357 | " iaa.Fliplr(0.5), # horizontal flips\n", 358 | " iaa.Flipud(0.2), # vertical flips\n", 359 | " \n", 360 | " # Small gaussian blur with random sigma between 0 and 0.5.\n", 361 | " # But we only blur about 50% of all images.\n", 362 | " sometimes(iaa.GaussianBlur(sigma=(0, 2.0))),\n", 363 | " \n", 364 | " # crop images by -10% to 20% of their height/width\n", 365 | " sometimes(iaa.CropAndPad(\n", 366 | " percent=(-0.1, 0.2),\n", 367 | " pad_mode=ia.ALL,\n", 368 | " pad_cval=(0, 255)\n", 369 | " )),\n", 370 | " \n", 371 | " # Apply affine transformations to some of the images\n", 372 | " # - scale to 80-120% of image height/width (each axis independently)\n", 373 | " # - translate by -20 to +20 relative to height/width (per axis)\n", 374 | " # - rotate by -45 to +45 degrees\n", 375 | " # - shear by -16 to +16 degrees\n", 376 | " # - order: use nearest neighbour or bilinear interpolation (fast)\n", 377 | " # - mode: use any available mode to fill newly created pixels\n", 378 | " # see API or scikit-image for which modes are available\n", 379 | " # - cval: if the mode is constant, then use a random brightness\n", 380 | " # for the newly created pixels (e.g. sometimes black,\n", 381 | " # sometimes white)\n", 382 | " sometimes(iaa.Affine(\n", 383 | " scale={\"x\": (0.8, 1.5), \"y\": (0.8, 1.5)},\n", 384 | " translate_percent={\"x\": (-0.2, 0.2), \"y\": (-0.2, 0.2)},\n", 385 | " rotate=(-45, 45),\n", 386 | " shear=(-16, 16),\n", 387 | " order=[0, 1],\n", 388 | " cval=(0, 255),\n", 389 | " mode=ia.ALL\n", 390 | " )),\n", 391 | " \n", 392 | " #drop 2-5% percent of the original size, leading to large dropped\n", 393 | " # rectangles.\n", 394 | " sometimes(iaa.CoarseDropout(\n", 395 | " (0.03, 0.15), size_percent=(0.02, 0.05),\n", 396 | " per_channel=0.2\n", 397 | " )),\n", 398 | " \n", 399 | " # Make some images brighter and some darker.\n", 400 | " # In 20% of all cases, we sample the multiplier once per channel,\n", 401 | " # which can end up changing the color of the images.\n", 402 | " sometimes(iaa.Multiply((0.8, 1.2), per_channel=0.2)),\n", 403 | " \n", 404 | " #Improve or worsen the contrast of images.\n", 405 | " #Comment it out after third model run (extreme saturation)\n", 406 | " sometimes(iaa.ContrastNormalization((0.75, 1.5), per_channel=0.5)), \n", 407 | " ],\n", 408 | " # do all of the above augmentations in random order\n", 409 | " random_order = True) # apply augmenters in random order\n", 410 | " \n", 411 | " output_img = seq.augment_image(input_img)\n", 412 | " return output_img\n", 413 | "\n", 414 | "train_datagen = ImageDataGenerator(rescale=1/255., preprocessing_function = CustomImageDataGen)\n", 415 | "valid_datagen = ImageDataGenerator(rescale=1/255.)" 416 | ], 417 | "execution_count": 0, 418 | "outputs": [] 419 | }, 420 | { 421 | "metadata": { 422 | "id": "QC4UyaJYAxxx", 423 | "colab_type": "code", 424 | "outputId": "98c2d91d-8da6-4cba-9e69-8f17697aa681", 425 | "colab": { 426 | "base_uri": "https://localhost:8080/", 427 | "height": 34 428 | } 429 | }, 430 | "cell_type": "code", 431 | "source": [ 432 | "train_generator = train_datagen.flow_from_directory( r'./tiny-imagenet-200/train/', \n", 433 | " target_size=(img_width, img_height), \n", 434 | " batch_size=batch_size, \n", 435 | " class_mode='categorical', \n", 436 | " shuffle=True, seed=101)" 437 | ], 438 | "execution_count": 0, 439 | "outputs": [ 440 | { 441 | "output_type": "stream", 442 | "text": [ 443 | "Found 100000 images belonging to 200 classes.\n" 444 | ], 445 | "name": "stdout" 446 | } 447 | ] 448 | }, 449 | { 450 | "metadata": { 451 | "id": "GDaw-gK8Az-l", 452 | "colab_type": "code", 453 | "outputId": "2b135115-47dd-4c1c-d260-2f98411200de", 454 | "colab": { 455 | "base_uri": "https://localhost:8080/", 456 | "height": 34 457 | } 458 | }, 459 | "cell_type": "code", 460 | "source": [ 461 | "validation_generator = valid_datagen.flow_from_dataframe(val_data, directory='./tiny-imagenet-200/val/images/', \n", 462 | " x_col='File', y_col='Class', \n", 463 | " target_size=(img_width, img_height),\n", 464 | " class_mode='categorical', \n", 465 | " batch_size=batch_size, \n", 466 | " shuffle=False, seed=101)" 467 | ], 468 | "execution_count": 0, 469 | "outputs": [ 470 | { 471 | "output_type": "stream", 472 | "text": [ 473 | "Found 10000 images belonging to 200 classes.\n" 474 | ], 475 | "name": "stdout" 476 | } 477 | ] 478 | }, 479 | { 480 | "metadata": { 481 | "id": "2cfpTiutDDBt", 482 | "colab_type": "text" 483 | }, 484 | "cell_type": "markdown", 485 | "source": [ 486 | "# Model Building and Compilation" 487 | ] 488 | }, 489 | { 490 | "metadata": { 491 | "id": "8c2YkRpjDFlQ", 492 | "colab_type": "text" 493 | }, 494 | "cell_type": "markdown", 495 | "source": [ 496 | "### Below is the custom Resnet Model, where architecture is inspired from Wide-Resnet and Resnet-18 keras models. As required for the project followings have not been used :\n", 497 | "1. 1x1 for an increasing number of channels\n", 498 | "2. dropout\n", 499 | "3. fully connected layers\n", 500 | "4. test dataset for training\n", 501 | "5. pre-trained model/weights\n", 502 | "6. someone else's code " 503 | ] 504 | }, 505 | { 506 | "metadata": { 507 | "id": "WyewaBesA8RA", 508 | "colab_type": "text" 509 | }, 510 | "cell_type": "markdown", 511 | "source": [ 512 | "### Note : For running the new model after 8 hours, don't run beyond this, as the saved model contains model architecture, weights and optimizer." 513 | ] 514 | }, 515 | { 516 | "metadata": { 517 | "id": "DJ4fm3yibgcS", 518 | "colab_type": "code", 519 | "outputId": "36dc985d-ad3f-4ed0-f46c-93044c9d158d", 520 | "colab": { 521 | "base_uri": "https://localhost:8080/", 522 | "height": 89 523 | } 524 | }, 525 | "cell_type": "code", 526 | "source": [ 527 | "# Model building\n", 528 | "input = Input(shape=(img_height, img_width, channels))\n", 529 | "\n", 530 | "# Block 1\n", 531 | "layer0 = Conv2D(32, (3,3), padding='same', kernel_initializer=\"VarianceScaling\",kernel_regularizer=l2(2e-4))(input)\n", 532 | "layer0 = BatchNormalization()(layer0)\n", 533 | "layer0 = Activation('relu')(layer0)\n", 534 | "\n", 535 | "skip_connection_1 = layer0\n", 536 | "\n", 537 | "# Block 2\n", 538 | "\n", 539 | "layer1 = Conv2D(128, (3,3), padding='same', kernel_initializer=\"VarianceScaling\",kernel_regularizer=l2(2e-4))(layer0)\n", 540 | "layer1 = BatchNormalization()(layer1)\n", 541 | "layer1 = Activation('relu')(layer1)\n", 542 | "\n", 543 | "layer2 = Conv2D(128, (3,3), padding='same', kernel_initializer=\"VarianceScaling\",kernel_regularizer=l2(2e-4))(layer1)\n", 544 | "layer2 = BatchNormalization()(layer2)\n", 545 | "layer2 = Activation('relu')(layer2)\n", 546 | "\n", 547 | "layer3 = Conv2D(128, (3,3), padding='same', kernel_initializer=\"VarianceScaling\",kernel_regularizer=l2(2e-4))(layer2)\n", 548 | "layer3 = BatchNormalization()(layer3)\n", 549 | "layer3 = Activation('relu')(layer3)\n", 550 | "\n", 551 | "layer4 = Conv2D(128, (3,3), padding='same', kernel_initializer=\"VarianceScaling\",kernel_regularizer=l2(2e-4))(layer3)\n", 552 | "layer4 = BatchNormalization()(layer4)\n", 553 | "layer4 = Activation('relu')(layer4)\n", 554 | "\n", 555 | "layer5 = concatenate([skip_connection_1, layer4])\n", 556 | "layer5 = BatchNormalization()(layer5)\n", 557 | "layer5 = Activation('relu')(layer5)\n", 558 | "layer5 = MaxPooling2D(pool_size=(2, 2))(layer5)\n", 559 | "\n", 560 | "skip_connection_2 = layer5\n", 561 | "\n", 562 | "# Block 3\n", 563 | "\n", 564 | "layer6 = Conv2D(256, (3,3), padding='same', kernel_initializer=\"VarianceScaling\",kernel_regularizer=l2(2e-4))(layer5)\n", 565 | "layer6 = BatchNormalization()(layer6)\n", 566 | "layer6 = Activation('relu')(layer6)\n", 567 | "\n", 568 | "layer7 = Conv2D(256, (3,3), padding='same', kernel_initializer=\"VarianceScaling\",kernel_regularizer=l2(2e-4))(layer6)\n", 569 | "layer7 = BatchNormalization()(layer7)\n", 570 | "layer7 = Activation('relu')(layer7)\n", 571 | "\n", 572 | "layer8 = Conv2D(256, (3,3), padding='same', kernel_initializer=\"VarianceScaling\",kernel_regularizer=l2(2e-4))(layer7)\n", 573 | "layer8 = BatchNormalization()(layer8)\n", 574 | "layer8 = Activation('relu')(layer8)\n", 575 | "\n", 576 | "layer9 = Conv2D(256, (3,3), padding='same', kernel_initializer=\"VarianceScaling\",kernel_regularizer=l2(2e-4))(layer8)\n", 577 | "layer9 = BatchNormalization()(layer9)\n", 578 | "layer9 = Activation('relu')(layer9)\n", 579 | "\n", 580 | "layer10 = concatenate([skip_connection_2, layer9])\n", 581 | "layer10 = BatchNormalization()(layer10)\n", 582 | "layer10 = Activation('relu')(layer10)\n", 583 | "layer10 = MaxPooling2D(pool_size=(2, 2))(layer10)\n", 584 | "\n", 585 | "skip_connection_3 = layer10\n", 586 | "\n", 587 | "\n", 588 | "# Block 4\n", 589 | "\n", 590 | "layer11 = Conv2D(512, (3,3), padding='same', kernel_initializer=\"VarianceScaling\",kernel_regularizer=l2(2e-4))(layer10)\n", 591 | "layer11 = BatchNormalization()(layer11)\n", 592 | "layer11 = Activation('relu')(layer11)\n", 593 | "\n", 594 | "layer12 = Conv2D(512, (3,3), padding='same', kernel_initializer=\"VarianceScaling\",kernel_regularizer=l2(2e-4))(layer11)\n", 595 | "layer12 = BatchNormalization()(layer12)\n", 596 | "layer12 = Activation('relu')(layer12)\n", 597 | "\n", 598 | "layer13 = Conv2D(512, (3,3), padding='same',kernel_initializer=\"VarianceScaling\",kernel_regularizer=l2(2e-4))(layer12)\n", 599 | "layer13 = BatchNormalization()(layer13)\n", 600 | "layer13 = Activation('relu')(layer13)\n", 601 | "\n", 602 | "layer14 = Conv2D(512, (3,3), padding='same',kernel_initializer=\"VarianceScaling\",kernel_regularizer=l2(2e-4))(layer13)\n", 603 | "layer14 = BatchNormalization()(layer14)\n", 604 | "layer14 = Activation('relu')(layer14)\n", 605 | "\n", 606 | "layer15 = concatenate([skip_connection_3, layer14])\n", 607 | "layer15 = BatchNormalization()(layer15)\n", 608 | "layer15 = Activation('relu')(layer15)\n", 609 | "layer15 = MaxPooling2D(pool_size=(2, 2))(layer15)\n", 610 | "\n", 611 | "\n", 612 | "#Layer 16\n", 613 | "layer16 = Conv2D(num_classes, (1,1), padding='same',kernel_initializer=\"VarianceScaling\",kernel_regularizer=l2(2e-4))(layer15)\n", 614 | "layer16 = GlobalAveragePooling2D()(layer16)\n", 615 | "\n", 616 | "#Output Layer\n", 617 | "output = Activation('softmax')(layer16)" 618 | ], 619 | "execution_count": 0, 620 | "outputs": [ 621 | { 622 | "output_type": "stream", 623 | "text": [ 624 | "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n", 625 | "Instructions for updating:\n", 626 | "Colocations handled automatically by placer.\n" 627 | ], 628 | "name": "stdout" 629 | } 630 | ] 631 | }, 632 | { 633 | "metadata": { 634 | "id": "3og9TJvCblde", 635 | "colab_type": "code", 636 | "outputId": "cc7490b1-29d4-4a21-ff1e-1bc276f12f9d", 637 | "colab": { 638 | "base_uri": "https://localhost:8080/", 639 | "height": 2101 640 | } 641 | }, 642 | "cell_type": "code", 643 | "source": [ 644 | "# Model Summary\n", 645 | "model = Model(inputs=[input], outputs=[output])\n", 646 | "model.summary()" 647 | ], 648 | "execution_count": 0, 649 | "outputs": [ 650 | { 651 | "output_type": "stream", 652 | "text": [ 653 | "__________________________________________________________________________________________________\n", 654 | "Layer (type) Output Shape Param # Connected to \n", 655 | "==================================================================================================\n", 656 | "input_1 (InputLayer) (None, 64, 64, 3) 0 \n", 657 | "__________________________________________________________________________________________________\n", 658 | "conv2d_1 (Conv2D) (None, 64, 64, 32) 896 input_1[0][0] \n", 659 | "__________________________________________________________________________________________________\n", 660 | "batch_normalization_1 (BatchNor (None, 64, 64, 32) 128 conv2d_1[0][0] \n", 661 | "__________________________________________________________________________________________________\n", 662 | "activation_1 (Activation) (None, 64, 64, 32) 0 batch_normalization_1[0][0] \n", 663 | "__________________________________________________________________________________________________\n", 664 | "conv2d_2 (Conv2D) (None, 64, 64, 128) 36992 activation_1[0][0] \n", 665 | "__________________________________________________________________________________________________\n", 666 | "batch_normalization_2 (BatchNor (None, 64, 64, 128) 512 conv2d_2[0][0] \n", 667 | "__________________________________________________________________________________________________\n", 668 | "activation_2 (Activation) (None, 64, 64, 128) 0 batch_normalization_2[0][0] \n", 669 | "__________________________________________________________________________________________________\n", 670 | "conv2d_3 (Conv2D) (None, 64, 64, 128) 147584 activation_2[0][0] \n", 671 | "__________________________________________________________________________________________________\n", 672 | "batch_normalization_3 (BatchNor (None, 64, 64, 128) 512 conv2d_3[0][0] \n", 673 | "__________________________________________________________________________________________________\n", 674 | "activation_3 (Activation) (None, 64, 64, 128) 0 batch_normalization_3[0][0] \n", 675 | "__________________________________________________________________________________________________\n", 676 | "conv2d_4 (Conv2D) (None, 64, 64, 128) 147584 activation_3[0][0] \n", 677 | "__________________________________________________________________________________________________\n", 678 | "batch_normalization_4 (BatchNor (None, 64, 64, 128) 512 conv2d_4[0][0] \n", 679 | "__________________________________________________________________________________________________\n", 680 | "activation_4 (Activation) (None, 64, 64, 128) 0 batch_normalization_4[0][0] \n", 681 | "__________________________________________________________________________________________________\n", 682 | "conv2d_5 (Conv2D) (None, 64, 64, 128) 147584 activation_4[0][0] \n", 683 | "__________________________________________________________________________________________________\n", 684 | "batch_normalization_5 (BatchNor (None, 64, 64, 128) 512 conv2d_5[0][0] \n", 685 | "__________________________________________________________________________________________________\n", 686 | "activation_5 (Activation) (None, 64, 64, 128) 0 batch_normalization_5[0][0] \n", 687 | "__________________________________________________________________________________________________\n", 688 | "concatenate_1 (Concatenate) (None, 64, 64, 160) 0 activation_1[0][0] \n", 689 | " activation_5[0][0] \n", 690 | "__________________________________________________________________________________________________\n", 691 | "batch_normalization_6 (BatchNor (None, 64, 64, 160) 640 concatenate_1[0][0] \n", 692 | "__________________________________________________________________________________________________\n", 693 | "activation_6 (Activation) (None, 64, 64, 160) 0 batch_normalization_6[0][0] \n", 694 | "__________________________________________________________________________________________________\n", 695 | "max_pooling2d_1 (MaxPooling2D) (None, 32, 32, 160) 0 activation_6[0][0] \n", 696 | "__________________________________________________________________________________________________\n", 697 | "conv2d_6 (Conv2D) (None, 32, 32, 256) 368896 max_pooling2d_1[0][0] \n", 698 | "__________________________________________________________________________________________________\n", 699 | "batch_normalization_7 (BatchNor (None, 32, 32, 256) 1024 conv2d_6[0][0] \n", 700 | "__________________________________________________________________________________________________\n", 701 | "activation_7 (Activation) (None, 32, 32, 256) 0 batch_normalization_7[0][0] \n", 702 | "__________________________________________________________________________________________________\n", 703 | "conv2d_7 (Conv2D) (None, 32, 32, 256) 590080 activation_7[0][0] \n", 704 | "__________________________________________________________________________________________________\n", 705 | "batch_normalization_8 (BatchNor (None, 32, 32, 256) 1024 conv2d_7[0][0] \n", 706 | "__________________________________________________________________________________________________\n", 707 | "activation_8 (Activation) (None, 32, 32, 256) 0 batch_normalization_8[0][0] \n", 708 | "__________________________________________________________________________________________________\n", 709 | "conv2d_8 (Conv2D) (None, 32, 32, 256) 590080 activation_8[0][0] \n", 710 | "__________________________________________________________________________________________________\n", 711 | "batch_normalization_9 (BatchNor (None, 32, 32, 256) 1024 conv2d_8[0][0] \n", 712 | "__________________________________________________________________________________________________\n", 713 | "activation_9 (Activation) (None, 32, 32, 256) 0 batch_normalization_9[0][0] \n", 714 | "__________________________________________________________________________________________________\n", 715 | "conv2d_9 (Conv2D) (None, 32, 32, 256) 590080 activation_9[0][0] \n", 716 | "__________________________________________________________________________________________________\n", 717 | "batch_normalization_10 (BatchNo (None, 32, 32, 256) 1024 conv2d_9[0][0] \n", 718 | "__________________________________________________________________________________________________\n", 719 | "activation_10 (Activation) (None, 32, 32, 256) 0 batch_normalization_10[0][0] \n", 720 | "__________________________________________________________________________________________________\n", 721 | "concatenate_2 (Concatenate) (None, 32, 32, 416) 0 max_pooling2d_1[0][0] \n", 722 | " activation_10[0][0] \n", 723 | "__________________________________________________________________________________________________\n", 724 | "batch_normalization_11 (BatchNo (None, 32, 32, 416) 1664 concatenate_2[0][0] \n", 725 | "__________________________________________________________________________________________________\n", 726 | "activation_11 (Activation) (None, 32, 32, 416) 0 batch_normalization_11[0][0] \n", 727 | "__________________________________________________________________________________________________\n", 728 | "max_pooling2d_2 (MaxPooling2D) (None, 16, 16, 416) 0 activation_11[0][0] \n", 729 | "__________________________________________________________________________________________________\n", 730 | "conv2d_10 (Conv2D) (None, 16, 16, 512) 1917440 max_pooling2d_2[0][0] \n", 731 | "__________________________________________________________________________________________________\n", 732 | "batch_normalization_12 (BatchNo (None, 16, 16, 512) 2048 conv2d_10[0][0] \n", 733 | "__________________________________________________________________________________________________\n", 734 | "activation_12 (Activation) (None, 16, 16, 512) 0 batch_normalization_12[0][0] \n", 735 | "__________________________________________________________________________________________________\n", 736 | "conv2d_11 (Conv2D) (None, 16, 16, 512) 2359808 activation_12[0][0] \n", 737 | "__________________________________________________________________________________________________\n", 738 | "batch_normalization_13 (BatchNo (None, 16, 16, 512) 2048 conv2d_11[0][0] \n", 739 | "__________________________________________________________________________________________________\n", 740 | "activation_13 (Activation) (None, 16, 16, 512) 0 batch_normalization_13[0][0] \n", 741 | "__________________________________________________________________________________________________\n", 742 | "conv2d_12 (Conv2D) (None, 16, 16, 512) 2359808 activation_13[0][0] \n", 743 | "__________________________________________________________________________________________________\n", 744 | "batch_normalization_14 (BatchNo (None, 16, 16, 512) 2048 conv2d_12[0][0] \n", 745 | "__________________________________________________________________________________________________\n", 746 | "activation_14 (Activation) (None, 16, 16, 512) 0 batch_normalization_14[0][0] \n", 747 | "__________________________________________________________________________________________________\n", 748 | "conv2d_13 (Conv2D) (None, 16, 16, 512) 2359808 activation_14[0][0] \n", 749 | "__________________________________________________________________________________________________\n", 750 | "batch_normalization_15 (BatchNo (None, 16, 16, 512) 2048 conv2d_13[0][0] \n", 751 | "__________________________________________________________________________________________________\n", 752 | "activation_15 (Activation) (None, 16, 16, 512) 0 batch_normalization_15[0][0] \n", 753 | "__________________________________________________________________________________________________\n", 754 | "concatenate_3 (Concatenate) (None, 16, 16, 928) 0 max_pooling2d_2[0][0] \n", 755 | " activation_15[0][0] \n", 756 | "__________________________________________________________________________________________________\n", 757 | "batch_normalization_16 (BatchNo (None, 16, 16, 928) 3712 concatenate_3[0][0] \n", 758 | "__________________________________________________________________________________________________\n", 759 | "activation_16 (Activation) (None, 16, 16, 928) 0 batch_normalization_16[0][0] \n", 760 | "__________________________________________________________________________________________________\n", 761 | "max_pooling2d_3 (MaxPooling2D) (None, 8, 8, 928) 0 activation_16[0][0] \n", 762 | "__________________________________________________________________________________________________\n", 763 | "conv2d_14 (Conv2D) (None, 8, 8, 200) 185800 max_pooling2d_3[0][0] \n", 764 | "__________________________________________________________________________________________________\n", 765 | "global_average_pooling2d_1 (Glo (None, 200) 0 conv2d_14[0][0] \n", 766 | "__________________________________________________________________________________________________\n", 767 | "activation_17 (Activation) (None, 200) 0 global_average_pooling2d_1[0][0] \n", 768 | "==================================================================================================\n", 769 | "Total params: 11,822,920\n", 770 | "Trainable params: 11,812,680\n", 771 | "Non-trainable params: 10,240\n", 772 | "__________________________________________________________________________________________________\n" 773 | ], 774 | "name": "stdout" 775 | } 776 | ] 777 | }, 778 | { 779 | "metadata": { 780 | "id": "kjvjtYk6bo6h", 781 | "colab_type": "code", 782 | "colab": {} 783 | }, 784 | "cell_type": "code", 785 | "source": [ 786 | "# Compile the Model\n", 787 | "model.compile(loss='categorical_crossentropy',\n", 788 | " optimizer= RMSprop(lr= 0.0001, epsilon=1e-08),\n", 789 | " #optimizer= Adam(lr= 0.0001, epsilon=1e-08),\n", 790 | " #optimizer = SGD(momentum=0.9),\n", 791 | " metrics=['accuracy'])" 792 | ], 793 | "execution_count": 0, 794 | "outputs": [] 795 | }, 796 | { 797 | "metadata": { 798 | "id": "leAtQomIbrwq", 799 | "colab_type": "code", 800 | "outputId": "90a51ea1-2190-4938-e08d-c9f2c3f70f7a", 801 | "colab": { 802 | "base_uri": "https://localhost:8080/", 803 | "height": 1774 804 | } 805 | }, 806 | "cell_type": "code", 807 | "source": [ 808 | "# Callbacks\n", 809 | "clr = CyclicLR(base_lr=0.0001, max_lr=0.0006, step_size=4686., mode='triangular2') #Cyclic learning rate\n", 810 | "checkpointer = ModelCheckpoint(filepath=\"./drive/My Drive/Colab Notebooks/model1.hdf5\", verbose=1, save_best_only=True, monitor=\"val_acc\")\n", 811 | "\n", 812 | "# Fit the Model\n", 813 | "model.fit_generator(train_generator,\n", 814 | " epochs=epochs,\n", 815 | " steps_per_epoch= num_train // batch_size,\n", 816 | " validation_steps= num_validation // batch_size,\n", 817 | " validation_data=validation_generator,\n", 818 | " verbose=1, callbacks=[clr, checkpointer]\n", 819 | " )" 820 | ], 821 | "execution_count": 0, 822 | "outputs": [ 823 | { 824 | "output_type": "stream", 825 | "text": [ 826 | "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.\n", 827 | "Instructions for updating:\n", 828 | "Use tf.cast instead.\n", 829 | "Epoch 1/24\n", 830 | "781/781 [==============================] - 1278s 2s/step - loss: 5.4892 - acc: 0.0531 - val_loss: 5.1116 - val_acc: 0.0896\n", 831 | "\n", 832 | "Epoch 00001: val_acc improved from -inf to 0.08964, saving model to ./drive/My Drive/Colab Notebooks/model1.hdf5\n", 833 | "Epoch 2/24\n", 834 | "781/781 [==============================] - 1264s 2s/step - loss: 4.8541 - acc: 0.1075 - val_loss: 4.6112 - val_acc: 0.1277\n", 835 | "\n", 836 | "Epoch 00002: val_acc improved from 0.08964 to 0.12774, saving model to ./drive/My Drive/Colab Notebooks/model1.hdf5\n", 837 | "Epoch 3/24\n", 838 | "781/781 [==============================] - 1261s 2s/step - loss: 4.5329 - acc: 0.1398 - val_loss: 4.2920 - val_acc: 0.1792\n", 839 | "\n", 840 | "Epoch 00003: val_acc improved from 0.12774 to 0.17919, saving model to ./drive/My Drive/Colab Notebooks/model1.hdf5\n", 841 | "Epoch 4/24\n", 842 | "781/781 [==============================] - 1260s 2s/step - loss: 4.3436 - acc: 0.1672 - val_loss: 4.4600 - val_acc: 0.1747\n", 843 | "\n", 844 | "Epoch 00004: val_acc did not improve from 0.17919\n", 845 | "Epoch 5/24\n", 846 | "781/781 [==============================] - 1261s 2s/step - loss: 4.2540 - acc: 0.1897 - val_loss: 4.5503 - val_acc: 0.1690\n", 847 | "\n", 848 | "Epoch 00005: val_acc did not improve from 0.17919\n", 849 | "Epoch 6/24\n", 850 | "781/781 [==============================] - 1262s 2s/step - loss: 4.2554 - acc: 0.2038 - val_loss: 4.2981 - val_acc: 0.1975\n", 851 | "\n", 852 | "Epoch 00006: val_acc improved from 0.17919 to 0.19753, saving model to ./drive/My Drive/Colab Notebooks/model1.hdf5\n", 853 | "Epoch 7/24\n", 854 | "781/781 [==============================] - 1261s 2s/step - loss: 4.2213 - acc: 0.2280 - val_loss: 4.4195 - val_acc: 0.2100\n", 855 | "\n", 856 | "Epoch 00007: val_acc improved from 0.19753 to 0.20999, saving model to ./drive/My Drive/Colab Notebooks/model1.hdf5\n", 857 | "Epoch 8/24\n", 858 | "781/781 [==============================] - 1260s 2s/step - loss: 4.1162 - acc: 0.2603 - val_loss: 3.8854 - val_acc: 0.3006\n", 859 | "\n", 860 | "Epoch 00008: val_acc improved from 0.20999 to 0.30065, saving model to ./drive/My Drive/Colab Notebooks/model1.hdf5\n", 861 | "Epoch 9/24\n", 862 | "781/781 [==============================] - 1260s 2s/step - loss: 4.0292 - acc: 0.2897 - val_loss: 3.8679 - val_acc: 0.3186\n", 863 | "\n", 864 | "Epoch 00009: val_acc improved from 0.30065 to 0.31858, saving model to ./drive/My Drive/Colab Notebooks/model1.hdf5\n", 865 | "Epoch 10/24\n", 866 | "781/781 [==============================] - 1260s 2s/step - loss: 3.9407 - acc: 0.3208 - val_loss: 3.5981 - val_acc: 0.3888\n", 867 | "\n", 868 | "Epoch 00010: val_acc improved from 0.31858 to 0.38878, saving model to ./drive/My Drive/Colab Notebooks/model1.hdf5\n", 869 | "Epoch 11/24\n", 870 | "781/781 [==============================] - 1260s 2s/step - loss: 3.8506 - acc: 0.3477 - val_loss: 3.5686 - val_acc: 0.3970\n", 871 | "\n", 872 | "Epoch 00011: val_acc improved from 0.38878 to 0.39698, saving model to ./drive/My Drive/Colab Notebooks/model1.hdf5\n", 873 | "Epoch 12/24\n", 874 | "781/781 [==============================] - 1260s 2s/step - loss: 3.7380 - acc: 0.3784 - val_loss: 3.3921 - val_acc: 0.4448\n", 875 | "\n", 876 | "Epoch 00012: val_acc improved from 0.39698 to 0.44479, saving model to ./drive/My Drive/Colab Notebooks/model1.hdf5\n", 877 | "Epoch 13/24\n", 878 | "781/781 [==============================] - 1259s 2s/step - loss: 3.6890 - acc: 0.3960 - val_loss: 3.4859 - val_acc: 0.4324\n", 879 | "\n", 880 | "Epoch 00013: val_acc did not improve from 0.44479\n", 881 | "Epoch 14/24\n", 882 | "781/781 [==============================] - 1259s 2s/step - loss: 3.7480 - acc: 0.3913 - val_loss: 3.6663 - val_acc: 0.4066\n", 883 | "\n", 884 | "Epoch 00014: val_acc did not improve from 0.44479\n", 885 | "Epoch 15/24\n", 886 | "781/781 [==============================] - 1258s 2s/step - loss: 3.8370 - acc: 0.3845 - val_loss: 3.6244 - val_acc: 0.4306\n", 887 | "\n", 888 | "Epoch 00015: val_acc did not improve from 0.44479\n", 889 | "Epoch 16/24\n", 890 | "781/781 [==============================] - 1258s 2s/step - loss: 3.9515 - acc: 0.3797 - val_loss: 3.9649 - val_acc: 0.3845\n", 891 | "\n", 892 | "Epoch 00016: val_acc did not improve from 0.44479\n", 893 | "Epoch 17/24\n", 894 | "781/781 [==============================] - 1257s 2s/step - loss: 4.0665 - acc: 0.3755 - val_loss: 3.9659 - val_acc: 0.4072\n", 895 | "\n", 896 | "Epoch 00017: val_acc did not improve from 0.44479\n", 897 | "Epoch 18/24\n", 898 | "781/781 [==============================] - 1257s 2s/step - loss: 4.2170 - acc: 0.3731 - val_loss: 4.5771 - val_acc: 0.3226\n", 899 | "\n", 900 | "Epoch 00018: val_acc did not improve from 0.44479\n", 901 | "Epoch 19/24\n", 902 | "781/781 [==============================] - 1257s 2s/step - loss: 4.3119 - acc: 0.3793 - val_loss: 4.3162 - val_acc: 0.3989\n", 903 | "\n", 904 | "Epoch 00019: val_acc did not improve from 0.44479\n", 905 | "Epoch 20/24\n", 906 | "781/781 [==============================] - 1257s 2s/step - loss: 4.3254 - acc: 0.3968 - val_loss: 4.2296 - val_acc: 0.4241\n", 907 | "\n", 908 | "Epoch 00020: val_acc did not improve from 0.44479\n", 909 | "Epoch 21/24\n", 910 | "781/781 [==============================] - 1257s 2s/step - loss: 4.3269 - acc: 0.4147 - val_loss: 4.1991 - val_acc: 0.4487\n", 911 | "\n", 912 | "Epoch 00021: val_acc improved from 0.44479 to 0.44874, saving model to ./drive/My Drive/Colab Notebooks/model1.hdf5\n", 913 | "Epoch 22/24\n", 914 | "781/781 [==============================] - 1257s 2s/step - loss: 4.3083 - acc: 0.4343 - val_loss: 4.1095 - val_acc: 0.4899\n", 915 | "\n", 916 | "Epoch 00022: val_acc improved from 0.44874 to 0.48987, saving model to ./drive/My Drive/Colab Notebooks/model1.hdf5\n", 917 | "Epoch 23/24\n", 918 | "781/781 [==============================] - 1257s 2s/step - loss: 4.2800 - acc: 0.4533 - val_loss: 4.0496 - val_acc: 0.5100\n", 919 | "\n", 920 | "Epoch 00023: val_acc improved from 0.48987 to 0.51003, saving model to ./drive/My Drive/Colab Notebooks/model1.hdf5\n", 921 | "Epoch 24/24\n", 922 | "781/781 [==============================] - 1256s 2s/step - loss: 4.2312 - acc: 0.4747 - val_loss: 3.9833 - val_acc: 0.5326\n", 923 | "\n", 924 | "Epoch 00024: val_acc improved from 0.51003 to 0.53262, saving model to ./drive/My Drive/Colab Notebooks/model1.hdf5\n" 925 | ], 926 | "name": "stdout" 927 | }, 928 | { 929 | "output_type": "execute_result", 930 | "data": { 931 | "text/plain": [ 932 | "" 933 | ] 934 | }, 935 | "metadata": { 936 | "tags": [] 937 | }, 938 | "execution_count": 14 939 | } 940 | ] 941 | }, 942 | { 943 | "metadata": { 944 | "id": "eLxYOfqGDYgw", 945 | "colab_type": "text" 946 | }, 947 | "cell_type": "markdown", 948 | "source": [ 949 | "### After 8 hours of running and saving the model, I shall run the new model from here after skipping the above part." 950 | ] 951 | }, 952 | { 953 | "metadata": { 954 | "id": "JliA0PxJb6qj", 955 | "colab_type": "code", 956 | "outputId": "30ba5def-99d8-4845-f162-978f083a70d6", 957 | "colab": { 958 | "base_uri": "https://localhost:8080/", 959 | "height": 141 960 | } 961 | }, 962 | "cell_type": "code", 963 | "source": [ 964 | "# load the model after 8 hours\n", 965 | "from keras.models import load_model\n", 966 | "new_model = load_model(\"./drive/My Drive/Colab Notebooks/model1.hdf5\")" 967 | ], 968 | "execution_count": 0, 969 | "outputs": [ 970 | { 971 | "output_type": "stream", 972 | "text": [ 973 | "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n", 974 | "Instructions for updating:\n", 975 | "Colocations handled automatically by placer.\n", 976 | "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.\n", 977 | "Instructions for updating:\n", 978 | "Use tf.cast instead.\n" 979 | ], 980 | "name": "stdout" 981 | } 982 | ] 983 | }, 984 | { 985 | "metadata": { 986 | "id": "d_uwpycYcLDA", 987 | "colab_type": "code", 988 | "outputId": "c8557e9f-14e0-4c3a-ca01-d3aab20f6a02", 989 | "colab": { 990 | "base_uri": "https://localhost:8080/", 991 | "height": 1702 992 | } 993 | }, 994 | "cell_type": "code", 995 | "source": [ 996 | "# callbacks\n", 997 | "clr = CyclicLR(base_lr=0.00001, max_lr=0.00006, step_size=4686., mode='triangular2') #Cyclic learning rate\n", 998 | "checkpointer_2 = ModelCheckpoint(filepath=\"./drive/My Drive/Colab Notebooks/model2.hdf5\", verbose=1, save_best_only=True, monitor=\"val_acc\")\n", 999 | "# fit the model\n", 1000 | "new_model.fit_generator(train_generator,\n", 1001 | " epochs=epochs,\n", 1002 | " steps_per_epoch= num_train // batch_size,\n", 1003 | " validation_steps= num_validation // batch_size,\n", 1004 | " validation_data=validation_generator,\n", 1005 | " verbose=1, callbacks=[clr, checkpointer_2]\n", 1006 | " )" 1007 | ], 1008 | "execution_count": 0, 1009 | "outputs": [ 1010 | { 1011 | "output_type": "stream", 1012 | "text": [ 1013 | "Epoch 1/24\n", 1014 | "781/781 [==============================] - 1192s 2s/step - loss: 4.1023 - acc: 0.5072 - val_loss: 3.7772 - val_acc: 0.5795\n", 1015 | "\n", 1016 | "Epoch 00001: val_acc improved from -inf to 0.57953, saving model to ./drive/My Drive/Colab Notebooks/model2.hdf5\n", 1017 | "Epoch 2/24\n", 1018 | "781/781 [==============================] - 1180s 2s/step - loss: 4.0781 - acc: 0.5143 - val_loss: 3.7887 - val_acc: 0.5737\n", 1019 | "\n", 1020 | "Epoch 00002: val_acc did not improve from 0.57953\n", 1021 | "Epoch 3/24\n", 1022 | "781/781 [==============================] - 1177s 2s/step - loss: 4.0725 - acc: 0.5165 - val_loss: 3.7946 - val_acc: 0.5775\n", 1023 | "\n", 1024 | "Epoch 00003: val_acc did not improve from 0.57953\n", 1025 | "Epoch 4/24\n", 1026 | "781/781 [==============================] - 1177s 2s/step - loss: 4.0765 - acc: 0.5194 - val_loss: 3.8587 - val_acc: 0.5682\n", 1027 | "\n", 1028 | "Epoch 00004: val_acc did not improve from 0.57953\n", 1029 | "Epoch 5/24\n", 1030 | "781/781 [==============================] - 1178s 2s/step - loss: 4.0900 - acc: 0.5178 - val_loss: 3.8729 - val_acc: 0.5688\n", 1031 | "\n", 1032 | "Epoch 00005: val_acc did not improve from 0.57953\n", 1033 | "Epoch 6/24\n", 1034 | "781/781 [==============================] - 1178s 2s/step - loss: 4.1046 - acc: 0.5195 - val_loss: 3.8839 - val_acc: 0.5733\n", 1035 | "\n", 1036 | "Epoch 00006: val_acc did not improve from 0.57953\n", 1037 | "Epoch 7/24\n", 1038 | "781/781 [==============================] - 1179s 2s/step - loss: 4.1115 - acc: 0.5245 - val_loss: 3.8964 - val_acc: 0.5726\n", 1039 | "\n", 1040 | "Epoch 00007: val_acc did not improve from 0.57953\n", 1041 | "Epoch 8/24\n", 1042 | "781/781 [==============================] - 1179s 2s/step - loss: 4.0914 - acc: 0.5310 - val_loss: 3.8866 - val_acc: 0.5751\n", 1043 | "\n", 1044 | "Epoch 00008: val_acc did not improve from 0.57953\n", 1045 | "Epoch 9/24\n", 1046 | "781/781 [==============================] - 1179s 2s/step - loss: 4.0767 - acc: 0.5385 - val_loss: 3.8663 - val_acc: 0.5865\n", 1047 | "\n", 1048 | "Epoch 00009: val_acc improved from 0.57953 to 0.58651, saving model to ./drive/My Drive/Colab Notebooks/model2.hdf5\n", 1049 | "Epoch 10/24\n", 1050 | "781/781 [==============================] - 1177s 2s/step - loss: 4.0573 - acc: 0.5458 - val_loss: 3.8548 - val_acc: 0.5896\n", 1051 | "\n", 1052 | "Epoch 00010: val_acc improved from 0.58651 to 0.58965, saving model to ./drive/My Drive/Colab Notebooks/model2.hdf5\n", 1053 | "Epoch 11/24\n", 1054 | "781/781 [==============================] - 1179s 2s/step - loss: 4.0398 - acc: 0.5500 - val_loss: 3.8476 - val_acc: 0.5933\n", 1055 | "\n", 1056 | "Epoch 00011: val_acc improved from 0.58965 to 0.59329, saving model to ./drive/My Drive/Colab Notebooks/model2.hdf5\n", 1057 | "Epoch 12/24\n", 1058 | "781/781 [==============================] - 1179s 2s/step - loss: 4.0228 - acc: 0.5585 - val_loss: 3.8213 - val_acc: 0.6036\n", 1059 | "\n", 1060 | "Epoch 00012: val_acc improved from 0.59329 to 0.60363, saving model to ./drive/My Drive/Colab Notebooks/model2.hdf5\n", 1061 | "Epoch 13/24\n", 1062 | "781/781 [==============================] - 1178s 2s/step - loss: 4.0159 - acc: 0.5600 - val_loss: 3.8356 - val_acc: 0.6002\n", 1063 | "\n", 1064 | "Epoch 00013: val_acc did not improve from 0.60363\n", 1065 | "Epoch 14/24\n", 1066 | "781/781 [==============================] - 1177s 2s/step - loss: 4.0198 - acc: 0.5598 - val_loss: 3.8584 - val_acc: 0.5964\n", 1067 | "\n", 1068 | "Epoch 00014: val_acc did not improve from 0.60363\n", 1069 | "Epoch 15/24\n", 1070 | "781/781 [==============================] - 1177s 2s/step - loss: 4.0232 - acc: 0.5608 - val_loss: 3.8767 - val_acc: 0.5932\n", 1071 | "\n", 1072 | "Epoch 00015: val_acc did not improve from 0.60363\n", 1073 | "Epoch 16/24\n", 1074 | "781/781 [==============================] - 1178s 2s/step - loss: 4.0231 - acc: 0.5616 - val_loss: 3.8944 - val_acc: 0.5944\n", 1075 | "\n", 1076 | "Epoch 00016: val_acc did not improve from 0.60363\n", 1077 | "Epoch 17/24\n", 1078 | "781/781 [==============================] - 1178s 2s/step - loss: 4.0189 - acc: 0.5653 - val_loss: 3.9046 - val_acc: 0.5969\n", 1079 | "\n", 1080 | "Epoch 00017: val_acc did not improve from 0.60363\n", 1081 | "Epoch 18/24\n", 1082 | "781/781 [==============================] - 1178s 2s/step - loss: 4.0317 - acc: 0.5663 - val_loss: 3.9477 - val_acc: 0.5865\n", 1083 | "\n", 1084 | "Epoch 00018: val_acc did not improve from 0.60363\n", 1085 | "Epoch 19/24\n", 1086 | "781/781 [==============================] - 1177s 2s/step - loss: 4.0287 - acc: 0.5702 - val_loss: 3.9422 - val_acc: 0.5941\n", 1087 | "\n", 1088 | "Epoch 00019: val_acc did not improve from 0.60363\n", 1089 | "Epoch 20/24\n", 1090 | "781/781 [==============================] - 1177s 2s/step - loss: 4.0051 - acc: 0.5783 - val_loss: 3.9382 - val_acc: 0.5922\n", 1091 | "\n", 1092 | "Epoch 00020: val_acc did not improve from 0.60363\n", 1093 | "Epoch 21/24\n", 1094 | "781/781 [==============================] - 1176s 2s/step - loss: 3.9902 - acc: 0.5855 - val_loss: 3.9377 - val_acc: 0.5981\n", 1095 | "\n", 1096 | "Epoch 00021: val_acc did not improve from 0.60363\n", 1097 | "Epoch 22/24\n", 1098 | "781/781 [==============================] - 1178s 2s/step - loss: 3.9685 - acc: 0.5919 - val_loss: 3.9214 - val_acc: 0.6063\n", 1099 | "\n", 1100 | "Epoch 00022: val_acc improved from 0.60363 to 0.60626, saving model to ./drive/My Drive/Colab Notebooks/model2.hdf5\n", 1101 | "Epoch 23/24\n", 1102 | "781/781 [==============================] - 1180s 2s/step - loss: 3.9517 - acc: 0.6004 - val_loss: 3.9175 - val_acc: 0.6064\n", 1103 | "\n", 1104 | "Epoch 00023: val_acc improved from 0.60626 to 0.60636, saving model to ./drive/My Drive/Colab Notebooks/model2.hdf5\n", 1105 | "Epoch 24/24\n", 1106 | "781/781 [==============================] - 1181s 2s/step - loss: 3.9410 - acc: 0.6031 - val_loss: 3.9151 - val_acc: 0.6086\n", 1107 | "\n", 1108 | "Epoch 00024: val_acc improved from 0.60636 to 0.60859, saving model to ./drive/My Drive/Colab Notebooks/model2.hdf5\n" 1109 | ], 1110 | "name": "stdout" 1111 | }, 1112 | { 1113 | "output_type": "execute_result", 1114 | "data": { 1115 | "text/plain": [ 1116 | "" 1117 | ] 1118 | }, 1119 | "metadata": { 1120 | "tags": [] 1121 | }, 1122 | "execution_count": 12 1123 | } 1124 | ] 1125 | }, 1126 | { 1127 | "metadata": { 1128 | "id": "e8EkvKXqkYMk", 1129 | "colab_type": "text" 1130 | }, 1131 | "cell_type": "markdown", 1132 | "source": [ 1133 | "### After 16 hours of running and saving the model, I shall run the new model from here after skipping the above parts." 1134 | ] 1135 | }, 1136 | { 1137 | "metadata": { 1138 | "id": "QptoyV3vDz3y", 1139 | "colab_type": "text" 1140 | }, 1141 | "cell_type": "markdown", 1142 | "source": [ 1143 | "### Before further running the model, we shall analyse the accuracy of individual classes" 1144 | ] 1145 | }, 1146 | { 1147 | "metadata": { 1148 | "id": "rO9-EZlFcpU4", 1149 | "colab_type": "code", 1150 | "outputId": "c48331b7-d6c3-48be-e4f8-f49a14697b23", 1151 | "colab": { 1152 | "base_uri": "https://localhost:8080/", 1153 | "height": 141 1154 | } 1155 | }, 1156 | "cell_type": "code", 1157 | "source": [ 1158 | "# load the model after 16 hours\n", 1159 | "from keras.models import load_model\n", 1160 | "extended_model = load_model(\"/content/drive/My Drive/Colab Notebooks/model2.hdf5\")" 1161 | ], 1162 | "execution_count": 0, 1163 | "outputs": [ 1164 | { 1165 | "output_type": "stream", 1166 | "text": [ 1167 | "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n", 1168 | "Instructions for updating:\n", 1169 | "Colocations handled automatically by placer.\n", 1170 | "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.\n", 1171 | "Instructions for updating:\n", 1172 | "Use tf.cast instead.\n" 1173 | ], 1174 | "name": "stdout" 1175 | } 1176 | ] 1177 | }, 1178 | { 1179 | "metadata": { 1180 | "id": "SXtmK6DPj3iy", 1181 | "colab_type": "code", 1182 | "outputId": "3d358905-22d5-48ca-aa03-3c6cc9062996", 1183 | "colab": { 1184 | "base_uri": "https://localhost:8080/", 1185 | "height": 34 1186 | } 1187 | }, 1188 | "cell_type": "code", 1189 | "source": [ 1190 | "#Prediction\n", 1191 | "pred=extended_model.predict_generator(validation_generator, steps= np.ceil(num_validation/batch_size), verbose=1)\n", 1192 | "predicted_class_indices=np.argmax(pred,axis=1)" 1193 | ], 1194 | "execution_count": 0, 1195 | "outputs": [ 1196 | { 1197 | "output_type": "stream", 1198 | "text": [ 1199 | "79/79 [==============================] - 39s 495ms/step\n" 1200 | ], 1201 | "name": "stdout" 1202 | } 1203 | ] 1204 | }, 1205 | { 1206 | "metadata": { 1207 | "id": "p9COv3Hbj6Ar", 1208 | "colab_type": "code", 1209 | "outputId": "2f0aef6c-1ef8-4be5-c58c-b7c04ca5069a", 1210 | "colab": { 1211 | "base_uri": "https://localhost:8080/", 1212 | "height": 34 1213 | } 1214 | }, 1215 | "cell_type": "code", 1216 | "source": [ 1217 | "# Predicted class indices of 1st 10 val images\n", 1218 | "predicted_class_indices[:10]" 1219 | ], 1220 | "execution_count": 0, 1221 | "outputs": [ 1222 | { 1223 | "output_type": "execute_result", 1224 | "data": { 1225 | "text/plain": [ 1226 | "array([107, 40, 89, 69, 132, 161, 99, 73, 145, 39])" 1227 | ] 1228 | }, 1229 | "metadata": { 1230 | "tags": [] 1231 | }, 1232 | "execution_count": 13 1233 | } 1234 | ] 1235 | }, 1236 | { 1237 | "metadata": { 1238 | "id": "aTpKgD88j9QS", 1239 | "colab_type": "code", 1240 | "outputId": "b51a3c79-c9eb-4e72-b8eb-088fd3de8a2f", 1241 | "colab": { 1242 | "base_uri": "https://localhost:8080/", 1243 | "height": 34 1244 | } 1245 | }, 1246 | "cell_type": "code", 1247 | "source": [ 1248 | "# True class indices of 1st 10 val images\n", 1249 | "validation_generator.classes[:10]" 1250 | ], 1251 | "execution_count": 0, 1252 | "outputs": [ 1253 | { 1254 | "output_type": "execute_result", 1255 | "data": { 1256 | "text/plain": [ 1257 | "[107, 139, 140, 69, 69, 161, 147, 73, 145, 39]" 1258 | ] 1259 | }, 1260 | "metadata": { 1261 | "tags": [] 1262 | }, 1263 | "execution_count": 14 1264 | } 1265 | ] 1266 | }, 1267 | { 1268 | "metadata": { 1269 | "id": "uFfekTdqj_pZ", 1270 | "colab_type": "code", 1271 | "outputId": "3731e3f6-2b5e-48df-f32f-5cc719ed3893", 1272 | "colab": { 1273 | "base_uri": "https://localhost:8080/", 1274 | "height": 191 1275 | } 1276 | }, 1277 | "cell_type": "code", 1278 | "source": [ 1279 | "# Predicted classes from their indices\n", 1280 | "labels = (validation_generator.class_indices)\n", 1281 | "labels = dict((v,k) for k,v in labels.items())\n", 1282 | "predictions = [labels[k] for k in predicted_class_indices]\n", 1283 | "predictions[:10]" 1284 | ], 1285 | "execution_count": 0, 1286 | "outputs": [ 1287 | { 1288 | "output_type": "execute_result", 1289 | "data": { 1290 | "text/plain": [ 1291 | "['n03444034',\n", 1292 | " 'n02231487',\n", 1293 | " 'n03014705',\n", 1294 | " 'n02808440',\n", 1295 | " 'n03976657',\n", 1296 | " 'n04399382',\n", 1297 | " 'n03250847',\n", 1298 | " 'n02823428',\n", 1299 | " 'n04146614',\n", 1300 | " 'n02226429']" 1301 | ] 1302 | }, 1303 | "metadata": { 1304 | "tags": [] 1305 | }, 1306 | "execution_count": 15 1307 | } 1308 | ] 1309 | }, 1310 | { 1311 | "metadata": { 1312 | "id": "oinJxT-6kBtX", 1313 | "colab_type": "code", 1314 | "colab": {} 1315 | }, 1316 | "cell_type": "code", 1317 | "source": [ 1318 | "# Validation class names from words.txt\n", 1319 | "import os\n", 1320 | "class_to_name = dict()\n", 1321 | "file = open('tiny-imagenet-200/words.txt','r')\n", 1322 | "data= file.readlines()\n", 1323 | "for line in data:\n", 1324 | " words = line.strip('\\n').split('\\t')\n", 1325 | " class_to_name[words[0]] = words[1].split(',')[0]\n", 1326 | "file.close()" 1327 | ], 1328 | "execution_count": 0, 1329 | "outputs": [] 1330 | }, 1331 | { 1332 | "metadata": { 1333 | "id": "Qdo95ObikFyI", 1334 | "colab_type": "code", 1335 | "colab": {} 1336 | }, 1337 | "cell_type": "code", 1338 | "source": [ 1339 | "# Asserting Validation Class names from words.txt\n", 1340 | "validation_class_names={}\n", 1341 | "for _class in validation_generator.class_indices.keys():\n", 1342 | " validation_class_names.update({_class : class_to_name[_class]})" 1343 | ], 1344 | "execution_count": 0, 1345 | "outputs": [] 1346 | }, 1347 | { 1348 | "metadata": { 1349 | "id": "YDXz41tBkHqM", 1350 | "colab_type": "code", 1351 | "outputId": "82b5e29a-c19e-4fa8-9823-540c14e37e81", 1352 | "colab": { 1353 | "base_uri": "https://localhost:8080/", 1354 | "height": 3612 1355 | } 1356 | }, 1357 | "cell_type": "code", 1358 | "source": [ 1359 | "# Classification Report of val classes\n", 1360 | "from sklearn.metrics import confusion_matrix, classification_report\n", 1361 | "\n", 1362 | "print(classification_report(validation_generator.classes, predicted_class_indices,\n", 1363 | " #target_names=validation_generator.class_indices.keys(),\n", 1364 | " target_names=validation_class_names.values(),\n", 1365 | " digits=4))" 1366 | ], 1367 | "execution_count": 0, 1368 | "outputs": [ 1369 | { 1370 | "output_type": "stream", 1371 | "text": [ 1372 | " precision recall f1-score support\n", 1373 | "\n", 1374 | " goldfish 0.8431 0.8600 0.8515 50\n", 1375 | "European fire salamander 0.8571 0.8400 0.8485 50\n", 1376 | " bullfrog 0.6111 0.6600 0.6346 50\n", 1377 | " tailed frog 0.5532 0.5200 0.5361 50\n", 1378 | " American alligator 0.6591 0.5800 0.6170 50\n", 1379 | " boa constrictor 0.4510 0.4600 0.4554 50\n", 1380 | " trilobite 0.6774 0.8400 0.7500 50\n", 1381 | " scorpion 0.7500 0.5400 0.6279 50\n", 1382 | " black widow 0.8039 0.8200 0.8119 50\n", 1383 | " tarantula 0.6226 0.6600 0.6408 50\n", 1384 | " centipede 0.7111 0.6400 0.6737 50\n", 1385 | " goose 0.7333 0.6600 0.6947 50\n", 1386 | " koala 0.7885 0.8200 0.8039 50\n", 1387 | " jellyfish 0.7091 0.7800 0.7429 50\n", 1388 | " brain coral 0.6923 0.7200 0.7059 50\n", 1389 | " snail 0.6667 0.5600 0.6087 50\n", 1390 | " slug 0.5385 0.4200 0.4719 50\n", 1391 | " sea slug 0.7843 0.8000 0.7921 50\n", 1392 | " American lobster 0.5833 0.5600 0.5714 50\n", 1393 | " spiny lobster 0.7674 0.6600 0.7097 50\n", 1394 | " black stork 0.6984 0.8800 0.7788 50\n", 1395 | " king penguin 0.8333 0.7000 0.7609 50\n", 1396 | " albatross 0.7407 0.8000 0.7692 50\n", 1397 | " dugong 0.7500 0.9000 0.8182 50\n", 1398 | " Chihuahua 0.5714 0.4000 0.4706 50\n", 1399 | " Yorkshire terrier 0.7857 0.8800 0.8302 50\n", 1400 | " golden retriever 0.5000 0.6000 0.5455 50\n", 1401 | " Labrador retriever 0.3774 0.4000 0.3883 50\n", 1402 | " German shepherd 0.5870 0.5400 0.5625 50\n", 1403 | " standard poodle 0.3469 0.3400 0.3434 50\n", 1404 | " tabby 0.5319 0.5000 0.5155 50\n", 1405 | " Persian cat 0.8333 0.7000 0.7609 50\n", 1406 | " Egyptian cat 0.4423 0.4600 0.4510 50\n", 1407 | " cougar 0.6154 0.4800 0.5393 50\n", 1408 | " lion 0.8049 0.6600 0.7253 50\n", 1409 | " brown bear 0.5625 0.7200 0.6316 50\n", 1410 | " ladybug 0.7885 0.8200 0.8039 50\n", 1411 | " fly 0.5862 0.6800 0.6296 50\n", 1412 | " bee 0.7170 0.7600 0.7379 50\n", 1413 | " grasshopper 0.6731 0.7000 0.6863 50\n", 1414 | " walking stick 0.5102 0.5000 0.5051 50\n", 1415 | " cockroach 0.5778 0.5200 0.5474 50\n", 1416 | " mantis 0.5957 0.5600 0.5773 50\n", 1417 | " dragonfly 0.6364 0.5600 0.5957 50\n", 1418 | " monarch 0.9583 0.9200 0.9388 50\n", 1419 | " sulphur butterfly 0.8776 0.8600 0.8687 50\n", 1420 | " sea cucumber 0.6000 0.6600 0.6286 50\n", 1421 | " guinea pig 0.7632 0.5800 0.6591 50\n", 1422 | " hog 0.6552 0.3800 0.4810 50\n", 1423 | " ox 0.4694 0.4600 0.4646 50\n", 1424 | " bison 0.7255 0.7400 0.7327 50\n", 1425 | " bighorn 0.5397 0.6800 0.6018 50\n", 1426 | " gazelle 0.7736 0.8200 0.7961 50\n", 1427 | " Arabian camel 0.6170 0.5800 0.5979 50\n", 1428 | " orangutan 0.6909 0.7600 0.7238 50\n", 1429 | " chimpanzee 0.5231 0.6800 0.5913 50\n", 1430 | " baboon 0.8611 0.6200 0.7209 50\n", 1431 | " African elephant 0.6964 0.7800 0.7358 50\n", 1432 | " lesser panda 0.8298 0.7800 0.8041 50\n", 1433 | " abacus 0.7179 0.5600 0.6292 50\n", 1434 | " academic gown 0.6207 0.7200 0.6667 50\n", 1435 | " altar 0.6531 0.6400 0.6465 50\n", 1436 | " apron 0.4474 0.3400 0.3864 50\n", 1437 | " backpack 0.5536 0.6200 0.5849 50\n", 1438 | " bannister 0.3171 0.2600 0.2857 50\n", 1439 | " barbershop 0.3556 0.3200 0.3368 50\n", 1440 | " barn 0.5574 0.6800 0.6126 50\n", 1441 | " barrel 0.4667 0.4200 0.4421 50\n", 1442 | " basketball 0.7234 0.6800 0.7010 50\n", 1443 | " bathtub 0.5957 0.5600 0.5773 50\n", 1444 | " beach wagon 0.6944 0.5000 0.5814 50\n", 1445 | " beacon 0.6154 0.8000 0.6957 50\n", 1446 | " beaker 0.6222 0.5600 0.5895 50\n", 1447 | " beer bottle 0.5294 0.5400 0.5347 50\n", 1448 | " bikini 0.7442 0.6400 0.6882 50\n", 1449 | " binoculars 0.5472 0.5800 0.5631 50\n", 1450 | " birdhouse 0.7317 0.6000 0.6593 50\n", 1451 | " bow tie 0.4595 0.3400 0.3908 50\n", 1452 | " brass 0.7647 0.7800 0.7723 50\n", 1453 | " broom 0.5000 0.3400 0.4048 50\n", 1454 | " bucket 0.3043 0.2800 0.2917 50\n", 1455 | " bullet train 0.7586 0.8800 0.8148 50\n", 1456 | " butcher shop 0.6250 0.7000 0.6604 50\n", 1457 | " candle 0.6383 0.6000 0.6186 50\n", 1458 | " cannon 0.4906 0.5200 0.5049 50\n", 1459 | " cardigan 0.6122 0.6000 0.6061 50\n", 1460 | " cash machine 0.5660 0.6000 0.5825 50\n", 1461 | " CD player 0.5909 0.5200 0.5532 50\n", 1462 | " chain 0.6176 0.4200 0.5000 50\n", 1463 | " chest 0.5490 0.5600 0.5545 50\n", 1464 | " Christmas stocking 0.6957 0.6400 0.6667 50\n", 1465 | " cliff dwelling 0.5254 0.6200 0.5688 50\n", 1466 | " computer keyboard 0.7250 0.5800 0.6444 50\n", 1467 | " confectionery 0.6863 0.7000 0.6931 50\n", 1468 | " convertible 0.4909 0.5400 0.5143 50\n", 1469 | " crane 0.7143 0.5000 0.5882 50\n", 1470 | " dam 0.6111 0.4400 0.5116 50\n", 1471 | " desk 0.5833 0.5600 0.5714 50\n", 1472 | " dining table 0.5781 0.7400 0.6491 50\n", 1473 | " drumstick 0.4474 0.3400 0.3864 50\n", 1474 | " dumbbell 0.3881 0.5200 0.4444 50\n", 1475 | " flagpole 0.5763 0.6800 0.6239 50\n", 1476 | " fountain 0.5000 0.6200 0.5536 50\n", 1477 | " freight car 0.6842 0.7800 0.7290 50\n", 1478 | " frying pan 0.5556 0.5000 0.5263 50\n", 1479 | " fur coat 0.4773 0.4200 0.4468 50\n", 1480 | " gasmask 0.4894 0.4600 0.4742 50\n", 1481 | " go-kart 0.6538 0.6800 0.6667 50\n", 1482 | " gondola 0.8039 0.8200 0.8119 50\n", 1483 | " hourglass 0.5962 0.6200 0.6078 50\n", 1484 | " iPod 0.6182 0.6800 0.6476 50\n", 1485 | " jinrikisha 0.6333 0.7600 0.6909 50\n", 1486 | " kimono 0.3929 0.4400 0.4151 50\n", 1487 | " lampshade 0.5577 0.5800 0.5686 50\n", 1488 | " lawn mower 0.6364 0.4200 0.5060 50\n", 1489 | " lifeboat 0.8667 0.7800 0.8211 50\n", 1490 | " limousine 0.6604 0.7000 0.6796 50\n", 1491 | " magnetic compass 0.7500 0.7200 0.7347 50\n", 1492 | " maypole 0.6393 0.7800 0.7027 50\n", 1493 | " military uniform 0.3333 0.3400 0.3366 50\n", 1494 | " miniskirt 0.4194 0.5200 0.4643 50\n", 1495 | " moving van 0.7143 0.6000 0.6522 50\n", 1496 | " nail 0.4694 0.4600 0.4646 50\n", 1497 | " neck brace 0.3857 0.5400 0.4500 50\n", 1498 | " obelisk 0.6949 0.8200 0.7523 50\n", 1499 | " oboe 0.4286 0.4200 0.4242 50\n", 1500 | " organ 0.5574 0.6800 0.6126 50\n", 1501 | " parking meter 0.5600 0.5600 0.5600 50\n", 1502 | " pay-phone 0.5085 0.6000 0.5505 50\n", 1503 | " picket fence 0.6429 0.7200 0.6792 50\n", 1504 | " pill bottle 0.4677 0.5800 0.5179 50\n", 1505 | " plunger 0.2500 0.1600 0.1951 50\n", 1506 | " pole 0.3333 0.2000 0.2500 50\n", 1507 | " police van 0.7647 0.7800 0.7723 50\n", 1508 | " poncho 0.6170 0.5800 0.5979 50\n", 1509 | " pop bottle 0.3590 0.2800 0.3146 50\n", 1510 | " potter's wheel 0.4306 0.6200 0.5082 50\n", 1511 | " projectile 0.4490 0.4400 0.4444 50\n", 1512 | " punching bag 0.3889 0.4200 0.4038 50\n", 1513 | " reel 0.3947 0.3000 0.3409 50\n", 1514 | " refrigerator 0.5952 0.5000 0.5435 50\n", 1515 | " remote control 0.5814 0.5000 0.5376 50\n", 1516 | " rocking chair 0.7500 0.4800 0.5854 50\n", 1517 | " rugby ball 0.7818 0.8600 0.8190 50\n", 1518 | " sandal 0.5385 0.7000 0.6087 50\n", 1519 | " school bus 0.7581 0.9400 0.8393 50\n", 1520 | " scoreboard 0.8163 0.8000 0.8081 50\n", 1521 | " sewing machine 0.6667 0.4800 0.5581 50\n", 1522 | " snorkel 0.5517 0.6400 0.5926 50\n", 1523 | " sock 0.6349 0.8000 0.7080 50\n", 1524 | " sombrero 0.6842 0.5200 0.5909 50\n", 1525 | " space heater 0.5000 0.4800 0.4898 50\n", 1526 | " spider web 0.6230 0.7600 0.6847 50\n", 1527 | " sports car 0.5128 0.8000 0.6250 50\n", 1528 | " steel arch bridge 0.6800 0.6800 0.6800 50\n", 1529 | " stopwatch 0.7447 0.7000 0.7216 50\n", 1530 | " sunglasses 0.6875 0.4400 0.5366 50\n", 1531 | " suspension bridge 0.5323 0.6600 0.5893 50\n", 1532 | " swimming trunks 0.4375 0.4200 0.4286 50\n", 1533 | " syringe 0.5000 0.2200 0.3056 50\n", 1534 | " teapot 0.4576 0.5400 0.4954 50\n", 1535 | " teddy 0.6939 0.6800 0.6869 50\n", 1536 | " thatch 0.6744 0.5800 0.6237 50\n", 1537 | " torch 0.6429 0.5400 0.5870 50\n", 1538 | " tractor 0.6111 0.6600 0.6346 50\n", 1539 | " triumphal arch 0.7719 0.8800 0.8224 50\n", 1540 | " trolleybus 0.7797 0.9200 0.8440 50\n", 1541 | " turnstile 0.4717 0.5000 0.4854 50\n", 1542 | " umbrella 0.2727 0.2400 0.2553 50\n", 1543 | " vestment 0.6182 0.6800 0.6476 50\n", 1544 | " viaduct 0.6852 0.7400 0.7115 50\n", 1545 | " volleyball 0.7091 0.7800 0.7429 50\n", 1546 | " water jug 0.3000 0.2400 0.2667 50\n", 1547 | " water tower 0.7500 0.8400 0.7925 50\n", 1548 | " wok 0.6000 0.6000 0.6000 50\n", 1549 | " wooden spoon 0.3103 0.1800 0.2278 50\n", 1550 | " comic book 0.7959 0.7800 0.7879 50\n", 1551 | " plate 0.4754 0.5800 0.5225 50\n", 1552 | " guacamole 0.7917 0.7600 0.7755 50\n", 1553 | " ice cream 0.4098 0.5000 0.4505 50\n", 1554 | " ice lolly 0.4000 0.4000 0.4000 50\n", 1555 | " pretzel 0.5962 0.6200 0.6078 50\n", 1556 | " mashed potato 0.5652 0.5200 0.5417 50\n", 1557 | " cauliflower 0.8000 0.6400 0.7111 50\n", 1558 | " bell pepper 0.7679 0.8600 0.8113 50\n", 1559 | " mushroom 0.7755 0.7600 0.7677 50\n", 1560 | " orange 0.6977 0.6000 0.6452 50\n", 1561 | " lemon 0.6122 0.6000 0.6061 50\n", 1562 | " banana 0.5484 0.6800 0.6071 50\n", 1563 | " pomegranate 0.7455 0.8200 0.7810 50\n", 1564 | " meat loaf 0.5370 0.5800 0.5577 50\n", 1565 | " pizza 0.7755 0.7600 0.7677 50\n", 1566 | " potpie 0.6538 0.6800 0.6667 50\n", 1567 | " espresso 0.6324 0.8600 0.7288 50\n", 1568 | " alp 0.6034 0.7000 0.6481 50\n", 1569 | " cliff 0.5556 0.6000 0.5769 50\n", 1570 | " coral reef 0.5968 0.7400 0.6607 50\n", 1571 | " lakeside 0.4651 0.4000 0.4301 50\n", 1572 | " seashore 0.5500 0.6600 0.6000 50\n", 1573 | " acorn 0.6122 0.6000 0.6061 50\n", 1574 | "\n", 1575 | " micro avg 0.6092 0.6092 0.6092 10000\n", 1576 | " macro avg 0.6101 0.6092 0.6049 10000\n", 1577 | " weighted avg 0.6101 0.6092 0.6049 10000\n", 1578 | "\n" 1579 | ], 1580 | "name": "stdout" 1581 | } 1582 | ] 1583 | }, 1584 | { 1585 | "metadata": { 1586 | "id": "w94eggUWkJ3d", 1587 | "colab_type": "code", 1588 | "colab": {} 1589 | }, 1590 | "cell_type": "code", 1591 | "source": [ 1592 | "# Class Weight dictionary\n", 1593 | "\"\"\"class_weights = {0:1,1:1,2:1,3:1,4:1,5:1,6:1,7:1,8:1,9:1,10:1,\n", 1594 | " 11:1,12:1,13:1,14:1,15:1,16:1,17:1,18:1,19:1,20:1,\n", 1595 | " 21:1,22:1,23:1,24:1,25:1,26:1,27:1,28:1,29:1,30:1,\n", 1596 | " 31:1,32:1,33:1,34:1,35:1,36:1,37:1,38:1,39:1,40:1,\n", 1597 | " 41:1,42:1,43:1,44:1,45:1,46:1,47:1,48:1,49:1,50:1,\n", 1598 | " 51:1,52:1,53:1,54:1,55:1,56:1,57:1,58:1,59:1,60:1,\n", 1599 | " 61:1,62:1,63:1,64:1.2,65:1,66:1,67:1,68:1,69:1,70:1,\n", 1600 | " 71:1,72:1,73:1,74:1,75:1,76:1,77:1,78:1,79:1,80:1.2,\n", 1601 | " 81:1,82:1,83:1,84:1,85:1,86:1,87:1,88:1,89:1,90:1,\n", 1602 | " 91:1,92:1,93:1,94:1,95:1,96:1,97:1,98:1,99:1,100:1,\n", 1603 | " 101:1,102:1,103:1,104:1,105:1,106:1,107:1,108:1,109:1,110:1,\n", 1604 | " 111:1,112:1,113:1,114:1,115:1,116:1,117:1,118:1,119:1,120:1,\n", 1605 | " 121:1,122:1,123:1,124:1,125:1,126:1,127:1,128:1,129:1,130:1,\n", 1606 | " 131:1.2,132:1,133:1,134:1,135:1,136:1,137:1,138:1,139:1,140:1,\n", 1607 | " 141:1,142:1,143:1,144:1,145:1,146:1,147:1,148:1,149:1,150:1,\n", 1608 | " 151:1,152:1,153:1,154:1,155:1,156:1,157:1,158:1,159:1,160:1,\n", 1609 | " 161:1,162:1,163:1,164:1,165:1,166:1,167:1,168:1.2,169:1,170:1,\n", 1610 | " 171:1,172:1.2,173:1,174:1,175:1.2,176:1,177:1,178:1,179:1,180:1,\n", 1611 | " 181:1,182:1,183:1,184:1,185:1,186:1,187:1,188:1,189:1,190:1,\n", 1612 | " 191:1,192:1,193:1,194:1,195:1,196:1,197:1,198:1,199:1,\n", 1613 | " }\"\"\"" 1614 | ], 1615 | "execution_count": 0, 1616 | "outputs": [] 1617 | }, 1618 | { 1619 | "metadata": { 1620 | "id": "cAhDKnbIFtZ6", 1621 | "colab_type": "text" 1622 | }, 1623 | "cell_type": "markdown", 1624 | "source": [ 1625 | "### Though implemented the technique of weighting the classes with Low Precision, it didn't improve the validation accuracy" 1626 | ] 1627 | }, 1628 | { 1629 | "metadata": { 1630 | "id": "w_6TWZ2-kOt6", 1631 | "colab_type": "code", 1632 | "outputId": "0eaef696-5b7b-420b-ca1b-2476ca7d2808", 1633 | "colab": { 1634 | "base_uri": "https://localhost:8080/", 1635 | "height": 1702 1636 | } 1637 | }, 1638 | "cell_type": "code", 1639 | "source": [ 1640 | "# Callbacks\n", 1641 | "clr = CyclicLR(base_lr=0.00001, max_lr=0.00006, step_size=3128., mode='triangular2') #Cyclic learning rate\n", 1642 | "checkpointer_3 = ModelCheckpoint(filepath=\"/content/drive/My Drive/Colab Notebooks/model3.hdf5\", verbose=1, save_best_only=True, monitor=\"val_acc\")\n", 1643 | "# fit the model\n", 1644 | "extended_model.fit_generator(train_generator,\n", 1645 | " epochs=epochs,\n", 1646 | " steps_per_epoch= np.ceil(num_train/batch_size),\n", 1647 | " validation_steps= np.ceil(num_validation/batch_size),\n", 1648 | " validation_data=validation_generator,\n", 1649 | " verbose=1, callbacks=[clr, checkpointer_3],\n", 1650 | " )" 1651 | ], 1652 | "execution_count": 0, 1653 | "outputs": [ 1654 | { 1655 | "output_type": "stream", 1656 | "text": [ 1657 | "Epoch 1/24\n", 1658 | "782/782 [==============================] - 1233s 2s/step - loss: 4.0270 - acc: 0.5835 - val_loss: 3.9649 - val_acc: 0.6060\n", 1659 | "\n", 1660 | "Epoch 00001: val_acc improved from -inf to 0.60600, saving model to /content/drive/My Drive/Colab Notebooks/model3.hdf5\n", 1661 | "Epoch 2/24\n", 1662 | "782/782 [==============================] - 1215s 2s/step - loss: 4.0542 - acc: 0.5800 - val_loss: 4.0233 - val_acc: 0.5931\n", 1663 | "\n", 1664 | "Epoch 00002: val_acc did not improve from 0.60600\n", 1665 | "Epoch 3/24\n", 1666 | "782/782 [==============================] - 1215s 2s/step - loss: 4.0802 - acc: 0.5772 - val_loss: 4.0899 - val_acc: 0.5814\n", 1667 | "\n", 1668 | "Epoch 00003: val_acc did not improve from 0.60600\n", 1669 | "Epoch 4/24\n", 1670 | "782/782 [==============================] - 1213s 2s/step - loss: 4.1185 - acc: 0.5719 - val_loss: 4.1946 - val_acc: 0.5678\n", 1671 | "\n", 1672 | "Epoch 00004: val_acc did not improve from 0.60600\n", 1673 | "Epoch 5/24\n", 1674 | "782/782 [==============================] - 1213s 2s/step - loss: 4.1382 - acc: 0.5731 - val_loss: 4.1346 - val_acc: 0.5799\n", 1675 | "\n", 1676 | "Epoch 00005: val_acc did not improve from 0.60600\n", 1677 | "Epoch 6/24\n", 1678 | "782/782 [==============================] - 1213s 2s/step - loss: 4.1008 - acc: 0.5844 - val_loss: 4.0813 - val_acc: 0.5994\n", 1679 | "\n", 1680 | "Epoch 00006: val_acc did not improve from 0.60600\n", 1681 | "Epoch 7/24\n", 1682 | "782/782 [==============================] - 1213s 2s/step - loss: 4.0679 - acc: 0.5998 - val_loss: 4.0438 - val_acc: 0.6066\n", 1683 | "\n", 1684 | "Epoch 00007: val_acc improved from 0.60600 to 0.60660, saving model to /content/drive/My Drive/Colab Notebooks/model3.hdf5\n", 1685 | "Epoch 8/24\n", 1686 | "782/782 [==============================] - 1213s 2s/step - loss: 4.0349 - acc: 0.6084 - val_loss: 4.0248 - val_acc: 0.6126\n", 1687 | "\n", 1688 | "Epoch 00008: val_acc improved from 0.60660 to 0.61260, saving model to /content/drive/My Drive/Colab Notebooks/model3.hdf5\n", 1689 | "Epoch 9/24\n", 1690 | "782/782 [==============================] - 1213s 2s/step - loss: 4.0275 - acc: 0.6128 - val_loss: 4.0379 - val_acc: 0.6060\n", 1691 | "\n", 1692 | "Epoch 00009: val_acc did not improve from 0.61260\n", 1693 | "Epoch 10/24\n", 1694 | "782/782 [==============================] - 1213s 2s/step - loss: 4.0476 - acc: 0.6080 - val_loss: 4.0833 - val_acc: 0.6023\n", 1695 | "\n", 1696 | "Epoch 00010: val_acc did not improve from 0.61260\n", 1697 | "Epoch 11/24\n", 1698 | "782/782 [==============================] - 1214s 2s/step - loss: 4.0776 - acc: 0.6027 - val_loss: 4.1125 - val_acc: 0.5943\n", 1699 | "\n", 1700 | "Epoch 00011: val_acc did not improve from 0.61260\n", 1701 | "Epoch 12/24\n", 1702 | "782/782 [==============================] - 1215s 2s/step - loss: 4.1148 - acc: 0.5987 - val_loss: 4.1814 - val_acc: 0.5887\n", 1703 | "\n", 1704 | "Epoch 00012: val_acc did not improve from 0.61260\n", 1705 | "Epoch 13/24\n", 1706 | "782/782 [==============================] - 1215s 2s/step - loss: 4.1356 - acc: 0.5961 - val_loss: 4.1645 - val_acc: 0.5947\n", 1707 | "\n", 1708 | "Epoch 00013: val_acc did not improve from 0.61260\n", 1709 | "Epoch 14/24\n", 1710 | "782/782 [==============================] - 1215s 2s/step - loss: 4.1139 - acc: 0.6053 - val_loss: 4.1670 - val_acc: 0.6020\n", 1711 | "\n", 1712 | "Epoch 00014: val_acc did not improve from 0.61260\n", 1713 | "Epoch 15/24\n", 1714 | "782/782 [==============================] - 1217s 2s/step - loss: 4.0844 - acc: 0.6130 - val_loss: 4.1104 - val_acc: 0.6093\n", 1715 | "\n", 1716 | "Epoch 00015: val_acc did not improve from 0.61260\n", 1717 | "Epoch 16/24\n", 1718 | "782/782 [==============================] - 1215s 2s/step - loss: 4.0487 - acc: 0.6221 - val_loss: 4.0982 - val_acc: 0.6167\n", 1719 | "\n", 1720 | "Epoch 00016: val_acc improved from 0.61260 to 0.61670, saving model to /content/drive/My Drive/Colab Notebooks/model3.hdf5\n", 1721 | "Epoch 17/24\n", 1722 | "782/782 [==============================] - 1216s 2s/step - loss: 4.0241 - acc: 0.6326 - val_loss: 4.1038 - val_acc: 0.6156\n", 1723 | "\n", 1724 | "Epoch 00017: val_acc did not improve from 0.61670\n", 1725 | "Epoch 18/24\n", 1726 | "782/782 [==============================] - 1216s 2s/step - loss: 4.0267 - acc: 0.6333 - val_loss: 4.1269 - val_acc: 0.6124\n", 1727 | "\n", 1728 | "Epoch 00018: val_acc did not improve from 0.61670\n", 1729 | "Epoch 19/24\n", 1730 | "782/782 [==============================] - 1216s 2s/step - loss: 4.0269 - acc: 0.6347 - val_loss: 4.1696 - val_acc: 0.6077\n", 1731 | "\n", 1732 | "Epoch 00019: val_acc did not improve from 0.61670\n", 1733 | "Epoch 20/24\n", 1734 | "782/782 [==============================] - 1216s 2s/step - loss: 4.0308 - acc: 0.6348 - val_loss: 4.1903 - val_acc: 0.5992\n", 1735 | "\n", 1736 | "Epoch 00020: val_acc did not improve from 0.61670\n", 1737 | "Epoch 21/24\n", 1738 | "782/782 [==============================] - 1215s 2s/step - loss: 4.0376 - acc: 0.6349 - val_loss: 4.1894 - val_acc: 0.6091\n", 1739 | "\n", 1740 | "Epoch 00021: val_acc did not improve from 0.61670\n", 1741 | "Epoch 22/24\n", 1742 | "782/782 [==============================] - 1215s 2s/step - loss: 4.0318 - acc: 0.6392 - val_loss: 4.1781 - val_acc: 0.6127\n", 1743 | "\n", 1744 | "Epoch 00022: val_acc did not improve from 0.61670\n", 1745 | "Epoch 23/24\n", 1746 | "782/782 [==============================] - 1215s 2s/step - loss: 4.0233 - acc: 0.6446 - val_loss: 4.1581 - val_acc: 0.6174\n", 1747 | "\n", 1748 | "Epoch 00023: val_acc improved from 0.61670 to 0.61740, saving model to /content/drive/My Drive/Colab Notebooks/model3.hdf5\n", 1749 | "Epoch 24/24\n", 1750 | "782/782 [==============================] - 1216s 2s/step - loss: 4.0245 - acc: 0.6440 - val_loss: 4.1576 - val_acc: 0.6160\n", 1751 | "\n", 1752 | "Epoch 00024: val_acc did not improve from 0.61740\n" 1753 | ], 1754 | "name": "stdout" 1755 | }, 1756 | { 1757 | "output_type": "execute_result", 1758 | "data": { 1759 | "text/plain": [ 1760 | "" 1761 | ] 1762 | }, 1763 | "metadata": { 1764 | "tags": [] 1765 | }, 1766 | "execution_count": 12 1767 | } 1768 | ] 1769 | }, 1770 | { 1771 | "metadata": { 1772 | "id": "mQUkQQMjJVLN", 1773 | "colab_type": "text" 1774 | }, 1775 | "cell_type": "markdown", 1776 | "source": [ 1777 | "### After 24 hours of running and saving the model, I shall run the new model from here after skipping the above parts." 1778 | ] 1779 | }, 1780 | { 1781 | "metadata": { 1782 | "id": "tDOVKOk_KDob", 1783 | "colab_type": "code", 1784 | "outputId": "3ffc329a-8c45-4fee-b074-54d7bba3f363", 1785 | "colab": { 1786 | "base_uri": "https://localhost:8080/", 1787 | "height": 141 1788 | } 1789 | }, 1790 | "cell_type": "code", 1791 | "source": [ 1792 | "# load the model after 24 hours\n", 1793 | "from keras.models import load_model\n", 1794 | "extended_model = load_model(\"/content/drive/My Drive/Colab Notebooks/model3.hdf5\")" 1795 | ], 1796 | "execution_count": 0, 1797 | "outputs": [ 1798 | { 1799 | "output_type": "stream", 1800 | "text": [ 1801 | "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n", 1802 | "Instructions for updating:\n", 1803 | "Colocations handled automatically by placer.\n", 1804 | "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.\n", 1805 | "Instructions for updating:\n", 1806 | "Use tf.cast instead.\n" 1807 | ], 1808 | "name": "stdout" 1809 | } 1810 | ] 1811 | }, 1812 | { 1813 | "metadata": { 1814 | "id": "IXn0LmC6juT3", 1815 | "colab_type": "code", 1816 | "outputId": "33505379-9ec5-45d4-e9df-1c6d82b25a86", 1817 | "colab": { 1818 | "base_uri": "https://localhost:8080/", 1819 | "height": 868 1820 | } 1821 | }, 1822 | "cell_type": "code", 1823 | "source": [ 1824 | "# Callbacks\n", 1825 | "clr = CyclicLR(base_lr=0.000001, max_lr=0.000006, step_size=1564., mode='triangular2') #Cyclic learning rate\n", 1826 | "checkpointer_4 = ModelCheckpoint(filepath=\"/content/drive/My Drive/Colab Notebooks/model4.hdf5\", verbose=1, save_best_only=True, monitor=\"val_acc\")\n", 1827 | "# fit the model\n", 1828 | "extended_model.fit_generator(train_generator,\n", 1829 | " epochs=12,\n", 1830 | " steps_per_epoch= np.ceil(num_train/batch_size),\n", 1831 | " validation_steps= np.ceil(num_validation/batch_size),\n", 1832 | " validation_data=validation_generator,\n", 1833 | " verbose=1, callbacks=[clr, checkpointer_4]\n", 1834 | " )" 1835 | ], 1836 | "execution_count": 0, 1837 | "outputs": [ 1838 | { 1839 | "output_type": "stream", 1840 | "text": [ 1841 | "Epoch 1/12\n", 1842 | "782/782 [==============================] - 1300s 2s/step - loss: 4.0547 - acc: 0.6351 - val_loss: 4.1352 - val_acc: 0.6216\n", 1843 | "\n", 1844 | "Epoch 00001: val_acc improved from -inf to 0.62160, saving model to /content/drive/My Drive/Colab Notebooks/model4.hdf5\n", 1845 | "Epoch 2/12\n", 1846 | "782/782 [==============================] - 1275s 2s/step - loss: 4.0245 - acc: 0.6460 - val_loss: 4.1414 - val_acc: 0.6205\n", 1847 | "\n", 1848 | "Epoch 00002: val_acc did not improve from 0.62160\n", 1849 | "Epoch 3/12\n", 1850 | "782/782 [==============================] - 1275s 2s/step - loss: 3.9912 - acc: 0.6541 - val_loss: 4.1333 - val_acc: 0.6227\n", 1851 | "\n", 1852 | "Epoch 00003: val_acc improved from 0.62160 to 0.62270, saving model to /content/drive/My Drive/Colab Notebooks/model4.hdf5\n", 1853 | "Epoch 4/12\n", 1854 | "782/782 [==============================] - 1275s 2s/step - loss: 3.9535 - acc: 0.6650 - val_loss: 4.1327 - val_acc: 0.6214\n", 1855 | "\n", 1856 | "Epoch 00004: val_acc did not improve from 0.62270\n", 1857 | "Epoch 5/12\n", 1858 | "782/782 [==============================] - 1276s 2s/step - loss: 3.9429 - acc: 0.6691 - val_loss: 4.1337 - val_acc: 0.6217\n", 1859 | "\n", 1860 | "Epoch 00005: val_acc did not improve from 0.62270\n", 1861 | "Epoch 6/12\n", 1862 | "782/782 [==============================] - 1276s 2s/step - loss: 3.9465 - acc: 0.6663 - val_loss: 4.1368 - val_acc: 0.6223\n", 1863 | "\n", 1864 | "Epoch 00006: val_acc did not improve from 0.62270\n", 1865 | "Epoch 7/12\n", 1866 | "782/782 [==============================] - 1276s 2s/step - loss: 3.9631 - acc: 0.6629 - val_loss: 4.1362 - val_acc: 0.6225\n", 1867 | "\n", 1868 | "Epoch 00007: val_acc did not improve from 0.62270\n", 1869 | "Epoch 8/12\n", 1870 | "782/782 [==============================] - 1276s 2s/step - loss: 3.9831 - acc: 0.6570 - val_loss: 4.1340 - val_acc: 0.6234\n", 1871 | "\n", 1872 | "Epoch 00008: val_acc improved from 0.62270 to 0.62340, saving model to /content/drive/My Drive/Colab Notebooks/model4.hdf5\n", 1873 | "Epoch 9/12\n", 1874 | "782/782 [==============================] - 1275s 2s/step - loss: 3.9927 - acc: 0.6545 - val_loss: 4.1339 - val_acc: 0.6243\n", 1875 | "\n", 1876 | "Epoch 00009: val_acc improved from 0.62340 to 0.62430, saving model to /content/drive/My Drive/Colab Notebooks/model4.hdf5\n", 1877 | "Epoch 10/12\n", 1878 | "782/782 [==============================] - 1275s 2s/step - loss: 3.9802 - acc: 0.6585 - val_loss: 4.1408 - val_acc: 0.6203\n", 1879 | "\n", 1880 | "Epoch 00010: val_acc did not improve from 0.62430\n", 1881 | "Epoch 11/12\n", 1882 | "782/782 [==============================] - 1276s 2s/step - loss: 3.9732 - acc: 0.6600 - val_loss: 4.1372 - val_acc: 0.6216\n", 1883 | "\n", 1884 | "Epoch 00011: val_acc did not improve from 0.62430\n", 1885 | "Epoch 12/12\n", 1886 | "782/782 [==============================] - 1276s 2s/step - loss: 3.9654 - acc: 0.6640 - val_loss: 4.1380 - val_acc: 0.6224\n", 1887 | "\n", 1888 | "Epoch 00012: val_acc did not improve from 0.62430\n" 1889 | ], 1890 | "name": "stdout" 1891 | }, 1892 | { 1893 | "output_type": "execute_result", 1894 | "data": { 1895 | "text/plain": [ 1896 | "" 1897 | ] 1898 | }, 1899 | "metadata": { 1900 | "tags": [] 1901 | }, 1902 | "execution_count": 12 1903 | } 1904 | ] 1905 | }, 1906 | { 1907 | "metadata": { 1908 | "id": "Gctl0JQEERwN", 1909 | "colab_type": "text" 1910 | }, 1911 | "cell_type": "markdown", 1912 | "source": [ 1913 | "### After 28 hours of running and saving the model, I shall run the new model from here after skipping the above parts." 1914 | ] 1915 | }, 1916 | { 1917 | "metadata": { 1918 | "id": "ka_Y06r2KNXh", 1919 | "colab_type": "code", 1920 | "outputId": "bafca02f-bc88-4182-c41c-8309becdd039", 1921 | "colab": { 1922 | "base_uri": "https://localhost:8080/", 1923 | "height": 141 1924 | } 1925 | }, 1926 | "cell_type": "code", 1927 | "source": [ 1928 | "# load the model after 28 hours\n", 1929 | "from keras.models import load_model\n", 1930 | "extended_model = load_model(\"/content/drive/My Drive/Colab Notebooks/model4.hdf5\")" 1931 | ], 1932 | "execution_count": 0, 1933 | "outputs": [ 1934 | { 1935 | "output_type": "stream", 1936 | "text": [ 1937 | "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.\n", 1938 | "Instructions for updating:\n", 1939 | "Colocations handled automatically by placer.\n", 1940 | "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.\n", 1941 | "Instructions for updating:\n", 1942 | "Use tf.cast instead.\n" 1943 | ], 1944 | "name": "stdout" 1945 | } 1946 | ] 1947 | }, 1948 | { 1949 | "metadata": { 1950 | "id": "oSQ83f6NbDbF", 1951 | "colab_type": "code", 1952 | "outputId": "8d81f197-16e9-4fc2-b5b3-08b7d3932fe4", 1953 | "colab": { 1954 | "base_uri": "https://localhost:8080/", 1955 | "height": 868 1956 | } 1957 | }, 1958 | "cell_type": "code", 1959 | "source": [ 1960 | "# Callbacks\n", 1961 | "clr = CyclicLR(base_lr=0.00001, max_lr=0.00006, step_size=1564., mode='triangular2') #Cyclic learning rate\n", 1962 | "checkpointer_5 = ModelCheckpoint(filepath=\"/content/drive/My Drive/Colab Notebooks/model5.hdf5\", verbose=1, save_best_only=True, monitor=\"val_acc\")\n", 1963 | "# fit the model\n", 1964 | "extended_model.fit_generator(train_generator,\n", 1965 | " epochs=12,\n", 1966 | " steps_per_epoch= np.ceil(num_train/batch_size),\n", 1967 | " validation_steps= np.ceil(num_validation/batch_size),\n", 1968 | " validation_data=validation_generator,\n", 1969 | " verbose=1, callbacks=[clr, checkpointer_5]\n", 1970 | " )" 1971 | ], 1972 | "execution_count": 0, 1973 | "outputs": [ 1974 | { 1975 | "output_type": "stream", 1976 | "text": [ 1977 | "Epoch 1/12\n", 1978 | "782/782 [==============================] - 1189s 2s/step - loss: 4.0826 - acc: 0.6316 - val_loss: 4.3063 - val_acc: 0.5952\n", 1979 | "\n", 1980 | "Epoch 00001: val_acc improved from -inf to 0.59520, saving model to /content/drive/My Drive/Colab Notebooks/model5.hdf5\n", 1981 | "Epoch 2/12\n", 1982 | "782/782 [==============================] - 1170s 1s/step - loss: 4.1577 - acc: 0.6179 - val_loss: 4.4593 - val_acc: 0.5657\n", 1983 | "\n", 1984 | "Epoch 00002: val_acc did not improve from 0.59520\n", 1985 | "Epoch 3/12\n", 1986 | "782/782 [==============================] - 1171s 1s/step - loss: 4.1736 - acc: 0.6200 - val_loss: 4.3616 - val_acc: 0.5924\n", 1987 | "\n", 1988 | "Epoch 00003: val_acc did not improve from 0.59520\n", 1989 | "Epoch 4/12\n", 1990 | "782/782 [==============================] - 1171s 1s/step - loss: 4.0826 - acc: 0.6468 - val_loss: 4.2524 - val_acc: 0.6140\n", 1991 | "\n", 1992 | "Epoch 00004: val_acc improved from 0.59520 to 0.61400, saving model to /content/drive/My Drive/Colab Notebooks/model5.hdf5\n", 1993 | "Epoch 5/12\n", 1994 | "782/782 [==============================] - 1171s 1s/step - loss: 4.0466 - acc: 0.6586 - val_loss: 4.2914 - val_acc: 0.6080\n", 1995 | "\n", 1996 | "Epoch 00005: val_acc did not improve from 0.61400\n", 1997 | "Epoch 6/12\n", 1998 | "782/782 [==============================] - 1170s 1s/step - loss: 4.0831 - acc: 0.6498 - val_loss: 4.3521 - val_acc: 0.5991\n", 1999 | "\n", 2000 | "Epoch 00006: val_acc did not improve from 0.61400\n", 2001 | "Epoch 7/12\n", 2002 | "782/782 [==============================] - 1170s 1s/step - loss: 4.1192 - acc: 0.6442 - val_loss: 4.3168 - val_acc: 0.6087\n", 2003 | "\n", 2004 | "Epoch 00007: val_acc did not improve from 0.61400\n", 2005 | "Epoch 8/12\n", 2006 | "782/782 [==============================] - 1170s 1s/step - loss: 4.1106 - acc: 0.6483 - val_loss: 4.2744 - val_acc: 0.6182\n", 2007 | "\n", 2008 | "Epoch 00008: val_acc improved from 0.61400 to 0.61820, saving model to /content/drive/My Drive/Colab Notebooks/model5.hdf5\n", 2009 | "Epoch 9/12\n", 2010 | "782/782 [==============================] - 1169s 1s/step - loss: 4.1032 - acc: 0.6526 - val_loss: 4.2937 - val_acc: 0.6138\n", 2011 | "\n", 2012 | "Epoch 00009: val_acc did not improve from 0.61820\n", 2013 | "Epoch 10/12\n", 2014 | "782/782 [==============================] - 1173s 1s/step - loss: 4.1174 - acc: 0.6503 - val_loss: 4.3620 - val_acc: 0.5999\n", 2015 | "\n", 2016 | "Epoch 00010: val_acc did not improve from 0.61820\n", 2017 | "Epoch 11/12\n", 2018 | "782/782 [==============================] - 1204s 2s/step - loss: 4.1202 - acc: 0.6517 - val_loss: 4.3146 - val_acc: 0.6124\n", 2019 | "\n", 2020 | "Epoch 00011: val_acc did not improve from 0.61820\n", 2021 | "Epoch 12/12\n", 2022 | "782/782 [==============================] - 1203s 2s/step - loss: 4.1001 - acc: 0.6611 - val_loss: 4.3117 - val_acc: 0.6183\n", 2023 | "\n", 2024 | "Epoch 00012: val_acc improved from 0.61820 to 0.61830, saving model to /content/drive/My Drive/Colab Notebooks/model5.hdf5\n" 2025 | ], 2026 | "name": "stdout" 2027 | }, 2028 | { 2029 | "output_type": "execute_result", 2030 | "data": { 2031 | "text/plain": [ 2032 | "" 2033 | ] 2034 | }, 2035 | "metadata": { 2036 | "tags": [] 2037 | }, 2038 | "execution_count": 12 2039 | } 2040 | ] 2041 | }, 2042 | { 2043 | "metadata": { 2044 | "id": "ZmrJme0wEWs0", 2045 | "colab_type": "text" 2046 | }, 2047 | "cell_type": "markdown", 2048 | "source": [ 2049 | "### After 32 hours of running and saving the model, I shall run the new model from here after skipping the above parts." 2050 | ] 2051 | }, 2052 | { 2053 | "metadata": { 2054 | "id": "s30oJ3RHbNue", 2055 | "colab_type": "code", 2056 | "colab": {} 2057 | }, 2058 | "cell_type": "code", 2059 | "source": [ 2060 | "# load the model after 32 hours\n", 2061 | "from keras.models import load_model\n", 2062 | "extended_model = load_model(\"/content/drive/My Drive/Colab Notebooks/model5.hdf5\")" 2063 | ], 2064 | "execution_count": 0, 2065 | "outputs": [] 2066 | }, 2067 | { 2068 | "metadata": { 2069 | "id": "VP9TbcZOlbog", 2070 | "colab_type": "code", 2071 | "outputId": "a2d39777-90cb-420d-d56f-8b39d121d843", 2072 | "colab": { 2073 | "base_uri": "https://localhost:8080/", 2074 | "height": 868 2075 | } 2076 | }, 2077 | "cell_type": "code", 2078 | "source": [ 2079 | "# Callbacks\n", 2080 | "clr = CyclicLR(base_lr=0.0000001, max_lr=0.0000006, step_size=1564., mode='triangular2') #Cyclic learning rate\n", 2081 | "checkpointer_6 = ModelCheckpoint(filepath=\"/content/drive/My Drive/Colab Notebooks/model6.hdf5\", verbose=1, save_best_only=True, monitor=\"val_acc\")\n", 2082 | "# fit the model\n", 2083 | "extended_model.fit_generator(train_generator,\n", 2084 | " epochs=12,\n", 2085 | " steps_per_epoch= np.ceil(num_train/batch_size),\n", 2086 | " validation_steps= np.ceil(num_validation/batch_size),\n", 2087 | " validation_data=validation_generator,\n", 2088 | " verbose=1, callbacks=[clr, checkpointer_6]\n", 2089 | " )" 2090 | ], 2091 | "execution_count": 0, 2092 | "outputs": [ 2093 | { 2094 | "output_type": "stream", 2095 | "text": [ 2096 | "Epoch 1/12\n", 2097 | "782/782 [==============================] - 1212s 2s/step - loss: 4.0801 - acc: 0.6662 - val_loss: 4.2796 - val_acc: 0.6258\n", 2098 | "\n", 2099 | "Epoch 00001: val_acc improved from -inf to 0.62580, saving model to /content/drive/My Drive/Colab Notebooks/model6.hdf5\n", 2100 | "Epoch 2/12\n", 2101 | "782/782 [==============================] - 1203s 2s/step - loss: 4.0799 - acc: 0.6668 - val_loss: 4.2786 - val_acc: 0.6258\n", 2102 | "\n", 2103 | "Epoch 00002: val_acc did not improve from 0.62580\n", 2104 | "Epoch 3/12\n", 2105 | "782/782 [==============================] - 1201s 2s/step - loss: 4.0770 - acc: 0.6670 - val_loss: 4.2744 - val_acc: 0.6266\n", 2106 | "\n", 2107 | "Epoch 00003: val_acc improved from 0.62580 to 0.62660, saving model to /content/drive/My Drive/Colab Notebooks/model6.hdf5\n", 2108 | "Epoch 4/12\n", 2109 | "782/782 [==============================] - 1178s 2s/step - loss: 4.0737 - acc: 0.6657 - val_loss: 4.2751 - val_acc: 0.6261\n", 2110 | "\n", 2111 | "Epoch 00004: val_acc did not improve from 0.62660\n", 2112 | "Epoch 5/12\n", 2113 | "782/782 [==============================] - 1169s 1s/step - loss: 4.0584 - acc: 0.6707 - val_loss: 4.2744 - val_acc: 0.6260\n", 2114 | "\n", 2115 | "Epoch 00005: val_acc did not improve from 0.62660\n", 2116 | "Epoch 6/12\n", 2117 | "782/782 [==============================] - 1169s 1s/step - loss: 4.0519 - acc: 0.6719 - val_loss: 4.2733 - val_acc: 0.6265\n", 2118 | "\n", 2119 | "Epoch 00006: val_acc did not improve from 0.62660\n", 2120 | "Epoch 7/12\n", 2121 | "782/782 [==============================] - 1169s 1s/step - loss: 4.0366 - acc: 0.6770 - val_loss: 4.2740 - val_acc: 0.6268\n", 2122 | "\n", 2123 | "Epoch 00007: val_acc improved from 0.62660 to 0.62680, saving model to /content/drive/My Drive/Colab Notebooks/model6.hdf5\n", 2124 | "Epoch 8/12\n", 2125 | "782/782 [==============================] - 1169s 1s/step - loss: 4.0196 - acc: 0.6824 - val_loss: 4.2732 - val_acc: 0.6272\n", 2126 | "\n", 2127 | "Epoch 00008: val_acc improved from 0.62680 to 0.62720, saving model to /content/drive/My Drive/Colab Notebooks/model6.hdf5\n", 2128 | "Epoch 9/12\n", 2129 | "782/782 [==============================] - 1169s 1s/step - loss: 4.0206 - acc: 0.6811 - val_loss: 4.2737 - val_acc: 0.6273\n", 2130 | "\n", 2131 | "Epoch 00009: val_acc improved from 0.62720 to 0.62730, saving model to /content/drive/My Drive/Colab Notebooks/model6.hdf5\n", 2132 | "Epoch 10/12\n", 2133 | "782/782 [==============================] - 1169s 1s/step - loss: 4.0215 - acc: 0.6819 - val_loss: 4.2737 - val_acc: 0.6266\n", 2134 | "\n", 2135 | "Epoch 00010: val_acc did not improve from 0.62730\n", 2136 | "Epoch 11/12\n", 2137 | "782/782 [==============================] - 1169s 1s/step - loss: 4.0257 - acc: 0.6809 - val_loss: 4.2734 - val_acc: 0.6271\n", 2138 | "\n", 2139 | "Epoch 00011: val_acc did not improve from 0.62730\n", 2140 | "Epoch 12/12\n", 2141 | "782/782 [==============================] - 1169s 1s/step - loss: 4.0683 - acc: 0.6683 - val_loss: 4.2734 - val_acc: 0.6272\n", 2142 | "\n", 2143 | "Epoch 00012: val_acc did not improve from 0.62730\n" 2144 | ], 2145 | "name": "stdout" 2146 | }, 2147 | { 2148 | "output_type": "execute_result", 2149 | "data": { 2150 | "text/plain": [ 2151 | "" 2152 | ] 2153 | }, 2154 | "metadata": { 2155 | "tags": [] 2156 | }, 2157 | "execution_count": 14 2158 | } 2159 | ] 2160 | }, 2161 | { 2162 | "metadata": { 2163 | "id": "xhS2U_LcEfJx", 2164 | "colab_type": "text" 2165 | }, 2166 | "cell_type": "markdown", 2167 | "source": [ 2168 | "# Top Validation Accuracy : 62.73%" 2169 | ] 2170 | }, 2171 | { 2172 | "metadata": { 2173 | "id": "Jp3Ux8MH_JDa", 2174 | "colab_type": "code", 2175 | "colab": {} 2176 | }, 2177 | "cell_type": "code", 2178 | "source": [ 2179 | "" 2180 | ], 2181 | "execution_count": 0, 2182 | "outputs": [] 2183 | } 2184 | ] 2185 | } --------------------------------------------------------------------------------