{"cells":[{"metadata":{},"cell_type":"markdown","source":"# Table of Contents\n\nIn this notebook we will try various shallow networks that are trained from scratch using tf.keras and ImageDataGenerator module.\n\n* [Imports](#imports)\n* [Prepare data](#prep_data)\n* [Networks](#nets)\n* [Load data](#load_data)\n* [Train Models](#train_models)\n  - [Shallow Model](#shallow_model1)\n  - [Shallow Model with Regularization](#shallow_model2)\n  - [ResNet Model](#resnet_model1)\n  - [InceptionNet Model](#inception_model1)\n* [Visulize Models](#visualize_models)\n* [Conclusion](#conclusion)","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"<a id=\"imports\"></a>\n## Imports","execution_count":null},{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport random # random numbers\nimport shutil # zip a folder\n\nimport numpy as np # linear algebra\nimport zipfile # unzip files\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\nfrom tqdm import tqdm\nfrom datetime import datetime\nfrom IPython.display import FileLink\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 5GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import os\nimport pathlib\n\nimport numpy as np\nimport tensorflow as tf\nimport tensorboard\nimport matplotlib.pyplot as plt\n\nfrom sklearn.model_selection import train_test_split","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"from tensorflow.data import Dataset\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Conv2D, Flatten, MaxPool2D, Dense, Dropout\nfrom tensorflow.keras.activations import relu\nfrom tensorflow.keras.losses import SparseCategoricalCrossentropy, CategoricalCrossentropy\nfrom tensorflow.keras.metrics import Accuracy, sparse_categorical_accuracy, SparseCategoricalAccuracy, CategoricalAccuracy\nfrom tensorflow.keras.optimizers import Adam\nfrom tensorflow.keras.regularizers import l2, l1\nfrom tensorflow.keras.datasets import mnist\nfrom tensorflow.keras.utils import to_categorical\nfrom tensorflow.keras.preprocessing.image import ImageDataGenerator","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"prep_data\"></a>\n## Prepare data","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"ls ../input/dogs-vs-cats-redux-kernels-edition/","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"zip_ref = zipfile.ZipFile(\"../input/dogs-vs-cats-redux-kernels-edition/train.zip\", \"r\")\nfilelist = zip_ref.filelist[1:]\nprint(f'{zip_ref.filelist[0].filename} is removed')\nrandom.shuffle(filelist)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"len(filelist)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Let us use 90% for training and 10% for testing","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"count_cats = 0\ncount_dogs = 0\ntrainN = int(len(filelist)*0.9)\nvalN = int(len(filelist)*0.1)\n\nfor file_path in tqdm(filelist[0:trainN]):\n    if file_path.filename.endswith(\".jpg\"):\n        file_name = file_path.filename[6:]\n        if file_name.startswith(\"cat\"):\n            zip_ref.extract(file_path.filename, path='train/cats/'+file_name)\n            count_cats += 1\n        elif file_name.startswith(\"dog\"):\n            zip_ref.extract(file_path.filename, path='train/dogs/'+file_name)\n            count_dogs += 1\n\nfor file_path in tqdm(filelist[trainN:]):\n    if file_path.filename.endswith(\".jpg\"):\n        file_name = file_path.filename[6:]\n        if file_name.startswith(\"cat\"):\n            zip_ref.extract(file_path.filename, path='valid/cats/'+file_name)\n            count_cats += 1\n        elif file_name.startswith(\"dog\"):\n            zip_ref.extract(file_path.filename, path='valid/dogs/'+file_name)\n            count_dogs += 1","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"!ls train/cats/ | wc -l\n!ls train/dogs/ | wc -l\n!ls valid/cats/ | wc -l\n!ls valid/dogs/ | wc -l","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"nets\"></a>\n## Networks","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"def get_shallow_cnn(input_shape=(28, 28, 1)):\n  model = Sequential()\n  model.add(Conv2D(16, 3, activation=relu, input_shape=input_shape))\n  model.add(MaxPool2D())\n  model.add(Conv2D(32, 3, activation=relu))\n  model.add(MaxPool2D())\n  model.add(Flatten())\n  model.add(Dense(128, activation=relu))\n  model.add(Dense(2, activation='softmax'))\n  return model","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"def get_shallow_cnn_regu(input_shape=(28, 28, 1), decay_rate=1e-3, dropout=0.1):\n    model = Sequential()\n    model.add(Conv2D(16, 3, activation=relu, input_shape=input_shape,\n                     kernel_regularizer=l2(decay_rate)))\n    model.add(Dropout(dropout))\n    model.add(MaxPool2D())\n    model.add(Conv2D(32, 3, activation=relu, kernel_regularizer=l2(decay_rate)))\n    model.add(Dropout(dropout))\n    model.add(MaxPool2D())\n    model.add(Flatten())\n    model.add(Dense(128, activation=relu, kernel_regularizer=l2(decay_rate)))\n    model.add(Dense(2, activation='softmax'))\n    return model","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"def get_shallow2_cnn(input_shape=(28, 28, 1)):\n    model = Sequential()\n    model.add(Conv2D(16, 3, activation=relu, input_shape=input_shape))\n    model.add(MaxPool2D())\n    model.add(Conv2D(32, 3, activation=relu))\n    model.add(MaxPool2D())\n    model.add(Conv2D(64, 3, activation=relu))\n    model.add(MaxPool2D())\n    model.add(Conv2D(64, 3, activation=relu))\n    model.add(MaxPool2D())\n    model.add(Flatten())\n    model.add(Dense(128, activation=relu))\n    model.add(Dense(2, activation='softmax'))\n    return model","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"def get_shallow2_cnn_regu(input_shape=(28, 28, 1), decay_rate=1e-3, dropout=0.1):\n    model = Sequential()\n    model.add(Conv2D(16, 3, activation=relu, input_shape=input_shape,\n                     kernel_regularizer=l2(decay_rate)))\n    model.add(Dropout(dropout))\n    model.add(MaxPool2D())\n    model.add(Conv2D(32, 3, activation=relu, kernel_regularizer=l2(decay_rate)))\n    model.add(Dropout(dropout))\n    model.add(MaxPool2D())\n    model.add(Conv2D(64, 3, activation=relu, kernel_regularizer=l2(decay_rate)))\n    model.add(Dropout(dropout))\n    model.add(MaxPool2D())\n    model.add(Conv2D(64, 3, activation=relu, kernel_regularizer=l2(decay_rate)))\n    model.add(Dropout(dropout))\n    model.add(MaxPool2D())\n    model.add(Flatten())\n    model.add(Dense(128, activation=relu))\n    model.add(Dense(2, activation='softmax'))\n    return model","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"load_data\"></a>\n## Load data","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"batch_size = 32\nimage_gen = ImageDataGenerator(rescale=1/255.0)\nimage_gen_train = image_gen.flow_from_directory(\"train\", target_size=(64, 64),\n                                                batch_size=batch_size, shuffle=True)\nimage_gen_valid = image_gen.flow_from_directory(\"valid\", target_size=(64, 64),\n                                                batch_size=batch_size, shuffle=True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"batch_size = 32\nimage_gen_augument = ImageDataGenerator(rescale=1/255.0, rotation_range=10,\n                                       horizontal_flip=True, zoom_range=0.2)\nimage_gen_augument_train = image_gen_augument.flow_from_directory(\"train\", target_size=(64, 64),\n                                                batch_size=batch_size, shuffle=True)\nimage_gen_augument_valid = image_gen_augument.flow_from_directory(\"valid\", target_size=(64, 64),\n                                                batch_size=batch_size, shuffle=True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"for image1, image2 in zip(image_gen_train, image_gen_augument_train):\n    plt.imshow(image1[0][0])\n    plt.figure()\n    plt.imshow(image2[0][0])\n    break","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"steps_per_epoch = image_gen_train.n//batch_size\nvalidation_steps = image_gen_valid.n//batch_size","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"print(steps_per_epoch, validation_steps)","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"<a id=\"train_models\"></a>\n## Train models","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"### Shallow CNN with no regularization","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"model1 = get_shallow_cnn((64, 64, 3))\nmodel1.compile(optimizer=tf.keras.optimizers.Adam(),\n              loss=tf.keras.losses.CategoricalCrossentropy(),\n              metrics=[tf.keras.metrics.BinaryAccuracy(),\n                      'AUC'])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"log_dir = \"logs/\" + datetime.now().strftime(\"%Y%m%d-%H%M%S\")\ntensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)\n\nhistory1 = model1.fit(image_gen_train, validation_data=image_gen_valid,\n               steps_per_epoch=steps_per_epoch, callbacks=[tensorboard_callback],\n               epochs=10, validation_steps=validation_steps)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"model1.save(\"shallow_cnn\")\nshutil.make_archive(\"shallow_cnn\", 'zip', \"shallow_cnn\")\nFileLink('shallow_cnn.zip')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_loss_results = history1.history['loss']\nvalid_loss_results = history1.history['val_loss']\ntrain_accuracy_results = history1.history['binary_accuracy']\nvalid_accuracy_results = history1.history['val_binary_accuracy']\ntrain_auc_results = history1.history['auc']\nvalid_auc_results = history1.history['val_auc']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.style.use('ggplot')\nfig, axes = plt.subplots(1, 3, sharex=True, figsize=(18, 5))\n\naxes[0].set_xlabel(\"Epochs\", fontsize=14)\naxes[0].set_ylabel(\"Loss\", fontsize=14)\naxes[0].set_title('Loss vs epochs')\naxes[0].plot(train_loss_results, label='train_loss')\naxes[0].plot(valid_loss_results, label='valid_loss')\naxes[0].legend()\n\naxes[1].set_title('Accuracy vs epochs')\naxes[1].set_ylabel(\"Accuracy\", fontsize=14)\naxes[1].set_xlabel(\"Epochs\", fontsize=14)\naxes[1].plot(train_accuracy_results, label='train_accuracy')\naxes[1].plot(valid_accuracy_results, label='valid_accuracy')\naxes[1].legend()\n\naxes[2].set_title('AUC vs epochs')\naxes[2].set_ylabel(\"AUC\", fontsize=14)\naxes[2].set_xlabel(\"Epochs\", fontsize=14)\naxes[2].plot(train_accuracy_results, label='train_auc')\naxes[2].plot(valid_accuracy_results, label='valid_auc')\naxes[2].legend()\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Clearly there is overfitting, of the model. Also we can increase the complexity of the model as the training error is still way far from 0%","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"### Shallow CNN with regularization","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"model2 = get_shallow_cnn_regu((64, 64, 3), decay_rate=1e-3, dropout=0.1)\nmodel2.compile(optimizer=tf.keras.optimizers.Adam(),\n              loss=tf.keras.losses.CategoricalCrossentropy(),\n              metrics=[tf.keras.metrics.BinaryAccuracy(),\n                      'AUC'])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"log_dir = \"logs/\" + datetime.now().strftime(\"%Y%m%d-%H%M%S\")\ntensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)\n\nhistory2 = model2.fit(image_gen_train, validation_data=image_gen_valid,\n               steps_per_epoch=steps_per_epoch, callbacks=[tensorboard_callback],\n               epochs=30, validation_steps=validation_steps)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"model2.save(\"shallow_cnn_reg\")\nshutil.make_archive(\"shallow_cnn_reg\", 'zip', \"shallow_cnn_reg\")\nFileLink('shallow_cnn_reg.zip')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"!ls shallow_cnn_reg","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_loss_results = history2.history['loss']\nvalid_loss_results = history2.history['val_loss']\ntrain_accuracy_results = history2.history['binary_accuracy']\nvalid_accuracy_results = history2.history['val_binary_accuracy']\ntrain_auc_results = history2.history['auc']\nvalid_auc_results = history2.history['val_auc']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.style.use('ggplot')\nfig, axes = plt.subplots(1, 3, sharex=True, figsize=(18, 5))\n\naxes[0].set_xlabel(\"Epochs\", fontsize=14)\naxes[0].set_ylabel(\"Loss\", fontsize=14)\naxes[0].set_title('Loss vs epochs')\naxes[0].plot(train_loss_results, label='train_loss')\naxes[0].plot(valid_loss_results, label='valid_loss')\naxes[0].legend()\n\naxes[1].set_title('Accuracy vs epochs')\naxes[1].set_ylabel(\"Accuracy\", fontsize=14)\naxes[1].set_xlabel(\"Epochs\", fontsize=14)\naxes[1].plot(train_accuracy_results, label='train_accuracy')\naxes[1].plot(valid_accuracy_results, label='valid_accuracy')\naxes[1].legend()\n\naxes[2].set_title('AUC vs epochs')\naxes[2].set_ylabel(\"AUC\", fontsize=14)\naxes[2].set_xlabel(\"Epochs\", fontsize=14)\naxes[2].plot(train_accuracy_results, label='train_auc')\naxes[2].plot(valid_accuracy_results, label='valid_auc')\naxes[2].legend()\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"* So now there is no overfitting problem but we are clearly underfitting.\n\n* The validation accuracy remains the same but training accuracy is much lower as well.\n\n* So we can train for longer or Train a much bigger network","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"### Shallow CNN-2 with regularization","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"model3 = get_shallow2_cnn_regu((64, 64, 3), decay_rate=1e-3, dropout=0.1)\nmodel3.compile(optimizer=tf.keras.optimizers.Adam(),\n              loss=tf.keras.losses.CategoricalCrossentropy(),\n              metrics=[tf.keras.metrics.BinaryAccuracy(),\n                      'AUC'])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"log_dir = \"logs/\" + datetime.now().strftime(\"%Y%m%d-%H%M%S\")\ntensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)\n\nhistory3 = model3.fit(image_gen_train, validation_data=image_gen_valid,\n               steps_per_epoch=steps_per_epoch, callbacks=[tensorboard_callback],\n               epochs=30, validation_steps=validation_steps)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"model3.save(\"shallow2_cnn_reg\")\nshutil.make_archive(\"shallow2_cnn_reg\", 'zip', \"shallow2_cnn_reg\")\nFileLink('shallow2_cnn_reg.zip')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_loss_results = history3.history['loss']\nvalid_loss_results = history3.history['val_loss']\ntrain_accuracy_results = history3.history['binary_accuracy']\nvalid_accuracy_results = history3.history['val_binary_accuracy']\ntrain_auc_results = history3.history['auc']\nvalid_auc_results = history3.history['val_auc']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.style.use('ggplot')\nfig, axes = plt.subplots(1, 3, sharex=True, figsize=(18, 5))\n\naxes[0].set_xlabel(\"Epochs\", fontsize=14)\naxes[0].set_ylabel(\"Loss\", fontsize=14)\naxes[0].set_title('Loss vs epochs')\naxes[0].plot(train_loss_results, label='train_loss')\naxes[0].plot(valid_loss_results, label='valid_loss')\naxes[0].legend()\n\naxes[1].set_title('Accuracy vs epochs')\naxes[1].set_ylabel(\"Accuracy\", fontsize=14)\naxes[1].set_xlabel(\"Epochs\", fontsize=14)\naxes[1].plot(train_accuracy_results, label='train_accuracy')\naxes[1].plot(valid_accuracy_results, label='valid_accuracy')\naxes[1].legend()\n\naxes[2].set_title('AUC vs epochs')\naxes[2].set_ylabel(\"AUC\", fontsize=14)\naxes[2].set_xlabel(\"Epochs\", fontsize=14)\naxes[2].plot(train_accuracy_results, label='train_auc')\naxes[2].plot(valid_accuracy_results, label='valid_auc')\naxes[2].legend()\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"Shows that the approach is working and can try running for more epochs","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"### Shallow CNN-2 with data-augumentation and regularization","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"model4 = get_shallow2_cnn_regu((64, 64, 3), decay_rate=1e-3, dropout=0.1)\nmodel4.compile(optimizer=tf.keras.optimizers.Adam(),\n              loss=tf.keras.losses.CategoricalCrossentropy(),\n              metrics=[tf.keras.metrics.BinaryAccuracy(),\n                      'AUC'])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"log_dir = \"logs/\" + datetime.now().strftime(\"%Y%m%d-%H%M%S\")\ntensorboard_callback = tf.keras.callbacks.TensorBoard(log_dir=log_dir, histogram_freq=1)\n\nhistory4 = model4.fit(image_gen_augument_train, validation_data=image_gen_augument_valid,\n               steps_per_epoch=steps_per_epoch, callbacks=[tensorboard_callback],\n               epochs=30, validation_steps=validation_steps)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"model4.save(\"shallow2_cnn_reg_aug\")\nshutil.make_archive(\"shallow2_cnn_reg_aug\", 'zip', \"shallow2_cnn_reg_aug\")\nFileLink('shallow2_cnn_reg_aug.zip')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_loss_results = history4.history['loss']\nvalid_loss_results = history4.history['val_loss']\ntrain_accuracy_results = history4.history['binary_accuracy']\nvalid_accuracy_results = history4.history['val_binary_accuracy']\ntrain_auc_results = history4.history['auc']\nvalid_auc_results = history4.history['val_auc']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"plt.style.use('ggplot')\nfig, axes = plt.subplots(1, 3, sharex=True, figsize=(18, 5))\n\naxes[0].set_xlabel(\"Epochs\", fontsize=14)\naxes[0].set_ylabel(\"Loss\", fontsize=14)\naxes[0].set_title('Loss vs epochs')\naxes[0].plot(train_loss_results, label='train_loss')\naxes[0].plot(valid_loss_results, label='valid_loss')\naxes[0].legend()\n\naxes[1].set_title('Accuracy vs epochs')\naxes[1].set_ylabel(\"Accuracy\", fontsize=14)\naxes[1].set_xlabel(\"Epochs\", fontsize=14)\naxes[1].plot(train_accuracy_results, label='train_accuracy')\naxes[1].plot(valid_accuracy_results, label='valid_accuracy')\naxes[1].legend()\n\naxes[2].set_title('AUC vs epochs')\naxes[2].set_ylabel(\"AUC\", fontsize=14)\naxes[2].set_xlabel(\"Epochs\", fontsize=14)\naxes[2].plot(train_accuracy_results, label='train_auc')\naxes[2].plot(valid_accuracy_results, label='valid_auc')\naxes[2].legend()\n\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### ResNet with data-augumentation and regularization\n\nUse the same network as tf2.2 course week-4","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"### Inception Net with data-augumentation and regularization","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Visualize the activation maps of hidden layers\n\nEasy: Create a model with outputs as layer outputs of interest","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Visualize the filters learnt by the hidden layers\n\nNeed to do backprop and train","execution_count":null},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## Visualize the input region responsible for classification\n\nDidnt understood how exactly this is done","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"# Questions to ponder?\n\n* Does the input image resolution affect the final outcome??","execution_count":null},{"metadata":{},"cell_type":"markdown","source":"","execution_count":null}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}