Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Spectrum_Keras-Multi-Cat.ipynb 52.6 KB
Newer Older
SoleneDc's avatar
SoleneDc committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 1. CNN"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Récupération des genres"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Permet de récupérer les labels qui seront mis dans une array"
   ]
  },
  {
   "cell_type": "code",
26
   "execution_count": 78,
SoleneDc's avatar
SoleneDc committed
27 28 29 30 31 32 33 34 35
   "metadata": {},
   "outputs": [],
   "source": [
    "import ast\n",
    "import pandas as pd\n",
    "from __future__ import absolute_import\n",
    "from __future__ import division\n",
    "from __future__ import print_function\n",
    "from keras.preprocessing.sequence import pad_sequences\n",
SoleneDc's avatar
SoleneDc committed
36
    "pd.options.mode.chained_assignment = None\n",
SoleneDc's avatar
SoleneDc committed
37 38 39 40 41 42 43 44 45 46 47 48
    "import argparse\n",
    "import sys\n",
    "import numpy as np\n",
    "import matplotlib as mpl\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.image as mpimg\n",
    "import tensorflow as tf\n",
    "import os\n",
    "import cv2\n",
    "from math import floor"
   ]
  },
SoleneDc's avatar
SoleneDc committed
49 50 51 52 53 54 55
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Choisir l'année !"
   ]
  },
SoleneDc's avatar
SoleneDc committed
56 57
  {
   "cell_type": "code",
58 59 60 61 62 63 64 65 66 67 68
   "execution_count": 141,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[2000, 2001, 2002, 2003, 2004, 2005, 2006]\n"
     ]
    }
   ],
SoleneDc's avatar
SoleneDc committed
69
   "source": [
70 71
    "year = [i for i in range(2000,2007)]\n",
    "print(year)"
SoleneDc's avatar
SoleneDc committed
72 73 74 75
   ]
  },
  {
   "cell_type": "code",
76 77
   "execution_count": 142,
   "metadata": {},
SoleneDc's avatar
SoleneDc committed
78 79 80
   "outputs": [],
   "source": [
    "list_of_eligible_spectrums = []\n",
81 82 83 84
    "for i in range(len(year)):\n",
    "    for file in os.listdir(\"../spectrumImages/SpectrumImages\" + str(year[i])):\n",
    "        if str(file)[-4:] == '.jpg':\n",
    "            list_of_eligible_spectrums += [f\"SpectrumImages{str(year[i])}/{file}\"]"
SoleneDc's avatar
SoleneDc committed
85 86
   ]
  },
SoleneDc's avatar
SoleneDc committed
87 88 89 90 91 92 93
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
94 95 96 97 98 99 100
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "{\"genres\":[{\"id\":28,\"name\":\"Action\"},{\"id\":12,\"name\":\"Adventure\"},{\"id\":16,\"name\":\"Animation\"},{\"id\":35,\"name\":\"Comedy\"},{\"id\":80,\"name\":\"Crime\"},{\"id\":99,\"name\":\"Documentary\"},{\"id\":18,\"name\":\"Drama\"},{\"id\":10751,\"name\":\"Family\"},{\"id\":14,\"name\":\"Fantasy\"},{\"id\":36,\"name\":\"History\"},{\"id\":27,\"name\":\"Horror\"},{\"id\":10402,\"name\":\"Music\"},{\"id\":9648,\"name\":\"Mystery\"},{\"id\":10749,\"name\":\"Romance\"},{\"id\":878,\"name\":\"Science Fiction\"},{\"id\":10770,\"name\":\"TV Movie\"},{\"id\":53,\"name\":\"Thriller\"},{\"id\":10752,\"name\":\"War\"},{\"id\":37,\"name\":\"Western\"}]}"
   ]
  },
SoleneDc's avatar
SoleneDc committed
101 102
  {
   "cell_type": "code",
103
   "execution_count": 143,
SoleneDc's avatar
SoleneDc committed
104
   "metadata": {},
SoleneDc's avatar
SoleneDc committed
105 106 107 108 109 110 111
   "outputs": [],
   "source": [
    "genres = [28, 35, 18, 99, 10749, 10752, 10402, 53, 878, 27, 9648, 80, 14, 12, 36, 10769, 16, 10751, 37, 10770]\n",
    "\n",
    "def get_genre_from_link():\n",
    "    dict_inverse = {}\n",
    "    links_to_be_removed = []\n",
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
    "    for i in range(len(year)):\n",
    "        path = \"./Link-dictionaries/Link-dictionary\" + str(year[i])+ \".txt\"\n",
    "        file = open(path, \"r\").read()\n",
    "        dictyear = ast.literal_eval(file)\n",
    "\n",
    "        for movie_id in dictyear.keys():\n",
    "            if dictyear[movie_id][1] != []:\n",
    "                dict_inverse[str(dictyear[movie_id][2])] = {}\n",
    "                for genre in genres:\n",
    "                    if genre in dictyear[movie_id][1]:\n",
    "                        dict_inverse[str(dictyear[movie_id][2])][genre] = 1\n",
    "                    else:\n",
    "                        dict_inverse[str(dictyear[movie_id][2])][genre] = 0\n",
    "            else:\n",
    "                #print(f'careful, link {dictyear[movie_id][2]} needs to be removed from the list')\n",
    "                links_to_be_removed += [dictyear[movie_id][2]]\n",
SoleneDc's avatar
SoleneDc committed
128 129 130 131 132 133 134 135 136
    "    return dict_inverse, links_to_be_removed\n",
    "\n",
    "def get_output_list(L):\n",
    "    dict_inverse, links_to_be_removed = get_genre_from_link()\n",
    "    eligible_links = []\n",
    "    output = []\n",
    "    for link in L:\n",
    "        link = str(link)\n",
    "        #print(dict_inverse[str(link)])\n",
137 138 139
    "        if link[-5] == \".\":\n",
    "            link=link[:-4]+link[-3:]\n",
    "        if link.split('/')[1][:-4] not in links_to_be_removed:\n",
SoleneDc's avatar
SoleneDc committed
140 141 142 143 144 145 146 147 148
    "            eligible_links += [link[:-4]]\n",
    "    return dict_inverse, eligible_links\n",
    "\n",
    "\n",
    "dict_inverse, eligible_links = get_output_list(list_of_eligible_spectrums)"
   ]
  },
  {
   "cell_type": "code",
149 150
   "execution_count": 144,
   "metadata": {},
SoleneDc's avatar
SoleneDc committed
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
   "outputs": [],
   "source": [
    "#for element in labels:\n",
    "#   for genre in element:\n",
    "#       if genre not in genres:\n",
    "#           genres += [genre]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#Modif pour ajouter des catégories\n",
    "trY[2][3]=1\n",
    "trY.shape\n",
    "from random import randint\n",
    "for i in range(1225):\n",
    "    rand = randint(0,19)\n",
    "    trY[i][rand] = 1\n",
    "trY[3]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Bien vérifier la taille des données !"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Extraction des images"
   ]
  },
  {
   "cell_type": "code",
189
   "execution_count": 145,
SoleneDc's avatar
SoleneDc committed
190
   "metadata": {},
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2000/PGeh7gH7Ol0\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2001/4olwbrY2kwE\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2001/671bZc4jX7g\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2001/H5PR6LTfWmk\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2001/ni4tEtuTccc\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2001/py_sPdBmstA\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2001/ZYvSK-xBAMU\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2002/2m1aCPB_Ni8\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2002/2T2pyqrr8UM\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2002/4olwbrY2kwE\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2002/8IAIJQpQuSM\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2002/aZaKktj-_H4\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2002/ErQ_hE9Ta3g\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2002/H5PR6LTfWmk\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2002/pNcUEraG5sA\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2002/V75dMMIW2B4\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2002/WFJgUm7iOKw\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2002/YywOMlbqLPo\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2003/1Gl2kVUsy2M\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2003/2m1aCPB_Ni8\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2003/8LFcNao5HmY\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2003/aZaKktj-_H4\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2003/DuTlpSfptO0\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2003/eBLqOtIzcXs\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2003/hsuKq5pNOcM\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2003/iJqc0t0XoMc\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2003/oulnfKJKIyg\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2003/pLEFn55bpR0\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2003/pNcUEraG5sA\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2003/V75dMMIW2B4\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2004/3HEjeVhdzP0\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2004/3jBFwltrxJw\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2004/bLjj5EwviQY\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2004/DuTlpSfptO0\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2004/fccho1IyX8Y\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2004/hsuKq5pNOcM\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2004/oulnfKJKIyg\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2004/PFUk-qUbfW4\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2006/BH0MLyu6HjY\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2006/ldbkr2eN6qk\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2006/myKtVl8N7jU\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2006/NlsISs23Qfs\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2006/OR-pbkIPT-U\n",
      "'NoneType' object is not subscriptable\n",
      "SpectrumImages2006/x9STUnqrE_c\n"
     ]
    }
   ],
