{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Keras tutorial - the Happy House\n", "\n", "Welcome to the first assignment of week 2. In this assignment, you will:\n", "1. Learn to use Keras, a high-level neural networks API (programming framework), written in Python and capable of running on top of several lower-level frameworks including TensorFlow and CNTK. \n", "2. See how you can in a couple of hours build a deep learning algorithm.\n", "\n", "Why are we using Keras? Keras was developed to enable deep learning engineers to build and experiment with different models very quickly. Just as TensorFlow is a higher-level framework than Python, Keras is an even higher-level framework and provides additional abstractions. Being able to go from idea to result with the least possible delay is key to finding good models. However, Keras is more restrictive than the lower-level frameworks, so there are some very complex models that you can implement in TensorFlow but not (without more difficulty) in Keras. That being said, Keras will work fine for many common models. \n", "\n", "In this exercise, you'll work on the \"Happy House\" problem, which we'll explain below. Let's load the required packages and solve the problem of the Happy House!" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import numpy as np\n", "from keras import layers\n", "from keras.layers import Input, Dense, Activation, ZeroPadding2D, BatchNormalization, Flatten, Conv2D\n", "from keras.layers import AveragePooling2D, MaxPooling2D, Dropout, GlobalMaxPooling2D, GlobalAveragePooling2D\n", "from keras.models import Model\n", "from keras.preprocessing import image\n", "from keras.utils import layer_utils\n", "from keras.utils.data_utils import get_file\n", "from keras.applications.imagenet_utils import preprocess_input\n", "import pydot\n", "from IPython.display import SVG\n", "from keras.utils.vis_utils import model_to_dot\n", "from keras.utils import plot_model\n", "from kt_utils import *\n", "\n", "import keras.backend as K\n", "K.set_image_data_format('channels_last')\n", "import matplotlib.pyplot as plt\n", "from matplotlib.pyplot import imshow\n", "\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Note**: As you can see, we've imported a lot of functions from Keras. You can use them easily just by calling them directly in the notebook. Ex: `X = Input(...)` or `X = ZeroPadding2D(...)`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1 - The Happy House \n", "\n", "For your next vacation, you decided to spend a week with five of your friends from school. It is a very convenient house with many things to do nearby. But the most important benefit is that everybody has commited to be happy when they are in the house. So anyone wanting to enter the house must prove their current state of happiness.\n", "\n", "\n", "