From 91a17cd55fba53f2383d510a3ae945342c024532 Mon Sep 17 00:00:00 2001 From: Mohamed Abo Al Kuar Date: Mon, 24 Aug 2020 19:52:17 +0200 Subject: [PATCH] Delete model_color_correction_crop_standrize.ipynb --- ...odel_color_correction_crop_standrize.ipynb | 856 ------------------ 1 file changed, 856 deletions(-) delete mode 100644 main code/model_color_correction_crop_standrize.ipynb diff --git a/main code/model_color_correction_crop_standrize.ipynb b/main code/model_color_correction_crop_standrize.ipynb deleted file mode 100644 index 8f14136..0000000 --- a/main code/model_color_correction_crop_standrize.ipynb +++ /dev/null @@ -1,856 +0,0 @@ -{ - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "name": "model_color_correction_crop_standrize.ipynb", - "provenance": [], - "collapsed_sections": [], - "toc_visible": true, - "machine_shape": "hm" - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "accelerator": "GPU" - }, - "cells": [ - { - "cell_type": "code", - "metadata": { - "id": "z9y7dkxN6AWc", - "colab_type": "code", - "outputId": "4b9cfa9f-085f-4429-ec2f-7479111e87ee", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 81 - } - }, - "source": [ - "\n", - "from keras.models import load_model\n", - "from keras.preprocessing import image\n", - "import matplotlib.pyplot as plt\n", - "import numpy as np\n", - "import os\n", - "\n", - "def load_image(img_path):\n", - "\n", - " img = image.load_img(img_path, target_size=(224, 224))\n", - " img_tensor = image.img_to_array(img) # (height, width, channels)\n", - " #img_tensor = np.expand_dims(img_tensor, axis=0) # (1, height, width, channels), add a dimension because the model expects this shape: (batch_size, height, width, channels)\n", - " return img_tensor \n", - "\n", - "#result=model_1.predict(load_image(\"/content/drive/My Drive/skin_cancer_models/model_1_nv_others/data/validation/nv/ISIC_0024306.jpg\"))\n", - "#print(result)" - ], - "execution_count": 0, - "outputs": [ - { - "output_type": "stream", - "text": [ - "Using TensorFlow backend.\n" - ], - "name": "stderr" - }, - { - "output_type": "display_data", - "data": { - "text/html": [ - "

\n", - "The default version of TensorFlow in Colab will soon switch to TensorFlow 2.x.
\n", - "We recommend you upgrade now \n", - "or ensure your notebook will continue to use TensorFlow 1.x via the %tensorflow_version 1.x magic:\n", - "more info.

\n" - ], - "text/plain": [ - "" - ] - }, - "metadata": { - "tags": [] - } - } - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "CV6T4JuM6k2j", - "colab_type": "code", - "colab": {} - }, - "source": [ - "import glob\n", - "def features_ex(file_path,lable):\n", - " counter=0\n", - " x_train=[]\n", - " y_train=[]\n", - " for filename in glob.glob(file_path+\"/*.jpg\"): #assuming gif \n", - " x_train.append(load_image(filename))\n", - " y_train.append(lable) \n", - " counter=counter+1\n", - " print(counter) \n", - " return x_train,y_train\n" - ], - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "9Y6YK1pOER3s", - "colab_type": "code", - "outputId": "8ff9f51a-40a6-4003-8e82-03e9e2883db8", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 126 - } - }, - "source": [ - "from google.colab import drive\n", - "drive.mount('/content/drive')" - ], - "execution_count": 0, - "outputs": [ - { - "output_type": "stream", - "text": [ - "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&response_type=code&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\n", - "\n", - "Enter your authorization code:\n", - "··········\n", - "Mounted at /content/drive\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "4V9edZUk40Kx", - "colab_type": "code", - "outputId": "26e5db66-d056-4bf6-ad37-d3590f9852fb", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 232 - } - }, - "source": [ - "#edit here to chose classes and make your dataset\n", - "x_train_nv=[]\n", - "y_train_nv=[]\n", - "x_train_nv,y_train_nv=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/nv/train\",0)\n", - "\n", - "x_val_nv=[]\n", - "y_val_nv=[]\n", - "x_val_nv,y_val_nv=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/nv/validation\",0)\n", - "\n", - "\n", - "x_train_others1=[]\n", - "y_train_others1=[]\n", - "x_train_others1,y_train_others1=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/vasc/train\",2)\n", - "\n", - "x_val_others1=[]\n", - "y_val_others1=[]\n", - "x_val_others1,y_val_others1=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/vasc/validation\",2)\n", - "\n", - "x_train_others2=[]\n", - "y_train_others2=[]\n", - "x_train_others2,y_train_others2=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/mel/train\",1)\n", - "\n", - "x_val_others2=[]\n", - "y_val_others2=[]\n", - "x_val_others2,y_val_others2=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/mel/validation\",1)\n", - "\n", - "x_train_others3=[]\n", - "y_train_others3=[]\n", - "x_train_others3,y_train_others3=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/df/train\",2)\n", - "\n", - "x_val_others3=[]\n", - "y_val_others3=[]\n", - "x_val_others3,y_val_others3=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/df/validation\",2)\n", - "\n", - "x_train_others4=[]\n", - "y_train_others4=[]\n", - "x_train_others4,y_train_others=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/bkl/train\",0)\n", - "\n", - "x_val_others4=[]\n", - "y_val_others4=[]\n", - "x_val_others4,y_val_others4=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/bkl/validation\",0)\n", - "\n", - "x_train_others5=[]\n", - "y_train_others5=[]\n", - "x_train_others5,y_train_others5=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/bcc/train\",2)\n", - "\n", - "x_val_others5=[]\n", - "y_val_others5=[]\n", - "x_val_others5,y_val_others5=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/bcc/validation\",2)\n", - "\n", - "x_train_others6=[]\n", - "y_train_others6=[]\n", - "x_train_others6,y_train_others6=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/akiec/train\",2)\n", - "\n", - "x_val_others6=[]\n", - "y_val_others6=[]\n", - "x_val_others6,y_val_others1=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/akiec/validation\",2)\n", - "\n", - "X_TRAIN=[]\n", - "Y_TRAIN=[]\n", - "X_VAL=[]\n", - "Y_VAL=[]\n", - "\n", - "X_TRAIN=x_train_others1+x_train_others2+x_train_others3+x_train_others4+x_train_others5+x_train_others6\n", - "Y_TRAIN=y_train_others1+y_train_others2+y_train_others3+y_train_others4+y_train_others5+y_train_others6\n", - "\n", - "X_VAL=x_val_others1+x_val_others2+x_val_others3+x_val_others4+x_val_others5+x_val_others6\n", - "Y_VAL=y_val_others1+y_val_others2+y_val_others3+y_val_others4+y_val_others5+y_val_others6\n", - "\n", - "\n", - "\n", - "\n" - ], - "execution_count": 0, - "outputs": [ - { - "output_type": "stream", - "text": [ - "113\n", - "29\n", - "890\n", - "223\n", - "92\n", - "23\n", - "879\n", - "220\n", - "401\n", - "103\n", - "261\n", - "66\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "8IbdeIfG4ucF", - "colab_type": "code", - "outputId": "e405d739-15e9-452b-8c4e-6376e84f7509", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 466 - } - }, - "source": [ - "print(len(y_train_others1))\n", - "print(len(y_train_others2))\n", - "print(len(y_train_others3))\n", - "print(len(y_train_others4))#\n", - "print(len(y_train_others5))\n", - "print(len(y_train_others6))\n", - "\n", - "print(len(y_val_others1))\n", - "print(len(y_val_others2))\n", - "print(len(y_val_others3))\n", - "print(len(y_val_others4))\n", - "print(len(y_val_others5))\n", - "print(len(y_val_others6))#\n", - "y_train_others1=len(x_train_others1)*[2]\n", - "y_train_others2=len(x_train_others2)*[1]\n", - "y_train_others3=len(x_train_others3)*[2]\n", - "y_train_others4=len(x_train_others4)*[0]\n", - "y_train_others5=len(x_train_others5)*[2]\n", - "y_train_others6=len(x_train_others6)*[2]\n", - "\n", - "\n", - "y_val_others1=len(x_val_others1)*[2]\n", - "y_val_others2=len(x_val_others2)*[1]\n", - "y_val_others3=len(x_val_others3)*[2]\n", - "y_val_others4=len(x_val_others4)*[0]\n", - "y_val_others5=len(x_val_others5)*[2]\n", - "y_val_others6=len(x_val_others6)*[2]\n", - "print(\"after\")\n", - "print(len(y_train_others1))\n", - "print(len(y_train_others2))\n", - "print(len(y_train_others3))\n", - "print(len(y_train_others4))#\n", - "print(len(y_train_others5))\n", - "print(len(y_train_others6))\n", - "\n", - "print(len(y_val_others1))\n", - "print(len(y_val_others2))\n", - "print(len(y_val_others3))\n", - "print(len(y_val_others4))\n", - "print(len(y_val_others5))\n", - "print(len(y_val_others6))#" - ], - "execution_count": 0, - "outputs": [ - { - "output_type": "stream", - "text": [ - "113\n", - "890\n", - "92\n", - "879\n", - "401\n", - "261\n", - "66\n", - "223\n", - "23\n", - "220\n", - "103\n", - "66\n", - "after\n", - "113\n", - "890\n", - "92\n", - "879\n", - "401\n", - "261\n", - "29\n", - "223\n", - "23\n", - "220\n", - "103\n", - "66\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "bmSI5SZt5IZ4", - "colab_type": "code", - "colab": {} - }, - "source": [ - "X_TRAIN=x_train_others1+x_train_others2+x_train_others3+x_train_others4+x_train_others5+x_train_others6\n", - "Y_TRAIN=y_train_others1+y_train_others2+y_train_others3+y_train_others4+y_train_others5+y_train_others6\n", - "\n", - "X_VAL=x_val_others1+x_val_others2+x_val_others3+x_val_others4+x_val_others5+x_val_others6\n", - "Y_VAL=y_val_others1+y_val_others2+y_val_others3+y_val_others4+y_val_others5+y_val_others6" - ], - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "OivAJ1ytsB_c", - "colab_type": "code", - "outputId": "d5c2003a-cbc5-4083-aa2f-ad4fc64a0aa2", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 196 - } - }, - "source": [ - "import math, os\n", - "from google.colab import drive\n", - "from keras import applications\n", - "from keras.layers import Convolution2D, MaxPooling2D, ZeroPadding2D\n", - "from sklearn.datasets import load_files \n", - "from glob import glob\n", - "from keras import applications\n", - "from keras.preprocessing.image import ImageDataGenerator \n", - "from keras import optimizers\n", - "from keras.models import Sequential,Model,load_model\n", - "from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPool2D,GlobalAveragePooling2D\n", - "from keras.callbacks import TensorBoard,ReduceLROnPlateau,ModelCheckpoint\n", - "!pip install keras-metrics\n", - "import keras\n", - "import keras_metrics\n", - "from google.colab import drive\n", - "drive.mount('/content/drive')" - ], - "execution_count": 0, - "outputs": [ - { - "output_type": "stream", - "text": [ - "Requirement already satisfied: keras-metrics in /usr/local/lib/python3.6/dist-packages (1.1.0)\n", - "Requirement already satisfied: Keras>=2.1.5 in /usr/local/lib/python3.6/dist-packages (from keras-metrics) (2.2.5)\n", - "Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.6/dist-packages (from Keras>=2.1.5->keras-metrics) (1.12.0)\n", - "Requirement already satisfied: numpy>=1.9.1 in /usr/local/lib/python3.6/dist-packages (from Keras>=2.1.5->keras-metrics) (1.17.5)\n", - "Requirement already satisfied: scipy>=0.14 in /usr/local/lib/python3.6/dist-packages (from Keras>=2.1.5->keras-metrics) (1.4.1)\n", - "Requirement already satisfied: keras-preprocessing>=1.1.0 in /usr/local/lib/python3.6/dist-packages (from Keras>=2.1.5->keras-metrics) (1.1.0)\n", - "Requirement already satisfied: h5py in /usr/local/lib/python3.6/dist-packages (from Keras>=2.1.5->keras-metrics) (2.8.0)\n", - "Requirement already satisfied: pyyaml in /usr/local/lib/python3.6/dist-packages (from Keras>=2.1.5->keras-metrics) (3.13)\n", - "Requirement already satisfied: keras-applications>=1.0.8 in /usr/local/lib/python3.6/dist-packages (from Keras>=2.1.5->keras-metrics) (1.0.8)\n", - "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "qLO68kjTxSyh", - "colab_type": "code", - "outputId": "237e2aa8-087c-4196-b26f-213184a2c251", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 88 - } - }, - "source": [ - "X_TRAIN=np.array(X_TRAIN)\n", - "Y_TRAIN=np.array(Y_TRAIN)\n", - "X_VAL=np.array(X_VAL)\n", - "Y_VAL=np.array(Y_VAL)\n", - "print(X_TRAIN.shape)\n", - "print(Y_TRAIN.shape)\n", - "print(X_VAL.shape)\n", - "print(Y_VAL.shape)" - ], - "execution_count": 0, - "outputs": [ - { - "output_type": "stream", - "text": [ - "(2636, 224, 224, 3)\n", - "(2636,)\n", - "(664, 224, 224, 3)\n", - "(664,)\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "VF9Qlj04lU7Y", - "colab_type": "code", - "colab": {} - }, - "source": [ - "datagen = ImageDataGenerator(\n", - " featurewise_center=True,\n", - " featurewise_std_normalization=True)\n", - "# compute quantities required for featurewise normalization\n", - "# (std, mean, and principal components if ZCA whitening is applied)\n", - "datagen.fit(X_TRAIN)\n", - "\n", - "\n" - ], - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "Xwy1friXy5J6", - "colab_type": "code", - "colab": {} - }, - "source": [ - "from keras.utils import to_categorical\n", - "Y_TRAIN = to_categorical(Y_TRAIN, 3)\n", - "Y_VAL = to_categorical(Y_VAL, 3)" - ], - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "neVRSl9Ww7Q0", - "colab_type": "code", - "colab": {} - }, - "source": [ - "batches = datagen.flow(X_TRAIN, Y_TRAIN, shuffle=True, batch_size=16)\n", - "val_batches = datagen.flow(X_VAL, Y_VAL, shuffle=True, batch_size=16)" - ], - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "yo93SA0J0ivj", - "colab_type": "code", - "outputId": "71364cf9-8d31-49ee-8cd8-171729f9d700", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 196 - } - }, - "source": [ - "!pip install keras-metrics\n", - "import keras\n", - "import keras_metrics\n", - "from google.colab import drive\n", - "drive.mount('/content/drive')" - ], - "execution_count": 0, - "outputs": [ - { - "output_type": "stream", - "text": [ - "Requirement already satisfied: keras-metrics in /usr/local/lib/python3.6/dist-packages (1.1.0)\n", - "Requirement already satisfied: Keras>=2.1.5 in /usr/local/lib/python3.6/dist-packages (from keras-metrics) (2.2.5)\n", - "Requirement already satisfied: keras-applications>=1.0.8 in /usr/local/lib/python3.6/dist-packages (from Keras>=2.1.5->keras-metrics) (1.0.8)\n", - "Requirement already satisfied: pyyaml in /usr/local/lib/python3.6/dist-packages (from Keras>=2.1.5->keras-metrics) (3.13)\n", - "Requirement already satisfied: scipy>=0.14 in /usr/local/lib/python3.6/dist-packages (from Keras>=2.1.5->keras-metrics) (1.4.1)\n", - "Requirement already satisfied: numpy>=1.9.1 in /usr/local/lib/python3.6/dist-packages (from Keras>=2.1.5->keras-metrics) (1.17.5)\n", - "Requirement already satisfied: keras-preprocessing>=1.1.0 in /usr/local/lib/python3.6/dist-packages (from Keras>=2.1.5->keras-metrics) (1.1.0)\n", - "Requirement already satisfied: six>=1.9.0 in /usr/local/lib/python3.6/dist-packages (from Keras>=2.1.5->keras-metrics) (1.12.0)\n", - "Requirement already satisfied: h5py in /usr/local/lib/python3.6/dist-packages (from Keras>=2.1.5->keras-metrics) (2.8.0)\n", - "Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "JZ1ErvzKsDpV", - "colab_type": "code", - "outputId": "ef09a66d-cb66-4d68-d80b-9b770bf7bb7c", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 1000 - } - }, - "source": [ - "#from tensorflow.keras.metrics import Recall\n", - "# nickname_model_v_verision_number \n", - "\n", - "\n", - "\n", - "SIZE = (224, 224)\n", - "BATCH_SIZE = 16\n", - "\n", - "num_train_steps = math.floor((113+890+92+879+401+261)/BATCH_SIZE)\n", - "num_valid_steps = math.floor((29+223+23+220+103+66)/BATCH_SIZE)\n", - "\n", - "\n", - "\n", - "model = applications.ResNet50()\n", - "#model = applications.ResNet101()\n", - "\n", - "\n", - "last = model.layers[-1].output\n", - "#x = Dropout(0.2)(last)\n", - "from keras import regularizers\n", - "#x = Dense(64, activation=\"relu\",kernel_regularizer=regularizers.l2(0.01),activity_regularizer=regularizers.l1(0.01))(last)\n", - "x = Dense(3, activation=\"softmax\")(last)\n", - "finetuned_model = Model(model.input, x)\n", - "finetuned_model.compile(optimizer=optimizers.Adam(lr=0.0001), loss='categorical_crossentropy', metrics=['accuracy',keras_metrics.categorical_recall(label=0),\n", - " keras_metrics.categorical_recall(label=1),\n", - " keras_metrics.categorical_recall(label=2) ])\n", - "\n", - "\n", - "history=finetuned_model.fit_generator(batches, steps_per_epoch=num_train_steps,\n", - " epochs=70, validation_data=val_batches, validation_steps=num_valid_steps)" - ], - "execution_count": 0, - "outputs": [ - { - "output_type": "stream", - "text": [ - "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/optimizers.py:793: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead.\n", - "\n", - "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:3576: The name tf.log is deprecated. Please use tf.math.log instead.\n", - "\n", - "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:1033: The name tf.assign_add is deprecated. Please use tf.compat.v1.assign_add instead.\n", - "\n", - "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/tensorflow_core/python/ops/math_grad.py:1424: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.\n", - "Instructions for updating:\n", - "Use tf.where in 2.0, which has the same broadcast rule as np.where\n", - "WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py:1020: The name tf.assign is deprecated. Please use tf.compat.v1.assign instead.\n", - "\n", - "Epoch 1/30\n", - "164/164 [==============================] - 38s 232ms/step - loss: 1.0730 - acc: 0.5908 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0721 - val_acc: 0.5381 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 2/30\n", - "164/164 [==============================] - 24s 146ms/step - loss: 1.0531 - acc: 0.6441 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0651 - val_acc: 0.5509 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 3/30\n", - "164/164 [==============================] - 24s 146ms/step - loss: 1.0448 - acc: 0.6437 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0686 - val_acc: 0.5262 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 4/30\n", - "164/164 [==============================] - 24s 146ms/step - loss: 1.0330 - acc: 0.6706 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0480 - val_acc: 0.5926 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 5/30\n", - "164/164 [==============================] - 24s 146ms/step - loss: 1.0216 - acc: 0.6916 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0519 - val_acc: 0.5432 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 6/30\n", - "164/164 [==============================] - 24s 146ms/step - loss: 1.0162 - acc: 0.6759 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0368 - val_acc: 0.5710 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 7/30\n", - "164/164 [==============================] - 24s 146ms/step - loss: 1.0023 - acc: 0.6979 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0509 - val_acc: 0.5077 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 8/30\n", - "164/164 [==============================] - 24s 146ms/step - loss: 0.9853 - acc: 0.7322 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0407 - val_acc: 0.5401 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 9/30\n", - "164/164 [==============================] - 24s 146ms/step - loss: 0.9776 - acc: 0.7218 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0289 - val_acc: 0.5664 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 10/30\n", - "164/164 [==============================] - 24s 146ms/step - loss: 0.9676 - acc: 0.7304 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0410 - val_acc: 0.5309 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 11/30\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.9622 - acc: 0.7233 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0397 - val_acc: 0.5154 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 12/30\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.9522 - acc: 0.7285 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0080 - val_acc: 0.5941 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 13/30\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.9449 - acc: 0.7278 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0137 - val_acc: 0.5602 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 14/30\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.9152 - acc: 0.7748 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0176 - val_acc: 0.5509 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 15/30\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.8877 - acc: 0.8185 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 0.9853 - val_acc: 0.6019 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 16/30\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.8812 - acc: 0.8053 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0082 - val_acc: 0.5602 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 17/30\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.8702 - acc: 0.8088 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0015 - val_acc: 0.5710 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 18/30\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.8574 - acc: 0.8130 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 1.0110 - val_acc: 0.5494 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 19/30\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.8350 - acc: 0.8354 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 0.9546 - val_acc: 0.6312 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 20/30\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.8105 - acc: 0.8565 - recall: 0.0000e+00 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 0.9401 - val_acc: 0.6512 - val_recall: 0.0000e+00 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 21/30\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.7833 - acc: 0.8815 - recall: 0.0934 - recall_1: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 0.9067 - val_acc: 0.6836 - val_recall: 0.3524 - val_recall_1: 0.0000e+00 - val_recall_2: 0.0000e+00\n", - "Epoch 22/30\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.7791 - acc: 0.8721 - recall: 0.8182 - recall_1: 0.3733 - recall_2: 0.5355 - val_loss: 0.9411 - val_acc: 0.6281 - val_recall: 0.4324 - val_recall_1: 0.6682 - val_recall_2: 0.5142\n", - "Epoch 23/30\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.7471 - acc: 0.8979 - recall: 0.8449 - recall_1: 0.8375 - recall_2: 0.8969 - val_loss: 0.9262 - val_acc: 0.6451 - val_recall: 0.5425 - val_recall_1: 0.5482 - val_recall_2: 0.6250\n", - "Epoch 24/30\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.7358 - acc: 0.9008 - recall: 0.8333 - recall_1: 0.8664 - recall_2: 0.8734 - val_loss: 0.9159 - val_acc: 0.6605 - val_recall: 0.6119 - val_recall_1: 0.4150 - val_recall_2: 0.6812\n", - "Epoch 25/30\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.7172 - acc: 0.9093 - recall: 0.8604 - recall_1: 0.8730 - recall_2: 0.8919 - val_loss: 0.9568 - val_acc: 0.5972 - val_recall: 0.6456 - val_recall_1: 0.4421 - val_recall_2: 0.5215\n", - "Epoch 26/30\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.6919 - acc: 0.9256 - recall: 0.8981 - recall_1: 0.9023 - recall_2: 0.9131 - val_loss: 0.8831 - val_acc: 0.6883 - val_recall: 0.6343 - val_recall_1: 0.4460 - val_recall_2: 0.7671\n", - "Epoch 27/30\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.6722 - acc: 0.9366 - recall: 0.9077 - recall_1: 0.8983 - recall_2: 0.9482 - val_loss: 0.9238 - val_acc: 0.6296 - val_recall: 0.4885 - val_recall_1: 0.4425 - val_recall_2: 0.8634\n", - "Epoch 28/30\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.6584 - acc: 0.9392 - recall: 0.9044 - recall_1: 0.9090 - recall_2: 0.9467 - val_loss: 0.8926 - val_acc: 0.6636 - val_recall: 0.5048 - val_recall_1: 0.5399 - val_recall_2: 0.7885\n", - "Epoch 29/30\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.6357 - acc: 0.9501 - recall: 0.9163 - recall_1: 0.9492 - recall_2: 0.9520 - val_loss: 0.8644 - val_acc: 0.6806 - val_recall: 0.4630 - val_recall_1: 0.6699 - val_recall_2: 0.7489\n", - "Epoch 30/30\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.6150 - acc: 0.9607 - recall: 0.9259 - recall_1: 0.9513 - recall_2: 0.9714 - val_loss: 0.9446 - val_acc: 0.5941 - val_recall: 0.3710 - val_recall_1: 0.7900 - val_recall_2: 0.4519\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "NyRiefKN-D7J", - "colab_type": "code", - "outputId": "a9e1f323-319b-46fd-dac0-a5ee4ee3e204", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 1000 - } - }, - "source": [ - "\n", - "history=finetuned_model.fit_generator(batches, steps_per_epoch=num_train_steps,\n", - " epochs=40, validation_data=val_batches, validation_steps=num_valid_steps)" - ], - "execution_count": 0, - "outputs": [ - { - "output_type": "stream", - "text": [ - "Epoch 1/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.2427 - acc: 0.9920 - recall: 0.9851 - recall_1: 0.9943 - recall_2: 0.9931 - val_loss: 0.8899 - val_acc: 0.6601 - val_recall: 0.6140 - val_recall_1: 0.6171 - val_recall_2: 0.6849\n", - "Epoch 2/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.2361 - acc: 0.9920 - recall: 0.9875 - recall_1: 0.9943 - recall_2: 0.9919 - val_loss: 0.9529 - val_acc: 0.6142 - val_recall: 0.5442 - val_recall_1: 0.7037 - val_recall_2: 0.5530\n", - "Epoch 3/40\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.2353 - acc: 0.9905 - recall: 0.9851 - recall_1: 0.9910 - recall_2: 0.9906 - val_loss: 0.9564 - val_acc: 0.6296 - val_recall: 0.5509 - val_recall_1: 0.6037 - val_recall_2: 0.6930\n", - "Epoch 4/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.2218 - acc: 0.9950 - recall: 0.9909 - recall_1: 0.9977 - recall_2: 0.9954 - val_loss: 1.0089 - val_acc: 0.5957 - val_recall: 0.4654 - val_recall_1: 0.6455 - val_recall_2: 0.6493\n", - "Epoch 5/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.2208 - acc: 0.9931 - recall: 0.9873 - recall_1: 0.9966 - recall_2: 0.9930 - val_loss: 0.9724 - val_acc: 0.6173 - val_recall: 0.5093 - val_recall_1: 0.6777 - val_recall_2: 0.6290\n", - "Epoch 6/40\n", - "164/164 [==============================] - 24s 146ms/step - loss: 0.2151 - acc: 0.9935 - recall: 0.9852 - recall_1: 0.9977 - recall_2: 0.9954 - val_loss: 0.9222 - val_acc: 0.6543 - val_recall: 0.5660 - val_recall_1: 0.5650 - val_recall_2: 0.7981\n", - "Epoch 7/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.2213 - acc: 0.9874 - recall: 0.9793 - recall_1: 0.9899 - recall_2: 0.9907 - val_loss: 0.9989 - val_acc: 0.6003 - val_recall: 0.7170 - val_recall_1: 0.3073 - val_recall_2: 0.7615\n", - "Epoch 8/40\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.2094 - acc: 0.9924 - recall: 0.9848 - recall_1: 0.9944 - recall_2: 0.9965 - val_loss: 0.9615 - val_acc: 0.6235 - val_recall: 0.6530 - val_recall_1: 0.3738 - val_recall_2: 0.7860\n", - "Epoch 9/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.2099 - acc: 0.9897 - recall: 0.9807 - recall_1: 0.9908 - recall_2: 0.9954 - val_loss: 1.0010 - val_acc: 0.6003 - val_recall: 0.6329 - val_recall_1: 0.4097 - val_recall_2: 0.7336\n", - "Epoch 10/40\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.2032 - acc: 0.9912 - recall: 0.9829 - recall_1: 0.9933 - recall_2: 0.9930 - val_loss: 0.9151 - val_acc: 0.6466 - val_recall: 0.4932 - val_recall_1: 0.6462 - val_recall_2: 0.7628\n", - "Epoch 11/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1941 - acc: 0.9926 - recall: 0.9875 - recall_1: 0.9943 - recall_2: 0.9953 - val_loss: 1.0067 - val_acc: 0.6080 - val_recall: 0.7037 - val_recall_1: 0.5209 - val_recall_2: 0.5622\n", - "Epoch 12/40\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.1885 - acc: 0.9935 - recall: 0.9885 - recall_1: 0.9955 - recall_2: 0.9965 - val_loss: 1.0251 - val_acc: 0.6034 - val_recall: 0.8454 - val_recall_1: 0.1878 - val_recall_2: 0.7456\n", - "Epoch 13/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1886 - acc: 0.9924 - recall: 0.9874 - recall_1: 0.9943 - recall_2: 0.9942 - val_loss: 0.9312 - val_acc: 0.6481 - val_recall: 0.6056 - val_recall_1: 0.5801 - val_recall_2: 0.7402\n", - "Epoch 14/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1777 - acc: 0.9954 - recall: 0.9919 - recall_1: 0.9978 - recall_2: 0.9954 - val_loss: 0.9066 - val_acc: 0.6636 - val_recall: 0.6878 - val_recall_1: 0.5694 - val_recall_2: 0.6881\n", - "Epoch 15/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1732 - acc: 0.9958 - recall: 0.9921 - recall_1: 0.9977 - recall_2: 0.9976 - val_loss: 0.9353 - val_acc: 0.6667 - val_recall: 0.5249 - val_recall_1: 0.6591 - val_recall_2: 0.7826\n", - "Epoch 16/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1678 - acc: 0.9966 - recall: 0.9930 - recall_1: 0.9989 - recall_2: 0.9977 - val_loss: 0.8630 - val_acc: 0.6975 - val_recall: 0.6995 - val_recall_1: 0.6389 - val_recall_2: 0.7205\n", - "Epoch 17/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1659 - acc: 0.9958 - recall: 0.9909 - recall_1: 0.9989 - recall_2: 0.9977 - val_loss: 0.9768 - val_acc: 0.6497 - val_recall: 0.5688 - val_recall_1: 0.6411 - val_recall_2: 0.7240\n", - "Epoch 18/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1794 - acc: 0.9874 - recall: 0.9818 - recall_1: 0.9861 - recall_2: 0.9909 - val_loss: 1.0677 - val_acc: 0.6065 - val_recall: 0.5773 - val_recall_1: 0.3852 - val_recall_2: 0.9022\n", - "Epoch 19/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1809 - acc: 0.9855 - recall: 0.9816 - recall_1: 0.9865 - recall_2: 0.9862 - val_loss: 1.0227 - val_acc: 0.6127 - val_recall: 0.4381 - val_recall_1: 0.6100 - val_recall_2: 0.7269\n", - "Epoch 20/40\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.1649 - acc: 0.9915 - recall: 0.9874 - recall_1: 0.9922 - recall_2: 0.9953 - val_loss: 0.9133 - val_acc: 0.6590 - val_recall: 0.5045 - val_recall_1: 0.7243 - val_recall_2: 0.7381\n", - "Epoch 21/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1594 - acc: 0.9931 - recall: 0.9875 - recall_1: 0.9966 - recall_2: 0.9942 - val_loss: 0.8771 - val_acc: 0.6775 - val_recall: 0.6667 - val_recall_1: 0.7091 - val_recall_2: 0.6415\n", - "Epoch 22/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1546 - acc: 0.9924 - recall: 0.9908 - recall_1: 0.9944 - recall_2: 0.9907 - val_loss: 1.2454 - val_acc: 0.5525 - val_recall: 0.8068 - val_recall_1: 0.1806 - val_recall_2: 0.6916\n", - "Epoch 23/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1675 - acc: 0.9848 - recall: 0.9781 - recall_1: 0.9840 - recall_2: 0.9897 - val_loss: 0.9508 - val_acc: 0.6528 - val_recall: 0.5385 - val_recall_1: 0.6957 - val_recall_2: 0.6864\n", - "Epoch 24/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1723 - acc: 0.9825 - recall: 0.9720 - recall_1: 0.9812 - recall_2: 0.9915 - val_loss: 1.0444 - val_acc: 0.6219 - val_recall: 0.7000 - val_recall_1: 0.5385 - val_recall_2: 0.5622\n", - "Epoch 25/40\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.1440 - acc: 0.9939 - recall: 0.9897 - recall_1: 0.9955 - recall_2: 0.9953 - val_loss: 1.0304 - val_acc: 0.6173 - val_recall: 0.5920 - val_recall_1: 0.6147 - val_recall_2: 0.6157\n", - "Epoch 26/40\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.1417 - acc: 0.9943 - recall: 0.9872 - recall_1: 0.9965 - recall_2: 0.9978 - val_loss: 1.0163 - val_acc: 0.6250 - val_recall: 0.6372 - val_recall_1: 0.5463 - val_recall_2: 0.6650\n", - "Epoch 27/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1362 - acc: 0.9947 - recall: 0.9897 - recall_1: 0.9989 - recall_2: 0.9953 - val_loss: 1.0011 - val_acc: 0.6404 - val_recall: 0.5337 - val_recall_1: 0.5399 - val_recall_2: 0.7974\n", - "Epoch 28/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1323 - acc: 0.9954 - recall: 0.9919 - recall_1: 0.9989 - recall_2: 0.9954 - val_loss: 1.1187 - val_acc: 0.6003 - val_recall: 0.5471 - val_recall_1: 0.5342 - val_recall_2: 0.7039\n", - "Epoch 29/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1310 - acc: 0.9947 - recall: 0.9876 - recall_1: 0.9989 - recall_2: 0.9965 - val_loss: 1.0178 - val_acc: 0.6404 - val_recall: 0.5381 - val_recall_1: 0.5570 - val_recall_2: 0.8190\n", - "Epoch 30/40\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.1297 - acc: 0.9947 - recall: 0.9932 - recall_1: 0.9967 - recall_2: 0.9941 - val_loss: 1.0274 - val_acc: 0.6343 - val_recall: 0.5392 - val_recall_1: 0.5502 - val_recall_2: 0.7793\n", - "Epoch 31/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1337 - acc: 0.9916 - recall: 0.9885 - recall_1: 0.9943 - recall_2: 0.9921 - val_loss: 0.9939 - val_acc: 0.6512 - val_recall: 0.5324 - val_recall_1: 0.6864 - val_recall_2: 0.7170\n", - "Epoch 32/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1178 - acc: 0.9970 - recall: 0.9965 - recall_1: 0.9977 - recall_2: 0.9966 - val_loss: 1.0269 - val_acc: 0.6420 - val_recall: 0.5370 - val_recall_1: 0.6071 - val_recall_2: 0.7644\n", - "Epoch 33/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1255 - acc: 0.9935 - recall: 0.9852 - recall_1: 0.9978 - recall_2: 0.9953 - val_loss: 1.0157 - val_acc: 0.6420 - val_recall: 0.5446 - val_recall_1: 0.6473 - val_recall_2: 0.7193\n", - "Epoch 34/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1229 - acc: 0.9931 - recall: 0.9896 - recall_1: 0.9956 - recall_2: 0.9930 - val_loss: 1.1082 - val_acc: 0.6204 - val_recall: 0.5841 - val_recall_1: 0.6620 - val_recall_2: 0.6029\n", - "Epoch 35/40\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.1145 - acc: 0.9950 - recall: 0.9933 - recall_1: 0.9955 - recall_2: 0.9964 - val_loss: 1.0964 - val_acc: 0.6265 - val_recall: 0.6927 - val_recall_1: 0.4273 - val_recall_2: 0.7593\n", - "Epoch 36/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1274 - acc: 0.9886 - recall: 0.9860 - recall_1: 0.9931 - recall_2: 0.9866 - val_loss: 1.4419 - val_acc: 0.5154 - val_recall: 0.1250 - val_recall_1: 0.4679 - val_recall_2: 0.9533\n", - "Epoch 37/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1187 - acc: 0.9909 - recall: 0.9883 - recall_1: 0.9921 - recall_2: 0.9921 - val_loss: 1.1270 - val_acc: 0.6142 - val_recall: 0.4067 - val_recall_1: 0.7176 - val_recall_2: 0.6861\n", - "Epoch 38/40\n", - "164/164 [==============================] - 24s 145ms/step - loss: 0.1252 - acc: 0.9874 - recall: 0.9798 - recall_1: 0.9909 - recall_2: 0.9906 - val_loss: 1.0801 - val_acc: 0.6358 - val_recall: 0.4248 - val_recall_1: 0.6179 - val_recall_2: 0.8619\n", - "Epoch 39/40\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.1122 - acc: 0.9931 - recall: 0.9875 - recall_1: 0.9955 - recall_2: 0.9952 - val_loss: 0.9988 - val_acc: 0.6605 - val_recall: 0.5981 - val_recall_1: 0.5644 - val_recall_2: 0.8131\n", - "Epoch 40/40\n", - "164/164 [==============================] - 24s 144ms/step - loss: 0.1038 - acc: 0.9954 - recall: 0.9930 - recall_1: 0.9977 - recall_2: 0.9955 - val_loss: 1.0642 - val_acc: 0.6373 - val_recall: 0.6103 - val_recall_1: 0.5926 - val_recall_2: 0.6895\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "o3wy0tBrDfgv", - "colab_type": "code", - "outputId": "ec57e24d-0829-4c86-859d-a70e0893a295", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 292 - } - }, - "source": [ - "x_val_others1=[]\n", - "y_val_others1=[]\n", - "x_val_others1,y_val_others1=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/vasc/validation\",0)\n", - "x_val_others3=[]\n", - "y_val_others3=[]\n", - "x_val_others3,y_val_others3=features_ex(\"/content/drive/My Drive/color_cons_skin_cancer_crop/df/validation\",1)\n", - "train=x_val_others1+x_val_others3\n", - "ye=y_val_others1+y_val_others3\n", - "from imblearn.over_sampling import SMOTE\n", - "# for reproducibility purposes\n", - "seed = 100\n", - "# SMOTE number of neighbors\n", - "k = 3\n", - "from sklearn.preprocessing import StandardScaler\n", - "scaler = StandardScaler()\n", - "print (np.shape(train))\n", - "nsamples, nx, ny = np.shape(train)\n", - "d2_train_dataset = train.reshape((nsamples,nx*ny))\n", - "scaler.fit(d2_train_dataset)\n", - "x_tr=scaler.transform(d2_train_dataset)\n", - "sm = SMOTE(sampling_strategy='auto', k_neighbors=k, random_state=seed)\n", - "X_res, y_res = sm.fit_resample(x_tr, ye)\n" - ], - "execution_count": 0, - "outputs": [ - { - "output_type": "stream", - "text": [ - "29\n", - "23\n", - "(52, 1, 224, 224, 3)\n" - ], - "name": "stdout" - }, - { - "output_type": "error", - "ename": "ValueError", - "evalue": "ignored", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", - "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 15\u001b[0m \u001b[0mscaler\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mStandardScaler\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0mprint\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 17\u001b[0;31m \u001b[0mnsamples\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mnx\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mny\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrain\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 18\u001b[0m \u001b[0md2_train_dataset\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtrain\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreshape\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnsamples\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mnx\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mny\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 19\u001b[0m \u001b[0mscaler\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0md2_train_dataset\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", - "\u001b[0;31mValueError\u001b[0m: too many values to unpack (expected 3)" - ] - } - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "CoewVmBnA_u7", - "colab_type": "code", - "colab": {} - }, - "source": [ - "from sklearn.preprocessing import StandardScaler\n", - "scaler = StandardScaler()\n", - "scaler.fit(X_TRAIN)\n", - "x_tr=scaler.transform(X_TRAIN)\n", - "x_va=scaler.transform(X_VAL)\n", - "\n" - ], - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "2Ge5WQhlAbi4", - "colab_type": "code", - "colab": {} - }, - "source": [ - "\n", - "from imblearn.over_sampling import SMOTE\n", - "# for reproducibility purposes\n", - "seed = 100\n", - "# SMOTE number of neighbors\n", - "k = 30\n", - "sm = SMOTE(sampling_strategy='auto', k_neighbors=k, random_state=seed)\n", - "X_res, y_res = sm.fit_resample(x_tr, Y_TRAIN)" - ], - "execution_count": 0, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "g4tuJiohB7-O", - "colab_type": "code", - "colab": {} - }, - "source": [ - "" - ], - "execution_count": 0, - "outputs": [] - } - ] -} \ No newline at end of file