SoleneDc's avatar
SoleneDc committed
287 288
   "source": [
    "for file in eligible_links:\n",
289 290 291 292 293 294 295 296 297 298
    "    if file[-1]==\".\":\n",
    "        file=file[-1]\n",
    "    img = cv2.imread('../spectrumImages/' + file + '.jpg', 1)\n",
    "    try:\n",
    "        img = img[0:1]\n",
    "    except Exception as e:\n",
    "        print(e)\n",
    "        print(file)\n",
    "        img = cv2.imread('../spectrumImages/' + file + '..jpg', 1)\n",
    "        img = img[0:1]\n",
SoleneDc's avatar
SoleneDc committed
299
    "    img = img.reshape((img.shape[1], img.shape[2]))\n",
300
    "    dict_inverse[file.split('/')[1]]['image'] = img"
SoleneDc's avatar
SoleneDc committed
301 302 303 304
   ]
  },
  {
   "cell_type": "code",
305 306
   "execution_count": 146,
   "metadata": {},
SoleneDc's avatar
SoleneDc committed
307 308 309 310 311 312 313 314 315 316 317
   "outputs": [],
   "source": [
    "df = pd.DataFrame.from_dict(dict_inverse)\n",
    "df = df.transpose()\n",
    "df = df.reset_index(drop=True)\n",
    "#shuffling\n",
    "df = df.sample(frac=1)"
   ]
  },
  {
   "cell_type": "code",
318 319
   "execution_count": 147,
   "metadata": {},
SoleneDc's avatar
SoleneDc committed
320 321 322 323 324 325 326
   "outputs": [],
   "source": [
    "df2 = df.dropna(axis=0)"
   ]
  },
  {
   "cell_type": "code",
327
   "execution_count": 148,
SoleneDc's avatar
SoleneDc committed
328 329 330 331 332
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
333
       "(6581, 21)"
SoleneDc's avatar
SoleneDc committed
334 335
      ]
     },
336
     "execution_count": 148,
SoleneDc's avatar
SoleneDc committed
337 338 339 340 341 342 343 344 345 346
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.shape"
   ]
  },
  {
   "cell_type": "code",
347
   "execution_count": 149,
SoleneDc's avatar
SoleneDc committed
348 349 350 351 352
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
353
       "(3791, 21)"
SoleneDc's avatar
SoleneDc committed
354 355
      ]
     },
356
     "execution_count": 149,
SoleneDc's avatar
SoleneDc committed
357 358 359 360 361 362 363 364 365 366
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.shape"
   ]
  },
  {
   "cell_type": "code",
367
   "execution_count": 150,
368 369 370 371 372 373
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
374 375 376
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
377 378 379 380 381
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
382 383 384 385
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>12</th>\n",
       "      <th>14</th>\n",
       "      <th>16</th>\n",
       "      <th>18</th>\n",
       "      <th>27</th>\n",
       "      <th>28</th>\n",
       "      <th>35</th>\n",
       "      <th>36</th>\n",
       "      <th>37</th>\n",
       "      <th>53</th>\n",
       "      <th>...</th>\n",
       "      <th>99</th>\n",
       "      <th>878</th>\n",
       "      <th>9648</th>\n",
       "      <th>10402</th>\n",
       "      <th>10749</th>\n",
       "      <th>10751</th>\n",
       "      <th>10752</th>\n",
       "      <th>10769</th>\n",
       "      <th>10770</th>\n",
       "      <th>image</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
417 418 419 420 421 422 423 424 425 426
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
427
       "      <td>...</td>\n",
428 429 430 431 432 433 434 435 436 437
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
       "      <td>3791</td>\n",
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
       "    </tr>\n",
       "    <tr>\n",
       "      <th>unique</th>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
461
       "      <td>3791</td>\n",
462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484
       "    </tr>\n",
       "    <tr>\n",
       "      <th>top</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
485
       "      <td>[[49, 38, 71], [79, 67, 115], [78, 64, 122], [...</td>\n",
486 487 488
       "    </tr>\n",
       "    <tr>\n",
       "      <th>freq</th>\n",
489 490 491 492 493 494 495 496 497 498
       "      <td>3359</td>\n",
       "      <td>3497</td>\n",
       "      <td>3521</td>\n",
       "      <td>1979</td>\n",
       "      <td>3315</td>\n",
       "      <td>3004</td>\n",
       "      <td>2534</td>\n",
       "      <td>3662</td>\n",
       "      <td>3740</td>\n",
       "      <td>2899</td>\n",
499
       "      <td>...</td>\n",
500 501 502 503 504 505 506 507 508
       "      <td>3578</td>\n",
       "      <td>3456</td>\n",
       "      <td>3549</td>\n",
       "      <td>3640</td>\n",
       "      <td>3063</td>\n",
       "      <td>3435</td>\n",
       "      <td>3684</td>\n",
       "      <td>3667</td>\n",
       "      <td>3748</td>\n",
509 510 511 512 513 514 515 516 517
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>4 rows × 21 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          12    14    16    18    27    28    35    36    37    53  \\\n",
518
       "count   3791  3791  3791  3791  3791  3791  3791  3791  3791  3791   \n",
519 520
       "unique     2     2     2     2     2     2     2     2     2     2   \n",
       "top        0     0     0     0     0     0     0     0     0     0   \n",
521
       "freq    3359  3497  3521  1979  3315  3004  2534  3662  3740  2899   \n",
522 523
       "\n",
       "                              ...                            99   878  9648  \\\n",
524
       "count                         ...                          3791  3791  3791   \n",
525 526
       "unique                        ...                             2     2     2   \n",
       "top                           ...                             0     0     0   \n",
527
       "freq                          ...                          3578  3456  3549   \n",
528 529
       "\n",
       "        10402  10749  10751  10752  10769  10770  \\\n",
530
       "count    3791   3791   3791   3791   3791   3791   \n",
531 532
       "unique      2      2      2      2      2      2   \n",
       "top         0      0      0      0      0      0   \n",
533
       "freq     3640   3063   3435   3684   3667   3748   \n",
534 535
       "\n",
       "                                                    image  \n",
536 537 538
       "count                                                3791  \n",
       "unique                                               3791  \n",
       "top     [[49, 38, 71], [79, 67, 115], [78, 64, 122], [...  \n",
539 540 541 542 543
       "freq                                                    1  \n",
       "\n",
       "[4 rows x 21 columns]"
      ]
     },
544
     "execution_count": 150,
545 546 547 548 549 550 551 552 553 554
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.describe()"
   ]
  },
  {
   "cell_type": "code",
555
   "execution_count": 151,
SoleneDc's avatar
SoleneDc committed
556 557 558 559 560 561
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
562 563 564
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
SoleneDc's avatar
SoleneDc committed
565 566 567 568 569
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
570 571 572 573
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
SoleneDc's avatar
SoleneDc committed
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>12</th>\n",
       "      <th>14</th>\n",
       "      <th>16</th>\n",
       "      <th>18</th>\n",
       "      <th>27</th>\n",
       "      <th>35</th>\n",
       "      <th>36</th>\n",
       "      <th>37</th>\n",
       "      <th>53</th>\n",
       "      <th>80</th>\n",
       "      <th>99</th>\n",
       "      <th>878</th>\n",
       "      <th>9648</th>\n",
       "      <th>10402</th>\n",
       "      <th>10749</th>\n",
       "      <th>10751</th>\n",
       "      <th>10752</th>\n",
       "      <th>10769</th>\n",
       "      <th>10770</th>\n",
       "      <th>image</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
       "      <td>3004</td>\n",
SoleneDc's avatar
SoleneDc committed
647 648 649
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
       "      <td>787</td>\n",
SoleneDc's avatar
SoleneDc committed
670 671 672 673 674 675 676 677
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      12    14    16    18    27    35    36    37    53    80    99   878  \\\n",
       "28                                                                           \n",
678 679
       "0   3004  3004  3004  3004  3004  3004  3004  3004  3004  3004  3004  3004   \n",
       "1    787   787   787   787   787   787   787   787   787   787   787   787   \n",
SoleneDc's avatar
SoleneDc committed
680 681 682
       "\n",
       "    9648  10402  10749  10751  10752  10769  10770  image  \n",
       "28                                                         \n",
683 684
       "0   3004   3004   3004   3004   3004   3004   3004   3004  \n",
       "1    787    787    787    787    787    787    787    787  "
SoleneDc's avatar
SoleneDc committed
685 686
      ]
     },
687
     "execution_count": 151,
SoleneDc's avatar
SoleneDc committed
688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df2.groupby(28).count()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
705
   "execution_count": 152,
SoleneDc's avatar
SoleneDc committed
706 707 708 709 710
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
711
       "3032"
SoleneDc's avatar
SoleneDc committed
712 713
      ]
     },
714
     "execution_count": 152,
SoleneDc's avatar
SoleneDc committed
715 716 717 718 719
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
720
    "train_len = int(df2.shape[0]*0.8)\n",
SoleneDc's avatar
SoleneDc committed
721 722 723 724 725
    "train_len"
   ]
  },
  {
   "cell_type": "code",
726 727
   "execution_count": 153,
   "metadata": {},
SoleneDc's avatar
SoleneDc committed
728 729 730 731 732 733 734 735
   "outputs": [],
   "source": [
    "train = df2.iloc[:train_len, :]\n",
    "test = df2.iloc[train_len:, :]"
   ]
  },
  {
   "cell_type": "code",
736
   "execution_count": 154,
SoleneDc's avatar
SoleneDc committed
737 738 739 740 741
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
742 743 744 745 746
       "220     [[56, 147, 48], [56, 147, 48], [56, 147, 48], ...\n",
       "6172    [[26, 28, 29], [53, 56, 60], [62, 68, 75], [64...\n",
       "2500    [[8, 3, 0], [24, 15, 12], [38, 23, 21], [43, 2...\n",
       "4922    [[9, 6, 1], [9, 6, 2], [5, 6, 2], [44, 47, 45]...\n",
       "5943    [[42, 76, 70], [41, 80, 78], [48, 88, 87], [52...\n",
SoleneDc's avatar
SoleneDc committed
747 748 749
       "Name: image, dtype: object"
      ]
     },
750
     "execution_count": 154,
SoleneDc's avatar
SoleneDc committed
751 752 753 754 755 756 757 758 759 760
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train['image'].head()"
   ]
  },
  {
   "cell_type": "code",
761
   "execution_count": 155,
SoleneDc's avatar
SoleneDc committed
762 763 764 765 766
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
767
       "((3032, 21), (759, 21))"
SoleneDc's avatar
SoleneDc committed
768 769
      ]
     },
770
     "execution_count": 155,
SoleneDc's avatar
SoleneDc committed
771 772 773 774 775 776 777 778 779 780
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train.shape, test.shape"
   ]
  },
  {
   "cell_type": "code",
781
   "execution_count": 156,
SoleneDc's avatar
SoleneDc committed
782
   "metadata": {},
SoleneDc's avatar
SoleneDc committed
783
   "outputs": [],
SoleneDc's avatar
SoleneDc committed
784
   "source": [
785 786 787 788
    "selected_genre = 28\n",
    "name = 'not' + str(selected_genre)\n",
    "train[name] = np.where(train[selected_genre] == 1, 0, 1)\n",
    "test[name] = np.where(test[selected_genre] == 1, 0, 1)\n",
SoleneDc's avatar
SoleneDc committed
789
    "X_train = train['image']\n",
790 791
    "Y_train = train[[selected_genre, name]]\n",
    "#Y_train = train.drop('image', 1)\n",
SoleneDc's avatar
SoleneDc committed
792
    "X_test = test['image']\n",
793 794
    "Y_test = test[[selected_genre, name]]\n",
    "#Y_test = test.drop('image', 1)"
SoleneDc's avatar
SoleneDc committed
795 796 797 798 799
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
800
   "metadata": {},
SoleneDc's avatar
SoleneDc committed
801
   "outputs": [],
802 803 804
   "source": [
    "\n"
   ]
SoleneDc's avatar
SoleneDc committed
805 806 807
  },
  {
   "cell_type": "code",
808
   "execution_count": 157,
SoleneDc's avatar
SoleneDc committed
809 810 811 812
   "metadata": {},
   "outputs": [
    {
     "data": {
813 814
      "text/html": [
       "<div>\n",
815 816 817
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
818 819 820 821 822
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
823 824 825 826
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>12</th>\n",
       "      <th>14</th>\n",
       "      <th>16</th>\n",
       "      <th>18</th>\n",
       "      <th>27</th>\n",
       "      <th>28</th>\n",
       "      <th>35</th>\n",
       "      <th>36</th>\n",
       "      <th>37</th>\n",
       "      <th>53</th>\n",
       "      <th>...</th>\n",
       "      <th>878</th>\n",
       "      <th>9648</th>\n",
       "      <th>10402</th>\n",
       "      <th>10749</th>\n",
       "      <th>10751</th>\n",
       "      <th>10752</th>\n",
       "      <th>10769</th>\n",
       "      <th>10770</th>\n",
       "      <th>image</th>\n",
SoleneDc's avatar
SoleneDc committed
852
       "      <th>not28</th>\n",
853 854 855 856
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
857
       "      <th>220</th>\n",
858 859 860 861 862
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
863
       "      <td>1</td>\n",
864 865 866
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
867
       "      <td>1</td>\n",
SoleneDc's avatar
SoleneDc committed
868
       "      <td>...</td>\n",
869
       "      <td>0</td>\n",
870
       "      <td>1</td>\n",
871 872 873 874 875 876
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
877
       "      <td>[[56, 147, 48], [56, 147, 48], [56, 147, 48], ...</td>\n",
878 879 880
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
881
       "      <th>6172</th>\n",
882 883 884
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
SoleneDc's avatar
SoleneDc committed
885
       "      <td>1</td>\n",
886 887 888 889 890 891
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
892
       "      <td>...</td>\n",
893 894 895 896
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
897
       "      <td>1</td>\n",
898 899
       "      <td>0</td>\n",
       "      <td>0</td>\n",
SoleneDc's avatar
SoleneDc committed
900
       "      <td>0</td>\n",
901 902
       "      <td>[[26, 28, 29], [53, 56, 60], [62, 68, 75], [64...</td>\n",
       "      <td>1</td>\n",
903 904
       "    </tr>\n",
       "    <tr>\n",
905
       "      <th>2500</th>\n",
906 907 908 909 910 911 912
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
913
       "      <td>1</td>\n",
914 915
       "      <td>0</td>\n",
       "      <td>0</td>\n",
916
       "      <td>...</td>\n",
917 918 919 920 921 922 923 924
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
925 926
       "      <td>[[8, 3, 0], [24, 15, 12], [38, 23, 21], [43, 2...</td>\n",
       "      <td>1</td>\n",
927 928
       "    </tr>\n",
       "    <tr>\n",
929
       "      <th>4922</th>\n",
SoleneDc's avatar
SoleneDc committed
930 931
       "      <td>0</td>\n",
       "      <td>0</td>\n",
932
       "      <td>0</td>\n",
933
       "      <td>1</td>\n",
934 935 936 937 938 939 940 941 942 943 944 945 946
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
SoleneDc's avatar
SoleneDc committed
947 948
       "      <td>0</td>\n",
       "      <td>0</td>\n",
949
       "      <td>[[9, 6, 1], [9, 6, 2], [5, 6, 2], [44, 47, 45]...</td>\n",
950 951 952
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
953
       "      <th>5943</th>\n",
954 955 956 957 958 959 960 961 962 963
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
SoleneDc's avatar
SoleneDc committed
964 965
       "      <td>...</td>\n",
       "      <td>0</td>\n",
966 967 968 969 970 971
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
972 973
       "      <td>0</td>\n",
       "      <td>[[42, 76, 70], [41, 80, 78], [48, 88, 87], [52...</td>\n",
SoleneDc's avatar
SoleneDc committed
974
       "      <td>1</td>\n",
975 976 977 978 979 980
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 22 columns</p>\n",
       "</div>"
      ],
SoleneDc's avatar
SoleneDc committed
981
      "text/plain": [
982
       "     12 14 16 18 27 28 35 36 37 53  ...  878 9648 10402 10749 10751 10752  \\\n",
983 984 985 986 987
       "220   0  0  0  1  0  1  0  0  0  1  ...    0    1     0     0     0     0   \n",
       "6172  0  0  0  1  0  0  0  0  0  0  ...    0    0     0     0     1     0   \n",
       "2500  0  0  0  0  0  0  0  1  0  0  ...    0    0     0     0     0     0   \n",
       "4922  0  0  0  1  0  0  0  1  0  0  ...    0    0     0     0     0     0   \n",
       "5943  0  0  0  1  0  0  0  0  0  0  ...    0    0     0     0     0     0   \n",
988
       "\n",
SoleneDc's avatar
SoleneDc committed
989
       "     10769 10770                                              image not28  \n",
990 991 992 993 994
       "220      0     0  [[56, 147, 48], [56, 147, 48], [56, 147, 48], ...     0  \n",
       "6172     0     0  [[26, 28, 29], [53, 56, 60], [62, 68, 75], [64...     1  \n",
       "2500     0     0  [[8, 3, 0], [24, 15, 12], [38, 23, 21], [43, 2...     1  \n",
       "4922     0     0  [[9, 6, 1], [9, 6, 2], [5, 6, 2], [44, 47, 45]...     1  \n",
       "5943     0     0  [[42, 76, 70], [41, 80, 78], [48, 88, 87], [52...     1  \n",
995 996
       "\n",
       "[5 rows x 22 columns]"
SoleneDc's avatar
SoleneDc committed
997 998
      ]
     },
999
     "execution_count": 157,
SoleneDc's avatar
SoleneDc committed
1000 1001 1002 1003 1004
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
1005 1006 1007 1008 1009
    "train.head()"
   ]
  },
  {
   "cell_type": "code",
1010
   "execution_count": 158,
1011 1012 1013 1014 1015 1016
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
1017 1018 1019
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
1020 1021 1022 1023 1024
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
1025 1026 1027 1028
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
1029 1030 1031 1032 1033
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
SoleneDc's avatar
SoleneDc committed
1034
       "      <th>not28</th>\n",
1035 1036
       "    </tr>\n",
       "    <tr>\n",
SoleneDc's avatar
SoleneDc committed
1037
       "      <th>28</th>\n",
1038 1039 1040 1041 1042 1043
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
1044
       "      <td>2406</td>\n",
1045 1046 1047
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
1048
       "      <td>626</td>\n",
1049 1050 1051 1052 1053 1054
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
SoleneDc's avatar
SoleneDc committed
1055 1056
       "    not28\n",
       "28       \n",
1057 1058
       "0    2406\n",
       "1     626"
1059 1060
      ]
     },
1061
     "execution_count": 158,
1062 1063 1064 1065 1066 1067 1068 1069 1070 1071
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "Y_train.groupby(selected_genre).count()"
   ]
  },
  {
   "cell_type": "code",
1072
   "execution_count": 159,
1073 1074 1075 1076 1077
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
SoleneDc's avatar
SoleneDc committed
1078
       "0.8378588052754073"
1079 1080
      ]
     },
1081
     "execution_count": 159,
1082 1083 1084 1085 1086
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
SoleneDc's avatar
SoleneDc committed
1087
    "1080/(1080+209)"
SoleneDc's avatar
SoleneDc committed
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Vérifications des données"
   ]
  },
  {
   "cell_type": "code",
SoleneDc's avatar
SoleneDc committed
1099
   "execution_count": null,
1100
   "metadata": {},
SoleneDc's avatar
SoleneDc committed
1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "code",
1113 1114
   "execution_count": 160,
   "metadata": {},
SoleneDc's avatar
SoleneDc committed
1115 1116 1117 1118 1119 1120 1121 1122
   "outputs": [],
   "source": [
    "X_train = pad_sequences(X_train)\n",
    "X_test = pad_sequences(X_test)"
   ]
  },
  {
   "cell_type": "code",
1123
   "execution_count": 161,
SoleneDc's avatar
SoleneDc committed
1124
   "metadata": {},
SoleneDc's avatar
SoleneDc committed
1125
   "outputs": [],
SoleneDc's avatar
SoleneDc committed
1126 1127 1128
   "source": [
    "input_shapeA = (X_train.shape[1], X_train.shape[2])"
   ]
SoleneDc's avatar
SoleneDc committed
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Modèle"
   ]
  },
  {
   "cell_type": "code",
1139
   "execution_count": 167,
SoleneDc's avatar
SoleneDc committed
1140 1141 1142 1143 1144 1145
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
1146 1147 1148 1149 1150
      "Conv1D 1 : (None, 4011, 2)\n",
      "MaxP1D 1 : (None, 2005, 2)\n",
      "Conv1D 2 : (None, 2003, 4)\n",
      "MaxP1D 2 : (None, 1001, 4)\n",
      "Flatten : (None, 4004)\n",
1151
      "Dense  2 : (None, 2)\n"
SoleneDc's avatar
SoleneDc committed
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161
     ]
    }
   ],
   "source": [
    "from keras.models import Sequential\n",
    "from keras.layers import Dense, Activation\n",
    "from keras.layers import Conv1D, MaxPooling1D\n",
    "from keras.layers import Dropout, Average, BatchNormalization\n",
    "from keras.layers import Flatten\n",
    "\n",
1162
    "num_classes=2\n",
SoleneDc's avatar
SoleneDc committed
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176
    "\n",
    "#Hyperparameters\n",
    "filtersCNN1=2 #pourquoi ??\n",
    "kernelSize1=3\n",
    "\n",
    "filtersCNN2=4\n",
    "kernelSize2=3\n",
    "\n",
    "unitsFC1=1000\n",
    "unitsFC2=num_classes\n",
    "\n",
    "#defining the layers architecture\n",
    "\n",
    "model = Sequential()\n",
SoleneDc's avatar
SoleneDc committed
1177
    "model.add(Conv1D(filtersCNN1,kernelSize1,strides=1, padding=\"valid\", activation='relu',input_shape=input_shapeA))\n",
SoleneDc's avatar
SoleneDc committed
1178 1179 1180 1181
    "print(\"Conv1D 1 : {}\".format(model.output_shape))\n",
    "model.add(MaxPooling1D(pool_size=2,padding=\"valid\"))\n",
    "print(\"MaxP1D 1 : {}\".format(model.output_shape))\n",
    "#BatchNormalization(axis=3)\n",
1182
    "#model.add(Dropout(0.25))\n",
SoleneDc's avatar
SoleneDc committed
1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199
    "\n",
    "model.add(Conv1D(filtersCNN2,kernelSize2,strides=1, padding=\"valid\", activation='relu'))\n",
    "print(\"Conv1D 2 : {}\".format(model.output_shape))\n",
    "model.add(MaxPooling1D(pool_size=2,strides=None,padding=\"valid\"))\n",
    "print(\"MaxP1D 2 : {}\".format(model.output_shape))\n",
    "#BatchNormalization(axis=3)\n",
    "\n",
    "model.add(Flatten())\n",
    "print(\"Flatten : {}\".format(model.output_shape))\n",
    "#model.add(Dense(1000, activation='relu'))\n",
    "#print(\"Dense  1 : {}\".format(model.output_shape))\n",
    "model.add(Dense(num_classes, activation='softmax'))\n",
    "print(\"Dense  2 : {}\".format(model.output_shape))"
   ]
  },
  {
   "cell_type": "code",
1200
   "execution_count": 168,
SoleneDc's avatar
SoleneDc committed
1201 1202 1203 1204 1205 1206 1207 1208 1209
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "_________________________________________________________________\n",
      "Layer (type)                 Output Shape              Param #   \n",
      "=================================================================\n",
1210
      "conv1d_7 (Conv1D)            (None, 4011, 2)           20        \n",
SoleneDc's avatar
SoleneDc committed
1211
      "_________________________________________________________________\n",
1212
      "max_pooling1d_7 (MaxPooling1 (None, 2005, 2)           0         \n",
SoleneDc's avatar
SoleneDc committed
1213
      "_________________________________________________________________\n",
1214
      "conv1d_8 (Conv1D)            (None, 2003, 4)           28        \n",
SoleneDc's avatar
SoleneDc committed
1215
      "_________________________________________________________________\n",
1216
      "max_pooling1d_8 (MaxPooling1 (None, 1001, 4)           0         \n",
SoleneDc's avatar
SoleneDc committed
1217
      "_________________________________________________________________\n",
1218
      "flatten_4 (Flatten)          (None, 4004)              0         \n",
SoleneDc's avatar
SoleneDc committed
1219
      "_________________________________________________________________\n",
1220
      "dense_4 (Dense)              (None, 2)                 8010      \n",
SoleneDc's avatar
SoleneDc committed
1221
      "=================================================================\n",
1222 1223
      "Total params: 8,058\n",
      "Trainable params: 8,058\n",
SoleneDc's avatar
SoleneDc committed
1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241
      "Non-trainable params: 0\n",
      "_________________________________________________________________\n"
     ]
    }
   ],
   "source": [
    "model.summary()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Entrainement du modèle"
   ]
  },
  {
   "cell_type": "code",
1242
   "execution_count": null,
SoleneDc's avatar
SoleneDc committed
1243 1244 1245 1246 1247 1248
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
1249
      "Train on 2122 samples, validate on 910 samples\n",
SoleneDc's avatar
SoleneDc committed
1250
      "Epoch 1/100\n",
1251
      "2122/2122 [==============================] - 2s 795us/step - loss: 3.2665 - acc: 0.7926 - val_loss: 3.4155 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1252
      "Epoch 2/100\n",
1253
      "2122/2122 [==============================] - 1s 678us/step - loss: 3.2205 - acc: 0.7978 - val_loss: 3.4157 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1254
      "Epoch 3/100\n",
1255
      "2122/2122 [==============================] - 1s 690us/step - loss: 3.2203 - acc: 0.7978 - val_loss: 3.4155 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1256
      "Epoch 4/100\n",
1257
      "2122/2122 [==============================] - 1s 686us/step - loss: 3.2207 - acc: 0.7978 - val_loss: 3.4161 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1258
      "Epoch 5/100\n",
1259
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2216 - acc: 0.7974 - val_loss: 3.4991 - val_acc: 0.7780\n",
SoleneDc's avatar
SoleneDc committed
1260
      "Epoch 6/100\n",
1261
      "2122/2122 [==============================] - 1s 686us/step - loss: 3.3181 - acc: 0.7917 - val_loss: 3.5394 - val_acc: 0.7758\n",
SoleneDc's avatar
SoleneDc committed
1262
      "Epoch 7/100\n",
1263
      "2122/2122 [==============================] - 2s 707us/step - loss: 3.3345 - acc: 0.7903 - val_loss: 3.4161 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1264
      "Epoch 8/100\n",
1265
      "2122/2122 [==============================] - 2s 747us/step - loss: 3.2276 - acc: 0.7969 - val_loss: 3.3986 - val_acc: 0.7846\n",
SoleneDc's avatar
SoleneDc committed
1266
      "Epoch 9/100\n",
1267
      "2122/2122 [==============================] - 1s 690us/step - loss: 3.2504 - acc: 0.7955 - val_loss: 3.3991 - val_acc: 0.7846\n",
SoleneDc's avatar
SoleneDc committed
1268
      "Epoch 10/100\n",
1269
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2359 - acc: 0.7964 - val_loss: 3.4157 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1270
      "Epoch 11/100\n",
1271
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2141 - acc: 0.7978 - val_loss: 3.4156 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1272
      "Epoch 12/100\n",
1273
      "2122/2122 [==============================] - 1s 678us/step - loss: 3.2125 - acc: 0.7978 - val_loss: 3.4155 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1274
      "Epoch 13/100\n",
1275
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2106 - acc: 0.7978 - val_loss: 3.4154 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1276
      "Epoch 14/100\n",
1277
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2100 - acc: 0.7978 - val_loss: 3.4155 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1278
      "Epoch 15/100\n",
1279
      "2122/2122 [==============================] - 1s 697us/step - loss: 3.2097 - acc: 0.7978 - val_loss: 3.4161 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1280
      "Epoch 16/100\n",
1281
      "2122/2122 [==============================] - 1s 678us/step - loss: 3.2084 - acc: 0.7983 - val_loss: 3.4157 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1282
      "Epoch 17/100\n",
1283
      "2122/2122 [==============================] - 1s 690us/step - loss: 3.2083 - acc: 0.7983 - val_loss: 3.4155 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1284
      "Epoch 18/100\n",
1285
      "2122/2122 [==============================] - 1s 678us/step - loss: 3.2081 - acc: 0.7983 - val_loss: 3.4156 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1286
      "Epoch 19/100\n",
1287
      "2122/2122 [==============================] - 1s 683us/step - loss: 3.2079 - acc: 0.7983 - val_loss: 3.4154 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1288
      "Epoch 20/100\n",
1289
      "2122/2122 [==============================] - 1s 678us/step - loss: 3.2080 - acc: 0.7983 - val_loss: 3.4155 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1290
      "Epoch 21/100\n",
1291
      "2122/2122 [==============================] - 1s 690us/step - loss: 3.2076 - acc: 0.7983 - val_loss: 3.4154 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1292
      "Epoch 22/100\n",
1293
      "2122/2122 [==============================] - 2s 707us/step - loss: 3.2073 - acc: 0.7983 - val_loss: 3.4155 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1294
      "Epoch 23/100\n",
1295
      "2122/2122 [==============================] - 2s 707us/step - loss: 3.2072 - acc: 0.7983 - val_loss: 3.4155 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1296
      "Epoch 24/100\n",
1297
      "2122/2122 [==============================] - 1s 678us/step - loss: 3.2136 - acc: 0.7978 - val_loss: 3.4164 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1298
      "Epoch 25/100\n",
1299
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2175 - acc: 0.7978 - val_loss: 3.4162 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1300
      "Epoch 26/100\n",
1301
      "2122/2122 [==============================] - 1s 678us/step - loss: 3.2154 - acc: 0.7978 - val_loss: 3.4170 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1302
      "Epoch 27/100\n",
1303
      "2122/2122 [==============================] - 1s 675us/step - loss: 3.2129 - acc: 0.7978 - val_loss: 3.4161 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1304
      "Epoch 28/100\n",
1305
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2117 - acc: 0.7978 - val_loss: 3.4164 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1306
      "Epoch 29/100\n",
1307
      "2122/2122 [==============================] - 1s 683us/step - loss: 3.2106 - acc: 0.7978 - val_loss: 3.4161 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1308
      "Epoch 30/100\n",
1309
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2092 - acc: 0.7978 - val_loss: 3.4161 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1310
      "Epoch 31/100\n",
1311
      "2122/2122 [==============================] - 1s 683us/step - loss: 3.2088 - acc: 0.7978 - val_loss: 3.4169 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1312
      "Epoch 32/100\n",
1313
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2080 - acc: 0.7978 - val_loss: 3.4161 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1314
      "Epoch 33/100\n",
1315
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2072 - acc: 0.7983 - val_loss: 3.4167 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1316
      "Epoch 34/100\n",
1317
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2075 - acc: 0.7983 - val_loss: 3.4165 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1318
      "Epoch 35/100\n",
1319
      "2122/2122 [==============================] - 1s 683us/step - loss: 3.2075 - acc: 0.7983 - val_loss: 3.4167 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1320
      "Epoch 36/100\n",
1321
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2068 - acc: 0.7983 - val_loss: 3.4165 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1322
      "Epoch 37/100\n",
1323
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2070 - acc: 0.7983 - val_loss: 3.4164 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1324
      "Epoch 38/100\n",
1325
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2070 - acc: 0.7983 - val_loss: 3.4165 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1326
      "Epoch 39/100\n",
1327
      "2122/2122 [==============================] - 1s 699us/step - loss: 3.2068 - acc: 0.7983 - val_loss: 3.4166 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1328
      "Epoch 40/100\n",
1329
      "2122/2122 [==============================] - 1s 691us/step - loss: 3.2072 - acc: 0.7983 - val_loss: 3.4165 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1330
      "Epoch 41/100\n",
1331
      "2122/2122 [==============================] - 1s 700us/step - loss: 3.2066 - acc: 0.7983 - val_loss: 3.4166 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1332
      "Epoch 42/100\n",
1333
      "2122/2122 [==============================] - 1s 693us/step - loss: 3.2067 - acc: 0.7983 - val_loss: 3.4166 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1334
      "Epoch 43/100\n",
1335
      "2122/2122 [==============================] - 1s 689us/step - loss: 3.2066 - acc: 0.7983 - val_loss: 3.4166 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1336
      "Epoch 44/100\n",
1337
      "2122/2122 [==============================] - 2s 707us/step - loss: 3.2068 - acc: 0.7983 - val_loss: 3.4167 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1338
      "Epoch 45/100\n",
1339
      "2122/2122 [==============================] - 1s 692us/step - loss: 3.2066 - acc: 0.7983 - val_loss: 3.4167 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1340
      "Epoch 46/100\n",
1341
      "2122/2122 [==============================] - 1s 692us/step - loss: 3.2068 - acc: 0.7983 - val_loss: 3.4168 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1342
      "Epoch 47/100\n",
1343
      "2122/2122 [==============================] - 1s 683us/step - loss: 3.2065 - acc: 0.7983 - val_loss: 3.4167 - val_acc: 0.7835\n",
SoleneDc's avatar
SoleneDc committed
1344
      "Epoch 48/100\n",
1345
      "2122/2122 [==============================] - 1s 686us/step - loss: 3.2065 - acc: 0.7983 - val_loss: 3.4168 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1346
      "Epoch 49/100\n",
1347
      "2122/2122 [==============================] - 1s 675us/step - loss: 3.2066 - acc: 0.7983 - val_loss: 3.4169 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1348
      "Epoch 50/100\n",
1349
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2064 - acc: 0.7983 - val_loss: 3.4169 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1350
      "Epoch 51/100\n",
1351
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2065 - acc: 0.7983 - val_loss: 3.4169 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1352
      "Epoch 52/100\n",
1353
      "2122/2122 [==============================] - 1s 678us/step - loss: 3.2067 - acc: 0.7983 - val_loss: 3.4169 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1354
      "Epoch 53/100\n",
1355
      "2122/2122 [==============================] - 1s 697us/step - loss: 3.2071 - acc: 0.7978 - val_loss: 3.4169 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1356
      "Epoch 54/100\n",
1357
      "2122/2122 [==============================] - 1s 678us/step - loss: 3.2065 - acc: 0.7983 - val_loss: 3.4170 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1358
      "Epoch 55/100\n",
1359
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2074 - acc: 0.7992 - val_loss: 3.4170 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1360
      "Epoch 56/100\n",
1361
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2064 - acc: 0.7983 - val_loss: 3.4170 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1362
      "Epoch 57/100\n",
1363
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2067 - acc: 0.7983 - val_loss: 3.4170 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1364
      "Epoch 58/100\n",
1365
      "2122/2122 [==============================] - 1s 700us/step - loss: 3.2063 - acc: 0.7983 - val_loss: 3.4171 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1366
      "Epoch 59/100\n",
1367
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2061 - acc: 0.7983 - val_loss: 3.4172 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1368
      "Epoch 60/100\n"
SoleneDc's avatar
SoleneDc committed
1369 1370 1371 1372 1373 1374
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
1375
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2066 - acc: 0.7978 - val_loss: 3.4173 - val_acc: 0.7824\n",
1376
      "Epoch 61/100\n",
1377
      "2122/2122 [==============================] - 1s 693us/step - loss: 3.2062 - acc: 0.7983 - val_loss: 3.4172 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1378
      "Epoch 62/100\n",
1379
      "2122/2122 [==============================] - 1s 675us/step - loss: 3.2062 - acc: 0.7983 - val_loss: 3.4173 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1380
      "Epoch 63/100\n",
1381
      "2122/2122 [==============================] - 1s 678us/step - loss: 3.2063 - acc: 0.7983 - val_loss: 3.4172 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1382
      "Epoch 64/100\n",
1383
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2061 - acc: 0.7988 - val_loss: 3.4172 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1384
      "Epoch 65/100\n",
1385
      "2122/2122 [==============================] - 1s 700us/step - loss: 3.2062 - acc: 0.7983 - val_loss: 3.4172 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1386
      "Epoch 66/100\n",
1387
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2066 - acc: 0.7983 - val_loss: 3.4174 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1388
      "Epoch 67/100\n",
1389
      "2122/2122 [==============================] - 2s 708us/step - loss: 3.2064 - acc: 0.7988 - val_loss: 3.4172 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1390
      "Epoch 68/100\n",
1391
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2063 - acc: 0.7983 - val_loss: 3.4173 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1392
      "Epoch 69/100\n",
1393
      "2122/2122 [==============================] - 1s 683us/step - loss: 3.2070 - acc: 0.7983 - val_loss: 3.4175 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1394
      "Epoch 70/100\n",
1395
      "2122/2122 [==============================] - 1s 676us/step - loss: 3.2062 - acc: 0.7988 - val_loss: 3.4173 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1396
      "Epoch 71/100\n",
1397
      "2122/2122 [==============================] - 1s 683us/step - loss: 3.2059 - acc: 0.7978 - val_loss: 3.4174 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1398
      "Epoch 72/100\n",
1399
      "2122/2122 [==============================] - 1s 678us/step - loss: 3.2060 - acc: 0.7988 - val_loss: 3.4173 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1400
      "Epoch 73/100\n",
1401
      "2122/2122 [==============================] - 1s 675us/step - loss: 3.2062 - acc: 0.7983 - val_loss: 3.4173 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1402
      "Epoch 74/100\n",
1403
      "2122/2122 [==============================] - 1s 700us/step - loss: 3.2060 - acc: 0.7978 - val_loss: 3.4173 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1404
      "Epoch 75/100\n",
1405
      "2122/2122 [==============================] - 1s 675us/step - loss: 3.2060 - acc: 0.7988 - val_loss: 3.4174 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1406
      "Epoch 76/100\n",
1407
      "2122/2122 [==============================] - 1s 678us/step - loss: 3.2057 - acc: 0.7988 - val_loss: 3.4177 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1408
      "Epoch 77/100\n",
1409
      "2122/2122 [==============================] - 1s 683us/step - loss: 3.2063 - acc: 0.7988 - val_loss: 3.4173 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1410
      "Epoch 78/100\n",
1411
      "2122/2122 [==============================] - 1s 686us/step - loss: 3.2059 - acc: 0.7988 - val_loss: 3.4173 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1412
      "Epoch 79/100\n",
1413
      "2122/2122 [==============================] - 1s 683us/step - loss: 3.2060 - acc: 0.7988 - val_loss: 3.4173 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1414
      "Epoch 80/100\n",
1415
      "2122/2122 [==============================] - 1s 678us/step - loss: 3.2063 - acc: 0.7983 - val_loss: 3.4174 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1416
      "Epoch 81/100\n",
1417
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2059 - acc: 0.7978 - val_loss: 3.4173 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1418
      "Epoch 82/100\n",
1419
      "2122/2122 [==============================] - 1s 675us/step - loss: 3.2061 - acc: 0.7983 - val_loss: 3.4174 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1420
      "Epoch 83/100\n",
1421
      "2122/2122 [==============================] - 1s 693us/step - loss: 3.2058 - acc: 0.7992 - val_loss: 3.4173 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1422
      "Epoch 84/100\n",
1423
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2058 - acc: 0.7988 - val_loss: 3.4174 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1424
      "Epoch 85/100\n",
1425
      "2122/2122 [==============================] - 1s 683us/step - loss: 3.2058 - acc: 0.7992 - val_loss: 3.4174 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1426
      "Epoch 86/100\n",
1427
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2058 - acc: 0.7988 - val_loss: 3.4173 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1428
      "Epoch 87/100\n",
1429
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2059 - acc: 0.7988 - val_loss: 3.4173 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1430
      "Epoch 88/100\n",
1431
      "2122/2122 [==============================] - 1s 684us/step - loss: 3.2059 - acc: 0.7992 - val_loss: 3.4173 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1432
      "Epoch 89/100\n",
1433
      "2122/2122 [==============================] - 1s 682us/step - loss: 3.2059 - acc: 0.7988 - val_loss: 3.4176 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1434
      "Epoch 90/100\n",
1435
      "2122/2122 [==============================] - 1s 685us/step - loss: 3.2070 - acc: 0.7988 - val_loss: 3.4172 - val_acc: 0.7824\n",
SoleneDc's avatar
SoleneDc committed
1436
      "Epoch 91/100\n",
1437
      "1750/2122 [=======================>......] - ETA: 0s - loss: 3.1947 - acc: 0.7989"
SoleneDc's avatar
SoleneDc committed
1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450
     ]
    }
   ],
   "source": [
    "model.compile(loss='categorical_crossentropy',\n",
    "              optimizer='adam',\n",
    "              metrics=['accuracy'])\n",
    "\n",
    "history = model.fit(X_train, Y_train, epochs=100, validation_split=0.3, batch_size=50 , verbose=1)"
   ]
  },
  {
   "cell_type": "code",
1451
   "execution_count": null,
SoleneDc's avatar
SoleneDc committed
1452
   "metadata": {},
1453
   "outputs": [],
SoleneDc's avatar
SoleneDc committed
1454 1455 1456 1457
   "source": [
    "import matplotlib.pyplot as plt\n",
    "train, =plt.plot(history.history['acc'], label='Train set')\n",
    "val, =plt.plot(history.history['val_acc'], label='Validation set')\n",
1458
    "print('')\n",
SoleneDc's avatar
SoleneDc committed
1459
    "print(f\"       Année: {year}   //  Genre: {selected_genre}  //  Données X_train: {X_train.shape}\")\n",
1460
    "print('')\n",
SoleneDc's avatar
SoleneDc committed
1461
    "plt.title('model accuracy')\n",
1462
    "plt.ylabel(\"Accuracy\")\n",
SoleneDc's avatar
SoleneDc committed
1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477
    "plt.xlabel('Epochs')\n",
    "plt.legend(handles=[train, val])\n",
    "plt.show()\n",
    "train, =plt.plot(history.history['loss'], label='Train set')\n",
    "val, =plt.plot(history.history['val_loss'], label='Validation set')\n",
    "plt.title('model Loss')\n",
    "plt.ylabel('Cross entropy')\n",
    "plt.xlabel('Epochs')\n",
    "plt.legend(handles=[train, val])\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
1478 1479 1480 1481 1482 1483 1484 1485
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
SoleneDc's avatar
SoleneDc committed
1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
1506
   "version": "3.6.4"
SoleneDc's avatar
SoleneDc committed
1507 1508 1509 1510 1511
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}