You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@madlib.apache.org by fm...@apache.org on 2020/03/18 03:48:56 UTC

[madlib-site] branch asf-site updated: remove ipython checkpoint files

This is an automated email from the ASF dual-hosted git repository.

fmcquillan pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/madlib-site.git


The following commit(s) were added to refs/heads/asf-site by this push:
     new c1c2249  remove ipython checkpoint files
c1c2249 is described below

commit c1c2249cd608e68acd4a4bf74d2bbc5b2c5569c4
Author: Frank McQuillan <fm...@pivotal.io>
AuthorDate: Tue Mar 17 20:47:30 2020 -0700

    remove ipython checkpoint files
---
 .../Load-images-v1-checkpoint.ipynb                |  701 --
 .../MADlib-Keras-cifar10-cnn-v3-checkpoint.ipynb   | 1297 ----
 ...model-selection-CNN-cifar10-v1-checkpoint.ipynb | 8037 --------------------
 ...b-Keras-model-selection-MLP-v1-checkpoint.ipynb | 5709 --------------
 ...r-images-distribution-rules-v1-checkpoint.ipynb | 1966 -----
 .../hyperband-diag-cifar10-v1-checkpoint.ipynb     | 5288 -------------
 6 files changed, 22998 deletions(-)

diff --git a/community-artifacts/Deep-learning/.ipynb_checkpoints/Load-images-v1-checkpoint.ipynb b/community-artifacts/Deep-learning/.ipynb_checkpoints/Load-images-v1-checkpoint.ipynb
deleted file mode 100644
index 2c8c108..0000000
--- a/community-artifacts/Deep-learning/.ipynb_checkpoints/Load-images-v1-checkpoint.ipynb
+++ /dev/null
@@ -1,701 +0,0 @@
-{
- "cells": [
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "# Load images into table\n",
-    "\n",
-    "This demonstrates different ways to load images into a database table.\n",
-    "\n",
-    "We use the script called <em>madlib_image_loader.py</em> located at https://github.com/apache/madlib-site/tree/asf-site/community-artifacts/Deep-learning which uses the Python Imaging Library so supports multiple formats http://www.pythonware.com/products/pil/\n",
-    "\n",
-    "## Table of contents\n",
-    "\n",
-    "<a href=\"#setup\">1. Setup image loader</a>\n",
-    "\n",
-    "<a href=\"#fetch_numpy\">2. Fetch images then load NumPy array into table</a>\n",
-    "\n",
-    "<a href=\"#file_system\">3. Load from file system into table</a>"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 1,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "/Users/fmcquillan/anaconda/lib/python2.7/site-packages/IPython/config.py:13: ShimWarning: The `IPython.config` package has been deprecated since IPython 4.0. You should import from traitlets.config instead.\n",
-      "  \"You should import from traitlets.config instead.\", ShimWarning)\n",
-      "/Users/fmcquillan/anaconda/lib/python2.7/site-packages/IPython/utils/traitlets.py:5: UserWarning: IPython.utils.traitlets has moved to a top-level traitlets package.\n",
-      "  warn(\"IPython.utils.traitlets has moved to a top-level traitlets package.\")\n"
-     ]
-    }
-   ],
-   "source": [
-    "%load_ext sql"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 2,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "u'Connected: fmcquillan@madlib'"
-      ]
-     },
-     "execution_count": 2,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "# Greenplum Database 5.x on GCP for deep learning (PM demo machine)\n",
-    "#%sql postgresql://gpadmin@35.239.240.26:5432/madlib\n",
-    "        \n",
-    "# PostgreSQL local\n",
-    "%sql postgresql://fmcquillan@localhost:5432/madlib"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 3,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>version</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>MADlib version: 1.16, git revision: rc/1.16-rc1, cmake configuration time: Mon Jul  1 17:45:09 UTC 2019, build type: Release, build system: Darwin-16.7.0, C compiler: Clang, C++ compiler: Clang</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(u'MADlib version: 1.16, git revision: rc/1.16-rc1, cmake configuration time: Mon Jul  1 17:45:09 UTC 2019, build type: Release, build system: Darwin-16.7.0, C compiler: Clang, C++ compiler: Clang',)]"
-      ]
-     },
-     "execution_count": 3,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%sql select madlib.version();\n",
-    "#%sql select version();"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"setup\"></a>\n",
-    "# 1. Set up image loader\n",
-    "\n",
-    "We use the script called <em>madlib_image_loader.py</em> located at https://github.com/apache/madlib-site/tree/asf-site/community-artifacts/Deep-learning"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 4,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "Using TensorFlow backend.\n"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Couldn't import dot_parser, loading of dot files will not be possible.\n"
-     ]
-    }
-   ],
-   "source": [
-    "import sys\n",
-    "import os\n",
-    "from keras.datasets import cifar10\n",
-    "\n",
-    "madlib_site_dir = '/Users/fmcquillan/Documents/Product/MADlib/Demos/data'\n",
-    "sys.path.append(madlib_site_dir)\n",
-    "\n",
-    "# Import image loader module\n",
-    "from madlib_image_loader import ImageLoader, DbCredentials\n",
-    "\n",
-    "# Specify database credentials, for connecting to db\n",
-    "#db_creds = DbCredentials(user='gpadmin',\n",
-    "#                         host='35.239.240.26',\n",
-    "#                         port='5432',\n",
-    "#                         password='')\n",
-    "\n",
-    "# Specify database credentials, for connecting to db\n",
-    "db_creds = DbCredentials(user='fmcquillan',\n",
-    "                          host='localhost',\n",
-    "                          port='5432',\n",
-    "                          password='')\n",
-    "\n",
-    "# Initialize ImageLoader (increase num_workers to run faster)\n",
-    "iloader = ImageLoader(num_workers=5, db_creds=db_creds)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"fetch_numpy\"></a>\n",
-    "# 2. Fetch images then load NumPy array into table\n",
-    "\n",
-    "<em>iloader.load_dataset_from_np(data_x, data_y, table_name, append=False)</em>\n",
-    "\n",
-    "- <em>data_x</em> contains image data in np.array format\n",
-    "\n",
-    "\n",
-    "- <em>data_y</em> is a 1D np.array of the image categories (labels).\n",
-    "\n",
-    "\n",
-    "- If the user passes a <em>table_name</em> while creating ImageLoader object, it will be used for all further calls to load_dataset_from_np.  It can be changed by passing it as a parameter during the actual call to load_dataset_from_np, and if so future calls will load to that table name instead.  This avoids needing to pass the table_name again every time, but also allows it to be changed at any time."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 5,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "# Load dataset into np array\n",
-    "(x_train, y_train), (x_test, y_test) = cifar10.load_data()"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 6,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Done.\n",
-      "MainProcess: Connected to madlib db.\n",
-      "Executing: CREATE TABLE cifar_10_train_data (id SERIAL, x REAL[], y TEXT)\n",
-      "CREATE TABLE\n",
-      "Created table cifar_10_train_data in madlib db\n",
-      "Spawning 5 workers...\n",
-      "Initializing PoolWorker-1 [pid 82412]\n",
-      "PoolWorker-1: Created temporary directory /tmp/madlib_Bt85aChbv0\n",
-      "Initializing PoolWorker-2 [pid 82413]\n",
-      "PoolWorker-2: Created temporary directory /tmp/madlib_cSyCSiEhHT\n",
-      "Initializing PoolWorker-3 [pid 82414]\n",
-      "PoolWorker-3: Created temporary directory /tmp/madlib_uvtHjGCU5S\n",
-      "PoolWorker-1: Connected to madlib db.\n",
-      "Initializing PoolWorker-4 [pid 82415]\n",
-      "PoolWorker-4: Created temporary directory /tmp/madlib_eJmkoDZTr8\n",
-      "PoolWorker-2: Connected to madlib db.\n",
-      "Initializing PoolWorker-5 [pid 82417]\n",
-      "PoolWorker-5: Created temporary directory /tmp/madlib_websbk05x2\n",
-      "PoolWorker-3: Connected to madlib db.\n",
-      "PoolWorker-4: Connected to madlib db.\n",
-      "PoolWorker-5: Connected to madlib db.\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_Bt85aChbv0/cifar_10_train_data0000.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_cSyCSiEhHT/cifar_10_train_data0000.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_uvtHjGCU5S/cifar_10_train_data0000.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_eJmkoDZTr8/cifar_10_train_data0000.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_websbk05x2/cifar_10_train_data0000.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_Bt85aChbv0/cifar_10_train_data0001.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_cSyCSiEhHT/cifar_10_train_data0001.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_uvtHjGCU5S/cifar_10_train_data0001.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_eJmkoDZTr8/cifar_10_train_data0001.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_websbk05x2/cifar_10_train_data0001.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_Bt85aChbv0/cifar_10_train_data0002.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_cSyCSiEhHT/cifar_10_train_data0002.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_uvtHjGCU5S/cifar_10_train_data0002.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_eJmkoDZTr8/cifar_10_train_data0002.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_websbk05x2/cifar_10_train_data0002.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_Bt85aChbv0/cifar_10_train_data0003.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_cSyCSiEhHT/cifar_10_train_data0003.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_uvtHjGCU5S/cifar_10_train_data0003.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_eJmkoDZTr8/cifar_10_train_data0003.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_websbk05x2/cifar_10_train_data0003.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_Bt85aChbv0/cifar_10_train_data0004.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_cSyCSiEhHT/cifar_10_train_data0004.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_uvtHjGCU5S/cifar_10_train_data0004.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_eJmkoDZTr8/cifar_10_train_data0004.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_websbk05x2/cifar_10_train_data0004.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_Bt85aChbv0/cifar_10_train_data0005.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_cSyCSiEhHT/cifar_10_train_data0005.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_uvtHjGCU5S/cifar_10_train_data0005.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_eJmkoDZTr8/cifar_10_train_data0005.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_websbk05x2/cifar_10_train_data0005.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_Bt85aChbv0/cifar_10_train_data0006.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_cSyCSiEhHT/cifar_10_train_data0006.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_uvtHjGCU5S/cifar_10_train_data0006.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_eJmkoDZTr8/cifar_10_train_data0006.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_websbk05x2/cifar_10_train_data0006.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_Bt85aChbv0/cifar_10_train_data0007.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_cSyCSiEhHT/cifar_10_train_data0007.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_uvtHjGCU5S/cifar_10_train_data0007.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_eJmkoDZTr8/cifar_10_train_data0007.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_websbk05x2/cifar_10_train_data0007.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_Bt85aChbv0/cifar_10_train_data0008.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_cSyCSiEhHT/cifar_10_train_data0008.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_uvtHjGCU5S/cifar_10_train_data0008.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_eJmkoDZTr8/cifar_10_train_data0008.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_websbk05x2/cifar_10_train_data0008.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_Bt85aChbv0/cifar_10_train_data0009.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_cSyCSiEhHT/cifar_10_train_data0009.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_Bt85aChbv0/cifar_10_train_data0010.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_cSyCSiEhHT/cifar_10_train_data0010.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_Bt85aChbv0/cifar_10_train_data0011.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Removed temporary directory /tmp/madlib_cSyCSiEhHT\n",
-      "PoolWorker-3: Removed temporary directory /tmp/madlib_uvtHjGCU5S\n"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "PoolWorker-5: Removed temporary directory /tmp/madlib_websbk05x2\n",
-      "PoolWorker-4: Removed temporary directory /tmp/madlib_eJmkoDZTr8\n",
-      "PoolWorker-1: Removed temporary directory /tmp/madlib_Bt85aChbv0\n",
-      "Done!  Loaded 50000 images in 24.2222080231s\n",
-      "5 workers terminated.\n",
-      "MainProcess: Connected to madlib db.\n",
-      "Executing: CREATE TABLE cifar_10_test_data (id SERIAL, x REAL[], y TEXT)\n",
-      "CREATE TABLE\n",
-      "Created table cifar_10_test_data in madlib db\n",
-      "Spawning 5 workers...\n",
-      "Initializing PoolWorker-6 [pid 82423]\n",
-      "PoolWorker-6: Created temporary directory /tmp/madlib_e615zVgkaE\n",
-      "Initializing PoolWorker-7 [pid 82424]\n",
-      "PoolWorker-7: Created temporary directory /tmp/madlib_iRi2oMNIFA\n",
-      "Initializing PoolWorker-8 [pid 82425]\n",
-      "PoolWorker-8: Created temporary directory /tmp/madlib_kkSktVCq3n\n",
-      "PoolWorker-6: Connected to madlib db.\n",
-      "Initializing PoolWorker-9 [pid 82426]\n",
-      "PoolWorker-7: Connected to madlib db.\n",
-      "PoolWorker-9: Created temporary directory /tmp/madlib_0To3XX96yI\n",
-      "Initializing PoolWorker-10 [pid 82428]\n",
-      "PoolWorker-8: Connected to madlib db.\n",
-      "PoolWorker-10: Created temporary directory /tmp/madlib_8zwK04IJsc\n",
-      "PoolWorker-9: Connected to madlib db.\n",
-      "PoolWorker-10: Connected to madlib db.\n",
-      "PoolWorker-6: Wrote 1000 images to /tmp/madlib_e615zVgkaE/cifar_10_test_data0000.tmp\n",
-      "PoolWorker-7: Wrote 1000 images to /tmp/madlib_iRi2oMNIFA/cifar_10_test_data0000.tmp\n",
-      "PoolWorker-8: Wrote 1000 images to /tmp/madlib_kkSktVCq3n/cifar_10_test_data0000.tmp\n",
-      "PoolWorker-9: Wrote 1000 images to /tmp/madlib_0To3XX96yI/cifar_10_test_data0000.tmp\n",
-      "PoolWorker-10: Wrote 1000 images to /tmp/madlib_8zwK04IJsc/cifar_10_test_data0000.tmp\n",
-      "PoolWorker-6: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-7: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-8: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-10: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-9: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-6: Wrote 1000 images to /tmp/madlib_e615zVgkaE/cifar_10_test_data0001.tmp\n",
-      "PoolWorker-7: Wrote 1000 images to /tmp/madlib_iRi2oMNIFA/cifar_10_test_data0001.tmp\n",
-      "PoolWorker-8: Wrote 1000 images to /tmp/madlib_kkSktVCq3n/cifar_10_test_data0001.tmp\n",
-      "PoolWorker-9: Wrote 1000 images to /tmp/madlib_0To3XX96yI/cifar_10_test_data0001.tmp\n",
-      "PoolWorker-10: Wrote 1000 images to /tmp/madlib_8zwK04IJsc/cifar_10_test_data0001.tmp\n",
-      "PoolWorker-6: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-7: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-8: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-9: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-10: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-10: Removed temporary directory /tmp/madlib_8zwK04IJsc\n",
-      "PoolWorker-8: Removed temporary directory /tmp/madlib_kkSktVCq3n\n",
-      "PoolWorker-7: Removed temporary directory /tmp/madlib_iRi2oMNIFA\n",
-      "PoolWorker-6: Removed temporary directory /tmp/madlib_e615zVgkaE\n",
-      "PoolWorker-9: Removed temporary directory /tmp/madlib_0To3XX96yI\n",
-      "Done!  Loaded 10000 images in 4.6932258606s\n",
-      "5 workers terminated.\n"
-     ]
-    }
-   ],
-   "source": [
-    "%sql DROP TABLE IF EXISTS cifar_10_train_data, cifar_10_test_data;\n",
-    "\n",
-    "# Save images to temporary directories and load into database\n",
-    "iloader.load_dataset_from_np(x_train, y_train, 'cifar_10_train_data', append=False)\n",
-    "iloader.load_dataset_from_np(x_test, y_test, 'cifar_10_test_data', append=False)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 12,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>count</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>50000</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(50000L,)]"
-      ]
-     },
-     "execution_count": 12,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "SELECT COUNT(*) FROM cifar_10_train_data;"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 13,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>count</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>10000</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(10000L,)]"
-      ]
-     },
-     "execution_count": 13,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "SELECT COUNT(*) FROM cifar_10_test_data;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"file_system\"></a>\n",
-    "# 3. Load from file system\n",
-    "\n",
-    "Uses the Python Imaging Library so supports multiple formats\n",
-    "http://www.pythonware.com/products/pil/\n",
-    "\n",
-    "<em>load_dataset_from_disk(root_dir, table_name, num_labels='all', append=False)</em>\n",
-    "\n",
-    "- Calling this function  will look in <em>root_dir</em> on the local disk of wherever this is being run.  It will skip over any files in that directory, but will load images contained in each of its subdirectories.  The images should be organized by category/class, where the name of each subdirectory is the label for the images contained within it.\n",
-    "\n",
-    "\n",
-    "- The <em>table_name</em> and <em>append</em> parameters are the same as above  The parameter <em>num_labels</em> is an optional parameter which can be used to restrict the number of labels (image classes) loaded, even if more are found in <em>root_dir</em>.  For example, for a large dataset you may have hundreds of labels, but only wish to use a subset of that containing a few dozen.\n",
-    "\n",
-    "For example, if we put the CIFAR-10 training data is in 10 subdirectories under directory <em>cifar10</em>, with one subdirectory for each class:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 14,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Done.\n",
-      "MainProcess: Connected to madlib db.\n",
-      "Executing: CREATE TABLE cifar_10_train_data_filesystem (id SERIAL, x REAL[], y TEXT,                        img_name TEXT)\n",
-      "CREATE TABLE\n",
-      "Created table cifar_10_train_data_filesystem in madlib db\n",
-      ".DS_Store is not a directory, skipping\n",
-      "number of labels = 10\n",
-      "Found 10 image labels in /Users/fmcquillan/tmp/cifar10\n",
-      "Spawning 5 workers...\n",
-      "Initializing PoolWorker-11 [pid 82438]\n",
-      "PoolWorker-11: Created temporary directory /tmp/madlib_aEC1lF2HqL\n",
-      "Initializing PoolWorker-12 [pid 82439]\n",
-      "PoolWorker-12: Created temporary directory /tmp/madlib_70qpwFzzqW\n",
-      "Initializing PoolWorker-13 [pid 82440]\n",
-      "PoolWorker-13: Created temporary directory /tmp/madlib_r2u4Zo5bPt\n",
-      "PoolWorker-11: Connected to madlib db.\n",
-      "Initializing PoolWorker-14 [pid 82441]\n",
-      "PoolWorker-12: Connected to madlib db.\n",
-      "PoolWorker-14: Created temporary directory /tmp/madlib_aTPESoNjVi\n",
-      "Initializing PoolWorker-15 [pid 82443]\n",
-      "PoolWorker-13: Connected to madlib db.\n",
-      "PoolWorker-15: Created temporary directory /tmp/madlib_rhVwjLTbWI\n",
-      "PoolWorker-14: Connected to madlib db.\n",
-      "PoolWorker-15: Connected to madlib db.\n",
-      "PoolWorker-13: Wrote 1000 images to /tmp/madlib_r2u4Zo5bPt/cifar_10_train_data_filesystem0000.tmp\n",
-      "PoolWorker-14: Wrote 1000 images to /tmp/madlib_aTPESoNjVi/cifar_10_train_data_filesystem0000.tmp\n",
-      "PoolWorker-12: Wrote 1000 images to /tmp/madlib_70qpwFzzqW/cifar_10_train_data_filesystem0000.tmp\n",
-      "PoolWorker-11: Wrote 1000 images to /tmp/madlib_aEC1lF2HqL/cifar_10_train_data_filesystem0000.tmp\n",
-      "PoolWorker-15: Wrote 1000 images to /tmp/madlib_rhVwjLTbWI/cifar_10_train_data_filesystem0000.tmp\n",
-      "PoolWorker-13: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-14: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-11: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-12: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-15: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-14: Wrote 1000 images to /tmp/madlib_aTPESoNjVi/cifar_10_train_data_filesystem0001.tmp\n",
-      "PoolWorker-11: Wrote 1000 images to /tmp/madlib_aEC1lF2HqL/cifar_10_train_data_filesystem0001.tmp\n",
-      "PoolWorker-13: Wrote 1000 images to /tmp/madlib_r2u4Zo5bPt/cifar_10_train_data_filesystem0001.tmp\n",
-      "PoolWorker-15: Wrote 1000 images to /tmp/madlib_rhVwjLTbWI/cifar_10_train_data_filesystem0001.tmp\n",
-      "PoolWorker-12: Wrote 1000 images to /tmp/madlib_70qpwFzzqW/cifar_10_train_data_filesystem0001.tmp\n",
-      "PoolWorker-14: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-11: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-13: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-15: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-12: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-14: Wrote 1000 images to /tmp/madlib_aTPESoNjVi/cifar_10_train_data_filesystem0002.tmp\n",
-      "PoolWorker-15: Wrote 1000 images to /tmp/madlib_rhVwjLTbWI/cifar_10_train_data_filesystem0002.tmp\n",
-      "PoolWorker-13: Wrote 1000 images to /tmp/madlib_r2u4Zo5bPt/cifar_10_train_data_filesystem0002.tmp\n",
-      "PoolWorker-11: Wrote 1000 images to /tmp/madlib_aEC1lF2HqL/cifar_10_train_data_filesystem0002.tmp\n",
-      "PoolWorker-12: Wrote 1000 images to /tmp/madlib_70qpwFzzqW/cifar_10_train_data_filesystem0002.tmp\n",
-      "PoolWorker-14: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-11: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-15: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-13: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-12: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-15: Wrote 1000 images to /tmp/madlib_rhVwjLTbWI/cifar_10_train_data_filesystem0003.tmp\n",
-      "PoolWorker-14: Wrote 1000 images to /tmp/madlib_aTPESoNjVi/cifar_10_train_data_filesystem0003.tmp\n",
-      "PoolWorker-13: Wrote 1000 images to /tmp/madlib_r2u4Zo5bPt/cifar_10_train_data_filesystem0003.tmp\n",
-      "PoolWorker-12: Wrote 1000 images to /tmp/madlib_70qpwFzzqW/cifar_10_train_data_filesystem0003.tmp\n",
-      "PoolWorker-11: Wrote 1000 images to /tmp/madlib_aEC1lF2HqL/cifar_10_train_data_filesystem0003.tmp\n",
-      "PoolWorker-15: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-14: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-13: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-11: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-12: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-15: Wrote 1000 images to /tmp/madlib_rhVwjLTbWI/cifar_10_train_data_filesystem0004.tmp\n",
-      "PoolWorker-14: Wrote 1000 images to /tmp/madlib_aTPESoNjVi/cifar_10_train_data_filesystem0004.tmp\n",
-      "PoolWorker-12: Wrote 1000 images to /tmp/madlib_70qpwFzzqW/cifar_10_train_data_filesystem0004.tmp\n",
-      "PoolWorker-13: Wrote 1000 images to /tmp/madlib_r2u4Zo5bPt/cifar_10_train_data_filesystem0004.tmp\n",
-      "PoolWorker-11: Wrote 1000 images to /tmp/madlib_aEC1lF2HqL/cifar_10_train_data_filesystem0004.tmp\n",
-      "PoolWorker-14: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-15: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-12: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-11: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-13: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-15: Wrote 1000 images to /tmp/madlib_rhVwjLTbWI/cifar_10_train_data_filesystem0005.tmp\n",
-      "PoolWorker-14: Wrote 1000 images to /tmp/madlib_aTPESoNjVi/cifar_10_train_data_filesystem0005.tmp\n",
-      "PoolWorker-12: Wrote 1000 images to /tmp/madlib_70qpwFzzqW/cifar_10_train_data_filesystem0005.tmp\n",
-      "PoolWorker-11: Wrote 1000 images to /tmp/madlib_aEC1lF2HqL/cifar_10_train_data_filesystem0005.tmp\n",
-      "PoolWorker-13: Wrote 1000 images to /tmp/madlib_r2u4Zo5bPt/cifar_10_train_data_filesystem0005.tmp\n",
-      "PoolWorker-14: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-15: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-12: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-13: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-11: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-15: Wrote 1000 images to /tmp/madlib_rhVwjLTbWI/cifar_10_train_data_filesystem0006.tmp\n",
-      "PoolWorker-14: Wrote 1000 images to /tmp/madlib_aTPESoNjVi/cifar_10_train_data_filesystem0006.tmp\n",
-      "PoolWorker-12: Wrote 1000 images to /tmp/madlib_70qpwFzzqW/cifar_10_train_data_filesystem0006.tmp\n",
-      "PoolWorker-13: Wrote 1000 images to /tmp/madlib_r2u4Zo5bPt/cifar_10_train_data_filesystem0006.tmp\n",
-      "PoolWorker-11: Wrote 1000 images to /tmp/madlib_aEC1lF2HqL/cifar_10_train_data_filesystem0006.tmp\n",
-      "PoolWorker-15: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-14: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-12: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-11: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-13: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-15: Wrote 1000 images to /tmp/madlib_rhVwjLTbWI/cifar_10_train_data_filesystem0007.tmp\n",
-      "PoolWorker-14: Wrote 1000 images to /tmp/madlib_aTPESoNjVi/cifar_10_train_data_filesystem0007.tmp\n",
-      "PoolWorker-12: Wrote 1000 images to /tmp/madlib_70qpwFzzqW/cifar_10_train_data_filesystem0007.tmp\n",
-      "PoolWorker-13: Wrote 1000 images to /tmp/madlib_r2u4Zo5bPt/cifar_10_train_data_filesystem0007.tmp\n",
-      "PoolWorker-11: Wrote 1000 images to /tmp/madlib_aEC1lF2HqL/cifar_10_train_data_filesystem0007.tmp\n",
-      "PoolWorker-15: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-14: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-12: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-13: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-11: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-14: Wrote 1000 images to /tmp/madlib_aTPESoNjVi/cifar_10_train_data_filesystem0008.tmp\n",
-      "PoolWorker-15: Wrote 1000 images to /tmp/madlib_rhVwjLTbWI/cifar_10_train_data_filesystem0008.tmp\n",
-      "PoolWorker-12: Wrote 1000 images to /tmp/madlib_70qpwFzzqW/cifar_10_train_data_filesystem0008.tmp\n",
-      "PoolWorker-13: Wrote 1000 images to /tmp/madlib_r2u4Zo5bPt/cifar_10_train_data_filesystem0008.tmp\n"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "PoolWorker-11: Wrote 1000 images to /tmp/madlib_aEC1lF2HqL/cifar_10_train_data_filesystem0008.tmp\n",
-      "PoolWorker-14: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-15: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-12: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-13: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-11: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-14: Wrote 1000 images to /tmp/madlib_aTPESoNjVi/cifar_10_train_data_filesystem0009.tmp\n",
-      "PoolWorker-15: Wrote 1000 images to /tmp/madlib_rhVwjLTbWI/cifar_10_train_data_filesystem0009.tmp\n",
-      "PoolWorker-12: Wrote 1000 images to /tmp/madlib_70qpwFzzqW/cifar_10_train_data_filesystem0009.tmp\n",
-      "PoolWorker-13: Wrote 1000 images to /tmp/madlib_r2u4Zo5bPt/cifar_10_train_data_filesystem0009.tmp\n",
-      "PoolWorker-11: Wrote 1000 images to /tmp/madlib_aEC1lF2HqL/cifar_10_train_data_filesystem0009.tmp\n",
-      "PoolWorker-14: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-12: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-15: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-13: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-11: Loaded 1000 images into cifar_10_train_data_filesystem\n",
-      "PoolWorker-12: Removed temporary directory /tmp/madlib_70qpwFzzqW\n",
-      "PoolWorker-13: Removed temporary directory /tmp/madlib_r2u4Zo5bPt\n",
-      "PoolWorker-15: Removed temporary directory /tmp/madlib_rhVwjLTbWI\n",
-      "PoolWorker-11: Removed temporary directory /tmp/madlib_aEC1lF2HqL\n",
-      "PoolWorker-14: Removed temporary directory /tmp/madlib_aTPESoNjVi\n",
-      "Done!  Loaded 10 image categories in 27.9927430153s\n",
-      "5 workers terminated.\n"
-     ]
-    }
-   ],
-   "source": [
-    "%sql drop table if exists cifar_10_train_data_filesystem;\n",
-    "# Load images from file system\n",
-    "iloader.load_dataset_from_disk('/Users/fmcquillan/tmp/cifar10', 'cifar_10_train_data_filesystem', num_labels='all', append=False)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 15,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>count</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>50000</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(50000L,)]"
-      ]
-     },
-     "execution_count": 15,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "SELECT COUNT(*) FROM cifar_10_train_data_filesystem;"
-   ]
-  }
- ],
- "metadata": {
-  "kernelspec": {
-   "display_name": "Python 2",
-   "language": "python",
-   "name": "python2"
-  },
-  "language_info": {
-   "codemirror_mode": {
-    "name": "ipython",
-    "version": 2
-   },
-   "file_extension": ".py",
-   "mimetype": "text/x-python",
-   "name": "python",
-   "nbconvert_exporter": "python",
-   "pygments_lexer": "ipython2",
-   "version": "2.7.16"
-  }
- },
- "nbformat": 4,
- "nbformat_minor": 2
-}
diff --git a/community-artifacts/Deep-learning/.ipynb_checkpoints/MADlib-Keras-cifar10-cnn-v3-checkpoint.ipynb b/community-artifacts/Deep-learning/.ipynb_checkpoints/MADlib-Keras-cifar10-cnn-v3-checkpoint.ipynb
deleted file mode 100644
index 987ff4b..0000000
--- a/community-artifacts/Deep-learning/.ipynb_checkpoints/MADlib-Keras-cifar10-cnn-v3-checkpoint.ipynb
+++ /dev/null
@@ -1,1297 +0,0 @@
-{
- "cells": [
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "# CNN Using Keras and MADlib\n",
-    "\n",
-    "E2E classification example using MADlib calling a Keras CNN.  Based on model architecture in https://keras.io/examples/cifar10_cnn/\n",
-    "\n",
-    "To load images into tables we use the script called <em>madlib_image_loader.py</em> located at https://github.com/apache/madlib-site/tree/asf-site/community-artifacts/Deep-learning which uses the Python Imaging Library so supports multiple formats\n",
-    "http://www.pythonware.com/products/pil/\n",
-    "\n",
-    "\n",
-    "## Table of contents\n",
-    "<a href=\"#import_libraries\">1. Import libraries</a>\n",
-    "\n",
-    "<a href=\"#load_and_prepare_data\">2. Load dataset into table</a>\n",
-    "\n",
-    "<a href=\"#image_preproc\">3. Call image preprocessor</a>\n",
-    "\n",
-    "<a href=\"#define_and_load_model\">4. Define and load model architecture</a>\n",
-    "\n",
-    "<a href=\"#train\">5. Train</a>\n",
-    "\n",
-    "<a href=\"#plot\">6. Plots by iteration and time</a>"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "The CIFAR-10 dataset consists of 60,000 32x32 colour images in 10 classes, with 6,000 images per class. There are 50,000 training images and 10,000 test images. \n",
-    "\n",
-    "https://www.cs.toronto.edu/~kriz/cifar.html"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 1,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "image/jpeg": "/9j/4AAQSkZJRgABAQAAkACQAAD/4QB0RXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAIdpAAQAAAABAAAATgAAAAAAAACQAAAAAQAAAJAAAAABAAKgAgAEAAAAAQAAA7igAwAEAAAAAQAAAuIAAAAA/+0AOFBob3Rvc2hvcCAzLjAAOEJJTQQEAAAAAAAAOEJJTQQlAAAAAAAQ1B2M2Y8AsgTpgAmY7PhCfv/AABEIAuIDuAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV [...]
-      "text/plain": [
-       "<IPython.core.display.Image object>"
-      ]
-     },
-     "execution_count": 1,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "from IPython.display import Image\n",
-    "Image(\"../../images/cifar10.jpg\")"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 2,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "/Users/fmcquillan/anaconda/lib/python2.7/site-packages/IPython/config.py:13: ShimWarning: The `IPython.config` package has been deprecated since IPython 4.0. You should import from traitlets.config instead.\n",
-      "  \"You should import from traitlets.config instead.\", ShimWarning)\n",
-      "/Users/fmcquillan/anaconda/lib/python2.7/site-packages/IPython/utils/traitlets.py:5: UserWarning: IPython.utils.traitlets has moved to a top-level traitlets package.\n",
-      "  warn(\"IPython.utils.traitlets has moved to a top-level traitlets package.\")\n"
-     ]
-    }
-   ],
-   "source": [
-    "%load_ext sql"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 4,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "u'Connected: gpadmin@madlib'"
-      ]
-     },
-     "execution_count": 4,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "# Greenplum Database 5.x on GCP (PM demo machine) - direct external IP access\n",
-    "#%sql postgresql://gpadmin@34.67.65.96:5432/madlib\n",
-    "\n",
-    "# Greenplum Database 5.x on GCP - via tunnel\n",
-    "%sql postgresql://gpadmin@localhost:8000/madlib\n",
-    "        \n",
-    "# PostgreSQL local\n",
-    "#%sql postgresql://fmcquillan@localhost:5432/madlib"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 5,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>version</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>MADlib version: 1.17-dev, git revision: rel/v1.16-54-gec5614f, cmake configuration time: Wed Dec 18 17:08:05 UTC 2019, build type: release, build system: Linux-3.10.0-1062.4.3.el7.x86_64, C compiler: gcc 4.8.5, C++ compiler: g++ 4.8.5</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(u'MADlib version: 1.17-dev, git revision: rel/v1.16-54-gec5614f, cmake configuration time: Wed Dec 18 17:08:05 UTC 2019, build type: release, build system: Linux-3.10.0-1062.4.3.el7.x86_64, C compiler: gcc 4.8.5, C++ compiler: g++ 4.8.5',)]"
-      ]
-     },
-     "execution_count": 5,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%sql select madlib.version();\n",
-    "#%sql select version();"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"import_libraries\"></a>\n",
-    "# 1.  Import libraries\n",
-    "From https://keras.io/examples/mnist_transfer_cnn/ import libraries and define some params"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 6,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "Using TensorFlow backend.\n"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Couldn't import dot_parser, loading of dot files will not be possible.\n"
-     ]
-    }
-   ],
-   "source": [
-    "from __future__ import print_function\n",
-    "import keras\n",
-    "from keras.datasets import cifar10\n",
-    "from keras.preprocessing.image import ImageDataGenerator\n",
-    "from keras.models import Sequential\n",
-    "from keras.layers import Dense, Dropout, Activation, Flatten\n",
-    "from keras.layers import Conv2D, MaxPooling2D\n",
-    "import os\n",
-    "\n",
-    "batch_size = 32\n",
-    "num_classes = 10\n",
-    "epochs = 100"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Others needed in this workbook"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 7,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "import pandas as pd\n",
-    "import numpy as np\n",
-    "import sys\n",
-    "import os\n",
-    "from matplotlib import pyplot as plt"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"load_and_prepare_data\"></a>\n",
-    "# 2.  Set up image loader and load dataset into table\n",
-    "\n",
-    "First set up image loader using the script called <em>madlib_image_loader.py</em> located at https://github.com/apache/madlib-site/tree/asf-site/community-artifacts/Deep-learning"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 11,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "madlib_site_dir = '/Users/fmcquillan/Documents/Product/MADlib/Demos/data'\n",
-    "sys.path.append(madlib_site_dir)\n",
-    "\n",
-    "# Import image loader module\n",
-    "from madlib_image_loader import ImageLoader, DbCredentials\n",
-    "\n",
-    "# Specify database credentials, for connecting to db\n",
-    "db_creds = DbCredentials(user='fmcquillan',\n",
-    "                         host='localhost',\n",
-    "                         port='5432',\n",
-    "                         password='')\n",
-    "\n",
-    "# Specify database credentials, for connecting to db\n",
-    "#db_creds = DbCredentials(user='gpadmin', \n",
-    "#                         db_name='madlib',\n",
-    "#                         host='35.239.240.26',\n",
-    "#                         port='5432',\n",
-    "#                         password='')\n",
-    "\n",
-    "# Initialize ImageLoader (increase num_workers to run faster)\n",
-    "iloader = ImageLoader(num_workers=5, db_creds=db_creds)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "First load CIFAR-10 data from Keras consisting of 50,000 32x32 color training images, labeled over 10 categories, and 10,000 test images."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 12,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Done.\n",
-      "MainProcess: Connected to madlib db.\n",
-      "Executing: CREATE TABLE cifar_10_train_data (id SERIAL, x REAL[], y TEXT)\n",
-      "CREATE TABLE\n",
-      "Created table cifar_10_train_data in madlib db\n",
-      "Spawning 5 workers...\n",
-      "Initializing PoolWorker-1 [pid 66874]\n",
-      "PoolWorker-1: Created temporary directory /tmp/madlib_rrRCbykUw0\n",
-      "Initializing PoolWorker-2 [pid 66875]\n",
-      "PoolWorker-2: Created temporary directory /tmp/madlib_w1bgWZpxCn\n",
-      "Initializing PoolWorker-3 [pid 66876]\n",
-      "PoolWorker-3: Created temporary directory /tmp/madlib_q2Xgd1TDVg\n",
-      "PoolWorker-1: Connected to madlib db.\n",
-      "Initializing PoolWorker-4 [pid 66877]\n",
-      "PoolWorker-2: Connected to madlib db.\n",
-      "PoolWorker-4: Created temporary directory /tmp/madlib_NJDD5nxkcT\n",
-      "Initializing PoolWorker-5 [pid 66879]\n",
-      "PoolWorker-3: Connected to madlib db.\n",
-      "PoolWorker-5: Created temporary directory /tmp/madlib_rQ5Tgpwhkw\n",
-      "PoolWorker-4: Connected to madlib db.\n",
-      "PoolWorker-5: Connected to madlib db.\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_rrRCbykUw0/cifar_10_train_data0000.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_w1bgWZpxCn/cifar_10_train_data0000.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_q2Xgd1TDVg/cifar_10_train_data0000.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_NJDD5nxkcT/cifar_10_train_data0000.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_rQ5Tgpwhkw/cifar_10_train_data0000.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_rrRCbykUw0/cifar_10_train_data0001.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_w1bgWZpxCn/cifar_10_train_data0001.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_q2Xgd1TDVg/cifar_10_train_data0001.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_NJDD5nxkcT/cifar_10_train_data0001.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_rQ5Tgpwhkw/cifar_10_train_data0001.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_rrRCbykUw0/cifar_10_train_data0002.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_w1bgWZpxCn/cifar_10_train_data0002.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_q2Xgd1TDVg/cifar_10_train_data0002.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_NJDD5nxkcT/cifar_10_train_data0002.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_rQ5Tgpwhkw/cifar_10_train_data0002.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_rrRCbykUw0/cifar_10_train_data0003.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_w1bgWZpxCn/cifar_10_train_data0003.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_q2Xgd1TDVg/cifar_10_train_data0003.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_NJDD5nxkcT/cifar_10_train_data0003.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_rQ5Tgpwhkw/cifar_10_train_data0003.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_rrRCbykUw0/cifar_10_train_data0004.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_w1bgWZpxCn/cifar_10_train_data0004.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_q2Xgd1TDVg/cifar_10_train_data0004.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_NJDD5nxkcT/cifar_10_train_data0004.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_rQ5Tgpwhkw/cifar_10_train_data0004.tmp\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_rrRCbykUw0/cifar_10_train_data0005.tmp\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_q2Xgd1TDVg/cifar_10_train_data0005.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_w1bgWZpxCn/cifar_10_train_data0005.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_NJDD5nxkcT/cifar_10_train_data0005.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_rQ5Tgpwhkw/cifar_10_train_data0005.tmp\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_rrRCbykUw0/cifar_10_train_data0006.tmp\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_q2Xgd1TDVg/cifar_10_train_data0006.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_w1bgWZpxCn/cifar_10_train_data0006.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_rQ5Tgpwhkw/cifar_10_train_data0006.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_NJDD5nxkcT/cifar_10_train_data0006.tmp\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_rrRCbykUw0/cifar_10_train_data0007.tmp\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_q2Xgd1TDVg/cifar_10_train_data0007.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_w1bgWZpxCn/cifar_10_train_data0007.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_rQ5Tgpwhkw/cifar_10_train_data0007.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_NJDD5nxkcT/cifar_10_train_data0007.tmp\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_rrRCbykUw0/cifar_10_train_data0008.tmp\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_q2Xgd1TDVg/cifar_10_train_data0008.tmp\n",
-      "PoolWorker-2: Wrote 1000 images to /tmp/madlib_w1bgWZpxCn/cifar_10_train_data0008.tmp\n",
-      "PoolWorker-5: Wrote 1000 images to /tmp/madlib_rQ5Tgpwhkw/cifar_10_train_data0008.tmp\n",
-      "PoolWorker-4: Wrote 1000 images to /tmp/madlib_NJDD5nxkcT/cifar_10_train_data0008.tmp\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_rrRCbykUw0/cifar_10_train_data0009.tmp\n",
-      "PoolWorker-2: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-5: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_q2Xgd1TDVg/cifar_10_train_data0009.tmp\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_rrRCbykUw0/cifar_10_train_data0010.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-3: Wrote 1000 images to /tmp/madlib_q2Xgd1TDVg/cifar_10_train_data0010.tmp\n",
-      "PoolWorker-3: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-1: Wrote 1000 images to /tmp/madlib_rrRCbykUw0/cifar_10_train_data0011.tmp\n",
-      "PoolWorker-1: Loaded 1000 images into cifar_10_train_data\n",
-      "PoolWorker-4: Removed temporary directory /tmp/madlib_NJDD5nxkcT\n",
-      "PoolWorker-3: Removed temporary directory /tmp/madlib_q2Xgd1TDVg\n"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "PoolWorker-2: Removed temporary directory /tmp/madlib_w1bgWZpxCn\n",
-      "PoolWorker-5: Removed temporary directory /tmp/madlib_rQ5Tgpwhkw\n",
-      "PoolWorker-1: Removed temporary directory /tmp/madlib_rrRCbykUw0\n",
-      "Done!  Loaded 50000 images in 24.2264728546s\n",
-      "5 workers terminated.\n",
-      "MainProcess: Connected to madlib db.\n",
-      "Executing: CREATE TABLE cifar_10_test_data (id SERIAL, x REAL[], y TEXT)\n",
-      "CREATE TABLE\n",
-      "Created table cifar_10_test_data in madlib db\n",
-      "Spawning 5 workers...\n",
-      "Initializing PoolWorker-6 [pid 66886]\n",
-      "PoolWorker-6: Created temporary directory /tmp/madlib_us7NnIzs4Z\n",
-      "Initializing PoolWorker-7 [pid 66887]\n",
-      "PoolWorker-7: Created temporary directory /tmp/madlib_YhsJADC7Iq\n",
-      "Initializing PoolWorker-8 [pid 66888]\n",
-      "PoolWorker-8: Created temporary directory /tmp/madlib_izbrkdZU7f\n",
-      "PoolWorker-6: Connected to madlib db.\n",
-      "Initializing PoolWorker-9 [pid 66889]\n",
-      "PoolWorker-7: Connected to madlib db.\n",
-      "PoolWorker-9: Created temporary directory /tmp/madlib_GgLgXeKpOp\n",
-      "Initializing PoolWorker-10 [pid 66891]\n",
-      "PoolWorker-10: Created temporary directory /tmp/madlib_JfRd66eGln\n",
-      "PoolWorker-8: Connected to madlib db.\n",
-      "PoolWorker-9: Connected to madlib db.\n",
-      "PoolWorker-10: Connected to madlib db.\n",
-      "PoolWorker-6: Wrote 1000 images to /tmp/madlib_us7NnIzs4Z/cifar_10_test_data0000.tmp\n",
-      "PoolWorker-7: Wrote 1000 images to /tmp/madlib_YhsJADC7Iq/cifar_10_test_data0000.tmp\n",
-      "PoolWorker-8: Wrote 1000 images to /tmp/madlib_izbrkdZU7f/cifar_10_test_data0000.tmp\n",
-      "PoolWorker-9: Wrote 1000 images to /tmp/madlib_GgLgXeKpOp/cifar_10_test_data0000.tmp\n",
-      "PoolWorker-10: Wrote 1000 images to /tmp/madlib_JfRd66eGln/cifar_10_test_data0000.tmp\n",
-      "PoolWorker-6: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-7: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-8: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-10: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-9: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-7: Wrote 1000 images to /tmp/madlib_YhsJADC7Iq/cifar_10_test_data0001.tmp\n",
-      "PoolWorker-6: Wrote 1000 images to /tmp/madlib_us7NnIzs4Z/cifar_10_test_data0001.tmp\n",
-      "PoolWorker-8: Wrote 1000 images to /tmp/madlib_izbrkdZU7f/cifar_10_test_data0001.tmp\n",
-      "PoolWorker-10: Wrote 1000 images to /tmp/madlib_JfRd66eGln/cifar_10_test_data0001.tmp\n",
-      "PoolWorker-9: Wrote 1000 images to /tmp/madlib_GgLgXeKpOp/cifar_10_test_data0001.tmp\n",
-      "PoolWorker-7: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-6: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-8: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-10: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-9: Loaded 1000 images into cifar_10_test_data\n",
-      "PoolWorker-8: Removed temporary directory /tmp/madlib_izbrkdZU7f\n",
-      "PoolWorker-6: Removed temporary directory /tmp/madlib_us7NnIzs4Z\n",
-      "PoolWorker-7: Removed temporary directory /tmp/madlib_YhsJADC7Iq\n",
-      "PoolWorker-10: Removed temporary directory /tmp/madlib_JfRd66eGln\n",
-      "PoolWorker-9: Removed temporary directory /tmp/madlib_GgLgXeKpOp\n",
-      "Done!  Loaded 10000 images in 5.36254000664s\n",
-      "5 workers terminated.\n"
-     ]
-    }
-   ],
-   "source": [
-    "# Load dataset into np array\n",
-    "(x_train, y_train), (x_test, y_test) = cifar10.load_data()\n",
-    "\n",
-    "%sql DROP TABLE IF EXISTS cifar_10_train_data, cifar_10_test_data;\n",
-    "\n",
-    "# Save images to temporary directories and load into database\n",
-    "iloader.load_dataset_from_np(x_train, y_train, 'cifar_10_train_data', append=False)\n",
-    "iloader.load_dataset_from_np(x_test, y_test, 'cifar_10_test_data', append=False)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 8,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>count</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>50000</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(50000L,)]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%sql select count(*) from cifar_10_train_data;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"image_preproc\"></a>\n",
-    "# 3. Call image preprocessor\n",
-    "\n",
-    "Transforms from one image per row to multiple images per row for batch optimization.  Also normalizes and one-hot encodes.\n",
-    "\n",
-    "Training data"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 15,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Done.\n",
-      "1 rows affected.\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>source_table</th>\n",
-       "        <th>output_table</th>\n",
-       "        <th>dependent_varname</th>\n",
-       "        <th>independent_varname</th>\n",
-       "        <th>dependent_vartype</th>\n",
-       "        <th>class_values</th>\n",
-       "        <th>buffer_size</th>\n",
-       "        <th>normalizing_const</th>\n",
-       "        <th>num_classes</th>\n",
-       "        <th>distribution_rules</th>\n",
-       "        <th>__internal_gpu_config__</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>cifar_10_train_data</td>\n",
-       "        <td>cifar_10_train_data_packed</td>\n",
-       "        <td>y</td>\n",
-       "        <td>x</td>\n",
-       "        <td>text</td>\n",
-       "        <td>[u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9']</td>\n",
-       "        <td>1000</td>\n",
-       "        <td>255.0</td>\n",
-       "        <td>10</td>\n",
-       "        <td>all_segments</td>\n",
-       "        <td>all_segments</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(u'cifar_10_train_data', u'cifar_10_train_data_packed', u'y', u'x', u'text', [u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9'], 1000, 255.0, 10, 'all_segments', 'all_segments')]"
-      ]
-     },
-     "execution_count": 15,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "DROP TABLE IF EXISTS cifar_10_train_data_packed, cifar_10_train_data_packed_summary;\n",
-    "\n",
-    "SELECT madlib.training_preprocessor_dl('cifar_10_train_data',        -- Source table\n",
-    "                                       'cifar_10_train_data_packed', -- Output table\n",
-    "                                       'y',                          -- Dependent variable\n",
-    "                                       'x',                          -- Independent variable\n",
-    "                                        1000,                        -- Buffer size\n",
-    "                                        255                          -- Normalizing constant\n",
-    "                                        );\n",
-    "\n",
-    "SELECT * FROM cifar_10_train_data_packed_summary;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Test data"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 16,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Done.\n",
-      "1 rows affected.\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>source_table</th>\n",
-       "        <th>output_table</th>\n",
-       "        <th>dependent_varname</th>\n",
-       "        <th>independent_varname</th>\n",
-       "        <th>dependent_vartype</th>\n",
-       "        <th>class_values</th>\n",
-       "        <th>buffer_size</th>\n",
-       "        <th>normalizing_const</th>\n",
-       "        <th>num_classes</th>\n",
-       "        <th>distribution_rules</th>\n",
-       "        <th>__internal_gpu_config__</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>cifar_10_test_data</td>\n",
-       "        <td>cifar_10_test_data_packed</td>\n",
-       "        <td>y</td>\n",
-       "        <td>x</td>\n",
-       "        <td>text</td>\n",
-       "        <td>[u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9']</td>\n",
-       "        <td>1000</td>\n",
-       "        <td>255.0</td>\n",
-       "        <td>10</td>\n",
-       "        <td>all_segments</td>\n",
-       "        <td>all_segments</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(u'cifar_10_test_data', u'cifar_10_test_data_packed', u'y', u'x', u'text', [u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9'], 1000, 255.0, 10, 'all_segments', 'all_segments')]"
-      ]
-     },
-     "execution_count": 16,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "DROP TABLE IF EXISTS cifar_10_test_data_packed, cifar_10_test_data_packed_summary;\n",
-    "\n",
-    "SELECT madlib.validation_preprocessor_dl('cifar_10_test_data',          -- Source table\n",
-    "                                         'cifar_10_test_data_packed',   -- Output table\n",
-    "                                         'y',                           -- Dependent variable\n",
-    "                                         'x',                           -- Independent variable\n",
-    "                                         'cifar_10_train_data_packed',  -- Training preproc table\n",
-    "                                         1000                           -- Buffer size\n",
-    "                                        );\n",
-    "\n",
-    "SELECT * FROM cifar_10_test_data_packed_summary;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"define_and_load_model\"></a>\n",
-    "# 4. Define and load model architecture\n",
-    "\n",
-    "Model architecture from https://keras.io/examples/cifar10_cnn/"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 17,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "_________________________________________________________________\n",
-      "Layer (type)                 Output Shape              Param #   \n",
-      "=================================================================\n",
-      "conv2d_5 (Conv2D)            (None, 32, 32, 32)        896       \n",
-      "_________________________________________________________________\n",
-      "activation_7 (Activation)    (None, 32, 32, 32)        0         \n",
-      "_________________________________________________________________\n",
-      "conv2d_6 (Conv2D)            (None, 30, 30, 32)        9248      \n",
-      "_________________________________________________________________\n",
-      "activation_8 (Activation)    (None, 30, 30, 32)        0         \n",
-      "_________________________________________________________________\n",
-      "max_pooling2d_3 (MaxPooling2 (None, 15, 15, 32)        0         \n",
-      "_________________________________________________________________\n",
-      "dropout_4 (Dropout)          (None, 15, 15, 32)        0         \n",
-      "_________________________________________________________________\n",
-      "conv2d_7 (Conv2D)            (None, 15, 15, 64)        18496     \n",
-      "_________________________________________________________________\n",
-      "activation_9 (Activation)    (None, 15, 15, 64)        0         \n",
-      "_________________________________________________________________\n",
-      "conv2d_8 (Conv2D)            (None, 13, 13, 64)        36928     \n",
-      "_________________________________________________________________\n",
-      "activation_10 (Activation)   (None, 13, 13, 64)        0         \n",
-      "_________________________________________________________________\n",
-      "max_pooling2d_4 (MaxPooling2 (None, 6, 6, 64)          0         \n",
-      "_________________________________________________________________\n",
-      "dropout_5 (Dropout)          (None, 6, 6, 64)          0         \n",
-      "_________________________________________________________________\n",
-      "flatten_2 (Flatten)          (None, 2304)              0         \n",
-      "_________________________________________________________________\n",
-      "dense_3 (Dense)              (None, 512)               1180160   \n",
-      "_________________________________________________________________\n",
-      "activation_11 (Activation)   (None, 512)               0         \n",
-      "_________________________________________________________________\n",
-      "dropout_6 (Dropout)          (None, 512)               0         \n",
-      "_________________________________________________________________\n",
-      "dense_4 (Dense)              (None, 10)                5130      \n",
-      "_________________________________________________________________\n",
-      "activation_12 (Activation)   (None, 10)                0         \n",
-      "=================================================================\n",
-      "Total params: 1,250,858\n",
-      "Trainable params: 1,250,858\n",
-      "Non-trainable params: 0\n",
-      "_________________________________________________________________\n"
-     ]
-    }
-   ],
-   "source": [
-    "model = Sequential()\n",
-    "model.add(Conv2D(32, (3, 3), padding='same',\n",
-    "                 input_shape=x_train.shape[1:]))\n",
-    "model.add(Activation('relu'))\n",
-    "model.add(Conv2D(32, (3, 3)))\n",
-    "model.add(Activation('relu'))\n",
-    "model.add(MaxPooling2D(pool_size=(2, 2)))\n",
-    "model.add(Dropout(0.25))\n",
-    "\n",
-    "model.add(Conv2D(64, (3, 3), padding='same'))\n",
-    "model.add(Activation('relu'))\n",
-    "model.add(Conv2D(64, (3, 3)))\n",
-    "model.add(Activation('relu'))\n",
-    "model.add(MaxPooling2D(pool_size=(2, 2)))\n",
-    "model.add(Dropout(0.25))\n",
-    "\n",
-    "model.add(Flatten())\n",
-    "model.add(Dense(512))\n",
-    "model.add(Activation('relu'))\n",
-    "model.add(Dropout(0.5))\n",
-    "model.add(Dense(num_classes))\n",
-    "model.add(Activation('softmax'))\n",
-    "\n",
-    "model.summary()"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Load into model architecture table using psycopg2"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 18,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Done.\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>model_id</th>\n",
-       "        <th>name</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>1</td>\n",
-       "        <td>CNN from Keras docs for CIFAR-10</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(1, u'CNN from Keras docs for CIFAR-10')]"
-      ]
-     },
-     "execution_count": 18,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "import psycopg2 as p2\n",
-    "#conn = p2.connect('postgresql://gpadmin@35.239.240.26:5432/madlib')\n",
-    "#conn = p2.connect('postgresql://fmcquillan@localhost:5432/madlib')\n",
-    "conn = p2.connect('postgresql://gpadmin@localhost:8000/madlib')\n",
-    "cur = conn.cursor()\n",
-    "\n",
-    "%sql DROP TABLE IF EXISTS model_arch_library;\n",
-    "query = \"SELECT madlib.load_keras_model('model_arch_library', %s, NULL, %s)\"\n",
-    "cur.execute(query,[model.to_json(), \"CNN from Keras docs for CIFAR-10\"])\n",
-    "conn.commit()\n",
-    "\n",
-    "# check model loaded OK\n",
-    "%sql SELECT model_id, name FROM model_arch_library;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"train\"></a>\n",
-    "# 5.  Train"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 19,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Done.\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>madlib_keras_fit</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td></td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[('',)]"
-      ]
-     },
-     "execution_count": 19,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "DROP TABLE IF EXISTS cifar_10_model, cifar_10_model_summary;\n",
-    "\n",
-    "SELECT madlib.madlib_keras_fit('cifar_10_train_data_packed',    -- source table\n",
-    "                               'cifar_10_model',                -- model output table\n",
-    "                               'model_arch_library',            -- model arch table\n",
-    "                                1,                              -- model arch id\n",
-    "                                $$ loss='categorical_crossentropy', optimizer='rmsprop(lr=0.0001, decay=1e-6)', metrics=['accuracy']$$,  -- compile_params\n",
-    "                                $$ batch_size=32, epochs=3 $$,  -- fit_params\n",
-    "                                3,                              -- num_iterations\n",
-    "                                FALSE,                          -- use GPUs\n",
-    "                                'cifar_10_test_data_packed',    -- validation dataset\n",
-    "                                2                               -- metrics compute frequency\n",
-    "                              );"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "View the model summary:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 20,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>source_table</th>\n",
-       "        <th>model</th>\n",
-       "        <th>dependent_varname</th>\n",
-       "        <th>independent_varname</th>\n",
-       "        <th>model_arch_table</th>\n",
-       "        <th>model_id</th>\n",
-       "        <th>compile_params</th>\n",
-       "        <th>fit_params</th>\n",
-       "        <th>num_iterations</th>\n",
-       "        <th>validation_table</th>\n",
-       "        <th>metrics_compute_frequency</th>\n",
-       "        <th>name</th>\n",
-       "        <th>description</th>\n",
-       "        <th>model_type</th>\n",
-       "        <th>model_size</th>\n",
-       "        <th>start_training_time</th>\n",
-       "        <th>end_training_time</th>\n",
-       "        <th>metrics_elapsed_time</th>\n",
-       "        <th>madlib_version</th>\n",
-       "        <th>num_classes</th>\n",
-       "        <th>class_values</th>\n",
-       "        <th>dependent_vartype</th>\n",
-       "        <th>normalizing_const</th>\n",
-       "        <th>metrics_type</th>\n",
-       "        <th>training_metrics_final</th>\n",
-       "        <th>training_loss_final</th>\n",
-       "        <th>training_metrics</th>\n",
-       "        <th>training_loss</th>\n",
-       "        <th>validation_metrics_final</th>\n",
-       "        <th>validation_loss_final</th>\n",
-       "        <th>validation_metrics</th>\n",
-       "        <th>validation_loss</th>\n",
-       "        <th>metrics_iters</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>cifar_10_train_data_packed</td>\n",
-       "        <td>cifar_10_model</td>\n",
-       "        <td>y</td>\n",
-       "        <td>x</td>\n",
-       "        <td>model_arch_library</td>\n",
-       "        <td>1</td>\n",
-       "        <td> loss='categorical_crossentropy', optimizer='rmsprop(lr=0.0001, decay=1e-6)', metrics=['accuracy']</td>\n",
-       "        <td> batch_size=32, epochs=3 </td>\n",
-       "        <td>3</td>\n",
-       "        <td>cifar_10_test_data_packed</td>\n",
-       "        <td>2</td>\n",
-       "        <td>None</td>\n",
-       "        <td>None</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>4886.20019531</td>\n",
-       "        <td>2019-12-18 21:46:34.610075</td>\n",
-       "        <td>2019-12-18 22:01:06.754356</td>\n",
-       "        <td>[568.416245222092, 872.144206047058]</td>\n",
-       "        <td>1.17-dev</td>\n",
-       "        <td>10</td>\n",
-       "        <td>[u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9']</td>\n",
-       "        <td>text</td>\n",
-       "        <td>255.0</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.612959980965</td>\n",
-       "        <td>1.09410715103</td>\n",
-       "        <td>[0.563260018825531, 0.612959980964661]</td>\n",
-       "        <td>[1.22403216362, 1.09410715103149]</td>\n",
-       "        <td>0.597299993038</td>\n",
-       "        <td>1.12304246426</td>\n",
-       "        <td>[0.55460000038147, 0.597299993038177]</td>\n",
-       "        <td>[1.23818647861481, 1.12304246425629]</td>\n",
-       "        <td>[2, 3]</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(u'cifar_10_train_data_packed', u'cifar_10_model', u'y', u'x', u'model_arch_library', 1, u\" loss='categorical_crossentropy', optimizer='rmsprop(lr=0.0001, decay=1e-6)', metrics=['accuracy']\", u' batch_size=32, epochs=3 ', 3, u'cifar_10_test_data_packed', 2, None, None, u'madlib_keras', 4886.20019531, datetime.datetime(2019, 12, 18, 21, 46, 34, 610075), datetime.datetime(2019, 12, 18, 22, 1, 6, 754356), [568.416245222092, 872.144206047058], u'1.17-dev', 10, [u'0', u'1', u'2', u [...]
-      ]
-     },
-     "execution_count": 20,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "SELECT * FROM cifar_10_model_summary;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Evaluate using test data (same values as last iteration from the fit output summary above)."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 21,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Done.\n",
-      "1 rows affected.\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>loss</th>\n",
-       "        <th>metric</th>\n",
-       "        <th>metrics_type</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>1.12304246426</td>\n",
-       "        <td>0.597299993038</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(1.12304246425629, 0.597299993038177, [u'accuracy'])]"
-      ]
-     },
-     "execution_count": 21,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "DROP TABLE IF EXISTS cifar10_validate;\n",
-    "\n",
-    "SELECT madlib.madlib_keras_evaluate('cifar_10_model',               -- model\n",
-    "                                    'cifar_10_test_data_packed',   -- test table\n",
-    "                                    'cifar10_validate'             -- output table\n",
-    "                                    );\n",
-    "\n",
-    "SELECT * FROM cifar10_validate;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"plot\"></a>\n",
-    "# 6.  Plots by iteration and by time\n",
-    "Accuracy by iteration"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 100,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1 rows affected.\n",
-      "1 rows affected.\n",
-      "1 rows affected.\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "<matplotlib.legend.Legend at 0x1195ef9d0>"
-      ]
-     },
-     "execution_count": 100,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEWCAYAAACXGLsWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJzs3Xd4FFX3wPHvSSD0Jr0TqVKkikZBg6gUXxEVESuK/rCLIio2xIIdrKivr6KiCHZEBBExUZCIgHSQ3pEWaoAQkj2/P+4kLCEN2M2mnM/z7LO7M3dmzk42c/bOnXtHVBVjjDEmK2GhDsAYY0zeZ8nCGGNMtixZGGOMyZYlC2OMMdmyZGGMMSZbliyMMcZky5KFMQWAiFwkIusCtK4PROSxQKzrFGJYLiIdQxmDOZYli0JMRK4TkTkikiAi/4rIZBHp4M0bKiKf+ZVVETng [...]
-      "text/plain": [
-       "<Figure size 432x288 with 1 Axes>"
-      ]
-     },
-     "metadata": {
-      "needs_background": "light"
-     },
-     "output_type": "display_data"
-    }
-   ],
-   "source": [
-    "# get accuracy and iteration number\n",
-    "iters_proxy = %sql SELECT metrics_iters FROM cifar_10_model_summary;\n",
-    "train_accuracy_proxy = %sql SELECT training_metrics FROM cifar_10_model_summary;\n",
-    "test_accuracy_proxy = %sql SELECT validation_metrics FROM cifar_10_model_summary;\n",
-    "\n",
-    "# get number of points\n",
-    "num_points_proxy = %sql SELECT array_length(metrics_iters,1) FROM cifar_10_model_summary;\n",
-    "num_points = num_points_proxy[0]\n",
-    "\n",
-    "# reshape to np arrays\n",
-    "iters = np.array(iters_proxy).reshape(num_points)\n",
-    "train_accuracy = np.array(train_accuracy_proxy).reshape(num_points)\n",
-    "test_accuracy = np.array(test_accuracy_proxy).reshape(num_points)\n",
-    "\n",
-    "#plot\n",
-    "plt.title('CIFAR-10 accuracy by iteration')\n",
-    "plt.xlabel('Iteration number')\n",
-    "plt.ylabel('Accuracy')\n",
-    "plt.grid(True)\n",
-    "plt.plot(iters, train_accuracy, 'g.-', label='Train')\n",
-    "plt.plot(iters, test_accuracy, 'r.-', label='Test')\n",
-    "plt.legend()"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Loss by iteration"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 101,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1 rows affected.\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "<matplotlib.legend.Legend at 0x119279910>"
-      ]
-     },
-     "execution_count": 101,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEWCAYAAACJ0YulAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJzs3XmcTfX/wPHXe3aMdWjIjOy7yNqEDCqiaJEsUSStX60qUUkSpW/1LeUbSvxoSqlUKmUJX6MQMZQlyR7GNpRlzPv3x7kzc41ZmTN3lvfz8TiPe+85n3POe+7cue/5fD7nfD6iqhhjjDEAfr4OwBhjTP5hScEYY0wKSwrGGGNSWFIwxhiTwpKCMcaYFJYUjDHGpLCkYIo8ERkkIovy6Fw1RSRXrgMXkadFZGJuHOsCYpgnIn19GYPJXZYUTKZEpI+IrBSRYyKyR0S+FpE2 [...]
-      "text/plain": [
-       "<Figure size 432x288 with 1 Axes>"
-      ]
-     },
-     "metadata": {
-      "needs_background": "light"
-     },
-     "output_type": "display_data"
-    }
-   ],
-   "source": [
-    "# get loss\n",
-    "train_loss_proxy = %sql SELECT training_loss FROM cifar_10_model_summary;\n",
-    "test_loss_proxy = %sql SELECT validation_loss FROM cifar_10_model_summary;\n",
-    "\n",
-    "# reshape to np arrays\n",
-    "train_loss = np.array(train_loss_proxy).reshape(num_points)\n",
-    "test_loss = np.array(test_loss_proxy).reshape(num_points)\n",
-    "\n",
-    "#plot\n",
-    "plt.title('CIFAR-10 loss by iteration')\n",
-    "plt.xlabel('Iteration number')\n",
-    "plt.ylabel('Loss')\n",
-    "plt.grid(True)\n",
-    "plt.plot(iters, train_loss, 'g.-', label='Train')\n",
-    "plt.plot(iters, test_loss, 'r.-', label='Test')\n",
-    "plt.legend()"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Accuracy by time"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 108,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "<matplotlib.legend.Legend at 0x119664410>"
-      ]
-     },
-     "execution_count": 108,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEWCAYAAACXGLsWAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJzt3Xd4FFX3wPHvSSD0DqLShdCUJghEUKNYaBYUFRBULPx8bSgWxMqrrwj6+trAilgARQFFUEAUiYAgIFJUpEvvLRBa2vn9cSdhE1KWsJtNOZ/n2Sc7M3dmzu7Cnr1z79wrqooxxhiTlbBQB2CMMSbvs2RhjDEmW5YsjDHGZMuShTHGmGxZsjDGGJMtSxbGGGOyZcnCmEJIRC4XkQ1BPP4qEbkoWMc3uc+ShfGbiPQSkd9EJE5EtovINBFp720bLCJjfMqqiBz2ysaJyIF0 [...]
-      "text/plain": [
-       "<Figure size 432x288 with 1 Axes>"
-      ]
-     },
-     "metadata": {
-      "needs_background": "light"
-     },
-     "output_type": "display_data"
-    }
-   ],
-   "source": [
-    "# get time\n",
-    "time_proxy = %sql SELECT metrics_elapsed_time FROM cifar_10_model_summary;\n",
-    "\n",
-    "# reshape to np arrays\n",
-    "time = np.array(time_proxy).reshape(num_points)/60.0\n",
-    "\n",
-    "#plot\n",
-    "plt.title('CIFAR-10 accuracy by time')\n",
-    "plt.xlabel('Time (min)')\n",
-    "plt.ylabel('Accuracy')\n",
-    "plt.grid(True)\n",
-    "plt.plot(time, train_accuracy, 'g.-', label='Train')\n",
-    "plt.plot(time, test_accuracy, 'r.-', label='Test')\n",
-    "plt.legend()"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Time to achieve a given accuracy"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 109,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "<matplotlib.legend.Legend at 0x119628690>"
-      ]
-     },
-     "execution_count": 109,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAEWCAYAAABIVsEJAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJzt3Xd4VFX6wPHvm0AIJRCkC2iwAFKkBEuQXYPIWhbFgoJIUVyxrWXRFcR1cXFta+/tJ2tgEcKCBVkUBQ2KREqA0KX33hIChJDk/f1xLzFAICGZmTuTeT/Pk2dm7r1z73syMG/OOfecI6qKMcYYc7oivA7AGGNMaLIEYowxplQsgRhjjCkVSyDGGGNKxRKIMcaYUrEEYowxplQsgRhzHBH5PxEZGoDrXCki6/x9HWP8xRKIOSkR6S0ic0UkS0S2isjXItLJ3fe0iPyn0LEq [...]
-      "text/plain": [
-       "<Figure size 432x288 with 1 Axes>"
-      ]
-     },
-     "metadata": {
-      "needs_background": "light"
-     },
-     "output_type": "display_data"
-    }
-   ],
-   "source": [
-    "#plot\n",
-    "plt.title('CIFAR-10 time by accuracy')\n",
-    "plt.xlabel('Accuracy')\n",
-    "plt.ylabel('Time (min)')\n",
-    "plt.grid(True)\n",
-    "plt.plot(train_accuracy, time, 'g.-', label='Train')\n",
-    "plt.plot(test_accuracy, time, 'r.-', label='Test')\n",
-    "plt.legend()"
-   ]
-  }
- ],
- "metadata": {
-  "kernelspec": {
-   "display_name": "Python 2",
-   "language": "python",
-   "name": "python2"
-  },
-  "language_info": {
-   "codemirror_mode": {
-    "name": "ipython",
-    "version": 2
-   },
-   "file_extension": ".py",
-   "mimetype": "text/x-python",
-   "name": "python",
-   "nbconvert_exporter": "python",
-   "pygments_lexer": "ipython2",
-   "version": "2.7.16"
-  }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}
diff --git a/community-artifacts/Deep-learning/.ipynb_checkpoints/MADlib-Keras-model-selection-CNN-cifar10-v1-checkpoint.ipynb b/community-artifacts/Deep-learning/.ipynb_checkpoints/MADlib-Keras-model-selection-CNN-cifar10-v1-checkpoint.ipynb
deleted file mode 100755
index 70b9129..0000000
--- a/community-artifacts/Deep-learning/.ipynb_checkpoints/MADlib-Keras-model-selection-CNN-cifar10-v1-checkpoint.ipynb
+++ /dev/null
@@ -1,8037 +0,0 @@
-{
- "cells": [
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "# Model Selection for CNN Using Keras and MADlib on CIFAR-10\n",
-    "\n",
-    "E2E classification example using MADlib calling a Keras CNN for different hyperparameters and model architectures on the CIFAR-10 dataset.\n",
-    "\n",
-    "The CIFAR-10 dataset consists of 60,000 32x32 colour images in 10 classes, with 6,000 images per class. There are 50,000 training images and 10,000 test images.\n",
-    "https://www.cs.toronto.edu/~kriz/cifar.html\n",
-    "\n",
-    "## Table of contents \n",
-    "\n",
-    "<a href=\"#setup\">0. Setup</a>\n",
-    "\n",
-    "<a href=\"#load_dataset\">1. Load dataset into table</a>\n",
-    "\n",
-    "<a href=\"#distr\">2. Setup distribution rules and call preprocessor</a>\n",
-    "\n",
-    "<a href=\"#arch\">3. Define and load model architectures</a>\n",
-    "\n",
-    "<a href=\"#mst\">4. Define and load model selection tuples</a>\n",
-    "\n",
-    "<a href=\"#train\">5. Train</a>\n",
-    "\n",
-    "<a href=\"#plot\">6. Plot results</a>\n",
-    "\n",
-    "<a href=\"#predict\">7. Inference</a>"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"setup\"></a>\n",
-    "# 0. Setup"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 1,
-   "metadata": {
-    "scrolled": false
-   },
-   "outputs": [],
-   "source": [
-    "%load_ext sql"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 2,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "u'Connected: gpadmin@cifar_places'"
-      ]
-     },
-     "execution_count": 2,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "# Greenplum Database 5.x on GCP - via tunnel\n",
-    "%sql postgresql://gpadmin@localhost:8000/cifar_places\n",
-    "        \n",
-    "# PostgreSQL local\n",
-    "#%sql postgresql://fmcquillan@localhost:5432/madlib"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 3,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>version</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>MADlib version: 1.17-dev, git revision: rc/1.16-rc1-95-gc62dfe7, cmake configuration time: Tue Mar 17 16:53:55 UTC 2020, build type: RelWithDebInfo, build system: Linux-2.6.32-754.6.3.el6.x86_64, C compiler: gcc 4.4.7, C++ compiler: g++ 4.4.7</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(u'MADlib version: 1.17-dev, git revision: rc/1.16-rc1-95-gc62dfe7, cmake configuration time: Tue Mar 17 16:53:55 UTC 2020, build type: RelWithDebInfo, build system: Linux-2.6.32-754.6.3.el6.x86_64, C compiler: gcc 4.4.7, C++ compiler: g++ 4.4.7',)]"
-      ]
-     },
-     "execution_count": 3,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%sql select madlib.version();\n",
-    "#%sql select version();"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Import libraries"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 4,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "Using TensorFlow backend.\n"
-     ]
-    }
-   ],
-   "source": [
-    "from __future__ import print_function\n",
-    "import keras\n",
-    "from keras.datasets import cifar10\n",
-    "from keras.preprocessing.image import ImageDataGenerator\n",
-    "from keras.models import Sequential\n",
-    "from keras.layers import Dense, Dropout, Activation, Flatten, BatchNormalization\n",
-    "from keras.layers import Conv2D, MaxPooling2D\n",
-    "import os"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Others needed in this workbook"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 5,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "import pandas as pd\n",
-    "import numpy as np\n",
-    "import sys\n",
-    "import os\n",
-    "from matplotlib import pyplot as plt"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"load_dataset\"></a>\n",
-    "# 1.  Load dataset into table\n",
-    "\n",
-    "PXF can be used to load image data into Greenplum database.\n",
-    "\n",
-    "But for this demo, we will get the dataset from Keras and use the script called madlib_image_loader.py located at https://github.com/apache/madlib-site/tree/asf-site/community-artifacts/Deep-learning .\n",
-    "\n",
-    "If the script is not in the same folder as the notebook, you can use the following lines to import it."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 6,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "import sys\n",
-    "sys.path.insert(1, '/Users/fmcquillan/workspace/madlib-site/community-artifacts/Deep-learning')\n",
-    "from madlib_image_loader import ImageLoader, DbCredentials\n",
-    "\n",
-    "# Specify database credentials, for connecting to db\n",
-    "db_creds = DbCredentials(db_name='cifar_places',\n",
-    "                         user='gpadmin',\n",
-    "                         host='localhost',\n",
-    "                         port='8000',\n",
-    "                         password='')\n",
-    "\n",
-    "#db_creds = DbCredentials(db_name='cifar_places',\n",
-    "#                         user='fmcquillan',\n",
-    "#                         host='localhost',\n",
-    "#                         port='5432',\n",
-    "#                         password='')\n",
-    "\n",
-    "# Initialize ImageLoader (increase num_workers to run faster)\n",
-    "iloader = ImageLoader(num_workers=5, db_creds=db_creds)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Load dataset into tables"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "# Load dataset into np array\n",
-    "(x_train, y_train), (x_test, y_test) = cifar10.load_data()\n",
-    "\n",
-    "%sql DROP TABLE IF EXISTS cifar10_train, cifar10_val;\n",
-    "\n",
-    "# Save images to temporary directories and load into database\n",
-    "iloader.load_dataset_from_np(x_train, y_train, 'cifar10_train', append=False)\n",
-    "iloader.load_dataset_from_np(x_test, y_test, 'cifar10_val', append=False)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 7,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>count</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>50000</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(50000L,)]"
-      ]
-     },
-     "execution_count": 7,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%sql SELECT COUNT(*) FROM cifar10_train;"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 8,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>count</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>10000</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(10000L,)]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%sql SELECT COUNT(*) FROM cifar10_val;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"distr\"></a>\n",
-    "# 2.  Setup distribution rules and call preprocessor\n",
-    "\n",
-    "In this example we will train on 4 VMs with 4 segments/VM and 4 GPUs/VM (i.e., 16 workers).\n",
-    "\n",
-    "First get the GPU configuration in the cluster using the MADlib helper function `gpu_configuration`:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 9,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "Done.\n",
-      "1 rows affected.\n",
-      "20 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>hostname</th>\n",
-       "        <th>gpu_descr</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix0</td>\n",
-       "        <td>device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix0</td>\n",
-       "        <td>device: 1, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:05.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix0</td>\n",
-       "        <td>device: 2, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:06.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix0</td>\n",
-       "        <td>device: 3, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:07.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix1</td>\n",
-       "        <td>device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix1</td>\n",
-       "        <td>device: 1, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:05.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix1</td>\n",
-       "        <td>device: 2, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:06.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix1</td>\n",
-       "        <td>device: 3, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:07.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix2</td>\n",
-       "        <td>device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix2</td>\n",
-       "        <td>device: 1, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:05.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix2</td>\n",
-       "        <td>device: 2, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:06.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix2</td>\n",
-       "        <td>device: 3, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:07.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix3</td>\n",
-       "        <td>device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix3</td>\n",
-       "        <td>device: 1, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:05.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix3</td>\n",
-       "        <td>device: 2, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:06.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix3</td>\n",
-       "        <td>device: 3, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:07.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix4</td>\n",
-       "        <td>device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix4</td>\n",
-       "        <td>device: 1, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:05.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix4</td>\n",
-       "        <td>device: 2, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:06.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>gpsix4</td>\n",
-       "        <td>device: 3, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:07.0, compute capability: 6.0</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(u'gpsix0', u'device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0, compute capability: 6.0'),\n",
-       " (u'gpsix0', u'device: 1, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:05.0, compute capability: 6.0'),\n",
-       " (u'gpsix0', u'device: 2, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:06.0, compute capability: 6.0'),\n",
-       " (u'gpsix0', u'device: 3, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:07.0, compute capability: 6.0'),\n",
-       " (u'gpsix1', u'device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0, compute capability: 6.0'),\n",
-       " (u'gpsix1', u'device: 1, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:05.0, compute capability: 6.0'),\n",
-       " (u'gpsix1', u'device: 2, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:06.0, compute capability: 6.0'),\n",
-       " (u'gpsix1', u'device: 3, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:07.0, compute capability: 6.0'),\n",
-       " (u'gpsix2', u'device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0, compute capability: 6.0'),\n",
-       " (u'gpsix2', u'device: 1, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:05.0, compute capability: 6.0'),\n",
-       " (u'gpsix2', u'device: 2, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:06.0, compute capability: 6.0'),\n",
-       " (u'gpsix2', u'device: 3, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:07.0, compute capability: 6.0'),\n",
-       " (u'gpsix3', u'device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0, compute capability: 6.0'),\n",
-       " (u'gpsix3', u'device: 1, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:05.0, compute capability: 6.0'),\n",
-       " (u'gpsix3', u'device: 2, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:06.0, compute capability: 6.0'),\n",
-       " (u'gpsix3', u'device: 3, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:07.0, compute capability: 6.0'),\n",
-       " (u'gpsix4', u'device: 0, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:04.0, compute capability: 6.0'),\n",
-       " (u'gpsix4', u'device: 1, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:05.0, compute capability: 6.0'),\n",
-       " (u'gpsix4', u'device: 2, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:06.0, compute capability: 6.0'),\n",
-       " (u'gpsix4', u'device: 3, name: Tesla P100-PCIE-16GB, pci bus id: 0000:00:07.0, compute capability: 6.0')]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "DROP TABLE IF EXISTS host_gpu_mapping_tf;\n",
-    "SELECT * FROM madlib.gpu_configuration('host_gpu_mapping_tf');\n",
-    "SELECT * FROM host_gpu_mapping_tf ORDER BY hostname, gpu_descr;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Review the Greenplum segments in the `gp_segment_configuration` table:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 10,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "21 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>dbid</th>\n",
-       "        <th>content</th>\n",
-       "        <th>role</th>\n",
-       "        <th>preferred_role</th>\n",
-       "        <th>mode</th>\n",
-       "        <th>status</th>\n",
-       "        <th>port</th>\n",
-       "        <th>hostname</th>\n",
-       "        <th>address</th>\n",
-       "        <th>datadir</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>1</td>\n",
-       "        <td>-1</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>5432</td>\n",
-       "        <td>gpsix0</td>\n",
-       "        <td>gpsix0</td>\n",
-       "        <td>/data/master/gpseg-1</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>2</td>\n",
-       "        <td>0</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40000</td>\n",
-       "        <td>gpsix0</td>\n",
-       "        <td>gpsix0</td>\n",
-       "        <td>/data/primary0/gpseg0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>3</td>\n",
-       "        <td>1</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40001</td>\n",
-       "        <td>gpsix0</td>\n",
-       "        <td>gpsix0</td>\n",
-       "        <td>/data/primary1/gpseg1</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>4</td>\n",
-       "        <td>2</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40002</td>\n",
-       "        <td>gpsix0</td>\n",
-       "        <td>gpsix0</td>\n",
-       "        <td>/data/primary2/gpseg2</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>5</td>\n",
-       "        <td>3</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40003</td>\n",
-       "        <td>gpsix0</td>\n",
-       "        <td>gpsix0</td>\n",
-       "        <td>/data/primary3/gpseg3</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>6</td>\n",
-       "        <td>4</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40000</td>\n",
-       "        <td>gpsix1</td>\n",
-       "        <td>gpsix1</td>\n",
-       "        <td>/data/primary0/gpseg4</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>7</td>\n",
-       "        <td>5</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40001</td>\n",
-       "        <td>gpsix1</td>\n",
-       "        <td>gpsix1</td>\n",
-       "        <td>/data/primary1/gpseg5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>8</td>\n",
-       "        <td>6</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40002</td>\n",
-       "        <td>gpsix1</td>\n",
-       "        <td>gpsix1</td>\n",
-       "        <td>/data/primary2/gpseg6</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>9</td>\n",
-       "        <td>7</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40003</td>\n",
-       "        <td>gpsix1</td>\n",
-       "        <td>gpsix1</td>\n",
-       "        <td>/data/primary3/gpseg7</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>10</td>\n",
-       "        <td>8</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40000</td>\n",
-       "        <td>gpsix2</td>\n",
-       "        <td>gpsix2</td>\n",
-       "        <td>/data/primary0/gpseg8</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>11</td>\n",
-       "        <td>9</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40001</td>\n",
-       "        <td>gpsix2</td>\n",
-       "        <td>gpsix2</td>\n",
-       "        <td>/data/primary1/gpseg9</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>12</td>\n",
-       "        <td>10</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40002</td>\n",
-       "        <td>gpsix2</td>\n",
-       "        <td>gpsix2</td>\n",
-       "        <td>/data/primary2/gpseg10</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>13</td>\n",
-       "        <td>11</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40003</td>\n",
-       "        <td>gpsix2</td>\n",
-       "        <td>gpsix2</td>\n",
-       "        <td>/data/primary3/gpseg11</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>14</td>\n",
-       "        <td>12</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40000</td>\n",
-       "        <td>gpsix3</td>\n",
-       "        <td>gpsix3</td>\n",
-       "        <td>/data/primary0/gpseg12</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>15</td>\n",
-       "        <td>13</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40001</td>\n",
-       "        <td>gpsix3</td>\n",
-       "        <td>gpsix3</td>\n",
-       "        <td>/data/primary1/gpseg13</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>16</td>\n",
-       "        <td>14</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40002</td>\n",
-       "        <td>gpsix3</td>\n",
-       "        <td>gpsix3</td>\n",
-       "        <td>/data/primary2/gpseg14</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>17</td>\n",
-       "        <td>15</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40003</td>\n",
-       "        <td>gpsix3</td>\n",
-       "        <td>gpsix3</td>\n",
-       "        <td>/data/primary3/gpseg15</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>18</td>\n",
-       "        <td>16</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40000</td>\n",
-       "        <td>gpsix4</td>\n",
-       "        <td>gpsix4</td>\n",
-       "        <td>/data/primary0/gpseg16</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>19</td>\n",
-       "        <td>17</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40001</td>\n",
-       "        <td>gpsix4</td>\n",
-       "        <td>gpsix4</td>\n",
-       "        <td>/data/primary1/gpseg17</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>20</td>\n",
-       "        <td>18</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40002</td>\n",
-       "        <td>gpsix4</td>\n",
-       "        <td>gpsix4</td>\n",
-       "        <td>/data/primary2/gpseg18</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>21</td>\n",
-       "        <td>19</td>\n",
-       "        <td>p</td>\n",
-       "        <td>p</td>\n",
-       "        <td>n</td>\n",
-       "        <td>u</td>\n",
-       "        <td>40003</td>\n",
-       "        <td>gpsix4</td>\n",
-       "        <td>gpsix4</td>\n",
-       "        <td>/data/primary3/gpseg19</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(1, -1, u'p', u'p', u'n', u'u', 5432, u'gpsix0', u'gpsix0', u'/data/master/gpseg-1'),\n",
-       " (2, 0, u'p', u'p', u'n', u'u', 40000, u'gpsix0', u'gpsix0', u'/data/primary0/gpseg0'),\n",
-       " (3, 1, u'p', u'p', u'n', u'u', 40001, u'gpsix0', u'gpsix0', u'/data/primary1/gpseg1'),\n",
-       " (4, 2, u'p', u'p', u'n', u'u', 40002, u'gpsix0', u'gpsix0', u'/data/primary2/gpseg2'),\n",
-       " (5, 3, u'p', u'p', u'n', u'u', 40003, u'gpsix0', u'gpsix0', u'/data/primary3/gpseg3'),\n",
-       " (6, 4, u'p', u'p', u'n', u'u', 40000, u'gpsix1', u'gpsix1', u'/data/primary0/gpseg4'),\n",
-       " (7, 5, u'p', u'p', u'n', u'u', 40001, u'gpsix1', u'gpsix1', u'/data/primary1/gpseg5'),\n",
-       " (8, 6, u'p', u'p', u'n', u'u', 40002, u'gpsix1', u'gpsix1', u'/data/primary2/gpseg6'),\n",
-       " (9, 7, u'p', u'p', u'n', u'u', 40003, u'gpsix1', u'gpsix1', u'/data/primary3/gpseg7'),\n",
-       " (10, 8, u'p', u'p', u'n', u'u', 40000, u'gpsix2', u'gpsix2', u'/data/primary0/gpseg8'),\n",
-       " (11, 9, u'p', u'p', u'n', u'u', 40001, u'gpsix2', u'gpsix2', u'/data/primary1/gpseg9'),\n",
-       " (12, 10, u'p', u'p', u'n', u'u', 40002, u'gpsix2', u'gpsix2', u'/data/primary2/gpseg10'),\n",
-       " (13, 11, u'p', u'p', u'n', u'u', 40003, u'gpsix2', u'gpsix2', u'/data/primary3/gpseg11'),\n",
-       " (14, 12, u'p', u'p', u'n', u'u', 40000, u'gpsix3', u'gpsix3', u'/data/primary0/gpseg12'),\n",
-       " (15, 13, u'p', u'p', u'n', u'u', 40001, u'gpsix3', u'gpsix3', u'/data/primary1/gpseg13'),\n",
-       " (16, 14, u'p', u'p', u'n', u'u', 40002, u'gpsix3', u'gpsix3', u'/data/primary2/gpseg14'),\n",
-       " (17, 15, u'p', u'p', u'n', u'u', 40003, u'gpsix3', u'gpsix3', u'/data/primary3/gpseg15'),\n",
-       " (18, 16, u'p', u'p', u'n', u'u', 40000, u'gpsix4', u'gpsix4', u'/data/primary0/gpseg16'),\n",
-       " (19, 17, u'p', u'p', u'n', u'u', 40001, u'gpsix4', u'gpsix4', u'/data/primary1/gpseg17'),\n",
-       " (20, 18, u'p', u'p', u'n', u'u', 40002, u'gpsix4', u'gpsix4', u'/data/primary2/gpseg18'),\n",
-       " (21, 19, u'p', u'p', u'n', u'u', 40003, u'gpsix4', u'gpsix4', u'/data/primary3/gpseg19')]"
-      ]
-     },
-     "execution_count": 10,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "SELECT * FROM gp_segment_configuration ORDER BY dbid;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Now JOIN the above 2 tables to build up various distribution rules, depending on your needs.\n",
-    "\n",
-    "We build distribution rules table for 4 VMs:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 11,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "Done.\n",
-      "16 rows affected.\n",
-      "16 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>dbid</th>\n",
-       "        <th>hostname</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>2</td>\n",
-       "        <td>gpsix0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>3</td>\n",
-       "        <td>gpsix0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>4</td>\n",
-       "        <td>gpsix0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>5</td>\n",
-       "        <td>gpsix0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>6</td>\n",
-       "        <td>gpsix1</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>7</td>\n",
-       "        <td>gpsix1</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>8</td>\n",
-       "        <td>gpsix1</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>9</td>\n",
-       "        <td>gpsix1</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>10</td>\n",
-       "        <td>gpsix2</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>11</td>\n",
-       "        <td>gpsix2</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>12</td>\n",
-       "        <td>gpsix2</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>13</td>\n",
-       "        <td>gpsix2</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>14</td>\n",
-       "        <td>gpsix3</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>15</td>\n",
-       "        <td>gpsix3</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>16</td>\n",
-       "        <td>gpsix3</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>17</td>\n",
-       "        <td>gpsix3</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(2, u'gpsix0'),\n",
-       " (3, u'gpsix0'),\n",
-       " (4, u'gpsix0'),\n",
-       " (5, u'gpsix0'),\n",
-       " (6, u'gpsix1'),\n",
-       " (7, u'gpsix1'),\n",
-       " (8, u'gpsix1'),\n",
-       " (9, u'gpsix1'),\n",
-       " (10, u'gpsix2'),\n",
-       " (11, u'gpsix2'),\n",
-       " (12, u'gpsix2'),\n",
-       " (13, u'gpsix2'),\n",
-       " (14, u'gpsix3'),\n",
-       " (15, u'gpsix3'),\n",
-       " (16, u'gpsix3'),\n",
-       " (17, u'gpsix3')]"
-      ]
-     },
-     "execution_count": 11,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "DROP TABLE IF EXISTS segments_to_use_4VMs;\n",
-    "CREATE TABLE segments_to_use_4VMs AS\n",
-    "  SELECT DISTINCT dbid, hostname FROM gp_segment_configuration JOIN host_gpu_mapping_tf USING (hostname)\n",
-    "  WHERE role='p' AND content>=0 AND hostname!='gpsix4';\n",
-    "SELECT * FROM segments_to_use_4VMs ORDER BY hostname, dbid;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Run the preprocessor to generate the packed output table on the segments we want to use for training:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 16,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "Done.\n",
-      "1 rows affected.\n",
-      "16 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>__dist_key__</th>\n",
-       "        <th>independent_var_shape</th>\n",
-       "        <th>dependent_var_shape</th>\n",
-       "        <th>buffer_id</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>0</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>1</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>1</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>4</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>2</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>9</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>3</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>7</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>4</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>14</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>7</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>11</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>9</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>13</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>12</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>15</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>14</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>6</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>19</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>12</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>27</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>10</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>28</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>29</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>8</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>34</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>55</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>3</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>56</td>\n",
-       "        <td>[3125, 32, 32, 3]</td>\n",
-       "        <td>[3125, 10]</td>\n",
-       "        <td>2</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(0, [3125, 32, 32, 3], [3125, 10], 1),\n",
-       " (1, [3125, 32, 32, 3], [3125, 10], 4),\n",
-       " (2, [3125, 32, 32, 3], [3125, 10], 9),\n",
-       " (3, [3125, 32, 32, 3], [3125, 10], 7),\n",
-       " (4, [3125, 32, 32, 3], [3125, 10], 14),\n",
-       " (7, [3125, 32, 32, 3], [3125, 10], 11),\n",
-       " (9, [3125, 32, 32, 3], [3125, 10], 13),\n",
-       " (12, [3125, 32, 32, 3], [3125, 10], 15),\n",
-       " (14, [3125, 32, 32, 3], [3125, 10], 6),\n",
-       " (19, [3125, 32, 32, 3], [3125, 10], 12),\n",
-       " (27, [3125, 32, 32, 3], [3125, 10], 10),\n",
-       " (28, [3125, 32, 32, 3], [3125, 10], 5),\n",
-       " (29, [3125, 32, 32, 3], [3125, 10], 8),\n",
-       " (34, [3125, 32, 32, 3], [3125, 10], 0),\n",
-       " (55, [3125, 32, 32, 3], [3125, 10], 3),\n",
-       " (56, [3125, 32, 32, 3], [3125, 10], 2)]"
-      ]
-     },
-     "execution_count": 16,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "DROP TABLE IF EXISTS cifar10_train_packed, cifar10_train_packed_summary;\n",
-    "\n",
-    "SELECT madlib.training_preprocessor_dl('cifar10_train',        -- Source table\n",
-    "                                       'cifar10_train_packed', -- Output table\n",
-    "                                       'y',                    -- Dependent variable\n",
-    "                                       'x',                    -- Independent variable\n",
-    "                                        NULL,                  -- Buffer size\n",
-    "                                        256.0,                 -- Normalizing constant\n",
-    "                                        NULL,                  -- Number of classes\n",
-    "                                       'segments_to_use_4VMs'  -- Distribution rules\n",
-    "                                        );\n",
-    "\n",
-    "SELECT __dist_key__, independent_var_shape, dependent_var_shape, buffer_id FROM cifar10_train_packed ORDER BY __dist_key__;"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 17,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>source_table</th>\n",
-       "        <th>output_table</th>\n",
-       "        <th>dependent_varname</th>\n",
-       "        <th>independent_varname</th>\n",
-       "        <th>dependent_vartype</th>\n",
-       "        <th>class_values</th>\n",
-       "        <th>buffer_size</th>\n",
-       "        <th>normalizing_const</th>\n",
-       "        <th>num_classes</th>\n",
-       "        <th>distribution_rules</th>\n",
-       "        <th>__internal_gpu_config__</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>cifar10_train</td>\n",
-       "        <td>cifar10_train_packed</td>\n",
-       "        <td>y</td>\n",
-       "        <td>x</td>\n",
-       "        <td>smallint</td>\n",
-       "        <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]</td>\n",
-       "        <td>3125</td>\n",
-       "        <td>256.0</td>\n",
-       "        <td>10</td>\n",
-       "        <td>[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]</td>\n",
-       "        <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(u'cifar10_train', u'cifar10_train_packed', u'y', u'x', u'smallint', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 3125, 256.0, 10, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])]"
-      ]
-     },
-     "execution_count": 17,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "SELECT * FROM cifar10_train_packed_summary;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Same for validation dataset:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 18,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "Done.\n",
-      "1 rows affected.\n",
-      "16 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>__dist_key__</th>\n",
-       "        <th>independent_var_shape</th>\n",
-       "        <th>dependent_var_shape</th>\n",
-       "        <th>buffer_id</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>0</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>1</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>1</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>4</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>2</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>9</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>3</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>7</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>4</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>14</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>7</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>11</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>9</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>13</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>12</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>15</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>14</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>6</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>19</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>12</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>27</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>10</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>28</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>29</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>8</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>34</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>0</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>55</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>3</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>56</td>\n",
-       "        <td>[625, 32, 32, 3]</td>\n",
-       "        <td>[625, 10]</td>\n",
-       "        <td>2</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(0, [625, 32, 32, 3], [625, 10], 1),\n",
-       " (1, [625, 32, 32, 3], [625, 10], 4),\n",
-       " (2, [625, 32, 32, 3], [625, 10], 9),\n",
-       " (3, [625, 32, 32, 3], [625, 10], 7),\n",
-       " (4, [625, 32, 32, 3], [625, 10], 14),\n",
-       " (7, [625, 32, 32, 3], [625, 10], 11),\n",
-       " (9, [625, 32, 32, 3], [625, 10], 13),\n",
-       " (12, [625, 32, 32, 3], [625, 10], 15),\n",
-       " (14, [625, 32, 32, 3], [625, 10], 6),\n",
-       " (19, [625, 32, 32, 3], [625, 10], 12),\n",
-       " (27, [625, 32, 32, 3], [625, 10], 10),\n",
-       " (28, [625, 32, 32, 3], [625, 10], 5),\n",
-       " (29, [625, 32, 32, 3], [625, 10], 8),\n",
-       " (34, [625, 32, 32, 3], [625, 10], 0),\n",
-       " (55, [625, 32, 32, 3], [625, 10], 3),\n",
-       " (56, [625, 32, 32, 3], [625, 10], 2)]"
-      ]
-     },
-     "execution_count": 18,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "DROP TABLE IF EXISTS cifar10_val_packed, cifar10_val_packed_summary;\n",
-    "\n",
-    "SELECT madlib.validation_preprocessor_dl('cifar10_val',          -- Source table\n",
-    "                                         'cifar10_val_packed',   -- Output table\n",
-    "                                         'y',                    -- Dependent variable\n",
-    "                                         'x',                    -- Independent variable\n",
-    "                                         'cifar10_train_packed', -- From training preprocessor step\n",
-    "                                         NULL,                   -- Buffer size\n",
-    "                                         'segments_to_use_4VMs'  -- Distribution rules\n",
-    "                                          ); \n",
-    "\n",
-    "SELECT __dist_key__, independent_var_shape, dependent_var_shape, buffer_id FROM cifar10_val_packed ORDER BY __dist_key__;"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 19,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>source_table</th>\n",
-       "        <th>output_table</th>\n",
-       "        <th>dependent_varname</th>\n",
-       "        <th>independent_varname</th>\n",
-       "        <th>dependent_vartype</th>\n",
-       "        <th>class_values</th>\n",
-       "        <th>buffer_size</th>\n",
-       "        <th>normalizing_const</th>\n",
-       "        <th>num_classes</th>\n",
-       "        <th>distribution_rules</th>\n",
-       "        <th>__internal_gpu_config__</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>cifar10_val</td>\n",
-       "        <td>cifar10_val_packed</td>\n",
-       "        <td>y</td>\n",
-       "        <td>x</td>\n",
-       "        <td>smallint</td>\n",
-       "        <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]</td>\n",
-       "        <td>625</td>\n",
-       "        <td>256.0</td>\n",
-       "        <td>10</td>\n",
-       "        <td>[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]</td>\n",
-       "        <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(u'cifar10_val', u'cifar10_val_packed', u'y', u'x', u'smallint', [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 625, 256.0, 10, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15])]"
-      ]
-     },
-     "execution_count": 19,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "SELECT * FROM cifar10_val_packed_summary;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"arch\"></a>\n",
-    "# 3. Define and load model architectures\n",
-    "\n",
-    "Model architecture from https://keras.io/examples/cifar10_cnn/"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 24,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "num_classes = 10"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 25,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "WARNING:tensorflow:From /Users/fmcquillan/Library/Python/2.7/lib/python/site-packages/keras/backend/tensorflow_backend.py:517: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.\n",
-      "\n",
-      "WARNING:tensorflow:From /Users/fmcquillan/Library/Python/2.7/lib/python/site-packages/keras/backend/tensorflow_backend.py:4138: The name tf.random_uniform is deprecated. Please use tf.random.uniform instead.\n",
-      "\n",
-      "WARNING:tensorflow:From /Users/fmcquillan/Library/Python/2.7/lib/python/site-packages/keras/backend/tensorflow_backend.py:3976: The name tf.nn.max_pool is deprecated. Please use tf.nn.max_pool2d instead.\n",
-      "\n",
-      "WARNING:tensorflow:From /Users/fmcquillan/Library/Python/2.7/lib/python/site-packages/keras/backend/tensorflow_backend.py:133: The name tf.placeholder_with_default is deprecated. Please use tf.compat.v1.placeholder_with_default instead.\n",
-      "\n",
-      "WARNING:tensorflow:From /Users/fmcquillan/Library/Python/2.7/lib/python/site-packages/keras/backend/tensorflow_backend.py:3445: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.\n",
-      "Instructions for updating:\n",
-      "Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.\n",
-      "_________________________________________________________________\n",
-      "Layer (type)                 Output Shape              Param #   \n",
-      "=================================================================\n",
-      "conv2d_1 (Conv2D)            (None, 32, 32, 32)        896       \n",
-      "_________________________________________________________________\n",
-      "activation_1 (Activation)    (None, 32, 32, 32)        0         \n",
-      "_________________________________________________________________\n",
-      "conv2d_2 (Conv2D)            (None, 30, 30, 32)        9248      \n",
-      "_________________________________________________________________\n",
-      "activation_2 (Activation)    (None, 30, 30, 32)        0         \n",
-      "_________________________________________________________________\n",
-      "max_pooling2d_1 (MaxPooling2 (None, 15, 15, 32)        0         \n",
-      "_________________________________________________________________\n",
-      "dropout_1 (Dropout)          (None, 15, 15, 32)        0         \n",
-      "_________________________________________________________________\n",
-      "conv2d_3 (Conv2D)            (None, 15, 15, 64)        18496     \n",
-      "_________________________________________________________________\n",
-      "activation_3 (Activation)    (None, 15, 15, 64)        0         \n",
-      "_________________________________________________________________\n",
-      "conv2d_4 (Conv2D)            (None, 13, 13, 64)        36928     \n",
-      "_________________________________________________________________\n",
-      "activation_4 (Activation)    (None, 13, 13, 64)        0         \n",
-      "_________________________________________________________________\n",
-      "max_pooling2d_2 (MaxPooling2 (None, 6, 6, 64)          0         \n",
-      "_________________________________________________________________\n",
-      "dropout_2 (Dropout)          (None, 6, 6, 64)          0         \n",
-      "_________________________________________________________________\n",
-      "flatten_1 (Flatten)          (None, 2304)              0         \n",
-      "_________________________________________________________________\n",
-      "dense_1 (Dense)              (None, 512)               1180160   \n",
-      "_________________________________________________________________\n",
-      "activation_5 (Activation)    (None, 512)               0         \n",
-      "_________________________________________________________________\n",
-      "dropout_3 (Dropout)          (None, 512)               0         \n",
-      "_________________________________________________________________\n",
-      "dense_2 (Dense)              (None, 10)                5130      \n",
-      "_________________________________________________________________\n",
-      "activation_6 (Activation)    (None, 10)                0         \n",
-      "=================================================================\n",
-      "Total params: 1,250,858\n",
-      "Trainable params: 1,250,858\n",
-      "Non-trainable params: 0\n",
-      "_________________________________________________________________\n"
-     ]
-    }
-   ],
-   "source": [
-    "model1 = Sequential()\n",
-    "\n",
-    "model1.add(Conv2D(32, (3, 3), padding='same',\n",
-    "                 input_shape=x_train.shape[1:]))\n",
-    "model1.add(Activation('relu'))\n",
-    "model1.add(Conv2D(32, (3, 3)))\n",
-    "model1.add(Activation('relu'))\n",
-    "model1.add(MaxPooling2D(pool_size=(2, 2)))\n",
-    "model1.add(Dropout(0.25))\n",
-    "\n",
-    "model1.add(Conv2D(64, (3, 3), padding='same'))\n",
-    "model1.add(Activation('relu'))\n",
-    "model1.add(Conv2D(64, (3, 3)))\n",
-    "model1.add(Activation('relu'))\n",
-    "model1.add(MaxPooling2D(pool_size=(2, 2)))\n",
-    "model1.add(Dropout(0.25))\n",
-    "\n",
-    "model1.add(Flatten())\n",
-    "model1.add(Dense(512))\n",
-    "model1.add(Activation('relu'))\n",
-    "model1.add(Dropout(0.5))\n",
-    "model1.add(Dense(num_classes))\n",
-    "model1.add(Activation('softmax'))\n",
-    "\n",
-    "model1.summary()"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 26,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "'{\"class_name\": \"Sequential\", \"keras_version\": \"2.2.4\", \"config\": {\"layers\": [{\"class_name\": \"Conv2D\", \"config\": {\"kernel_initializer\": {\"class_name\": \"VarianceScaling\", \"config\": {\"distribution\": \"uniform\", \"scale\": 1.0, \"seed\": null, \"mode\": \"fan_avg\"}}, \"name\": \"conv2d_1\", \"kernel_constraint\": null, \"bias_regularizer\": null, \"bias_constraint\": null, \"dtype\": \"float32\", \"activation\": \"linear\", \"trainable\": true, \"data_f [...]
-      ]
-     },
-     "execution_count": 26,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "model1.to_json()"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Model architecture from https://machinelearningmastery.com/how-to-develop-a-cnn-from-scratch-for-cifar-10-photo-classification/"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 27,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "WARNING:tensorflow:From /Users/fmcquillan/Library/Python/2.7/lib/python/site-packages/keras/backend/tensorflow_backend.py:174: The name tf.get_default_session is deprecated. Please use tf.compat.v1.get_default_session instead.\n",
-      "\n",
-      "WARNING:tensorflow:From /Users/fmcquillan/Library/Python/2.7/lib/python/site-packages/keras/backend/tensorflow_backend.py:1834: The name tf.nn.fused_batch_norm is deprecated. Please use tf.compat.v1.nn.fused_batch_norm instead.\n",
-      "\n",
-      "_________________________________________________________________\n",
-      "Layer (type)                 Output Shape              Param #   \n",
-      "=================================================================\n",
-      "conv2d_5 (Conv2D)            (None, 32, 32, 32)        896       \n",
-      "_________________________________________________________________\n",
-      "batch_normalization_1 (Batch (None, 32, 32, 32)        128       \n",
-      "_________________________________________________________________\n",
-      "conv2d_6 (Conv2D)            (None, 32, 32, 32)        9248      \n",
-      "_________________________________________________________________\n",
-      "batch_normalization_2 (Batch (None, 32, 32, 32)        128       \n",
-      "_________________________________________________________________\n",
-      "max_pooling2d_3 (MaxPooling2 (None, 16, 16, 32)        0         \n",
-      "_________________________________________________________________\n",
-      "dropout_4 (Dropout)          (None, 16, 16, 32)        0         \n",
-      "_________________________________________________________________\n",
-      "conv2d_7 (Conv2D)            (None, 16, 16, 64)        18496     \n",
-      "_________________________________________________________________\n",
-      "batch_normalization_3 (Batch (None, 16, 16, 64)        256       \n",
-      "_________________________________________________________________\n",
-      "conv2d_8 (Conv2D)            (None, 16, 16, 64)        36928     \n",
-      "_________________________________________________________________\n",
-      "batch_normalization_4 (Batch (None, 16, 16, 64)        256       \n",
-      "_________________________________________________________________\n",
-      "max_pooling2d_4 (MaxPooling2 (None, 8, 8, 64)          0         \n",
-      "_________________________________________________________________\n",
-      "dropout_5 (Dropout)          (None, 8, 8, 64)          0         \n",
-      "_________________________________________________________________\n",
-      "conv2d_9 (Conv2D)            (None, 8, 8, 128)         73856     \n",
-      "_________________________________________________________________\n",
-      "batch_normalization_5 (Batch (None, 8, 8, 128)         512       \n",
-      "_________________________________________________________________\n",
-      "conv2d_10 (Conv2D)           (None, 8, 8, 128)         147584    \n",
-      "_________________________________________________________________\n",
-      "batch_normalization_6 (Batch (None, 8, 8, 128)         512       \n",
-      "_________________________________________________________________\n",
-      "max_pooling2d_5 (MaxPooling2 (None, 4, 4, 128)         0         \n",
-      "_________________________________________________________________\n",
-      "dropout_6 (Dropout)          (None, 4, 4, 128)         0         \n",
-      "_________________________________________________________________\n",
-      "flatten_2 (Flatten)          (None, 2048)              0         \n",
-      "_________________________________________________________________\n",
-      "dense_3 (Dense)              (None, 128)               262272    \n",
-      "_________________________________________________________________\n",
-      "batch_normalization_7 (Batch (None, 128)               512       \n",
-      "_________________________________________________________________\n",
-      "dropout_7 (Dropout)          (None, 128)               0         \n",
-      "_________________________________________________________________\n",
-      "dense_4 (Dense)              (None, 10)                1290      \n",
-      "=================================================================\n",
-      "Total params: 552,874\n",
-      "Trainable params: 551,722\n",
-      "Non-trainable params: 1,152\n",
-      "_________________________________________________________________\n"
-     ]
-    }
-   ],
-   "source": [
-    "model2 = Sequential()\n",
-    "\n",
-    "model2.add(Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same', input_shape=(32, 32, 3)))\n",
-    "model2.add(BatchNormalization())\n",
-    "model2.add(Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same'))\n",
-    "model2.add(BatchNormalization())\n",
-    "model2.add(MaxPooling2D((2, 2)))\n",
-    "model2.add(Dropout(0.2))\n",
-    "model2.add(Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same'))\n",
-    "model2.add(BatchNormalization())\n",
-    "model2.add(Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same'))\n",
-    "model2.add(BatchNormalization())\n",
-    "model2.add(MaxPooling2D((2, 2)))\n",
-    "model2.add(Dropout(0.3))\n",
-    "model2.add(Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same'))\n",
-    "model2.add(BatchNormalization())\n",
-    "model2.add(Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same'))\n",
-    "model2.add(BatchNormalization())\n",
-    "model2.add(MaxPooling2D((2, 2)))\n",
-    "model2.add(Dropout(0.4))\n",
-    "model2.add(Flatten())\n",
-    "model2.add(Dense(128, activation='relu', kernel_initializer='he_uniform'))\n",
-    "model2.add(BatchNormalization())\n",
-    "model2.add(Dropout(0.5))\n",
-    "model2.add(Dense(10, activation='softmax'))\n",
-    "\n",
-    "model2.summary()"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 28,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "'{\"class_name\": \"Sequential\", \"keras_version\": \"2.2.4\", \"config\": {\"layers\": [{\"class_name\": \"Conv2D\", \"config\": {\"kernel_initializer\": {\"class_name\": \"VarianceScaling\", \"config\": {\"distribution\": \"uniform\", \"scale\": 2.0, \"seed\": null, \"mode\": \"fan_in\"}}, \"name\": \"conv2d_5\", \"kernel_constraint\": null, \"bias_regularizer\": null, \"bias_constraint\": null, \"dtype\": \"float32\", \"activation\": \"relu\", \"trainable\": true, \"data_form [...]
-      ]
-     },
-     "execution_count": 28,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "model2.to_json()"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Another model architecture from https://machinelearningmastery.com/how-to-develop-a-cnn-from-scratch-for-cifar-10-photo-classification/"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 29,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "_________________________________________________________________\n",
-      "Layer (type)                 Output Shape              Param #   \n",
-      "=================================================================\n",
-      "conv2d_11 (Conv2D)           (None, 32, 32, 32)        896       \n",
-      "_________________________________________________________________\n",
-      "conv2d_12 (Conv2D)           (None, 32, 32, 32)        9248      \n",
-      "_________________________________________________________________\n",
-      "max_pooling2d_6 (MaxPooling2 (None, 16, 16, 32)        0         \n",
-      "_________________________________________________________________\n",
-      "dropout_8 (Dropout)          (None, 16, 16, 32)        0         \n",
-      "_________________________________________________________________\n",
-      "conv2d_13 (Conv2D)           (None, 16, 16, 64)        18496     \n",
-      "_________________________________________________________________\n",
-      "conv2d_14 (Conv2D)           (None, 16, 16, 64)        36928     \n",
-      "_________________________________________________________________\n",
-      "max_pooling2d_7 (MaxPooling2 (None, 8, 8, 64)          0         \n",
-      "_________________________________________________________________\n",
-      "dropout_9 (Dropout)          (None, 8, 8, 64)          0         \n",
-      "_________________________________________________________________\n",
-      "conv2d_15 (Conv2D)           (None, 8, 8, 128)         73856     \n",
-      "_________________________________________________________________\n",
-      "conv2d_16 (Conv2D)           (None, 8, 8, 128)         147584    \n",
-      "_________________________________________________________________\n",
-      "max_pooling2d_8 (MaxPooling2 (None, 4, 4, 128)         0         \n",
-      "_________________________________________________________________\n",
-      "dropout_10 (Dropout)         (None, 4, 4, 128)         0         \n",
-      "_________________________________________________________________\n",
-      "flatten_3 (Flatten)          (None, 2048)              0         \n",
-      "_________________________________________________________________\n",
-      "dense_5 (Dense)              (None, 128)               262272    \n",
-      "_________________________________________________________________\n",
-      "dropout_11 (Dropout)         (None, 128)               0         \n",
-      "_________________________________________________________________\n",
-      "dense_6 (Dense)              (None, 10)                1290      \n",
-      "=================================================================\n",
-      "Total params: 550,570\n",
-      "Trainable params: 550,570\n",
-      "Non-trainable params: 0\n",
-      "_________________________________________________________________\n"
-     ]
-    }
-   ],
-   "source": [
-    "model3 = Sequential()\n",
-    "\n",
-    "model3.add(Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same', input_shape=(32, 32, 3)))\n",
-    "model3.add(Conv2D(32, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same'))\n",
-    "model3.add(MaxPooling2D((2, 2)))\n",
-    "model3.add(Dropout(0.2))\n",
-    "model3.add(Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same'))\n",
-    "model3.add(Conv2D(64, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same'))\n",
-    "model3.add(MaxPooling2D((2, 2)))\n",
-    "model3.add(Dropout(0.3))\n",
-    "model3.add(Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same'))\n",
-    "model3.add(Conv2D(128, (3, 3), activation='relu', kernel_initializer='he_uniform', padding='same'))\n",
-    "model3.add(MaxPooling2D((2, 2)))\n",
-    "model3.add(Dropout(0.4))\n",
-    "model3.add(Flatten())\n",
-    "model3.add(Dense(128, activation='relu', kernel_initializer='he_uniform'))\n",
-    "model3.add(Dropout(0.5))\n",
-    "model3.add(Dense(10, activation='softmax'))\n",
-    "\n",
-    "model3.summary()"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 18,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "'{\"class_name\": \"Sequential\", \"keras_version\": \"2.1.6\", \"config\": [{\"class_name\": \"Conv2D\", \"config\": {\"kernel_initializer\": {\"class_name\": \"VarianceScaling\", \"config\": {\"distribution\": \"uniform\", \"scale\": 2.0, \"seed\": null, \"mode\": \"fan_in\"}}, \"name\": \"conv2d_17\", \"kernel_constraint\": null, \"bias_regularizer\": null, \"bias_constraint\": null, \"dtype\": \"float32\", \"activation\": \"relu\", \"trainable\": true, \"data_format\": \"chan [...]
-      ]
-     },
-     "execution_count": 18,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "model3.to_json()"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Load into model architecture table using psycopg2"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 31,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "Done.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[]"
-      ]
-     },
-     "execution_count": 31,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "3 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>model_id</th>\n",
-       "        <th>name</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>1</td>\n",
-       "        <td>CNN from Keras docs for CIFAR-10</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>2</td>\n",
-       "        <td>CNN from Jason Brownlee blog post</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>3</td>\n",
-       "        <td>CNN from Jason Brownlee blog post - no batch normalization</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(1, u'CNN from Keras docs for CIFAR-10'),\n",
-       " (2, u'CNN from Jason Brownlee blog post'),\n",
-       " (3, u'CNN from Jason Brownlee blog post - no batch normalization')]"
-      ]
-     },
-     "execution_count": 31,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "import psycopg2 as p2\n",
-    "#conn = p2.connect('postgresql://gpadmin@35.239.240.26:5432/madlib')\n",
-    "#conn = p2.connect('postgresql://fmcquillan@localhost:5432/madlib')\n",
-    "conn = p2.connect('postgresql://gpadmin@localhost:8000/cifar_places')\n",
-    "cur = conn.cursor()\n",
-    "\n",
-    "%sql DROP TABLE IF EXISTS model_arch_library;\n",
-    "query = \"SELECT madlib.load_keras_model('model_arch_library', %s, NULL, %s)\"\n",
-    "cur.execute(query,[model1.to_json(), \"CNN from Keras docs for CIFAR-10\"])\n",
-    "conn.commit()\n",
-    "\n",
-    "query = \"SELECT madlib.load_keras_model('model_arch_library', %s, NULL, %s)\"\n",
-    "cur.execute(query,[model2.to_json(), \"CNN from Jason Brownlee blog post\"])\n",
-    "conn.commit()\n",
-    "\n",
-    "query = \"SELECT madlib.load_keras_model('model_arch_library', %s, NULL, %s)\"\n",
-    "cur.execute(query,[model3.to_json(), \"CNN from Jason Brownlee blog post - no batch normalization\"])\n",
-    "conn.commit()\n",
-    "\n",
-    "# check model loaded OK\n",
-    "%sql SELECT model_id, name FROM model_arch_library ORDER BY model_id;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"mst\"></a>\n",
-    "# 4.  Define and load model selection tuples"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Select the model(s) from the model architecture table that you want to run, along with the compile and fit parameters. Permutations for grid search will be created for the set of model selection parameters will be loaded:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 32,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "Done.\n",
-      "1 rows affected.\n",
-      "16 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>mst_key</th>\n",
-       "        <th>model_id</th>\n",
-       "        <th>compile_params</th>\n",
-       "        <th>fit_params</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>1</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>2</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>3</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>4</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>5</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>6</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>7</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>8</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>9</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>10</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>11</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>12</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>13</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>14</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>15</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>16</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(1, 1, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']\", u'batch_size=64,epochs=5'),\n",
-       " (2, 1, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']\", u'batch_size=128,epochs=5'),\n",
-       " (3, 1, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=64,epochs=5'),\n",
-       " (4, 1, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=128,epochs=5'),\n",
-       " (5, 1, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=64,epochs=5'),\n",
-       " (6, 1, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=128,epochs=5'),\n",
-       " (7, 1, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']\", u'batch_size=64,epochs=5'),\n",
-       " (8, 1, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']\", u'batch_size=128,epochs=5'),\n",
-       " (9, 2, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']\", u'batch_size=64,epochs=5'),\n",
-       " (10, 2, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']\", u'batch_size=128,epochs=5'),\n",
-       " (11, 2, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=64,epochs=5'),\n",
-       " (12, 2, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=128,epochs=5'),\n",
-       " (13, 2, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=64,epochs=5'),\n",
-       " (14, 2, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=128,epochs=5'),\n",
-       " (15, 2, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']\", u'batch_size=64,epochs=5'),\n",
-       " (16, 2, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']\", u'batch_size=128,epochs=5')]"
-      ]
-     },
-     "execution_count": 32,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "DROP TABLE IF EXISTS mst_table, mst_table_summary;\n",
-    "\n",
-    "SELECT madlib.load_model_selection_table('model_arch_library', -- model architecture table\n",
-    "                                         'mst_table',          -- model selection table output\n",
-    "                                          ARRAY[1,2],          -- model ids from model architecture table\n",
-    "                                          ARRAY[               -- compile params   \n",
-    "                                              $$loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']$$,\n",
-    "                                              $$loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']$$,\n",
-    "                                              $$loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']$$,\n",
-    "                                              $$loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']$$\n",
-    "                                          ],\n",
-    "                                          ARRAY[                -- fit params\n",
-    "                                              $$batch_size=64,epochs=5$$, \n",
-    "                                              $$batch_size=128,epochs=5$$\n",
-    "                                          ]\n",
-    "                                         );\n",
-    "                                  \n",
-    "SELECT * FROM mst_table ORDER BY mst_key;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "This is the name of the model architecture table that corresponds to the model selection table:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 33,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>model_arch_table</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>model_arch_library</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(u'model_arch_library',)]"
-      ]
-     },
-     "execution_count": 33,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "SELECT * FROM mst_table_summary;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"train\"></a>\n",
-    "# 5.  Train\n",
-    "Train multiple models:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 6,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Done.\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>madlib_keras_fit_multiple_model</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td></td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[('',)]"
-      ]
-     },
-     "execution_count": 6,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "DROP TABLE IF EXISTS cifar10_multi_model, cifar10_multi_model_summary, cifar10_multi_model_info;\n",
-    "\n",
-    "SELECT madlib.madlib_keras_fit_multiple_model('cifar10_train_packed',    -- source_table\n",
-    "                                              'cifar10_multi_model',     -- model_output_table\n",
-    "                                              'mst_table',               -- model_selection_table\n",
-    "                                               10,                       -- num_iterations\n",
-    "                                               TRUE,                     -- use gpus\n",
-    "                                              'cifar10_val_packed',      -- validation dataset\n",
-    "                                               1                         -- metrics compute frequency\n",
-    "                                             );"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "View the model summary:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 34,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>source_table</th>\n",
-       "        <th>validation_table</th>\n",
-       "        <th>model</th>\n",
-       "        <th>model_info</th>\n",
-       "        <th>dependent_varname</th>\n",
-       "        <th>independent_varname</th>\n",
-       "        <th>model_arch_table</th>\n",
-       "        <th>num_iterations</th>\n",
-       "        <th>metrics_compute_frequency</th>\n",
-       "        <th>warm_start</th>\n",
-       "        <th>name</th>\n",
-       "        <th>description</th>\n",
-       "        <th>start_training_time</th>\n",
-       "        <th>end_training_time</th>\n",
-       "        <th>madlib_version</th>\n",
-       "        <th>num_classes</th>\n",
-       "        <th>class_values</th>\n",
-       "        <th>dependent_vartype</th>\n",
-       "        <th>normalizing_const</th>\n",
-       "        <th>metrics_iters</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>cifar10_train_packed</td>\n",
-       "        <td>cifar10_val_packed</td>\n",
-       "        <td>cifar10_multi_model</td>\n",
-       "        <td>cifar10_multi_model_info</td>\n",
-       "        <td>y</td>\n",
-       "        <td>x</td>\n",
-       "        <td>model_arch_library</td>\n",
-       "        <td>10</td>\n",
-       "        <td>1</td>\n",
-       "        <td>False</td>\n",
-       "        <td>None</td>\n",
-       "        <td>None</td>\n",
-       "        <td>2020-03-17 23:21:35.497938</td>\n",
-       "        <td>2020-03-17 23:50:01.109448</td>\n",
-       "        <td>1.17-dev</td>\n",
-       "        <td>10</td>\n",
-       "        <td>[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]</td>\n",
-       "        <td>smallint</td>\n",
-       "        <td>256.0</td>\n",
-       "        <td>[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(u'cifar10_train_packed', u'cifar10_val_packed', u'cifar10_multi_model', u'cifar10_multi_model_info', u'y', u'x', u'model_arch_library', 10, 1, False, None, None, datetime.datetime(2020, 3, 17, 23, 21, 35, 497938), datetime.datetime(2020, 3, 17, 23, 50, 1, 109448), u'1.17-dev', 10, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], u'smallint', 256.0, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])]"
-      ]
-     },
-     "execution_count": 34,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "SELECT * FROM cifar10_multi_model_summary;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "View performance of each model:"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 37,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>mst_key</th>\n",
-       "        <th>model_id</th>\n",
-       "        <th>compile_params</th>\n",
-       "        <th>fit_params</th>\n",
-       "        <th>model_type</th>\n",
-       "        <th>model_size</th>\n",
-       "        <th>metrics_elapsed_time</th>\n",
-       "        <th>metrics_type</th>\n",
-       "        <th>training_metrics_final</th>\n",
-       "        <th>training_loss_final</th>\n",
-       "        <th>training_metrics</th>\n",
-       "        <th>training_loss</th>\n",
-       "        <th>validation_metrics_final</th>\n",
-       "        <th>validation_loss_final</th>\n",
-       "        <th>validation_metrics</th>\n",
-       "        <th>validation_loss</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>15</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>2159.70019531</td>\n",
-       "        <td>[160.21645283699, 325.693609952927, 493.035051822662, 661.953631877899, 831.346253871918, 1001.65144181252, 1171.72806191444, 1342.43474984169, 1515.81184601784, 1689.71926879883]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.958739995956</td>\n",
-       "        <td>0.12002915144</td>\n",
-       "        <td>[0.779980003833771, 0.845019996166229, 0.873939990997314, 0.893540024757385, 0.905359983444214, 0.92519998550415, 0.942740023136139, 0.936339974403381, 0.944379985332489, 0.958739995956421]</td>\n",
-       "        <td>[0.63620263338089, 0.451914638280869, 0.365966022014618, 0.304257303476334, 0.272642701864243, 0.214935272932053, 0.167475894093513, 0.184087827801704, 0.162149116396904, 0.120029151439667]</td>\n",
-       "        <td>0.838599979877</td>\n",
-       "        <td>0.570000112057</td>\n",
-       "        <td>[0.749100029468536, 0.795099973678589, 0.809499979019165, 0.814599990844727, 0.817300021648407, 0.825900018215179, 0.831399977207184, 0.829599976539612, 0.826099991798401, 0.838599979877472]</td>\n",
-       "        <td>[0.729304790496826, 0.612815201282501, 0.598590016365051, 0.574969530105591, 0.585948467254639, 0.566278994083405, 0.566746890544891, 0.570696115493774, 0.600630104541779, 0.570000112056732]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>16</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>2159.70019531</td>\n",
-       "        <td>[168.006911993027, 334.143662929535, 501.23655295372, 670.235726833344, 840.096035003662, 1010.38422298431, 1180.51074194908, 1351.65223288536, 1524.53146886826, 1699.84652090073]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.959839999676</td>\n",
-       "        <td>0.119847580791</td>\n",
-       "        <td>[0.763499975204468, 0.829859972000122, 0.858560025691986, 0.889379978179932, 0.903039991855621, 0.922519981861115, 0.938279986381531, 0.941100001335144, 0.953220009803772, 0.959839999675751]</td>\n",
-       "        <td>[0.676432132720947, 0.491187304258347, 0.408329516649246, 0.319939345121384, 0.279028236865997, 0.222155645489693, 0.179503843188286, 0.17168553173542, 0.136883869767189, 0.11984758079052]</td>\n",
-       "        <td>0.833100020885</td>\n",
-       "        <td>0.599731981754</td>\n",
-       "        <td>[0.741900026798248, 0.784900009632111, 0.796500027179718, 0.814000010490417, 0.820100009441376, 0.828100025653839, 0.83160001039505, 0.831499993801117, 0.834399998188019, 0.833100020885468]</td>\n",
-       "        <td>[0.74375057220459, 0.641318619251251, 0.627871870994568, 0.585915207862854, 0.588144600391388, 0.569212675094604, 0.577586710453033, 0.590799033641815, 0.581186473369598, 0.599731981754303]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>13</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>2159.70019531</td>\n",
-       "        <td>[165.07025885582, 331.04939699173, 498.211872816086, 667.060778856277, 836.708249807358, 1007.20118093491, 1176.76868081093, 1348.24542784691, 1520.97673892975, 1695.76891899109]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.94892001152</td>\n",
-       "        <td>0.146594136953</td>\n",
-       "        <td>[0.786400020122528, 0.839680016040802, 0.869140028953552, 0.878480017185211, 0.909940004348755, 0.913100004196167, 0.934099972248077, 0.94021999835968, 0.936819970607758, 0.948920011520386]</td>\n",
-       "        <td>[0.625118017196655, 0.466760665178299, 0.38435173034668, 0.353523939847946, 0.260264813899994, 0.252679228782654, 0.190901413559914, 0.176555588841438, 0.181787580251694, 0.146594136953354]</td>\n",
-       "        <td>0.82959997654</td>\n",
-       "        <td>0.581429600716</td>\n",
-       "        <td>[0.76120001077652, 0.787599980831146, 0.804199993610382, 0.805400013923645, 0.815400004386902, 0.824199974536896, 0.827499985694885, 0.826099991798401, 0.822399973869324, 0.829599976539612]</td>\n",
-       "        <td>[0.711538255214691, 0.647833049297333, 0.601243674755096, 0.620489895343781, 0.593936264514923, 0.592362821102142, 0.572449862957001, 0.586679399013519, 0.630510628223419, 0.581429600715637]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>14</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>2159.70019531</td>\n",
-       "        <td>[161.95653796196, 327.381590843201, 494.75689291954, 663.697657823563, 833.140888929367, 1003.58734488487, 1173.66367697716, 1344.3388338089, 1517.75524687767, 1691.74780988693]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.942839980125</td>\n",
-       "        <td>0.167295366526</td>\n",
-       "        <td>[0.770560026168823, 0.822459995746613, 0.871060013771057, 0.886059999465942, 0.906120002269745, 0.91347998380661, 0.916339993476868, 0.929560005664825, 0.938979983329773, 0.942839980125427]</td>\n",
-       "        <td>[0.656668424606323, 0.515599489212036, 0.367846250534058, 0.332457065582275, 0.276119023561478, 0.253687649965286, 0.2399021089077, 0.203119158744812, 0.174109742045403, 0.16729536652565]</td>\n",
-       "        <td>0.827600002289</td>\n",
-       "        <td>0.60536968708</td>\n",
-       "        <td>[0.734799981117249, 0.784600019454956, 0.806299984455109, 0.811600029468536, 0.817499995231628, 0.823800027370453, 0.828299999237061, 0.829900026321411, 0.828999996185303, 0.827600002288818]</td>\n",
-       "        <td>[0.777421414852142, 0.645794928073883, 0.587472915649414, 0.603748321533203, 0.590349853038788, 0.586721003055573, 0.58501935005188, 0.603322744369507, 0.596234917640686, 0.605369687080383]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>11</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>2159.70019531</td>\n",
-       "        <td>[173.035629987717, 339.004810810089, 506.329674959183, 675.320897817612, 845.306622982025, 1015.91489100456, 1185.85607385635, 1357.71336293221, 1530.14687585831, 1705.61137890816]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.892719984055</td>\n",
-       "        <td>0.309859842062</td>\n",
-       "        <td>[0.583959996700287, 0.695259988307953, 0.754980027675629, 0.787720024585724, 0.814040005207062, 0.835359990596771, 0.856899976730347, 0.871460020542145, 0.884779989719391, 0.892719984054565]</td>\n",
-       "        <td>[1.16789627075195, 0.861167967319489, 0.705251038074493, 0.607605278491974, 0.531997323036194, 0.470408618450165, 0.413226217031479, 0.370105147361755, 0.334705889225006, 0.309859842061996]</td>\n",
-       "        <td>0.813000023365</td>\n",
-       "        <td>0.566866695881</td>\n",
-       "        <td>[0.579999983310699, 0.690999984741211, 0.738099992275238, 0.763599991798401, 0.773800015449524, 0.783800005912781, 0.798500001430511, 0.802699983119965, 0.80620002746582, 0.813000023365021]</td>\n",
-       "        <td>[1.17161071300507, 0.881313383579254, 0.754627048969269, 0.680095791816711, 0.643820106983185, 0.620280385017395, 0.590712904930115, 0.576853334903717, 0.574894845485687, 0.56686669588089]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>9</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>2159.70019531</td>\n",
-       "        <td>[156.6842648983, 322.059647798538, 489.514621019363, 658.153139829636, 827.505573987961, 997.966463804245, 1168.05154681206, 1338.58688092232, 1511.8177728653, 1685.66397881508]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.89484000206</td>\n",
-       "        <td>0.305973917246</td>\n",
-       "        <td>[0.607659995555878, 0.689279973506927, 0.748199999332428, 0.779420018196106, 0.812300026416779, 0.830940008163452, 0.854920029640198, 0.868260025978088, 0.885720014572144, 0.894840002059937]</td>\n",
-       "        <td>[1.11698472499847, 0.874710261821747, 0.711394190788269, 0.626727402210236, 0.533221900463104, 0.478961884975433, 0.414784848690033, 0.376370459794998, 0.330575972795486, 0.305973917245865]</td>\n",
-       "        <td>0.81099998951</td>\n",
-       "        <td>0.550887346268</td>\n",
-       "        <td>[0.602699995040894, 0.681299984455109, 0.728600025177002, 0.754400014877319, 0.774600028991699, 0.784300029277802, 0.795799970626831, 0.80129998922348, 0.807399988174438, 0.810999989509583]</td>\n",
-       "        <td>[1.11438655853271, 0.900401651859283, 0.765824854373932, 0.704216003417969, 0.643769145011902, 0.616570711135864, 0.586219370365143, 0.571570515632629, 0.558478593826294, 0.5508873462677]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>10</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>2159.70019531</td>\n",
-       "        <td>[158.506701946259, 323.779083013535, 491.302199840546, 660.148201942444, 829.340363025665, 999.844955921173, 1169.83032798767, 1340.5411260128, 1513.8498609066, 1687.69545793533]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.867579996586</td>\n",
-       "        <td>0.380911707878</td>\n",
-       "        <td>[0.576640009880066, 0.66431999206543, 0.707199990749359, 0.749520003795624, 0.778980016708374, 0.799520015716553, 0.820659995079041, 0.839940011501312, 0.854659974575043, 0.867579996585846]</td>\n",
-       "        <td>[1.20035827159882, 0.945839285850525, 0.823047578334808, 0.703792750835419, 0.624295234680176, 0.566677749156952, 0.511338114738464, 0.459649682044983, 0.418204575777054, 0.380911707878113]</td>\n",
-       "        <td>0.799700021744</td>\n",
-       "        <td>0.571797966957</td>\n",
-       "        <td>[0.572700023651123, 0.655099987983704, 0.69980001449585, 0.731299996376038, 0.756399989128113, 0.771399974822998, 0.778999984264374, 0.791599988937378, 0.798200011253357, 0.799700021743774]</td>\n",
-       "        <td>[1.20565474033356, 0.964107036590576, 0.849484860897064, 0.752416431903839, 0.691979646682739, 0.65268349647522, 0.628291726112366, 0.599337160587311, 0.586054861545563, 0.571797966957092]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>12</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>2159.70019531</td>\n",
-       "        <td>[170.873965024948, 337.211632966995, 504.536657810211, 673.510901927948, 843.392476797104, 1014.04761791229, 1183.94673490524, 1355.76256680489, 1528.15198993683, 1703.5478978157]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.856419980526</td>\n",
-       "        <td>0.410014539957</td>\n",
-       "        <td>[0.547559976577759, 0.647800028324127, 0.698180019855499, 0.746360003948212, 0.769439995288849, 0.794420003890991, 0.814459979534149, 0.829039990901947, 0.850260019302368, 0.85641998052597]</td>\n",
-       "        <td>[1.27583348751068, 1.00206804275513, 0.853795170783997, 0.720450162887573, 0.650525093078613, 0.582838296890259, 0.527670443058014, 0.484861791133881, 0.428409487009048, 0.410014539957047]</td>\n",
-       "        <td>0.798799991608</td>\n",
-       "        <td>0.597697675228</td>\n",
-       "        <td>[0.546700000762939, 0.638999998569489, 0.690900027751923, 0.731299996376038, 0.745500028133392, 0.763100028038025, 0.776300013065338, 0.78549998998642, 0.795000016689301, 0.798799991607666]</td>\n",
-       "        <td>[1.27788388729095, 1.02294909954071, 0.881045579910278, 0.773496091365814, 0.725675582885742, 0.681352615356445, 0.649362862110138, 0.62593412399292, 0.598857045173645, 0.597697675228119]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>8</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>4886.20019531</td>\n",
-       "        <td>[165.667771816254, 331.63804101944, 498.80203294754, 667.662895917892, 837.58491396904, 1007.91998696327, 1177.68679785728, 1348.86184287071, 1521.96094989777, 1696.78608179092]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.909500002861</td>\n",
-       "        <td>0.272008836269</td>\n",
-       "        <td>[0.752040028572083, 0.828859984874725, 0.851639986038208, 0.888540029525757, 0.888599991798401, 0.894879996776581, 0.903320014476776, 0.910380005836487, 0.879000008106232, 0.909500002861023]</td>\n",
-       "        <td>[0.712807893753052, 0.499261021614075, 0.437727391719818, 0.330645024776459, 0.325151771306992, 0.308288186788559, 0.296011507511139, 0.272213906049728, 0.394761264324188, 0.272008836269379]</td>\n",
-       "        <td>0.779699981213</td>\n",
-       "        <td>0.834259152412</td>\n",
-       "        <td>[0.708500027656555, 0.751299977302551, 0.765500009059906, 0.772300004959106, 0.777100026607513, 0.783599972724915, 0.777999997138977, 0.784099996089935, 0.769800007343292, 0.779699981212616]</td>\n",
-       "        <td>[0.841326177120209, 0.729629755020142, 0.776288628578186, 0.718003392219543, 0.76948493719101, 0.767067849636078, 0.827211439609528, 0.747310042381287, 0.895535230636597, 0.834259152412415]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>1</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>4886.20019531</td>\n",
-       "        <td>[168.611300945282, 334.899528980255, 502.037551879883, 671.096584796906, 840.693498849869, 1011.29117488861, 1181.11248087883, 1352.68110394478, 1525.13323402405, 1700.88493180275]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.920239984989</td>\n",
-       "        <td>0.272924244404</td>\n",
-       "        <td>[0.584800004959106, 0.682219982147217, 0.732940018177032, 0.774779975414276, 0.806119978427887, 0.837840020656586, 0.862119972705841, 0.883340001106262, 0.90311998128891, 0.920239984989166]</td>\n",
-       "        <td>[1.17424917221069, 0.919099688529968, 0.776308834552765, 0.661072790622711, 0.573073744773865, 0.487901866436005, 0.420156627893448, 0.368478238582611, 0.319370418787003, 0.272924244403839]</td>\n",
-       "        <td>0.775600016117</td>\n",
-       "        <td>0.679777920246</td>\n",
-       "        <td>[0.576799988746643, 0.657599985599518, 0.694700002670288, 0.721199989318848, 0.741400003433228, 0.750500023365021, 0.758800029754639, 0.764599978923798, 0.771899998188019, 0.775600016117096]</td>\n",
-       "        <td>[1.19727396965027, 0.98458856344223, 0.873661160469055, 0.809533834457397, 0.764622151851654, 0.735906422138214, 0.700538396835327, 0.705035388469696, 0.696578562259674, 0.679777920246124]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>7</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>4886.20019531</td>\n",
-       "        <td>[154.371929883957, 319.090498924255, 486.952117919922, 655.78808093071, 824.799381971359, 995.210795879364, 1165.24253582954, 1336.07785487175, 1508.86772489548, 1682.56205582619]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.861419975758</td>\n",
-       "        <td>0.432331353426</td>\n",
-       "        <td>[0.766240000724792, 0.827859997749329, 0.855539977550507, 0.868900001049042, 0.871540009975433, 0.88238000869751, 0.873179972171783, 0.878740012645721, 0.873459994792938, 0.861419975757599]</td>\n",
-       "        <td>[0.682850182056427, 0.503075182437897, 0.426931649446487, 0.385531783103943, 0.383735597133636, 0.371502071619034, 0.389450550079346, 0.369848489761353, 0.391900181770325, 0.43233135342598]</td>\n",
-       "        <td>0.767599999905</td>\n",
-       "        <td>0.752326309681</td>\n",
-       "        <td>[0.719299972057343, 0.751500010490417, 0.765399992465973, 0.769999980926514, 0.772499978542328, 0.776799976825714, 0.770099997520447, 0.77649998664856, 0.76800000667572, 0.767599999904633]</td>\n",
-       "        <td>[0.819014072418213, 0.739358127117157, 0.74931389093399, 0.773028433322906, 0.763317465782166, 0.729169189929962, 0.805014729499817, 0.808122754096985, 0.812756359577179, 0.752326309680939]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>3</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>4886.20019531</td>\n",
-       "        <td>[154.969959974289, 319.906549930573, 487.758535861969, 656.377619981766, 825.622062921524, 996.102727890015, 1166.17477893829, 1336.67210102081, 1509.83961796761, 1683.64339399338]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.821099996567</td>\n",
-       "        <td>0.525239348412</td>\n",
-       "        <td>[0.561699986457825, 0.668940007686615, 0.717679977416992, 0.75297999382019, 0.767099976539612, 0.795260012149811, 0.807739973068237, 0.811280012130737, 0.826099991798401, 0.821099996566772]</td>\n",
-       "        <td>[1.220210313797, 0.947799980640411, 0.812605798244476, 0.718978762626648, 0.679905712604523, 0.613099038600922, 0.566433131694794, 0.552485108375549, 0.512454450130463, 0.52523934841156]</td>\n",
-       "        <td>0.758599996567</td>\n",
-       "        <td>0.737899065018</td>\n",
-       "        <td>[0.559899985790253, 0.647000014781952, 0.683300018310547, 0.709100008010864, 0.723800003528595, 0.742299973964691, 0.749700009822845, 0.757099986076355, 0.765600025653839, 0.758599996566772]</td>\n",
-       "        <td>[1.22284317016602, 0.988233506679535, 0.88149094581604, 0.825053095817566, 0.811959385871887, 0.752561450004578, 0.741220593452454, 0.739940404891968, 0.711078464984894, 0.7378990650177]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>2</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>4886.20019531</td>\n",
-       "        <td>[169.201556921005, 335.50149679184, 502.804733991623, 671.735637903214, 841.536010980606, 1012.17449593544, 1182.0387070179, 1353.62765884399, 1526.14807486534, 1701.52705287933]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.866079986095</td>\n",
-       "        <td>0.411734908819</td>\n",
-       "        <td>[0.535120010375977, 0.633019983768463, 0.683080017566681, 0.727400004863739, 0.757719993591309, 0.788060009479523, 0.812640011310577, 0.835120022296906, 0.846180021762848, 0.866079986095428]</td>\n",
-       "        <td>[1.29918956756592, 1.05417799949646, 0.917978286743164, 0.795661866664886, 0.70832484960556, 0.632884621620178, 0.562899112701416, 0.502775311470032, 0.463661164045334, 0.411734908819199]</td>\n",
-       "        <td>0.758199989796</td>\n",
-       "        <td>0.725014865398</td>\n",
-       "        <td>[0.527800023555756, 0.620299994945526, 0.656300008296967, 0.690400004386902, 0.707400023937225, 0.726199984550476, 0.734799981117249, 0.746500015258789, 0.750999987125397, 0.758199989795685]</td>\n",
-       "        <td>[1.31133198738098, 1.09069919586182, 0.985389471054077, 0.897808969020844, 0.84535801410675, 0.804515540599823, 0.770778298377991, 0.748202204704285, 0.736022055149078, 0.725014865398407]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>4</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>4886.20019531</td>\n",
-       "        <td>[163.359121799469, 328.837852954865, 496.364542961121, 665.302300930023, 834.891145944595, 1005.38074088097, 1174.84563589096, 1345.91664791107, 1518.93280696869, 1693.73289394379]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.82415997982</td>\n",
-       "        <td>0.518441617489</td>\n",
-       "        <td>[0.521520018577576, 0.612500011920929, 0.638840019702911, 0.686819970607758, 0.740119993686676, 0.765739977359772, 0.78847998380661, 0.814140021800995, 0.825020015239716, 0.824159979820251]</td>\n",
-       "        <td>[1.33973300457001, 1.10515522956848, 1.02763831615448, 0.890439391136169, 0.749050080776215, 0.679889440536499, 0.620155572891235, 0.560859560966492, 0.520996809005737, 0.518441617488861]</td>\n",
-       "        <td>0.757799983025</td>\n",
-       "        <td>0.732741773129</td>\n",
-       "        <td>[0.515500009059906, 0.602699995040894, 0.630599975585938, 0.66619998216629, 0.70959997177124, 0.721300005912781, 0.73470002412796, 0.751500010490417, 0.756099998950958, 0.757799983024597]</td>\n",
-       "        <td>[1.34494018554688, 1.12949633598328, 1.05980122089386, 0.951755106449127, 0.840038895606995, 0.81215900182724, 0.776918768882751, 0.734996318817139, 0.712943911552429, 0.73274177312851]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>6</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>4886.20019531</td>\n",
-       "        <td>[162.552975893021, 328.213756799698, 495.55163693428, 664.478772878647, 834.023772001266, 1004.50640487671, 1174.26192784309, 1344.94176697731, 1518.35087895393, 1692.74292802811]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.734799981117</td>\n",
-       "        <td>0.835899949074</td>\n",
-       "        <td>[0.71916002035141, 0.750440001487732, 0.720459997653961, 0.801540017127991, 0.725839972496033, 0.777220010757446, 0.780219972133636, 0.706719994544983, 0.750180006027222, 0.734799981117249]</td>\n",
-       "        <td>[0.821036815643311, 0.778892278671265, 0.90295821428299, 0.621506929397583, 0.841251850128174, 0.677752196788788, 0.701953232288361, 0.95904815196991, 0.82386702299118, 0.835899949073792]</td>\n",
-       "        <td>0.709599971771</td>\n",
-       "        <td>0.930533230305</td>\n",
-       "        <td>[0.680499970912933, 0.7185999751091, 0.670499980449677, 0.75220000743866, 0.685699999332428, 0.733200013637543, 0.733200013637543, 0.669700026512146, 0.712100028991699, 0.70959997177124]</td>\n",
-       "        <td>[0.936905562877655, 0.941630959510803, 1.1544371843338, 0.890039265155792, 1.02143895626068, 0.915954768657684, 0.975173354148865, 1.12838399410248, 0.942200124263763, 0.930533230304718]</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>5</td>\n",
-       "        <td>1</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=64,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>4886.20019531</td>\n",
-       "        <td>[166.255312919617, 332.407908916473, 499.474656820297, 668.450613975525, 838.271963834763, 1008.50526785851, 1178.62056994438, 1349.74808692932, 1522.54409790039, 1697.81855082512]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.585380017757</td>\n",
-       "        <td>1.2495957613</td>\n",
-       "        <td>[0.71341997385025, 0.755879998207092, 0.7189000248909, 0.719219982624054, 0.683700025081635, 0.646440029144287, 0.565659999847412, 0.623939990997314, 0.66210001707077, 0.585380017757416]</td>\n",
-       "        <td>[0.875595450401306, 0.737006664276123, 0.879582762718201, 0.826622664928436, 0.986110627651215, 1.02004647254944, 1.33022010326385, 1.12789785861969, 0.977221727371216, 1.24959576129913]</td>\n",
-       "        <td>0.591700017452</td>\n",
-       "        <td>1.32029783726</td>\n",
-       "        <td>[0.690599977970123, 0.721400022506714, 0.707000017166138, 0.700900018215179, 0.673799991607666, 0.638000011444092, 0.565599977970123, 0.620199978351593, 0.65719997882843, 0.59170001745224]</td>\n",
-       "        <td>[0.990004479885101, 0.883562862873077, 0.931297481060028, 0.941763758659363, 1.02153491973877, 1.06588494777679, 1.32568216323853, 1.17570757865906, 1.0156409740448, 1.32029783725739]</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(15, 2, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']\", u'batch_size=64,epochs=5', u'madlib_keras', 2159.70019531, [160.21645283699, 325.693609952927, 493.035051822662, 661.953631877899, 831.346253871918, 1001.65144181252, 1171.72806191444, 1342.43474984169, 1515.81184601784, 1689.71926879883], [u'accuracy'], 0.958739995956, 0.12002915144, [0.779980003833771, 0.845019996166229, 0.873939990997314, 0.893540024757385, 0.905359983444214, 0.92519 [...]
-       " (16, 2, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']\", u'batch_size=128,epochs=5', u'madlib_keras', 2159.70019531, [168.006911993027, 334.143662929535, 501.23655295372, 670.235726833344, 840.096035003662, 1010.38422298431, 1180.51074194908, 1351.65223288536, 1524.53146886826, 1699.84652090073], [u'accuracy'], 0.959839999676, 0.119847580791, [0.763499975204468, 0.829859972000122, 0.858560025691986, 0.889379978179932, 0.903039991855621, 0.922 [...]
-       " (13, 2, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=64,epochs=5', u'madlib_keras', 2159.70019531, [165.07025885582, 331.04939699173, 498.211872816086, 667.060778856277, 836.708249807358, 1007.20118093491, 1176.76868081093, 1348.24542784691, 1520.97673892975, 1695.76891899109], [u'accuracy'], 0.94892001152, 0.146594136953, [0.786400020122528, 0.839680016040802, 0.869140028953552, 0.878480017185211, 0.9099400043 [...]
-       " (14, 2, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=128,epochs=5', u'madlib_keras', 2159.70019531, [161.95653796196, 327.381590843201, 494.75689291954, 663.697657823563, 833.140888929367, 1003.58734488487, 1173.66367697716, 1344.3388338089, 1517.75524687767, 1691.74780988693], [u'accuracy'], 0.942839980125, 0.167295366526, [0.770560026168823, 0.822459995746613, 0.871060013771057, 0.886059999465942, 0.906120002 [...]
-       " (11, 2, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=64,epochs=5', u'madlib_keras', 2159.70019531, [173.035629987717, 339.004810810089, 506.329674959183, 675.320897817612, 845.306622982025, 1015.91489100456, 1185.85607385635, 1357.71336293221, 1530.14687585831, 1705.61137890816], [u'accuracy'], 0.892719984055, 0.309859842062, [0.583959996700287, 0.695259988307953, 0.754980027675629, 0.787720024585724, 0.814040 [...]
-       " (9, 2, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']\", u'batch_size=64,epochs=5', u'madlib_keras', 2159.70019531, [156.6842648983, 322.059647798538, 489.514621019363, 658.153139829636, 827.505573987961, 997.966463804245, 1168.05154681206, 1338.58688092232, 1511.8177728653, 1685.66397881508], [u'accuracy'], 0.89484000206, 0.305973917246, [0.607659995555878, 0.689279973506927, 0.748199999332428, 0.779420018196106, 0.812300026416779, 0.8309400 [...]
-       " (10, 2, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']\", u'batch_size=128,epochs=5', u'madlib_keras', 2159.70019531, [158.506701946259, 323.779083013535, 491.302199840546, 660.148201942444, 829.340363025665, 999.844955921173, 1169.83032798767, 1340.5411260128, 1513.8498609066, 1687.69545793533], [u'accuracy'], 0.867579996586, 0.380911707878, [0.576640009880066, 0.66431999206543, 0.707199990749359, 0.749520003795624, 0.778980016708374, 0.7995 [...]
-       " (12, 2, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=128,epochs=5', u'madlib_keras', 2159.70019531, [170.873965024948, 337.211632966995, 504.536657810211, 673.510901927948, 843.392476797104, 1014.04761791229, 1183.94673490524, 1355.76256680489, 1528.15198993683, 1703.5478978157], [u'accuracy'], 0.856419980526, 0.410014539957, [0.547559976577759, 0.647800028324127, 0.698180019855499, 0.746360003948212, 0.769439 [...]
-       " (8, 1, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']\", u'batch_size=128,epochs=5', u'madlib_keras', 4886.20019531, [165.667771816254, 331.63804101944, 498.80203294754, 667.662895917892, 837.58491396904, 1007.91998696327, 1177.68679785728, 1348.86184287071, 1521.96094989777, 1696.78608179092], [u'accuracy'], 0.909500002861, 0.272008836269, [0.752040028572083, 0.828859984874725, 0.851639986038208, 0.888540029525757, 0.888599991798401, 0.894879 [...]
-       " (1, 1, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']\", u'batch_size=64,epochs=5', u'madlib_keras', 4886.20019531, [168.611300945282, 334.899528980255, 502.037551879883, 671.096584796906, 840.693498849869, 1011.29117488861, 1181.11248087883, 1352.68110394478, 1525.13323402405, 1700.88493180275], [u'accuracy'], 0.920239984989, 0.272924244404, [0.584800004959106, 0.682219982147217, 0.732940018177032, 0.774779975414276, 0.806119978427887, 0.837 [...]
-       " (7, 1, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.001)',metrics=['accuracy']\", u'batch_size=64,epochs=5', u'madlib_keras', 4886.20019531, [154.371929883957, 319.090498924255, 486.952117919922, 655.78808093071, 824.799381971359, 995.210795879364, 1165.24253582954, 1336.07785487175, 1508.86772489548, 1682.56205582619], [u'accuracy'], 0.861419975758, 0.432331353426, [0.766240000724792, 0.827859997749329, 0.855539977550507, 0.868900001049042, 0.871540009975433, 0.88238 [...]
-       " (3, 1, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=64,epochs=5', u'madlib_keras', 4886.20019531, [154.969959974289, 319.906549930573, 487.758535861969, 656.377619981766, 825.622062921524, 996.102727890015, 1166.17477893829, 1336.67210102081, 1509.83961796761, 1683.64339399338], [u'accuracy'], 0.821099996567, 0.525239348412, [0.561699986457825, 0.668940007686615, 0.717679977416992, 0.75297999382019, 0.76709997 [...]
-       " (2, 1, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']\", u'batch_size=128,epochs=5', u'madlib_keras', 4886.20019531, [169.201556921005, 335.50149679184, 502.804733991623, 671.735637903214, 841.536010980606, 1012.17449593544, 1182.0387070179, 1353.62765884399, 1526.14807486534, 1701.52705287933], [u'accuracy'], 0.866079986095, 0.411734908819, [0.535120010375977, 0.633019983768463, 0.683080017566681, 0.727400004863739, 0.757719993591309, 0.7880 [...]
-       " (4, 1, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.0001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=128,epochs=5', u'madlib_keras', 4886.20019531, [163.359121799469, 328.837852954865, 496.364542961121, 665.302300930023, 834.891145944595, 1005.38074088097, 1174.84563589096, 1345.91664791107, 1518.93280696869, 1693.73289394379], [u'accuracy'], 0.82415997982, 0.518441617489, [0.521520018577576, 0.612500011920929, 0.638840019702911, 0.686819970607758, 0.7401199 [...]
-       " (6, 1, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=128,epochs=5', u'madlib_keras', 4886.20019531, [162.552975893021, 328.213756799698, 495.55163693428, 664.478772878647, 834.023772001266, 1004.50640487671, 1174.26192784309, 1344.94176697731, 1518.35087895393, 1692.74292802811], [u'accuracy'], 0.734799981117, 0.835899949074, [0.71916002035141, 0.750440001487732, 0.720459997653961, 0.801540017127991, 0.725839972 [...]
-       " (5, 1, u\"loss='categorical_crossentropy',optimizer='rmsprop(lr=0.001, decay=1e-6)',metrics=['accuracy']\", u'batch_size=64,epochs=5', u'madlib_keras', 4886.20019531, [166.255312919617, 332.407908916473, 499.474656820297, 668.450613975525, 838.271963834763, 1008.50526785851, 1178.62056994438, 1349.74808692932, 1522.54409790039, 1697.81855082512], [u'accuracy'], 0.585380017757, 1.2495957613, [0.71341997385025, 0.755879998207092, 0.7189000248909, 0.719219982624054, 0.6837000250816 [...]
-      ]
-     },
-     "execution_count": 37,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "SELECT * FROM cifar10_multi_model_info ORDER BY validation_metrics_final DESC;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"plot\"></a>\n",
-    "# 6. Plot results"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 7,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "%matplotlib notebook\n",
-    "import matplotlib.pyplot as plt\n",
-    "from matplotlib.ticker import MaxNLocator\n",
-    "from collections import defaultdict\n",
-    "import pandas as pd\n",
-    "plt.rcParams.update({'font.size': 12})\n",
-    "pd.set_option('display.max_colwidth', -1)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Training data"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 8,
-   "metadata": {
-    "scrolled": false
-   },
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "application/javascript": [
-       "/* Put everything inside the global mpl namespace */\n",
-       "window.mpl = {};\n",
-       "\n",
-       "\n",
-       "mpl.get_websocket_type = function() {\n",
-       "    if (typeof(WebSocket) !== 'undefined') {\n",
-       "        return WebSocket;\n",
-       "    } else if (typeof(MozWebSocket) !== 'undefined') {\n",
-       "        return MozWebSocket;\n",
-       "    } else {\n",
-       "        alert('Your browser does not have WebSocket support.' +\n",
-       "              'Please try Chrome, Safari or Firefox ≥ 6. ' +\n",
-       "              'Firefox 4 and 5 are also supported but you ' +\n",
-       "              'have to enable WebSockets in about:config.');\n",
-       "    };\n",
-       "}\n",
-       "\n",
-       "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n",
-       "    this.id = figure_id;\n",
-       "\n",
-       "    this.ws = websocket;\n",
-       "\n",
-       "    this.supports_binary = (this.ws.binaryType != undefined);\n",
-       "\n",
-       "    if (!this.supports_binary) {\n",
-       "        var warnings = document.getElementById(\"mpl-warnings\");\n",
-       "        if (warnings) {\n",
-       "            warnings.style.display = 'block';\n",
-       "            warnings.textContent = (\n",
-       "                \"This browser does not support binary websocket messages. \" +\n",
-       "                    \"Performance may be slow.\");\n",
-       "        }\n",
-       "    }\n",
-       "\n",
-       "    this.imageObj = new Image();\n",
-       "\n",
-       "    this.context = undefined;\n",
-       "    this.message = undefined;\n",
-       "    this.canvas = undefined;\n",
-       "    this.rubberband_canvas = undefined;\n",
-       "    this.rubberband_context = undefined;\n",
-       "    this.format_dropdown = undefined;\n",
-       "\n",
-       "    this.image_mode = 'full';\n",
-       "\n",
-       "    this.root = $('<div/>');\n",
-       "    this._root_extra_style(this.root)\n",
-       "    this.root.attr('style', 'display: inline-block');\n",
-       "\n",
-       "    $(parent_element).append(this.root);\n",
-       "\n",
-       "    this._init_header(this);\n",
-       "    this._init_canvas(this);\n",
-       "    this._init_toolbar(this);\n",
-       "\n",
-       "    var fig = this;\n",
-       "\n",
-       "    this.waiting = false;\n",
-       "\n",
-       "    this.ws.onopen =  function () {\n",
-       "            fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n",
-       "            fig.send_message(\"send_image_mode\", {});\n",
-       "            if (mpl.ratio != 1) {\n",
-       "                fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n",
-       "            }\n",
-       "            fig.send_message(\"refresh\", {});\n",
-       "        }\n",
-       "\n",
-       "    this.imageObj.onload = function() {\n",
-       "            if (fig.image_mode == 'full') {\n",
-       "                // Full images could contain transparency (where diff images\n",
-       "                // almost always do), so we need to clear the canvas so that\n",
-       "                // there is no ghosting.\n",
-       "                fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n",
-       "            }\n",
-       "            fig.context.drawImage(fig.imageObj, 0, 0);\n",
-       "        };\n",
-       "\n",
-       "    this.imageObj.onunload = function() {\n",
-       "        fig.ws.close();\n",
-       "    }\n",
-       "\n",
-       "    this.ws.onmessage = this._make_on_message_function(this);\n",
-       "\n",
-       "    this.ondownload = ondownload;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_header = function() {\n",
-       "    var titlebar = $(\n",
-       "        '<div class=\"ui-dialog-titlebar ui-widget-header ui-corner-all ' +\n",
-       "        'ui-helper-clearfix\"/>');\n",
-       "    var titletext = $(\n",
-       "        '<div class=\"ui-dialog-title\" style=\"width: 100%; ' +\n",
-       "        'text-align: center; padding: 3px;\"/>');\n",
-       "    titlebar.append(titletext)\n",
-       "    this.root.append(titlebar);\n",
-       "    this.header = titletext[0];\n",
-       "}\n",
-       "\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n",
-       "\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n",
-       "\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_canvas = function() {\n",
-       "    var fig = this;\n",
-       "\n",
-       "    var canvas_div = $('<div/>');\n",
-       "\n",
-       "    canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n",
-       "\n",
-       "    function canvas_keyboard_event(event) {\n",
-       "        return fig.key_event(event, event['data']);\n",
-       "    }\n",
-       "\n",
-       "    canvas_div.keydown('key_press', canvas_keyboard_event);\n",
-       "    canvas_div.keyup('key_release', canvas_keyboard_event);\n",
-       "    this.canvas_div = canvas_div\n",
-       "    this._canvas_extra_style(canvas_div)\n",
-       "    this.root.append(canvas_div);\n",
-       "\n",
-       "    var canvas = $('<canvas/>');\n",
-       "    canvas.addClass('mpl-canvas');\n",
-       "    canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n",
-       "\n",
-       "    this.canvas = canvas[0];\n",
-       "    this.context = canvas[0].getContext(\"2d\");\n",
-       "\n",
-       "    var backingStore = this.context.backingStorePixelRatio ||\n",
-       "\tthis.context.webkitBackingStorePixelRatio ||\n",
-       "\tthis.context.mozBackingStorePixelRatio ||\n",
-       "\tthis.context.msBackingStorePixelRatio ||\n",
-       "\tthis.context.oBackingStorePixelRatio ||\n",
-       "\tthis.context.backingStorePixelRatio || 1;\n",
-       "\n",
-       "    mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n",
-       "\n",
-       "    var rubberband = $('<canvas/>');\n",
-       "    rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n",
-       "\n",
-       "    var pass_mouse_events = true;\n",
-       "\n",
-       "    canvas_div.resizable({\n",
-       "        start: function(event, ui) {\n",
-       "            pass_mouse_events = false;\n",
-       "        },\n",
-       "        resize: function(event, ui) {\n",
-       "            fig.request_resize(ui.size.width, ui.size.height);\n",
-       "        },\n",
-       "        stop: function(event, ui) {\n",
-       "            pass_mouse_events = true;\n",
-       "            fig.request_resize(ui.size.width, ui.size.height);\n",
-       "        },\n",
-       "    });\n",
-       "\n",
-       "    function mouse_event_fn(event) {\n",
-       "        if (pass_mouse_events)\n",
-       "            return fig.mouse_event(event, event['data']);\n",
-       "    }\n",
-       "\n",
-       "    rubberband.mousedown('button_press', mouse_event_fn);\n",
-       "    rubberband.mouseup('button_release', mouse_event_fn);\n",
-       "    // Throttle sequential mouse events to 1 every 20ms.\n",
-       "    rubberband.mousemove('motion_notify', mouse_event_fn);\n",
-       "\n",
-       "    rubberband.mouseenter('figure_enter', mouse_event_fn);\n",
-       "    rubberband.mouseleave('figure_leave', mouse_event_fn);\n",
-       "\n",
-       "    canvas_div.on(\"wheel\", function (event) {\n",
-       "        event = event.originalEvent;\n",
-       "        event['data'] = 'scroll'\n",
-       "        if (event.deltaY < 0) {\n",
-       "            event.step = 1;\n",
-       "        } else {\n",
-       "            event.step = -1;\n",
-       "        }\n",
-       "        mouse_event_fn(event);\n",
-       "    });\n",
-       "\n",
-       "    canvas_div.append(canvas);\n",
-       "    canvas_div.append(rubberband);\n",
-       "\n",
-       "    this.rubberband = rubberband;\n",
-       "    this.rubberband_canvas = rubberband[0];\n",
-       "    this.rubberband_context = rubberband[0].getContext(\"2d\");\n",
-       "    this.rubberband_context.strokeStyle = \"#000000\";\n",
-       "\n",
-       "    this._resize_canvas = function(width, height) {\n",
-       "        // Keep the size of the canvas, canvas container, and rubber band\n",
-       "        // canvas in synch.\n",
-       "        canvas_div.css('width', width)\n",
-       "        canvas_div.css('height', height)\n",
-       "\n",
-       "        canvas.attr('width', width * mpl.ratio);\n",
-       "        canvas.attr('height', height * mpl.ratio);\n",
-       "        canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n",
-       "\n",
-       "        rubberband.attr('width', width);\n",
-       "        rubberband.attr('height', height);\n",
-       "    }\n",
-       "\n",
-       "    // Set the figure to an initial 600x600px, this will subsequently be updated\n",
-       "    // upon first draw.\n",
-       "    this._resize_canvas(600, 600);\n",
-       "\n",
-       "    // Disable right mouse context menu.\n",
-       "    $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n",
-       "        return false;\n",
-       "    });\n",
-       "\n",
-       "    function set_focus () {\n",
-       "        canvas.focus();\n",
-       "        canvas_div.focus();\n",
-       "    }\n",
-       "\n",
-       "    window.setTimeout(set_focus, 100);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_toolbar = function() {\n",
-       "    var fig = this;\n",
-       "\n",
-       "    var nav_element = $('<div/>')\n",
-       "    nav_element.attr('style', 'width: 100%');\n",
-       "    this.root.append(nav_element);\n",
-       "\n",
-       "    // Define a callback function for later on.\n",
-       "    function toolbar_event(event) {\n",
-       "        return fig.toolbar_button_onclick(event['data']);\n",
-       "    }\n",
-       "    function toolbar_mouse_event(event) {\n",
-       "        return fig.toolbar_button_onmouseover(event['data']);\n",
-       "    }\n",
-       "\n",
-       "    for(var toolbar_ind in mpl.toolbar_items) {\n",
-       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
-       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
-       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
-       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
-       "\n",
-       "        if (!name) {\n",
-       "            // put a spacer in here.\n",
-       "            continue;\n",
-       "        }\n",
-       "        var button = $('<button/>');\n",
-       "        button.addClass('ui-button ui-widget ui-state-default ui-corner-all ' +\n",
-       "                        'ui-button-icon-only');\n",
-       "        button.attr('role', 'button');\n",
-       "        button.attr('aria-disabled', 'false');\n",
-       "        button.click(method_name, toolbar_event);\n",
-       "        button.mouseover(tooltip, toolbar_mouse_event);\n",
-       "\n",
-       "        var icon_img = $('<span/>');\n",
-       "        icon_img.addClass('ui-button-icon-primary ui-icon');\n",
-       "        icon_img.addClass(image);\n",
-       "        icon_img.addClass('ui-corner-all');\n",
-       "\n",
-       "        var tooltip_span = $('<span/>');\n",
-       "        tooltip_span.addClass('ui-button-text');\n",
-       "        tooltip_span.html(tooltip);\n",
-       "\n",
-       "        button.append(icon_img);\n",
-       "        button.append(tooltip_span);\n",
-       "\n",
-       "        nav_element.append(button);\n",
-       "    }\n",
-       "\n",
-       "    var fmt_picker_span = $('<span/>');\n",
-       "\n",
-       "    var fmt_picker = $('<select/>');\n",
-       "    fmt_picker.addClass('mpl-toolbar-option ui-widget ui-widget-content');\n",
-       "    fmt_picker_span.append(fmt_picker);\n",
-       "    nav_element.append(fmt_picker_span);\n",
-       "    this.format_dropdown = fmt_picker[0];\n",
-       "\n",
-       "    for (var ind in mpl.extensions) {\n",
-       "        var fmt = mpl.extensions[ind];\n",
-       "        var option = $(\n",
-       "            '<option/>', {selected: fmt === mpl.default_extension}).html(fmt);\n",
-       "        fmt_picker.append(option)\n",
-       "    }\n",
-       "\n",
-       "    // Add hover states to the ui-buttons\n",
-       "    $( \".ui-button\" ).hover(\n",
-       "        function() { $(this).addClass(\"ui-state-hover\");},\n",
-       "        function() { $(this).removeClass(\"ui-state-hover\");}\n",
-       "    );\n",
-       "\n",
-       "    var status_bar = $('<span class=\"mpl-message\"/>');\n",
-       "    nav_element.append(status_bar);\n",
-       "    this.message = status_bar[0];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.request_resize = function(x_pixels, y_pixels) {\n",
-       "    // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n",
-       "    // which will in turn request a refresh of the image.\n",
-       "    this.send_message('resize', {'width': x_pixels, 'height': y_pixels});\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.send_message = function(type, properties) {\n",
-       "    properties['type'] = type;\n",
-       "    properties['figure_id'] = this.id;\n",
-       "    this.ws.send(JSON.stringify(properties));\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.send_draw_message = function() {\n",
-       "    if (!this.waiting) {\n",
-       "        this.waiting = true;\n",
-       "        this.ws.send(JSON.stringify({type: \"draw\", figure_id: this.id}));\n",
-       "    }\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype.handle_save = function(fig, msg) {\n",
-       "    var format_dropdown = fig.format_dropdown;\n",
-       "    var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n",
-       "    fig.ondownload(fig, format);\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype.handle_resize = function(fig, msg) {\n",
-       "    var size = msg['size'];\n",
-       "    if (size[0] != fig.canvas.width || size[1] != fig.canvas.height) {\n",
-       "        fig._resize_canvas(size[0], size[1]);\n",
-       "        fig.send_message(\"refresh\", {});\n",
-       "    };\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_rubberband = function(fig, msg) {\n",
-       "    var x0 = msg['x0'] / mpl.ratio;\n",
-       "    var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n",
-       "    var x1 = msg['x1'] / mpl.ratio;\n",
-       "    var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n",
-       "    x0 = Math.floor(x0) + 0.5;\n",
-       "    y0 = Math.floor(y0) + 0.5;\n",
-       "    x1 = Math.floor(x1) + 0.5;\n",
-       "    y1 = Math.floor(y1) + 0.5;\n",
-       "    var min_x = Math.min(x0, x1);\n",
-       "    var min_y = Math.min(y0, y1);\n",
-       "    var width = Math.abs(x1 - x0);\n",
-       "    var height = Math.abs(y1 - y0);\n",
-       "\n",
-       "    fig.rubberband_context.clearRect(\n",
-       "        0, 0, fig.canvas.width, fig.canvas.height);\n",
-       "\n",
-       "    fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_figure_label = function(fig, msg) {\n",
-       "    // Updates the figure title.\n",
-       "    fig.header.textContent = msg['label'];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_cursor = function(fig, msg) {\n",
-       "    var cursor = msg['cursor'];\n",
-       "    switch(cursor)\n",
-       "    {\n",
-       "    case 0:\n",
-       "        cursor = 'pointer';\n",
-       "        break;\n",
-       "    case 1:\n",
-       "        cursor = 'default';\n",
-       "        break;\n",
-       "    case 2:\n",
-       "        cursor = 'crosshair';\n",
-       "        break;\n",
-       "    case 3:\n",
-       "        cursor = 'move';\n",
-       "        break;\n",
-       "    }\n",
-       "    fig.rubberband_canvas.style.cursor = cursor;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_message = function(fig, msg) {\n",
-       "    fig.message.textContent = msg['message'];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_draw = function(fig, msg) {\n",
-       "    // Request the server to send over a new figure.\n",
-       "    fig.send_draw_message();\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_image_mode = function(fig, msg) {\n",
-       "    fig.image_mode = msg['mode'];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.updated_canvas_event = function() {\n",
-       "    // Called whenever the canvas gets updated.\n",
-       "    this.send_message(\"ack\", {});\n",
-       "}\n",
-       "\n",
-       "// A function to construct a web socket function for onmessage handling.\n",
-       "// Called in the figure constructor.\n",
-       "mpl.figure.prototype._make_on_message_function = function(fig) {\n",
-       "    return function socket_on_message(evt) {\n",
-       "        if (evt.data instanceof Blob) {\n",
-       "            /* FIXME: We get \"Resource interpreted as Image but\n",
-       "             * transferred with MIME type text/plain:\" errors on\n",
-       "             * Chrome.  But how to set the MIME type?  It doesn't seem\n",
-       "             * to be part of the websocket stream */\n",
-       "            evt.data.type = \"image/png\";\n",
-       "\n",
-       "            /* Free the memory for the previous frames */\n",
-       "            if (fig.imageObj.src) {\n",
-       "                (window.URL || window.webkitURL).revokeObjectURL(\n",
-       "                    fig.imageObj.src);\n",
-       "            }\n",
-       "\n",
-       "            fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n",
-       "                evt.data);\n",
-       "            fig.updated_canvas_event();\n",
-       "            fig.waiting = false;\n",
-       "            return;\n",
-       "        }\n",
-       "        else if (typeof evt.data === 'string' && evt.data.slice(0, 21) == \"data:image/png;base64\") {\n",
-       "            fig.imageObj.src = evt.data;\n",
-       "            fig.updated_canvas_event();\n",
-       "            fig.waiting = false;\n",
-       "            return;\n",
-       "        }\n",
-       "\n",
-       "        var msg = JSON.parse(evt.data);\n",
-       "        var msg_type = msg['type'];\n",
-       "\n",
-       "        // Call the  \"handle_{type}\" callback, which takes\n",
-       "        // the figure and JSON message as its only arguments.\n",
-       "        try {\n",
-       "            var callback = fig[\"handle_\" + msg_type];\n",
-       "        } catch (e) {\n",
-       "            console.log(\"No handler for the '\" + msg_type + \"' message type: \", msg);\n",
-       "            return;\n",
-       "        }\n",
-       "\n",
-       "        if (callback) {\n",
-       "            try {\n",
-       "                // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n",
-       "                callback(fig, msg);\n",
-       "            } catch (e) {\n",
-       "                console.log(\"Exception inside the 'handler_\" + msg_type + \"' callback:\", e, e.stack, msg);\n",
-       "            }\n",
-       "        }\n",
-       "    };\n",
-       "}\n",
-       "\n",
-       "// from http://stackoverflow.com/questions/1114465/getting-mouse-location-in-canvas\n",
-       "mpl.findpos = function(e) {\n",
-       "    //this section is from http://www.quirksmode.org/js/events_properties.html\n",
-       "    var targ;\n",
-       "    if (!e)\n",
-       "        e = window.event;\n",
-       "    if (e.target)\n",
-       "        targ = e.target;\n",
-       "    else if (e.srcElement)\n",
-       "        targ = e.srcElement;\n",
-       "    if (targ.nodeType == 3) // defeat Safari bug\n",
-       "        targ = targ.parentNode;\n",
-       "\n",
-       "    // jQuery normalizes the pageX and pageY\n",
-       "    // pageX,Y are the mouse positions relative to the document\n",
-       "    // offset() returns the position of the element relative to the document\n",
-       "    var x = e.pageX - $(targ).offset().left;\n",
-       "    var y = e.pageY - $(targ).offset().top;\n",
-       "\n",
-       "    return {\"x\": x, \"y\": y};\n",
-       "};\n",
-       "\n",
-       "/*\n",
-       " * return a copy of an object with only non-object keys\n",
-       " * we need this to avoid circular references\n",
-       " * http://stackoverflow.com/a/24161582/3208463\n",
-       " */\n",
-       "function simpleKeys (original) {\n",
-       "  return Object.keys(original).reduce(function (obj, key) {\n",
-       "    if (typeof original[key] !== 'object')\n",
-       "        obj[key] = original[key]\n",
-       "    return obj;\n",
-       "  }, {});\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.mouse_event = function(event, name) {\n",
-       "    var canvas_pos = mpl.findpos(event)\n",
-       "\n",
-       "    if (name === 'button_press')\n",
-       "    {\n",
-       "        this.canvas.focus();\n",
-       "        this.canvas_div.focus();\n",
-       "    }\n",
-       "\n",
-       "    var x = canvas_pos.x * mpl.ratio;\n",
-       "    var y = canvas_pos.y * mpl.ratio;\n",
-       "\n",
-       "    this.send_message(name, {x: x, y: y, button: event.button,\n",
-       "                             step: event.step,\n",
-       "                             guiEvent: simpleKeys(event)});\n",
-       "\n",
-       "    /* This prevents the web browser from automatically changing to\n",
-       "     * the text insertion cursor when the button is pressed.  We want\n",
-       "     * to control all of the cursor setting manually through the\n",
-       "     * 'cursor' event from matplotlib */\n",
-       "    event.preventDefault();\n",
-       "    return false;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._key_event_extra = function(event, name) {\n",
-       "    // Handle any extra behaviour associated with a key event\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.key_event = function(event, name) {\n",
-       "\n",
-       "    // Prevent repeat events\n",
-       "    if (name == 'key_press')\n",
-       "    {\n",
-       "        if (event.which === this._key)\n",
-       "            return;\n",
-       "        else\n",
-       "            this._key = event.which;\n",
-       "    }\n",
-       "    if (name == 'key_release')\n",
-       "        this._key = null;\n",
-       "\n",
-       "    var value = '';\n",
-       "    if (event.ctrlKey && event.which != 17)\n",
-       "        value += \"ctrl+\";\n",
-       "    if (event.altKey && event.which != 18)\n",
-       "        value += \"alt+\";\n",
-       "    if (event.shiftKey && event.which != 16)\n",
-       "        value += \"shift+\";\n",
-       "\n",
-       "    value += 'k';\n",
-       "    value += event.which.toString();\n",
-       "\n",
-       "    this._key_event_extra(event, name);\n",
-       "\n",
-       "    this.send_message(name, {key: value,\n",
-       "                             guiEvent: simpleKeys(event)});\n",
-       "    return false;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.toolbar_button_onclick = function(name) {\n",
-       "    if (name == 'download') {\n",
-       "        this.handle_save(this, null);\n",
-       "    } else {\n",
-       "        this.send_message(\"toolbar_button\", {name: name});\n",
-       "    }\n",
-       "};\n",
-       "\n",
-       "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n",
-       "    this.message.textContent = tooltip;\n",
-       "};\n",
-       "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to  previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\" [...]
-       "\n",
-       "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n",
-       "\n",
-       "mpl.default_extension = \"png\";var comm_websocket_adapter = function(comm) {\n",
-       "    // Create a \"websocket\"-like object which calls the given IPython comm\n",
-       "    // object with the appropriate methods. Currently this is a non binary\n",
-       "    // socket, so there is still some room for performance tuning.\n",
-       "    var ws = {};\n",
-       "\n",
-       "    ws.close = function() {\n",
-       "        comm.close()\n",
-       "    };\n",
-       "    ws.send = function(m) {\n",
-       "        //console.log('sending', m);\n",
-       "        comm.send(m);\n",
-       "    };\n",
-       "    // Register the callback with on_msg.\n",
-       "    comm.on_msg(function(msg) {\n",
-       "        //console.log('receiving', msg['content']['data'], msg);\n",
-       "        // Pass the mpl event to the overridden (by mpl) onmessage function.\n",
-       "        ws.onmessage(msg['content']['data'])\n",
-       "    });\n",
-       "    return ws;\n",
-       "}\n",
-       "\n",
-       "mpl.mpl_figure_comm = function(comm, msg) {\n",
-       "    // This is the function which gets called when the mpl process\n",
-       "    // starts-up an IPython Comm through the \"matplotlib\" channel.\n",
-       "\n",
-       "    var id = msg.content.data.id;\n",
-       "    // Get hold of the div created by the display call when the Comm\n",
-       "    // socket was opened in Python.\n",
-       "    var element = $(\"#\" + id);\n",
-       "    var ws_proxy = comm_websocket_adapter(comm)\n",
-       "\n",
-       "    function ondownload(figure, format) {\n",
-       "        window.open(figure.imageObj.src);\n",
-       "    }\n",
-       "\n",
-       "    var fig = new mpl.figure(id, ws_proxy,\n",
-       "                           ondownload,\n",
-       "                           element.get(0));\n",
-       "\n",
-       "    // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n",
-       "    // web socket which is closed, not our websocket->open comm proxy.\n",
-       "    ws_proxy.onopen();\n",
-       "\n",
-       "    fig.parent_element = element.get(0);\n",
-       "    fig.cell_info = mpl.find_output_cell(\"<div id='\" + id + \"'></div>\");\n",
-       "    if (!fig.cell_info) {\n",
-       "        console.error(\"Failed to find cell for figure\", id, fig);\n",
-       "        return;\n",
-       "    }\n",
-       "\n",
-       "    var output_index = fig.cell_info[2]\n",
-       "    var cell = fig.cell_info[0];\n",
-       "\n",
-       "};\n",
-       "\n",
-       "mpl.figure.prototype.handle_close = function(fig, msg) {\n",
-       "    var width = fig.canvas.width/mpl.ratio\n",
-       "    fig.root.unbind('remove')\n",
-       "\n",
-       "    // Update the output cell to use the data from the current canvas.\n",
-       "    fig.push_to_output();\n",
-       "    var dataURL = fig.canvas.toDataURL();\n",
-       "    // Re-enable the keyboard manager in IPython - without this line, in FF,\n",
-       "    // the notebook keyboard shortcuts fail.\n",
-       "    IPython.keyboard_manager.enable()\n",
-       "    $(fig.parent_element).html('<img src=\"' + dataURL + '\" width=\"' + width + '\">');\n",
-       "    fig.close_ws(fig, msg);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.close_ws = function(fig, msg){\n",
-       "    fig.send_message('closing', msg);\n",
-       "    // fig.ws.close()\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.push_to_output = function(remove_interactive) {\n",
-       "    // Turn the data on the canvas into data in the output cell.\n",
-       "    var width = this.canvas.width/mpl.ratio\n",
-       "    var dataURL = this.canvas.toDataURL();\n",
-       "    this.cell_info[1]['text/html'] = '<img src=\"' + dataURL + '\" width=\"' + width + '\">';\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.updated_canvas_event = function() {\n",
-       "    // Tell IPython that the notebook contents must change.\n",
-       "    IPython.notebook.set_dirty(true);\n",
-       "    this.send_message(\"ack\", {});\n",
-       "    var fig = this;\n",
-       "    // Wait a second, then push the new image to the DOM so\n",
-       "    // that it is saved nicely (might be nice to debounce this).\n",
-       "    setTimeout(function () { fig.push_to_output() }, 1000);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_toolbar = function() {\n",
-       "    var fig = this;\n",
-       "\n",
-       "    var nav_element = $('<div/>')\n",
-       "    nav_element.attr('style', 'width: 100%');\n",
-       "    this.root.append(nav_element);\n",
-       "\n",
-       "    // Define a callback function for later on.\n",
-       "    function toolbar_event(event) {\n",
-       "        return fig.toolbar_button_onclick(event['data']);\n",
-       "    }\n",
-       "    function toolbar_mouse_event(event) {\n",
-       "        return fig.toolbar_button_onmouseover(event['data']);\n",
-       "    }\n",
-       "\n",
-       "    for(var toolbar_ind in mpl.toolbar_items){\n",
-       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
-       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
-       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
-       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
-       "\n",
-       "        if (!name) { continue; };\n",
-       "\n",
-       "        var button = $('<button class=\"btn btn-default\" href=\"#\" title=\"' + name + '\"><i class=\"fa ' + image + ' fa-lg\"></i></button>');\n",
-       "        button.click(method_name, toolbar_event);\n",
-       "        button.mouseover(tooltip, toolbar_mouse_event);\n",
-       "        nav_element.append(button);\n",
-       "    }\n",
-       "\n",
-       "    // Add the status bar.\n",
-       "    var status_bar = $('<span class=\"mpl-message\" style=\"text-align:right; float: right;\"/>');\n",
-       "    nav_element.append(status_bar);\n",
-       "    this.message = status_bar[0];\n",
-       "\n",
-       "    // Add the close button to the window.\n",
-       "    var buttongrp = $('<div class=\"btn-group inline pull-right\"></div>');\n",
-       "    var button = $('<button class=\"btn btn-mini btn-primary\" href=\"#\" title=\"Stop Interaction\"><i class=\"fa fa-power-off icon-remove icon-large\"></i></button>');\n",
-       "    button.click(function (evt) { fig.handle_close(fig, {}); } );\n",
-       "    button.mouseover('Stop Interaction', toolbar_mouse_event);\n",
-       "    buttongrp.append(button);\n",
-       "    var titlebar = this.root.find($('.ui-dialog-titlebar'));\n",
-       "    titlebar.prepend(buttongrp);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._root_extra_style = function(el){\n",
-       "    var fig = this\n",
-       "    el.on(\"remove\", function(){\n",
-       "\tfig.close_ws(fig, {});\n",
-       "    });\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._canvas_extra_style = function(el){\n",
-       "    // this is important to make the div 'focusable\n",
-       "    el.attr('tabindex', 0)\n",
-       "    // reach out to IPython and tell the keyboard manager to turn it's self\n",
-       "    // off when our div gets focus\n",
-       "\n",
-       "    // location in version 3\n",
-       "    if (IPython.notebook.keyboard_manager) {\n",
-       "        IPython.notebook.keyboard_manager.register_events(el);\n",
-       "    }\n",
-       "    else {\n",
-       "        // location in version 2\n",
-       "        IPython.keyboard_manager.register_events(el);\n",
-       "    }\n",
-       "\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._key_event_extra = function(event, name) {\n",
-       "    var manager = IPython.notebook.keyboard_manager;\n",
-       "    if (!manager)\n",
-       "        manager = IPython.keyboard_manager;\n",
-       "\n",
-       "    // Check for shift+enter\n",
-       "    if (event.shiftKey && event.which == 13) {\n",
-       "        this.canvas_div.blur();\n",
-       "        // select the cell after this one\n",
-       "        var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n",
-       "        IPython.notebook.select(index + 1);\n",
-       "    }\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_save = function(fig, msg) {\n",
-       "    fig.ondownload(fig, null);\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.find_output_cell = function(html_output) {\n",
-       "    // Return the cell and output element which can be found *uniquely* in the notebook.\n",
-       "    // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n",
-       "    // IPython event is triggered only after the cells have been serialised, which for\n",
-       "    // our purposes (turning an active figure into a static one), is too late.\n",
-       "    var cells = IPython.notebook.get_cells();\n",
-       "    var ncells = cells.length;\n",
-       "    for (var i=0; i<ncells; i++) {\n",
-       "        var cell = cells[i];\n",
-       "        if (cell.cell_type === 'code'){\n",
-       "            for (var j=0; j<cell.output_area.outputs.length; j++) {\n",
-       "                var data = cell.output_area.outputs[j];\n",
-       "                if (data.data) {\n",
-       "                    // IPython >= 3 moved mimebundle to data attribute of output\n",
-       "                    data = data.data;\n",
-       "                }\n",
-       "                if (data['text/html'] == html_output) {\n",
-       "                    return [cell, data, j];\n",
-       "                }\n",
-       "            }\n",
-       "        }\n",
-       "    }\n",
-       "}\n",
-       "\n",
-       "// Register the function which deals with the matplotlib target/channel.\n",
-       "// The kernel may be null if the page has been refreshed.\n",
-       "if (IPython.notebook.kernel != null) {\n",
-       "    IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n",
-       "}\n"
-      ],
-      "text/plain": [
-       "<IPython.core.display.Javascript object>"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/html": [
-       "<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABDgAAAIcCAYAAAAT/R6VAAAgAElEQVR4XuydB3hc1Zn+3ynqXbJkFVvFXe4V3LBNCc1AQkI1KYRUIG2TzWZTNiHZJCT8N7ubZGFDQkkBJxAWCJhiim1cwLj3KtuyLcmyetdoNOX/vHfulUbjGU3RzOiO9J3nMSOkc+8553ePdL/73q8YIE0ICAEhIASEgBAQAkJACAgBISAEhIAQEAIxTsAQ4/OX6QsBISAEhIAQEAJCQAgIASEgBISAEBACQgAicMgmGK0EnCEs/LMA/hjCcYEe8hUAvwXwKAB+PdT2AoBPALgdAL/We5sJ4KA6yT8BuFfvE5b5CQEhIASEAOR+OvybIBVAuzqNXAANwz+lsM/ACGAXgBwAUwD0eBmBfe4EcBuARQDIgvuzBsAOAM8BeEX9XtgnqIMTuttRg01nG4D [...]
-      ],
-      "text/plain": [
-       "<IPython.core.display.HTML object>"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "<matplotlib.legend.Legend at 0x154945910>"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,21,'Iteration')"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,1,'Training Accuracy')"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,21,'Iteration')"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,1,'Training Loss (Cross Entropy)')"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156a53950>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156a331d0>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156a5f250>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156a45e90>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156a5f310>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156a82290>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156a827d0>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156a82d10>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156a82790>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156a45dd0>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156a97610>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156a97b50>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156aa40d0>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156a97b10>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156aa4110>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156aa4990>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "application/javascript": [
-       "/* Put everything inside the global mpl namespace */\n",
-       "window.mpl = {};\n",
-       "\n",
-       "\n",
-       "mpl.get_websocket_type = function() {\n",
-       "    if (typeof(WebSocket) !== 'undefined') {\n",
-       "        return WebSocket;\n",
-       "    } else if (typeof(MozWebSocket) !== 'undefined') {\n",
-       "        return MozWebSocket;\n",
-       "    } else {\n",
-       "        alert('Your browser does not have WebSocket support.' +\n",
-       "              'Please try Chrome, Safari or Firefox ≥ 6. ' +\n",
-       "              'Firefox 4 and 5 are also supported but you ' +\n",
-       "              'have to enable WebSockets in about:config.');\n",
-       "    };\n",
-       "}\n",
-       "\n",
-       "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n",
-       "    this.id = figure_id;\n",
-       "\n",
-       "    this.ws = websocket;\n",
-       "\n",
-       "    this.supports_binary = (this.ws.binaryType != undefined);\n",
-       "\n",
-       "    if (!this.supports_binary) {\n",
-       "        var warnings = document.getElementById(\"mpl-warnings\");\n",
-       "        if (warnings) {\n",
-       "            warnings.style.display = 'block';\n",
-       "            warnings.textContent = (\n",
-       "                \"This browser does not support binary websocket messages. \" +\n",
-       "                    \"Performance may be slow.\");\n",
-       "        }\n",
-       "    }\n",
-       "\n",
-       "    this.imageObj = new Image();\n",
-       "\n",
-       "    this.context = undefined;\n",
-       "    this.message = undefined;\n",
-       "    this.canvas = undefined;\n",
-       "    this.rubberband_canvas = undefined;\n",
-       "    this.rubberband_context = undefined;\n",
-       "    this.format_dropdown = undefined;\n",
-       "\n",
-       "    this.image_mode = 'full';\n",
-       "\n",
-       "    this.root = $('<div/>');\n",
-       "    this._root_extra_style(this.root)\n",
-       "    this.root.attr('style', 'display: inline-block');\n",
-       "\n",
-       "    $(parent_element).append(this.root);\n",
-       "\n",
-       "    this._init_header(this);\n",
-       "    this._init_canvas(this);\n",
-       "    this._init_toolbar(this);\n",
-       "\n",
-       "    var fig = this;\n",
-       "\n",
-       "    this.waiting = false;\n",
-       "\n",
-       "    this.ws.onopen =  function () {\n",
-       "            fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n",
-       "            fig.send_message(\"send_image_mode\", {});\n",
-       "            if (mpl.ratio != 1) {\n",
-       "                fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n",
-       "            }\n",
-       "            fig.send_message(\"refresh\", {});\n",
-       "        }\n",
-       "\n",
-       "    this.imageObj.onload = function() {\n",
-       "            if (fig.image_mode == 'full') {\n",
-       "                // Full images could contain transparency (where diff images\n",
-       "                // almost always do), so we need to clear the canvas so that\n",
-       "                // there is no ghosting.\n",
-       "                fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n",
-       "            }\n",
-       "            fig.context.drawImage(fig.imageObj, 0, 0);\n",
-       "        };\n",
-       "\n",
-       "    this.imageObj.onunload = function() {\n",
-       "        fig.ws.close();\n",
-       "    }\n",
-       "\n",
-       "    this.ws.onmessage = this._make_on_message_function(this);\n",
-       "\n",
-       "    this.ondownload = ondownload;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_header = function() {\n",
-       "    var titlebar = $(\n",
-       "        '<div class=\"ui-dialog-titlebar ui-widget-header ui-corner-all ' +\n",
-       "        'ui-helper-clearfix\"/>');\n",
-       "    var titletext = $(\n",
-       "        '<div class=\"ui-dialog-title\" style=\"width: 100%; ' +\n",
-       "        'text-align: center; padding: 3px;\"/>');\n",
-       "    titlebar.append(titletext)\n",
-       "    this.root.append(titlebar);\n",
-       "    this.header = titletext[0];\n",
-       "}\n",
-       "\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n",
-       "\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n",
-       "\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_canvas = function() {\n",
-       "    var fig = this;\n",
-       "\n",
-       "    var canvas_div = $('<div/>');\n",
-       "\n",
-       "    canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n",
-       "\n",
-       "    function canvas_keyboard_event(event) {\n",
-       "        return fig.key_event(event, event['data']);\n",
-       "    }\n",
-       "\n",
-       "    canvas_div.keydown('key_press', canvas_keyboard_event);\n",
-       "    canvas_div.keyup('key_release', canvas_keyboard_event);\n",
-       "    this.canvas_div = canvas_div\n",
-       "    this._canvas_extra_style(canvas_div)\n",
-       "    this.root.append(canvas_div);\n",
-       "\n",
-       "    var canvas = $('<canvas/>');\n",
-       "    canvas.addClass('mpl-canvas');\n",
-       "    canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n",
-       "\n",
-       "    this.canvas = canvas[0];\n",
-       "    this.context = canvas[0].getContext(\"2d\");\n",
-       "\n",
-       "    var backingStore = this.context.backingStorePixelRatio ||\n",
-       "\tthis.context.webkitBackingStorePixelRatio ||\n",
-       "\tthis.context.mozBackingStorePixelRatio ||\n",
-       "\tthis.context.msBackingStorePixelRatio ||\n",
-       "\tthis.context.oBackingStorePixelRatio ||\n",
-       "\tthis.context.backingStorePixelRatio || 1;\n",
-       "\n",
-       "    mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n",
-       "\n",
-       "    var rubberband = $('<canvas/>');\n",
-       "    rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n",
-       "\n",
-       "    var pass_mouse_events = true;\n",
-       "\n",
-       "    canvas_div.resizable({\n",
-       "        start: function(event, ui) {\n",
-       "            pass_mouse_events = false;\n",
-       "        },\n",
-       "        resize: function(event, ui) {\n",
-       "            fig.request_resize(ui.size.width, ui.size.height);\n",
-       "        },\n",
-       "        stop: function(event, ui) {\n",
-       "            pass_mouse_events = true;\n",
-       "            fig.request_resize(ui.size.width, ui.size.height);\n",
-       "        },\n",
-       "    });\n",
-       "\n",
-       "    function mouse_event_fn(event) {\n",
-       "        if (pass_mouse_events)\n",
-       "            return fig.mouse_event(event, event['data']);\n",
-       "    }\n",
-       "\n",
-       "    rubberband.mousedown('button_press', mouse_event_fn);\n",
-       "    rubberband.mouseup('button_release', mouse_event_fn);\n",
-       "    // Throttle sequential mouse events to 1 every 20ms.\n",
-       "    rubberband.mousemove('motion_notify', mouse_event_fn);\n",
-       "\n",
-       "    rubberband.mouseenter('figure_enter', mouse_event_fn);\n",
-       "    rubberband.mouseleave('figure_leave', mouse_event_fn);\n",
-       "\n",
-       "    canvas_div.on(\"wheel\", function (event) {\n",
-       "        event = event.originalEvent;\n",
-       "        event['data'] = 'scroll'\n",
-       "        if (event.deltaY < 0) {\n",
-       "            event.step = 1;\n",
-       "        } else {\n",
-       "            event.step = -1;\n",
-       "        }\n",
-       "        mouse_event_fn(event);\n",
-       "    });\n",
-       "\n",
-       "    canvas_div.append(canvas);\n",
-       "    canvas_div.append(rubberband);\n",
-       "\n",
-       "    this.rubberband = rubberband;\n",
-       "    this.rubberband_canvas = rubberband[0];\n",
-       "    this.rubberband_context = rubberband[0].getContext(\"2d\");\n",
-       "    this.rubberband_context.strokeStyle = \"#000000\";\n",
-       "\n",
-       "    this._resize_canvas = function(width, height) {\n",
-       "        // Keep the size of the canvas, canvas container, and rubber band\n",
-       "        // canvas in synch.\n",
-       "        canvas_div.css('width', width)\n",
-       "        canvas_div.css('height', height)\n",
-       "\n",
-       "        canvas.attr('width', width * mpl.ratio);\n",
-       "        canvas.attr('height', height * mpl.ratio);\n",
-       "        canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n",
-       "\n",
-       "        rubberband.attr('width', width);\n",
-       "        rubberband.attr('height', height);\n",
-       "    }\n",
-       "\n",
-       "    // Set the figure to an initial 600x600px, this will subsequently be updated\n",
-       "    // upon first draw.\n",
-       "    this._resize_canvas(600, 600);\n",
-       "\n",
-       "    // Disable right mouse context menu.\n",
-       "    $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n",
-       "        return false;\n",
-       "    });\n",
-       "\n",
-       "    function set_focus () {\n",
-       "        canvas.focus();\n",
-       "        canvas_div.focus();\n",
-       "    }\n",
-       "\n",
-       "    window.setTimeout(set_focus, 100);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_toolbar = function() {\n",
-       "    var fig = this;\n",
-       "\n",
-       "    var nav_element = $('<div/>')\n",
-       "    nav_element.attr('style', 'width: 100%');\n",
-       "    this.root.append(nav_element);\n",
-       "\n",
-       "    // Define a callback function for later on.\n",
-       "    function toolbar_event(event) {\n",
-       "        return fig.toolbar_button_onclick(event['data']);\n",
-       "    }\n",
-       "    function toolbar_mouse_event(event) {\n",
-       "        return fig.toolbar_button_onmouseover(event['data']);\n",
-       "    }\n",
-       "\n",
-       "    for(var toolbar_ind in mpl.toolbar_items) {\n",
-       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
-       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
-       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
-       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
-       "\n",
-       "        if (!name) {\n",
-       "            // put a spacer in here.\n",
-       "            continue;\n",
-       "        }\n",
-       "        var button = $('<button/>');\n",
-       "        button.addClass('ui-button ui-widget ui-state-default ui-corner-all ' +\n",
-       "                        'ui-button-icon-only');\n",
-       "        button.attr('role', 'button');\n",
-       "        button.attr('aria-disabled', 'false');\n",
-       "        button.click(method_name, toolbar_event);\n",
-       "        button.mouseover(tooltip, toolbar_mouse_event);\n",
-       "\n",
-       "        var icon_img = $('<span/>');\n",
-       "        icon_img.addClass('ui-button-icon-primary ui-icon');\n",
-       "        icon_img.addClass(image);\n",
-       "        icon_img.addClass('ui-corner-all');\n",
-       "\n",
-       "        var tooltip_span = $('<span/>');\n",
-       "        tooltip_span.addClass('ui-button-text');\n",
-       "        tooltip_span.html(tooltip);\n",
-       "\n",
-       "        button.append(icon_img);\n",
-       "        button.append(tooltip_span);\n",
-       "\n",
-       "        nav_element.append(button);\n",
-       "    }\n",
-       "\n",
-       "    var fmt_picker_span = $('<span/>');\n",
-       "\n",
-       "    var fmt_picker = $('<select/>');\n",
-       "    fmt_picker.addClass('mpl-toolbar-option ui-widget ui-widget-content');\n",
-       "    fmt_picker_span.append(fmt_picker);\n",
-       "    nav_element.append(fmt_picker_span);\n",
-       "    this.format_dropdown = fmt_picker[0];\n",
-       "\n",
-       "    for (var ind in mpl.extensions) {\n",
-       "        var fmt = mpl.extensions[ind];\n",
-       "        var option = $(\n",
-       "            '<option/>', {selected: fmt === mpl.default_extension}).html(fmt);\n",
-       "        fmt_picker.append(option)\n",
-       "    }\n",
-       "\n",
-       "    // Add hover states to the ui-buttons\n",
-       "    $( \".ui-button\" ).hover(\n",
-       "        function() { $(this).addClass(\"ui-state-hover\");},\n",
-       "        function() { $(this).removeClass(\"ui-state-hover\");}\n",
-       "    );\n",
-       "\n",
-       "    var status_bar = $('<span class=\"mpl-message\"/>');\n",
-       "    nav_element.append(status_bar);\n",
-       "    this.message = status_bar[0];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.request_resize = function(x_pixels, y_pixels) {\n",
-       "    // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n",
-       "    // which will in turn request a refresh of the image.\n",
-       "    this.send_message('resize', {'width': x_pixels, 'height': y_pixels});\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.send_message = function(type, properties) {\n",
-       "    properties['type'] = type;\n",
-       "    properties['figure_id'] = this.id;\n",
-       "    this.ws.send(JSON.stringify(properties));\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.send_draw_message = function() {\n",
-       "    if (!this.waiting) {\n",
-       "        this.waiting = true;\n",
-       "        this.ws.send(JSON.stringify({type: \"draw\", figure_id: this.id}));\n",
-       "    }\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype.handle_save = function(fig, msg) {\n",
-       "    var format_dropdown = fig.format_dropdown;\n",
-       "    var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n",
-       "    fig.ondownload(fig, format);\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype.handle_resize = function(fig, msg) {\n",
-       "    var size = msg['size'];\n",
-       "    if (size[0] != fig.canvas.width || size[1] != fig.canvas.height) {\n",
-       "        fig._resize_canvas(size[0], size[1]);\n",
-       "        fig.send_message(\"refresh\", {});\n",
-       "    };\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_rubberband = function(fig, msg) {\n",
-       "    var x0 = msg['x0'] / mpl.ratio;\n",
-       "    var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n",
-       "    var x1 = msg['x1'] / mpl.ratio;\n",
-       "    var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n",
-       "    x0 = Math.floor(x0) + 0.5;\n",
-       "    y0 = Math.floor(y0) + 0.5;\n",
-       "    x1 = Math.floor(x1) + 0.5;\n",
-       "    y1 = Math.floor(y1) + 0.5;\n",
-       "    var min_x = Math.min(x0, x1);\n",
-       "    var min_y = Math.min(y0, y1);\n",
-       "    var width = Math.abs(x1 - x0);\n",
-       "    var height = Math.abs(y1 - y0);\n",
-       "\n",
-       "    fig.rubberband_context.clearRect(\n",
-       "        0, 0, fig.canvas.width, fig.canvas.height);\n",
-       "\n",
-       "    fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_figure_label = function(fig, msg) {\n",
-       "    // Updates the figure title.\n",
-       "    fig.header.textContent = msg['label'];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_cursor = function(fig, msg) {\n",
-       "    var cursor = msg['cursor'];\n",
-       "    switch(cursor)\n",
-       "    {\n",
-       "    case 0:\n",
-       "        cursor = 'pointer';\n",
-       "        break;\n",
-       "    case 1:\n",
-       "        cursor = 'default';\n",
-       "        break;\n",
-       "    case 2:\n",
-       "        cursor = 'crosshair';\n",
-       "        break;\n",
-       "    case 3:\n",
-       "        cursor = 'move';\n",
-       "        break;\n",
-       "    }\n",
-       "    fig.rubberband_canvas.style.cursor = cursor;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_message = function(fig, msg) {\n",
-       "    fig.message.textContent = msg['message'];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_draw = function(fig, msg) {\n",
-       "    // Request the server to send over a new figure.\n",
-       "    fig.send_draw_message();\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_image_mode = function(fig, msg) {\n",
-       "    fig.image_mode = msg['mode'];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.updated_canvas_event = function() {\n",
-       "    // Called whenever the canvas gets updated.\n",
-       "    this.send_message(\"ack\", {});\n",
-       "}\n",
-       "\n",
-       "// A function to construct a web socket function for onmessage handling.\n",
-       "// Called in the figure constructor.\n",
-       "mpl.figure.prototype._make_on_message_function = function(fig) {\n",
-       "    return function socket_on_message(evt) {\n",
-       "        if (evt.data instanceof Blob) {\n",
-       "            /* FIXME: We get \"Resource interpreted as Image but\n",
-       "             * transferred with MIME type text/plain:\" errors on\n",
-       "             * Chrome.  But how to set the MIME type?  It doesn't seem\n",
-       "             * to be part of the websocket stream */\n",
-       "            evt.data.type = \"image/png\";\n",
-       "\n",
-       "            /* Free the memory for the previous frames */\n",
-       "            if (fig.imageObj.src) {\n",
-       "                (window.URL || window.webkitURL).revokeObjectURL(\n",
-       "                    fig.imageObj.src);\n",
-       "            }\n",
-       "\n",
-       "            fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n",
-       "                evt.data);\n",
-       "            fig.updated_canvas_event();\n",
-       "            fig.waiting = false;\n",
-       "            return;\n",
-       "        }\n",
-       "        else if (typeof evt.data === 'string' && evt.data.slice(0, 21) == \"data:image/png;base64\") {\n",
-       "            fig.imageObj.src = evt.data;\n",
-       "            fig.updated_canvas_event();\n",
-       "            fig.waiting = false;\n",
-       "            return;\n",
-       "        }\n",
-       "\n",
-       "        var msg = JSON.parse(evt.data);\n",
-       "        var msg_type = msg['type'];\n",
-       "\n",
-       "        // Call the  \"handle_{type}\" callback, which takes\n",
-       "        // the figure and JSON message as its only arguments.\n",
-       "        try {\n",
-       "            var callback = fig[\"handle_\" + msg_type];\n",
-       "        } catch (e) {\n",
-       "            console.log(\"No handler for the '\" + msg_type + \"' message type: \", msg);\n",
-       "            return;\n",
-       "        }\n",
-       "\n",
-       "        if (callback) {\n",
-       "            try {\n",
-       "                // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n",
-       "                callback(fig, msg);\n",
-       "            } catch (e) {\n",
-       "                console.log(\"Exception inside the 'handler_\" + msg_type + \"' callback:\", e, e.stack, msg);\n",
-       "            }\n",
-       "        }\n",
-       "    };\n",
-       "}\n",
-       "\n",
-       "// from http://stackoverflow.com/questions/1114465/getting-mouse-location-in-canvas\n",
-       "mpl.findpos = function(e) {\n",
-       "    //this section is from http://www.quirksmode.org/js/events_properties.html\n",
-       "    var targ;\n",
-       "    if (!e)\n",
-       "        e = window.event;\n",
-       "    if (e.target)\n",
-       "        targ = e.target;\n",
-       "    else if (e.srcElement)\n",
-       "        targ = e.srcElement;\n",
-       "    if (targ.nodeType == 3) // defeat Safari bug\n",
-       "        targ = targ.parentNode;\n",
-       "\n",
-       "    // jQuery normalizes the pageX and pageY\n",
-       "    // pageX,Y are the mouse positions relative to the document\n",
-       "    // offset() returns the position of the element relative to the document\n",
-       "    var x = e.pageX - $(targ).offset().left;\n",
-       "    var y = e.pageY - $(targ).offset().top;\n",
-       "\n",
-       "    return {\"x\": x, \"y\": y};\n",
-       "};\n",
-       "\n",
-       "/*\n",
-       " * return a copy of an object with only non-object keys\n",
-       " * we need this to avoid circular references\n",
-       " * http://stackoverflow.com/a/24161582/3208463\n",
-       " */\n",
-       "function simpleKeys (original) {\n",
-       "  return Object.keys(original).reduce(function (obj, key) {\n",
-       "    if (typeof original[key] !== 'object')\n",
-       "        obj[key] = original[key]\n",
-       "    return obj;\n",
-       "  }, {});\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.mouse_event = function(event, name) {\n",
-       "    var canvas_pos = mpl.findpos(event)\n",
-       "\n",
-       "    if (name === 'button_press')\n",
-       "    {\n",
-       "        this.canvas.focus();\n",
-       "        this.canvas_div.focus();\n",
-       "    }\n",
-       "\n",
-       "    var x = canvas_pos.x * mpl.ratio;\n",
-       "    var y = canvas_pos.y * mpl.ratio;\n",
-       "\n",
-       "    this.send_message(name, {x: x, y: y, button: event.button,\n",
-       "                             step: event.step,\n",
-       "                             guiEvent: simpleKeys(event)});\n",
-       "\n",
-       "    /* This prevents the web browser from automatically changing to\n",
-       "     * the text insertion cursor when the button is pressed.  We want\n",
-       "     * to control all of the cursor setting manually through the\n",
-       "     * 'cursor' event from matplotlib */\n",
-       "    event.preventDefault();\n",
-       "    return false;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._key_event_extra = function(event, name) {\n",
-       "    // Handle any extra behaviour associated with a key event\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.key_event = function(event, name) {\n",
-       "\n",
-       "    // Prevent repeat events\n",
-       "    if (name == 'key_press')\n",
-       "    {\n",
-       "        if (event.which === this._key)\n",
-       "            return;\n",
-       "        else\n",
-       "            this._key = event.which;\n",
-       "    }\n",
-       "    if (name == 'key_release')\n",
-       "        this._key = null;\n",
-       "\n",
-       "    var value = '';\n",
-       "    if (event.ctrlKey && event.which != 17)\n",
-       "        value += \"ctrl+\";\n",
-       "    if (event.altKey && event.which != 18)\n",
-       "        value += \"alt+\";\n",
-       "    if (event.shiftKey && event.which != 16)\n",
-       "        value += \"shift+\";\n",
-       "\n",
-       "    value += 'k';\n",
-       "    value += event.which.toString();\n",
-       "\n",
-       "    this._key_event_extra(event, name);\n",
-       "\n",
-       "    this.send_message(name, {key: value,\n",
-       "                             guiEvent: simpleKeys(event)});\n",
-       "    return false;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.toolbar_button_onclick = function(name) {\n",
-       "    if (name == 'download') {\n",
-       "        this.handle_save(this, null);\n",
-       "    } else {\n",
-       "        this.send_message(\"toolbar_button\", {name: name});\n",
-       "    }\n",
-       "};\n",
-       "\n",
-       "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n",
-       "    this.message.textContent = tooltip;\n",
-       "};\n",
-       "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to  previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\" [...]
-       "\n",
-       "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n",
-       "\n",
-       "mpl.default_extension = \"png\";var comm_websocket_adapter = function(comm) {\n",
-       "    // Create a \"websocket\"-like object which calls the given IPython comm\n",
-       "    // object with the appropriate methods. Currently this is a non binary\n",
-       "    // socket, so there is still some room for performance tuning.\n",
-       "    var ws = {};\n",
-       "\n",
-       "    ws.close = function() {\n",
-       "        comm.close()\n",
-       "    };\n",
-       "    ws.send = function(m) {\n",
-       "        //console.log('sending', m);\n",
-       "        comm.send(m);\n",
-       "    };\n",
-       "    // Register the callback with on_msg.\n",
-       "    comm.on_msg(function(msg) {\n",
-       "        //console.log('receiving', msg['content']['data'], msg);\n",
-       "        // Pass the mpl event to the overridden (by mpl) onmessage function.\n",
-       "        ws.onmessage(msg['content']['data'])\n",
-       "    });\n",
-       "    return ws;\n",
-       "}\n",
-       "\n",
-       "mpl.mpl_figure_comm = function(comm, msg) {\n",
-       "    // This is the function which gets called when the mpl process\n",
-       "    // starts-up an IPython Comm through the \"matplotlib\" channel.\n",
-       "\n",
-       "    var id = msg.content.data.id;\n",
-       "    // Get hold of the div created by the display call when the Comm\n",
-       "    // socket was opened in Python.\n",
-       "    var element = $(\"#\" + id);\n",
-       "    var ws_proxy = comm_websocket_adapter(comm)\n",
-       "\n",
-       "    function ondownload(figure, format) {\n",
-       "        window.open(figure.imageObj.src);\n",
-       "    }\n",
-       "\n",
-       "    var fig = new mpl.figure(id, ws_proxy,\n",
-       "                           ondownload,\n",
-       "                           element.get(0));\n",
-       "\n",
-       "    // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n",
-       "    // web socket which is closed, not our websocket->open comm proxy.\n",
-       "    ws_proxy.onopen();\n",
-       "\n",
-       "    fig.parent_element = element.get(0);\n",
-       "    fig.cell_info = mpl.find_output_cell(\"<div id='\" + id + \"'></div>\");\n",
-       "    if (!fig.cell_info) {\n",
-       "        console.error(\"Failed to find cell for figure\", id, fig);\n",
-       "        return;\n",
-       "    }\n",
-       "\n",
-       "    var output_index = fig.cell_info[2]\n",
-       "    var cell = fig.cell_info[0];\n",
-       "\n",
-       "};\n",
-       "\n",
-       "mpl.figure.prototype.handle_close = function(fig, msg) {\n",
-       "    var width = fig.canvas.width/mpl.ratio\n",
-       "    fig.root.unbind('remove')\n",
-       "\n",
-       "    // Update the output cell to use the data from the current canvas.\n",
-       "    fig.push_to_output();\n",
-       "    var dataURL = fig.canvas.toDataURL();\n",
-       "    // Re-enable the keyboard manager in IPython - without this line, in FF,\n",
-       "    // the notebook keyboard shortcuts fail.\n",
-       "    IPython.keyboard_manager.enable()\n",
-       "    $(fig.parent_element).html('<img src=\"' + dataURL + '\" width=\"' + width + '\">');\n",
-       "    fig.close_ws(fig, msg);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.close_ws = function(fig, msg){\n",
-       "    fig.send_message('closing', msg);\n",
-       "    // fig.ws.close()\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.push_to_output = function(remove_interactive) {\n",
-       "    // Turn the data on the canvas into data in the output cell.\n",
-       "    var width = this.canvas.width/mpl.ratio\n",
-       "    var dataURL = this.canvas.toDataURL();\n",
-       "    this.cell_info[1]['text/html'] = '<img src=\"' + dataURL + '\" width=\"' + width + '\">';\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.updated_canvas_event = function() {\n",
-       "    // Tell IPython that the notebook contents must change.\n",
-       "    IPython.notebook.set_dirty(true);\n",
-       "    this.send_message(\"ack\", {});\n",
-       "    var fig = this;\n",
-       "    // Wait a second, then push the new image to the DOM so\n",
-       "    // that it is saved nicely (might be nice to debounce this).\n",
-       "    setTimeout(function () { fig.push_to_output() }, 1000);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_toolbar = function() {\n",
-       "    var fig = this;\n",
-       "\n",
-       "    var nav_element = $('<div/>')\n",
-       "    nav_element.attr('style', 'width: 100%');\n",
-       "    this.root.append(nav_element);\n",
-       "\n",
-       "    // Define a callback function for later on.\n",
-       "    function toolbar_event(event) {\n",
-       "        return fig.toolbar_button_onclick(event['data']);\n",
-       "    }\n",
-       "    function toolbar_mouse_event(event) {\n",
-       "        return fig.toolbar_button_onmouseover(event['data']);\n",
-       "    }\n",
-       "\n",
-       "    for(var toolbar_ind in mpl.toolbar_items){\n",
-       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
-       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
-       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
-       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
-       "\n",
-       "        if (!name) { continue; };\n",
-       "\n",
-       "        var button = $('<button class=\"btn btn-default\" href=\"#\" title=\"' + name + '\"><i class=\"fa ' + image + ' fa-lg\"></i></button>');\n",
-       "        button.click(method_name, toolbar_event);\n",
-       "        button.mouseover(tooltip, toolbar_mouse_event);\n",
-       "        nav_element.append(button);\n",
-       "    }\n",
-       "\n",
-       "    // Add the status bar.\n",
-       "    var status_bar = $('<span class=\"mpl-message\" style=\"text-align:right; float: right;\"/>');\n",
-       "    nav_element.append(status_bar);\n",
-       "    this.message = status_bar[0];\n",
-       "\n",
-       "    // Add the close button to the window.\n",
-       "    var buttongrp = $('<div class=\"btn-group inline pull-right\"></div>');\n",
-       "    var button = $('<button class=\"btn btn-mini btn-primary\" href=\"#\" title=\"Stop Interaction\"><i class=\"fa fa-power-off icon-remove icon-large\"></i></button>');\n",
-       "    button.click(function (evt) { fig.handle_close(fig, {}); } );\n",
-       "    button.mouseover('Stop Interaction', toolbar_mouse_event);\n",
-       "    buttongrp.append(button);\n",
-       "    var titlebar = this.root.find($('.ui-dialog-titlebar'));\n",
-       "    titlebar.prepend(buttongrp);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._root_extra_style = function(el){\n",
-       "    var fig = this\n",
-       "    el.on(\"remove\", function(){\n",
-       "\tfig.close_ws(fig, {});\n",
-       "    });\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._canvas_extra_style = function(el){\n",
-       "    // this is important to make the div 'focusable\n",
-       "    el.attr('tabindex', 0)\n",
-       "    // reach out to IPython and tell the keyboard manager to turn it's self\n",
-       "    // off when our div gets focus\n",
-       "\n",
-       "    // location in version 3\n",
-       "    if (IPython.notebook.keyboard_manager) {\n",
-       "        IPython.notebook.keyboard_manager.register_events(el);\n",
-       "    }\n",
-       "    else {\n",
-       "        // location in version 2\n",
-       "        IPython.keyboard_manager.register_events(el);\n",
-       "    }\n",
-       "\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._key_event_extra = function(event, name) {\n",
-       "    var manager = IPython.notebook.keyboard_manager;\n",
-       "    if (!manager)\n",
-       "        manager = IPython.keyboard_manager;\n",
-       "\n",
-       "    // Check for shift+enter\n",
-       "    if (event.shiftKey && event.which == 13) {\n",
-       "        this.canvas_div.blur();\n",
-       "        // select the cell after this one\n",
-       "        var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n",
-       "        IPython.notebook.select(index + 1);\n",
-       "    }\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_save = function(fig, msg) {\n",
-       "    fig.ondownload(fig, null);\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.find_output_cell = function(html_output) {\n",
-       "    // Return the cell and output element which can be found *uniquely* in the notebook.\n",
-       "    // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n",
-       "    // IPython event is triggered only after the cells have been serialised, which for\n",
-       "    // our purposes (turning an active figure into a static one), is too late.\n",
-       "    var cells = IPython.notebook.get_cells();\n",
-       "    var ncells = cells.length;\n",
-       "    for (var i=0; i<ncells; i++) {\n",
-       "        var cell = cells[i];\n",
-       "        if (cell.cell_type === 'code'){\n",
-       "            for (var j=0; j<cell.output_area.outputs.length; j++) {\n",
-       "                var data = cell.output_area.outputs[j];\n",
-       "                if (data.data) {\n",
-       "                    // IPython >= 3 moved mimebundle to data attribute of output\n",
-       "                    data = data.data;\n",
-       "                }\n",
-       "                if (data['text/html'] == html_output) {\n",
-       "                    return [cell, data, j];\n",
-       "                }\n",
-       "            }\n",
-       "        }\n",
-       "    }\n",
-       "}\n",
-       "\n",
-       "// Register the function which deals with the matplotlib target/channel.\n",
-       "// The kernel may be null if the page has been refreshed.\n",
-       "if (IPython.notebook.kernel != null) {\n",
-       "    IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n",
-       "}\n"
-      ],
-      "text/plain": [
-       "<IPython.core.display.Javascript object>"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/html": [
-       "<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABDgAAAIcCAYAAAAT/R6VAAAgAElEQVR4XuydB3xV5fnHf/dm700SEhIS9kaGIKBgtaKgqHWv1rrrbJ3VWqvV1r2r/mttRRFXq6gouMGBIEvZKwSSELL3Tu74f37n3pPc3Iw7cm5ykjzv5xMSknPe877f9yTnOb/3GQZIEwJCQAgIASEgBISAEBACQkAICAEhIASEQD8nYOjn45fhCwEhIASEgBAQAkJACAgBISAEhIAQEAJCACJwyE0wWAlYvZj4bwEs9eI8d0+5EcDzAF4AwK972v4H4BwA5wHg13pvEwHssA/yNQCX633AMj4hIASEgBCAPE/7/iYIB1BjH0YCgNK+H5LmIzAC2AwgDsBoAE2dXIHHXADgXAAzAZAF78+jADYCeAfAR/bvaT5AHXToaEd1N5x1AObpYLz9YQjPAfg [...]
-      ],
-      "text/plain": [
-       "<IPython.core.display.HTML object>"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "<matplotlib.legend.Legend at 0x15699d090>"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,21,'Iteration')"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,1,'Training Accuracy')"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,21,'Iteration')"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,1,'Training Loss (Cross Entropy)')"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b1c4d0>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b583d0>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b58b50>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b4c610>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b3f510>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b3f6d0>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b6d090>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b6d290>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b6d990>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b6da90>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b7a210>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b7a350>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b3f090>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b7a690>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b86050>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b86110>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b868d0>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b86990>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b90190>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b90250>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b7af90>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b3f310>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b90a90>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b90f50>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b9d610>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b9d890>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156bac090>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156bac150>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b9d5d0>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156b90ed0>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156baca50>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156bacb50>]"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "<matplotlib.legend.Legend at 0x156abfc90>"
-      ]
-     },
-     "execution_count": 8,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "df_results = %sql SELECT * FROM cifar10_multi_model_info ORDER BY training_loss_final ASC LIMIT 100;\n",
-    "df_results = df_results.DataFrame()\n",
-    "\n",
-    "df_summary = %sql SELECT * FROM cifar10_multi_model_summary;\n",
-    "df_summary = df_summary.DataFrame()\n",
-    "\n",
-    "#set up plots\n",
-    "fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(10,5))\n",
-    "fig.legend(ncol=4)\n",
-    "fig.tight_layout()\n",
-    "\n",
-    "ax_metric = axs[0]\n",
-    "ax_loss = axs[1]\n",
-    "\n",
-    "ax_metric.xaxis.set_major_locator(MaxNLocator(integer=True))\n",
-    "ax_metric.set_xlabel('Iteration')\n",
-    "#ax_metric.set_ylabel('Accuracy')\n",
-    "ax_metric.set_title('Training Accuracy')\n",
-    "\n",
-    "ax_loss.xaxis.set_major_locator(MaxNLocator(integer=True))\n",
-    "ax_loss.set_xlabel('Iteration')\n",
-    "#ax_loss.set_ylabel('Cross Entropy Loss')\n",
-    "ax_loss.set_title('Training Loss (Cross Entropy)')\n",
-    "\n",
-    "iters = df_summary['metrics_iters'][0]\n",
-    "\n",
-    "for mst_key in df_results['mst_key']:\n",
-    "    df_output_info = %sql SELECT training_metrics,training_loss FROM cifar10_multi_model_info WHERE mst_key = $mst_key\n",
-    "    df_output_info = df_output_info.DataFrame()\n",
-    "    training_metrics = df_output_info['training_metrics'][0]\n",
-    "    training_loss = df_output_info['training_loss'][0]\n",
-    "    \n",
-    "    ax_metric.plot(iters, training_metrics, label=mst_key, marker='o')\n",
-    "    df_results = %sql SELECT * FROM cifar10_multi_model_info ORDER BY training_loss_final ASC LIMIT 100;\n",
-    "df_results = df_results.DataFrame()\n",
-    "\n",
-    "df_summary = %sql SELECT * FROM cifar10_multi_model_summary;\n",
-    "df_summary = df_summary.DataFrame()\n",
-    "\n",
-    "#set up plots\n",
-    "fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(10,5))\n",
-    "fig.legend(ncol=4)\n",
-    "fig.tight_layout()\n",
-    "\n",
-    "ax_metric = axs[0]\n",
-    "ax_loss = axs[1]\n",
-    "\n",
-    "ax_metric.xaxis.set_major_locator(MaxNLocator(integer=True))\n",
-    "ax_metric.set_xlabel('Iteration')\n",
-    "#ax_metric.set_ylabel('Accuracy')\n",
-    "ax_metric.set_title('Training Accuracy')\n",
-    "\n",
-    "ax_loss.xaxis.set_major_locator(MaxNLocator(integer=True))\n",
-    "ax_loss.set_xlabel('Iteration')\n",
-    "#ax_loss.set_ylabel('Cross Entropy Loss')\n",
-    "ax_loss.set_title('Training Loss (Cross Entropy)')\n",
-    "\n",
-    "iters = df_summary['metrics_iters'][0]\n",
-    "\n",
-    "for mst_key in df_results['mst_key']:\n",
-    "    df_output_info = %sql SELECT training_metrics,training_loss FROM cifar10_multi_model_info WHERE mst_key = $mst_key\n",
-    "    df_output_info = df_output_info.DataFrame()\n",
-    "    training_metrics = df_output_info['training_metrics'][0]\n",
-    "    training_loss = df_output_info['training_loss'][0]\n",
-    "    \n",
-    "    #ax_metric.plot(iters, training_metrics, label=mst_key, marker='o')\n",
-    "    ax_metric.plot(iters, training_metrics)\n",
-    "    \n",
-    "    #ax_loss.plot(iters, training_loss, label=mst_key, marker='o')\n",
-    "    ax_loss.plot(iters, training_loss)\n",
-    "\n",
-    "plt.legend()\n",
-    "# fig.savefig('./lc_keras_fit.png', dpi = 300)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Validation data"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 9,
-   "metadata": {
-    "scrolled": false
-   },
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "16 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "application/javascript": [
-       "/* Put everything inside the global mpl namespace */\n",
-       "window.mpl = {};\n",
-       "\n",
-       "\n",
-       "mpl.get_websocket_type = function() {\n",
-       "    if (typeof(WebSocket) !== 'undefined') {\n",
-       "        return WebSocket;\n",
-       "    } else if (typeof(MozWebSocket) !== 'undefined') {\n",
-       "        return MozWebSocket;\n",
-       "    } else {\n",
-       "        alert('Your browser does not have WebSocket support.' +\n",
-       "              'Please try Chrome, Safari or Firefox ≥ 6. ' +\n",
-       "              'Firefox 4 and 5 are also supported but you ' +\n",
-       "              'have to enable WebSockets in about:config.');\n",
-       "    };\n",
-       "}\n",
-       "\n",
-       "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n",
-       "    this.id = figure_id;\n",
-       "\n",
-       "    this.ws = websocket;\n",
-       "\n",
-       "    this.supports_binary = (this.ws.binaryType != undefined);\n",
-       "\n",
-       "    if (!this.supports_binary) {\n",
-       "        var warnings = document.getElementById(\"mpl-warnings\");\n",
-       "        if (warnings) {\n",
-       "            warnings.style.display = 'block';\n",
-       "            warnings.textContent = (\n",
-       "                \"This browser does not support binary websocket messages. \" +\n",
-       "                    \"Performance may be slow.\");\n",
-       "        }\n",
-       "    }\n",
-       "\n",
-       "    this.imageObj = new Image();\n",
-       "\n",
-       "    this.context = undefined;\n",
-       "    this.message = undefined;\n",
-       "    this.canvas = undefined;\n",
-       "    this.rubberband_canvas = undefined;\n",
-       "    this.rubberband_context = undefined;\n",
-       "    this.format_dropdown = undefined;\n",
-       "\n",
-       "    this.image_mode = 'full';\n",
-       "\n",
-       "    this.root = $('<div/>');\n",
-       "    this._root_extra_style(this.root)\n",
-       "    this.root.attr('style', 'display: inline-block');\n",
-       "\n",
-       "    $(parent_element).append(this.root);\n",
-       "\n",
-       "    this._init_header(this);\n",
-       "    this._init_canvas(this);\n",
-       "    this._init_toolbar(this);\n",
-       "\n",
-       "    var fig = this;\n",
-       "\n",
-       "    this.waiting = false;\n",
-       "\n",
-       "    this.ws.onopen =  function () {\n",
-       "            fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n",
-       "            fig.send_message(\"send_image_mode\", {});\n",
-       "            if (mpl.ratio != 1) {\n",
-       "                fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n",
-       "            }\n",
-       "            fig.send_message(\"refresh\", {});\n",
-       "        }\n",
-       "\n",
-       "    this.imageObj.onload = function() {\n",
-       "            if (fig.image_mode == 'full') {\n",
-       "                // Full images could contain transparency (where diff images\n",
-       "                // almost always do), so we need to clear the canvas so that\n",
-       "                // there is no ghosting.\n",
-       "                fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n",
-       "            }\n",
-       "            fig.context.drawImage(fig.imageObj, 0, 0);\n",
-       "        };\n",
-       "\n",
-       "    this.imageObj.onunload = function() {\n",
-       "        fig.ws.close();\n",
-       "    }\n",
-       "\n",
-       "    this.ws.onmessage = this._make_on_message_function(this);\n",
-       "\n",
-       "    this.ondownload = ondownload;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_header = function() {\n",
-       "    var titlebar = $(\n",
-       "        '<div class=\"ui-dialog-titlebar ui-widget-header ui-corner-all ' +\n",
-       "        'ui-helper-clearfix\"/>');\n",
-       "    var titletext = $(\n",
-       "        '<div class=\"ui-dialog-title\" style=\"width: 100%; ' +\n",
-       "        'text-align: center; padding: 3px;\"/>');\n",
-       "    titlebar.append(titletext)\n",
-       "    this.root.append(titlebar);\n",
-       "    this.header = titletext[0];\n",
-       "}\n",
-       "\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n",
-       "\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n",
-       "\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_canvas = function() {\n",
-       "    var fig = this;\n",
-       "\n",
-       "    var canvas_div = $('<div/>');\n",
-       "\n",
-       "    canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n",
-       "\n",
-       "    function canvas_keyboard_event(event) {\n",
-       "        return fig.key_event(event, event['data']);\n",
-       "    }\n",
-       "\n",
-       "    canvas_div.keydown('key_press', canvas_keyboard_event);\n",
-       "    canvas_div.keyup('key_release', canvas_keyboard_event);\n",
-       "    this.canvas_div = canvas_div\n",
-       "    this._canvas_extra_style(canvas_div)\n",
-       "    this.root.append(canvas_div);\n",
-       "\n",
-       "    var canvas = $('<canvas/>');\n",
-       "    canvas.addClass('mpl-canvas');\n",
-       "    canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n",
-       "\n",
-       "    this.canvas = canvas[0];\n",
-       "    this.context = canvas[0].getContext(\"2d\");\n",
-       "\n",
-       "    var backingStore = this.context.backingStorePixelRatio ||\n",
-       "\tthis.context.webkitBackingStorePixelRatio ||\n",
-       "\tthis.context.mozBackingStorePixelRatio ||\n",
-       "\tthis.context.msBackingStorePixelRatio ||\n",
-       "\tthis.context.oBackingStorePixelRatio ||\n",
-       "\tthis.context.backingStorePixelRatio || 1;\n",
-       "\n",
-       "    mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n",
-       "\n",
-       "    var rubberband = $('<canvas/>');\n",
-       "    rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n",
-       "\n",
-       "    var pass_mouse_events = true;\n",
-       "\n",
-       "    canvas_div.resizable({\n",
-       "        start: function(event, ui) {\n",
-       "            pass_mouse_events = false;\n",
-       "        },\n",
-       "        resize: function(event, ui) {\n",
-       "            fig.request_resize(ui.size.width, ui.size.height);\n",
-       "        },\n",
-       "        stop: function(event, ui) {\n",
-       "            pass_mouse_events = true;\n",
-       "            fig.request_resize(ui.size.width, ui.size.height);\n",
-       "        },\n",
-       "    });\n",
-       "\n",
-       "    function mouse_event_fn(event) {\n",
-       "        if (pass_mouse_events)\n",
-       "            return fig.mouse_event(event, event['data']);\n",
-       "    }\n",
-       "\n",
-       "    rubberband.mousedown('button_press', mouse_event_fn);\n",
-       "    rubberband.mouseup('button_release', mouse_event_fn);\n",
-       "    // Throttle sequential mouse events to 1 every 20ms.\n",
-       "    rubberband.mousemove('motion_notify', mouse_event_fn);\n",
-       "\n",
-       "    rubberband.mouseenter('figure_enter', mouse_event_fn);\n",
-       "    rubberband.mouseleave('figure_leave', mouse_event_fn);\n",
-       "\n",
-       "    canvas_div.on(\"wheel\", function (event) {\n",
-       "        event = event.originalEvent;\n",
-       "        event['data'] = 'scroll'\n",
-       "        if (event.deltaY < 0) {\n",
-       "            event.step = 1;\n",
-       "        } else {\n",
-       "            event.step = -1;\n",
-       "        }\n",
-       "        mouse_event_fn(event);\n",
-       "    });\n",
-       "\n",
-       "    canvas_div.append(canvas);\n",
-       "    canvas_div.append(rubberband);\n",
-       "\n",
-       "    this.rubberband = rubberband;\n",
-       "    this.rubberband_canvas = rubberband[0];\n",
-       "    this.rubberband_context = rubberband[0].getContext(\"2d\");\n",
-       "    this.rubberband_context.strokeStyle = \"#000000\";\n",
-       "\n",
-       "    this._resize_canvas = function(width, height) {\n",
-       "        // Keep the size of the canvas, canvas container, and rubber band\n",
-       "        // canvas in synch.\n",
-       "        canvas_div.css('width', width)\n",
-       "        canvas_div.css('height', height)\n",
-       "\n",
-       "        canvas.attr('width', width * mpl.ratio);\n",
-       "        canvas.attr('height', height * mpl.ratio);\n",
-       "        canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n",
-       "\n",
-       "        rubberband.attr('width', width);\n",
-       "        rubberband.attr('height', height);\n",
-       "    }\n",
-       "\n",
-       "    // Set the figure to an initial 600x600px, this will subsequently be updated\n",
-       "    // upon first draw.\n",
-       "    this._resize_canvas(600, 600);\n",
-       "\n",
-       "    // Disable right mouse context menu.\n",
-       "    $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n",
-       "        return false;\n",
-       "    });\n",
-       "\n",
-       "    function set_focus () {\n",
-       "        canvas.focus();\n",
-       "        canvas_div.focus();\n",
-       "    }\n",
-       "\n",
-       "    window.setTimeout(set_focus, 100);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_toolbar = function() {\n",
-       "    var fig = this;\n",
-       "\n",
-       "    var nav_element = $('<div/>')\n",
-       "    nav_element.attr('style', 'width: 100%');\n",
-       "    this.root.append(nav_element);\n",
-       "\n",
-       "    // Define a callback function for later on.\n",
-       "    function toolbar_event(event) {\n",
-       "        return fig.toolbar_button_onclick(event['data']);\n",
-       "    }\n",
-       "    function toolbar_mouse_event(event) {\n",
-       "        return fig.toolbar_button_onmouseover(event['data']);\n",
-       "    }\n",
-       "\n",
-       "    for(var toolbar_ind in mpl.toolbar_items) {\n",
-       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
-       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
-       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
-       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
-       "\n",
-       "        if (!name) {\n",
-       "            // put a spacer in here.\n",
-       "            continue;\n",
-       "        }\n",
-       "        var button = $('<button/>');\n",
-       "        button.addClass('ui-button ui-widget ui-state-default ui-corner-all ' +\n",
-       "                        'ui-button-icon-only');\n",
-       "        button.attr('role', 'button');\n",
-       "        button.attr('aria-disabled', 'false');\n",
-       "        button.click(method_name, toolbar_event);\n",
-       "        button.mouseover(tooltip, toolbar_mouse_event);\n",
-       "\n",
-       "        var icon_img = $('<span/>');\n",
-       "        icon_img.addClass('ui-button-icon-primary ui-icon');\n",
-       "        icon_img.addClass(image);\n",
-       "        icon_img.addClass('ui-corner-all');\n",
-       "\n",
-       "        var tooltip_span = $('<span/>');\n",
-       "        tooltip_span.addClass('ui-button-text');\n",
-       "        tooltip_span.html(tooltip);\n",
-       "\n",
-       "        button.append(icon_img);\n",
-       "        button.append(tooltip_span);\n",
-       "\n",
-       "        nav_element.append(button);\n",
-       "    }\n",
-       "\n",
-       "    var fmt_picker_span = $('<span/>');\n",
-       "\n",
-       "    var fmt_picker = $('<select/>');\n",
-       "    fmt_picker.addClass('mpl-toolbar-option ui-widget ui-widget-content');\n",
-       "    fmt_picker_span.append(fmt_picker);\n",
-       "    nav_element.append(fmt_picker_span);\n",
-       "    this.format_dropdown = fmt_picker[0];\n",
-       "\n",
-       "    for (var ind in mpl.extensions) {\n",
-       "        var fmt = mpl.extensions[ind];\n",
-       "        var option = $(\n",
-       "            '<option/>', {selected: fmt === mpl.default_extension}).html(fmt);\n",
-       "        fmt_picker.append(option)\n",
-       "    }\n",
-       "\n",
-       "    // Add hover states to the ui-buttons\n",
-       "    $( \".ui-button\" ).hover(\n",
-       "        function() { $(this).addClass(\"ui-state-hover\");},\n",
-       "        function() { $(this).removeClass(\"ui-state-hover\");}\n",
-       "    );\n",
-       "\n",
-       "    var status_bar = $('<span class=\"mpl-message\"/>');\n",
-       "    nav_element.append(status_bar);\n",
-       "    this.message = status_bar[0];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.request_resize = function(x_pixels, y_pixels) {\n",
-       "    // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n",
-       "    // which will in turn request a refresh of the image.\n",
-       "    this.send_message('resize', {'width': x_pixels, 'height': y_pixels});\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.send_message = function(type, properties) {\n",
-       "    properties['type'] = type;\n",
-       "    properties['figure_id'] = this.id;\n",
-       "    this.ws.send(JSON.stringify(properties));\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.send_draw_message = function() {\n",
-       "    if (!this.waiting) {\n",
-       "        this.waiting = true;\n",
-       "        this.ws.send(JSON.stringify({type: \"draw\", figure_id: this.id}));\n",
-       "    }\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype.handle_save = function(fig, msg) {\n",
-       "    var format_dropdown = fig.format_dropdown;\n",
-       "    var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n",
-       "    fig.ondownload(fig, format);\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype.handle_resize = function(fig, msg) {\n",
-       "    var size = msg['size'];\n",
-       "    if (size[0] != fig.canvas.width || size[1] != fig.canvas.height) {\n",
-       "        fig._resize_canvas(size[0], size[1]);\n",
-       "        fig.send_message(\"refresh\", {});\n",
-       "    };\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_rubberband = function(fig, msg) {\n",
-       "    var x0 = msg['x0'] / mpl.ratio;\n",
-       "    var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n",
-       "    var x1 = msg['x1'] / mpl.ratio;\n",
-       "    var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n",
-       "    x0 = Math.floor(x0) + 0.5;\n",
-       "    y0 = Math.floor(y0) + 0.5;\n",
-       "    x1 = Math.floor(x1) + 0.5;\n",
-       "    y1 = Math.floor(y1) + 0.5;\n",
-       "    var min_x = Math.min(x0, x1);\n",
-       "    var min_y = Math.min(y0, y1);\n",
-       "    var width = Math.abs(x1 - x0);\n",
-       "    var height = Math.abs(y1 - y0);\n",
-       "\n",
-       "    fig.rubberband_context.clearRect(\n",
-       "        0, 0, fig.canvas.width, fig.canvas.height);\n",
-       "\n",
-       "    fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_figure_label = function(fig, msg) {\n",
-       "    // Updates the figure title.\n",
-       "    fig.header.textContent = msg['label'];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_cursor = function(fig, msg) {\n",
-       "    var cursor = msg['cursor'];\n",
-       "    switch(cursor)\n",
-       "    {\n",
-       "    case 0:\n",
-       "        cursor = 'pointer';\n",
-       "        break;\n",
-       "    case 1:\n",
-       "        cursor = 'default';\n",
-       "        break;\n",
-       "    case 2:\n",
-       "        cursor = 'crosshair';\n",
-       "        break;\n",
-       "    case 3:\n",
-       "        cursor = 'move';\n",
-       "        break;\n",
-       "    }\n",
-       "    fig.rubberband_canvas.style.cursor = cursor;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_message = function(fig, msg) {\n",
-       "    fig.message.textContent = msg['message'];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_draw = function(fig, msg) {\n",
-       "    // Request the server to send over a new figure.\n",
-       "    fig.send_draw_message();\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_image_mode = function(fig, msg) {\n",
-       "    fig.image_mode = msg['mode'];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.updated_canvas_event = function() {\n",
-       "    // Called whenever the canvas gets updated.\n",
-       "    this.send_message(\"ack\", {});\n",
-       "}\n",
-       "\n",
-       "// A function to construct a web socket function for onmessage handling.\n",
-       "// Called in the figure constructor.\n",
-       "mpl.figure.prototype._make_on_message_function = function(fig) {\n",
-       "    return function socket_on_message(evt) {\n",
-       "        if (evt.data instanceof Blob) {\n",
-       "            /* FIXME: We get \"Resource interpreted as Image but\n",
-       "             * transferred with MIME type text/plain:\" errors on\n",
-       "             * Chrome.  But how to set the MIME type?  It doesn't seem\n",
-       "             * to be part of the websocket stream */\n",
-       "            evt.data.type = \"image/png\";\n",
-       "\n",
-       "            /* Free the memory for the previous frames */\n",
-       "            if (fig.imageObj.src) {\n",
-       "                (window.URL || window.webkitURL).revokeObjectURL(\n",
-       "                    fig.imageObj.src);\n",
-       "            }\n",
-       "\n",
-       "            fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n",
-       "                evt.data);\n",
-       "            fig.updated_canvas_event();\n",
-       "            fig.waiting = false;\n",
-       "            return;\n",
-       "        }\n",
-       "        else if (typeof evt.data === 'string' && evt.data.slice(0, 21) == \"data:image/png;base64\") {\n",
-       "            fig.imageObj.src = evt.data;\n",
-       "            fig.updated_canvas_event();\n",
-       "            fig.waiting = false;\n",
-       "            return;\n",
-       "        }\n",
-       "\n",
-       "        var msg = JSON.parse(evt.data);\n",
-       "        var msg_type = msg['type'];\n",
-       "\n",
-       "        // Call the  \"handle_{type}\" callback, which takes\n",
-       "        // the figure and JSON message as its only arguments.\n",
-       "        try {\n",
-       "            var callback = fig[\"handle_\" + msg_type];\n",
-       "        } catch (e) {\n",
-       "            console.log(\"No handler for the '\" + msg_type + \"' message type: \", msg);\n",
-       "            return;\n",
-       "        }\n",
-       "\n",
-       "        if (callback) {\n",
-       "            try {\n",
-       "                // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n",
-       "                callback(fig, msg);\n",
-       "            } catch (e) {\n",
-       "                console.log(\"Exception inside the 'handler_\" + msg_type + \"' callback:\", e, e.stack, msg);\n",
-       "            }\n",
-       "        }\n",
-       "    };\n",
-       "}\n",
-       "\n",
-       "// from http://stackoverflow.com/questions/1114465/getting-mouse-location-in-canvas\n",
-       "mpl.findpos = function(e) {\n",
-       "    //this section is from http://www.quirksmode.org/js/events_properties.html\n",
-       "    var targ;\n",
-       "    if (!e)\n",
-       "        e = window.event;\n",
-       "    if (e.target)\n",
-       "        targ = e.target;\n",
-       "    else if (e.srcElement)\n",
-       "        targ = e.srcElement;\n",
-       "    if (targ.nodeType == 3) // defeat Safari bug\n",
-       "        targ = targ.parentNode;\n",
-       "\n",
-       "    // jQuery normalizes the pageX and pageY\n",
-       "    // pageX,Y are the mouse positions relative to the document\n",
-       "    // offset() returns the position of the element relative to the document\n",
-       "    var x = e.pageX - $(targ).offset().left;\n",
-       "    var y = e.pageY - $(targ).offset().top;\n",
-       "\n",
-       "    return {\"x\": x, \"y\": y};\n",
-       "};\n",
-       "\n",
-       "/*\n",
-       " * return a copy of an object with only non-object keys\n",
-       " * we need this to avoid circular references\n",
-       " * http://stackoverflow.com/a/24161582/3208463\n",
-       " */\n",
-       "function simpleKeys (original) {\n",
-       "  return Object.keys(original).reduce(function (obj, key) {\n",
-       "    if (typeof original[key] !== 'object')\n",
-       "        obj[key] = original[key]\n",
-       "    return obj;\n",
-       "  }, {});\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.mouse_event = function(event, name) {\n",
-       "    var canvas_pos = mpl.findpos(event)\n",
-       "\n",
-       "    if (name === 'button_press')\n",
-       "    {\n",
-       "        this.canvas.focus();\n",
-       "        this.canvas_div.focus();\n",
-       "    }\n",
-       "\n",
-       "    var x = canvas_pos.x * mpl.ratio;\n",
-       "    var y = canvas_pos.y * mpl.ratio;\n",
-       "\n",
-       "    this.send_message(name, {x: x, y: y, button: event.button,\n",
-       "                             step: event.step,\n",
-       "                             guiEvent: simpleKeys(event)});\n",
-       "\n",
-       "    /* This prevents the web browser from automatically changing to\n",
-       "     * the text insertion cursor when the button is pressed.  We want\n",
-       "     * to control all of the cursor setting manually through the\n",
-       "     * 'cursor' event from matplotlib */\n",
-       "    event.preventDefault();\n",
-       "    return false;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._key_event_extra = function(event, name) {\n",
-       "    // Handle any extra behaviour associated with a key event\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.key_event = function(event, name) {\n",
-       "\n",
-       "    // Prevent repeat events\n",
-       "    if (name == 'key_press')\n",
-       "    {\n",
-       "        if (event.which === this._key)\n",
-       "            return;\n",
-       "        else\n",
-       "            this._key = event.which;\n",
-       "    }\n",
-       "    if (name == 'key_release')\n",
-       "        this._key = null;\n",
-       "\n",
-       "    var value = '';\n",
-       "    if (event.ctrlKey && event.which != 17)\n",
-       "        value += \"ctrl+\";\n",
-       "    if (event.altKey && event.which != 18)\n",
-       "        value += \"alt+\";\n",
-       "    if (event.shiftKey && event.which != 16)\n",
-       "        value += \"shift+\";\n",
-       "\n",
-       "    value += 'k';\n",
-       "    value += event.which.toString();\n",
-       "\n",
-       "    this._key_event_extra(event, name);\n",
-       "\n",
-       "    this.send_message(name, {key: value,\n",
-       "                             guiEvent: simpleKeys(event)});\n",
-       "    return false;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.toolbar_button_onclick = function(name) {\n",
-       "    if (name == 'download') {\n",
-       "        this.handle_save(this, null);\n",
-       "    } else {\n",
-       "        this.send_message(\"toolbar_button\", {name: name});\n",
-       "    }\n",
-       "};\n",
-       "\n",
-       "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n",
-       "    this.message.textContent = tooltip;\n",
-       "};\n",
-       "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to  previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\" [...]
-       "\n",
-       "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n",
-       "\n",
-       "mpl.default_extension = \"png\";var comm_websocket_adapter = function(comm) {\n",
-       "    // Create a \"websocket\"-like object which calls the given IPython comm\n",
-       "    // object with the appropriate methods. Currently this is a non binary\n",
-       "    // socket, so there is still some room for performance tuning.\n",
-       "    var ws = {};\n",
-       "\n",
-       "    ws.close = function() {\n",
-       "        comm.close()\n",
-       "    };\n",
-       "    ws.send = function(m) {\n",
-       "        //console.log('sending', m);\n",
-       "        comm.send(m);\n",
-       "    };\n",
-       "    // Register the callback with on_msg.\n",
-       "    comm.on_msg(function(msg) {\n",
-       "        //console.log('receiving', msg['content']['data'], msg);\n",
-       "        // Pass the mpl event to the overridden (by mpl) onmessage function.\n",
-       "        ws.onmessage(msg['content']['data'])\n",
-       "    });\n",
-       "    return ws;\n",
-       "}\n",
-       "\n",
-       "mpl.mpl_figure_comm = function(comm, msg) {\n",
-       "    // This is the function which gets called when the mpl process\n",
-       "    // starts-up an IPython Comm through the \"matplotlib\" channel.\n",
-       "\n",
-       "    var id = msg.content.data.id;\n",
-       "    // Get hold of the div created by the display call when the Comm\n",
-       "    // socket was opened in Python.\n",
-       "    var element = $(\"#\" + id);\n",
-       "    var ws_proxy = comm_websocket_adapter(comm)\n",
-       "\n",
-       "    function ondownload(figure, format) {\n",
-       "        window.open(figure.imageObj.src);\n",
-       "    }\n",
-       "\n",
-       "    var fig = new mpl.figure(id, ws_proxy,\n",
-       "                           ondownload,\n",
-       "                           element.get(0));\n",
-       "\n",
-       "    // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n",
-       "    // web socket which is closed, not our websocket->open comm proxy.\n",
-       "    ws_proxy.onopen();\n",
-       "\n",
-       "    fig.parent_element = element.get(0);\n",
-       "    fig.cell_info = mpl.find_output_cell(\"<div id='\" + id + \"'></div>\");\n",
-       "    if (!fig.cell_info) {\n",
-       "        console.error(\"Failed to find cell for figure\", id, fig);\n",
-       "        return;\n",
-       "    }\n",
-       "\n",
-       "    var output_index = fig.cell_info[2]\n",
-       "    var cell = fig.cell_info[0];\n",
-       "\n",
-       "};\n",
-       "\n",
-       "mpl.figure.prototype.handle_close = function(fig, msg) {\n",
-       "    var width = fig.canvas.width/mpl.ratio\n",
-       "    fig.root.unbind('remove')\n",
-       "\n",
-       "    // Update the output cell to use the data from the current canvas.\n",
-       "    fig.push_to_output();\n",
-       "    var dataURL = fig.canvas.toDataURL();\n",
-       "    // Re-enable the keyboard manager in IPython - without this line, in FF,\n",
-       "    // the notebook keyboard shortcuts fail.\n",
-       "    IPython.keyboard_manager.enable()\n",
-       "    $(fig.parent_element).html('<img src=\"' + dataURL + '\" width=\"' + width + '\">');\n",
-       "    fig.close_ws(fig, msg);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.close_ws = function(fig, msg){\n",
-       "    fig.send_message('closing', msg);\n",
-       "    // fig.ws.close()\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.push_to_output = function(remove_interactive) {\n",
-       "    // Turn the data on the canvas into data in the output cell.\n",
-       "    var width = this.canvas.width/mpl.ratio\n",
-       "    var dataURL = this.canvas.toDataURL();\n",
-       "    this.cell_info[1]['text/html'] = '<img src=\"' + dataURL + '\" width=\"' + width + '\">';\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.updated_canvas_event = function() {\n",
-       "    // Tell IPython that the notebook contents must change.\n",
-       "    IPython.notebook.set_dirty(true);\n",
-       "    this.send_message(\"ack\", {});\n",
-       "    var fig = this;\n",
-       "    // Wait a second, then push the new image to the DOM so\n",
-       "    // that it is saved nicely (might be nice to debounce this).\n",
-       "    setTimeout(function () { fig.push_to_output() }, 1000);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_toolbar = function() {\n",
-       "    var fig = this;\n",
-       "\n",
-       "    var nav_element = $('<div/>')\n",
-       "    nav_element.attr('style', 'width: 100%');\n",
-       "    this.root.append(nav_element);\n",
-       "\n",
-       "    // Define a callback function for later on.\n",
-       "    function toolbar_event(event) {\n",
-       "        return fig.toolbar_button_onclick(event['data']);\n",
-       "    }\n",
-       "    function toolbar_mouse_event(event) {\n",
-       "        return fig.toolbar_button_onmouseover(event['data']);\n",
-       "    }\n",
-       "\n",
-       "    for(var toolbar_ind in mpl.toolbar_items){\n",
-       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
-       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
-       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
-       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
-       "\n",
-       "        if (!name) { continue; };\n",
-       "\n",
-       "        var button = $('<button class=\"btn btn-default\" href=\"#\" title=\"' + name + '\"><i class=\"fa ' + image + ' fa-lg\"></i></button>');\n",
-       "        button.click(method_name, toolbar_event);\n",
-       "        button.mouseover(tooltip, toolbar_mouse_event);\n",
-       "        nav_element.append(button);\n",
-       "    }\n",
-       "\n",
-       "    // Add the status bar.\n",
-       "    var status_bar = $('<span class=\"mpl-message\" style=\"text-align:right; float: right;\"/>');\n",
-       "    nav_element.append(status_bar);\n",
-       "    this.message = status_bar[0];\n",
-       "\n",
-       "    // Add the close button to the window.\n",
-       "    var buttongrp = $('<div class=\"btn-group inline pull-right\"></div>');\n",
-       "    var button = $('<button class=\"btn btn-mini btn-primary\" href=\"#\" title=\"Stop Interaction\"><i class=\"fa fa-power-off icon-remove icon-large\"></i></button>');\n",
-       "    button.click(function (evt) { fig.handle_close(fig, {}); } );\n",
-       "    button.mouseover('Stop Interaction', toolbar_mouse_event);\n",
-       "    buttongrp.append(button);\n",
-       "    var titlebar = this.root.find($('.ui-dialog-titlebar'));\n",
-       "    titlebar.prepend(buttongrp);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._root_extra_style = function(el){\n",
-       "    var fig = this\n",
-       "    el.on(\"remove\", function(){\n",
-       "\tfig.close_ws(fig, {});\n",
-       "    });\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._canvas_extra_style = function(el){\n",
-       "    // this is important to make the div 'focusable\n",
-       "    el.attr('tabindex', 0)\n",
-       "    // reach out to IPython and tell the keyboard manager to turn it's self\n",
-       "    // off when our div gets focus\n",
-       "\n",
-       "    // location in version 3\n",
-       "    if (IPython.notebook.keyboard_manager) {\n",
-       "        IPython.notebook.keyboard_manager.register_events(el);\n",
-       "    }\n",
-       "    else {\n",
-       "        // location in version 2\n",
-       "        IPython.keyboard_manager.register_events(el);\n",
-       "    }\n",
-       "\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._key_event_extra = function(event, name) {\n",
-       "    var manager = IPython.notebook.keyboard_manager;\n",
-       "    if (!manager)\n",
-       "        manager = IPython.keyboard_manager;\n",
-       "\n",
-       "    // Check for shift+enter\n",
-       "    if (event.shiftKey && event.which == 13) {\n",
-       "        this.canvas_div.blur();\n",
-       "        // select the cell after this one\n",
-       "        var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n",
-       "        IPython.notebook.select(index + 1);\n",
-       "    }\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_save = function(fig, msg) {\n",
-       "    fig.ondownload(fig, null);\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.find_output_cell = function(html_output) {\n",
-       "    // Return the cell and output element which can be found *uniquely* in the notebook.\n",
-       "    // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n",
-       "    // IPython event is triggered only after the cells have been serialised, which for\n",
-       "    // our purposes (turning an active figure into a static one), is too late.\n",
-       "    var cells = IPython.notebook.get_cells();\n",
-       "    var ncells = cells.length;\n",
-       "    for (var i=0; i<ncells; i++) {\n",
-       "        var cell = cells[i];\n",
-       "        if (cell.cell_type === 'code'){\n",
-       "            for (var j=0; j<cell.output_area.outputs.length; j++) {\n",
-       "                var data = cell.output_area.outputs[j];\n",
-       "                if (data.data) {\n",
-       "                    // IPython >= 3 moved mimebundle to data attribute of output\n",
-       "                    data = data.data;\n",
-       "                }\n",
-       "                if (data['text/html'] == html_output) {\n",
-       "                    return [cell, data, j];\n",
-       "                }\n",
-       "            }\n",
-       "        }\n",
-       "    }\n",
-       "}\n",
-       "\n",
-       "// Register the function which deals with the matplotlib target/channel.\n",
-       "// The kernel may be null if the page has been refreshed.\n",
-       "if (IPython.notebook.kernel != null) {\n",
-       "    IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n",
-       "}\n"
-      ],
-      "text/plain": [
-       "<IPython.core.display.Javascript object>"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/html": [
-       "<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABDgAAAIcCAYAAAAT/R6VAAAgAElEQVR4Xux9B3xb1dn+oy3ZkvfKsJ2dkLAT9t6zg9FFW0r5PjYdlA5o6aClQKGD9qOU1QUt7R8ohZZV9igUaBJCICGQYJLYcTziKQ9t/X/P1b32lSLZV7ZkX9vvG4Rk6dxzz3nOkc57nvMOC0QEAUFAEBAEBAFBQBAQBAQBQUAQEAQEAUFAEJjiCFimePul+YKAICAICAKCgCAgCAgCgoAgIAgIAoKAICAIQAgOmQTTDYE/AfgsgFsBfMlA51YDWKmW5TVjETuAMIAoAL7WJNP7o91jEYDNAD4AwNf5lv8FcBeA3wLga7PLdQC+ozbyFABPmr3B0j5BQBAQBKYgArKeZj9oZl9PtfY9C+D47Ls3Ja7YE8A6AL8G8JUMLS4HcAmAkwEsAVACYEDVvV4 [...]
-      ],
-      "text/plain": [
-       "<IPython.core.display.HTML object>"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "<matplotlib.legend.Legend at 0x156c14f10>"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,21,'Iteration')"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,1,'Validation Accuracy')"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,21,'Iteration')"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,1,'Validation Loss (Cross Entropy)')"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156ccc1d0>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156ccc150>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156c9a110>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156c9af50>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156cda710>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156cdad90>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156ced550>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156cc1e10>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156cedad0>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156cedc50>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156cfc410>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156cfc990>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156cfced0>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d060d0>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d068d0>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156cdabd0>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d069d0>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d06e50>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d046d0>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d04b10>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d1c090>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d1c110>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d1c990>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156cfc4d0>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d1c910>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d24050>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d247d0>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d248d0>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d330d0>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d33250>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d33a50>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x156d33bd0>]"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "<matplotlib.legend.Legend at 0x156c72690>"
-      ]
-     },
-     "execution_count": 9,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "df_results = %sql SELECT * FROM cifar10_multi_model_info ORDER BY validation_loss_final ASC LIMIT 100;\n",
-    "df_results = df_results.DataFrame()\n",
-    "\n",
-    "df_summary = %sql SELECT * FROM cifar10_multi_model_summary;\n",
-    "df_summary = df_summary.DataFrame()\n",
-    "\n",
-    "#set up plots\n",
-    "fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(10,5))\n",
-    "fig.legend(ncol=4)\n",
-    "fig.tight_layout()\n",
-    "\n",
-    "ax_metric = axs[0]\n",
-    "ax_loss = axs[1]\n",
-    "\n",
-    "ax_metric.xaxis.set_major_locator(MaxNLocator(integer=True))\n",
-    "ax_metric.set_xlabel('Iteration')\n",
-    "#ax_metric.set_ylabel('Accuracy')\n",
-    "ax_metric.set_title('Validation Accuracy')\n",
-    "\n",
-    "ax_loss.xaxis.set_major_locator(MaxNLocator(integer=True))\n",
-    "ax_loss.set_xlabel('Iteration')\n",
-    "#ax_loss.set_ylabel('Cross Entropy Loss')\n",
-    "ax_loss.set_title('Validation Loss (Cross Entropy)')\n",
-    "\n",
-    "iters = df_summary['metrics_iters'][0]\n",
-    "\n",
-    "for mst_key in df_results['mst_key']:\n",
-    "    df_output_info = %sql SELECT validation_metrics,validation_loss FROM cifar10_multi_model_info WHERE mst_key = $mst_key\n",
-    "    df_output_info = df_output_info.DataFrame()\n",
-    "    validation_metrics = df_output_info['validation_metrics'][0]\n",
-    "    validation_loss = df_output_info['validation_loss'][0]\n",
-    "    \n",
-    "    #ax_metric.plot(iters, validation_metrics, label=mst_key, marker='o')\n",
-    "    ax_metric.plot(iters, validation_metrics)\n",
-    "    \n",
-    "    #ax_loss.plot(iters, validation_loss, label=mst_key, marker='o')\n",
-    "    ax_loss.plot(iters, validation_loss)\n",
-    "\n",
-    "plt.legend()\n",
-    "# fig.savefig('./lc_keras_fit.png', dpi = 300)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Plot training and validation curves together"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 13,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "application/javascript": [
-       "/* Put everything inside the global mpl namespace */\n",
-       "window.mpl = {};\n",
-       "\n",
-       "\n",
-       "mpl.get_websocket_type = function() {\n",
-       "    if (typeof(WebSocket) !== 'undefined') {\n",
-       "        return WebSocket;\n",
-       "    } else if (typeof(MozWebSocket) !== 'undefined') {\n",
-       "        return MozWebSocket;\n",
-       "    } else {\n",
-       "        alert('Your browser does not have WebSocket support.' +\n",
-       "              'Please try Chrome, Safari or Firefox ≥ 6. ' +\n",
-       "              'Firefox 4 and 5 are also supported but you ' +\n",
-       "              'have to enable WebSockets in about:config.');\n",
-       "    };\n",
-       "}\n",
-       "\n",
-       "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n",
-       "    this.id = figure_id;\n",
-       "\n",
-       "    this.ws = websocket;\n",
-       "\n",
-       "    this.supports_binary = (this.ws.binaryType != undefined);\n",
-       "\n",
-       "    if (!this.supports_binary) {\n",
-       "        var warnings = document.getElementById(\"mpl-warnings\");\n",
-       "        if (warnings) {\n",
-       "            warnings.style.display = 'block';\n",
-       "            warnings.textContent = (\n",
-       "                \"This browser does not support binary websocket messages. \" +\n",
-       "                    \"Performance may be slow.\");\n",
-       "        }\n",
-       "    }\n",
-       "\n",
-       "    this.imageObj = new Image();\n",
-       "\n",
-       "    this.context = undefined;\n",
-       "    this.message = undefined;\n",
-       "    this.canvas = undefined;\n",
-       "    this.rubberband_canvas = undefined;\n",
-       "    this.rubberband_context = undefined;\n",
-       "    this.format_dropdown = undefined;\n",
-       "\n",
-       "    this.image_mode = 'full';\n",
-       "\n",
-       "    this.root = $('<div/>');\n",
-       "    this._root_extra_style(this.root)\n",
-       "    this.root.attr('style', 'display: inline-block');\n",
-       "\n",
-       "    $(parent_element).append(this.root);\n",
-       "\n",
-       "    this._init_header(this);\n",
-       "    this._init_canvas(this);\n",
-       "    this._init_toolbar(this);\n",
-       "\n",
-       "    var fig = this;\n",
-       "\n",
-       "    this.waiting = false;\n",
-       "\n",
-       "    this.ws.onopen =  function () {\n",
-       "            fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n",
-       "            fig.send_message(\"send_image_mode\", {});\n",
-       "            if (mpl.ratio != 1) {\n",
-       "                fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n",
-       "            }\n",
-       "            fig.send_message(\"refresh\", {});\n",
-       "        }\n",
-       "\n",
-       "    this.imageObj.onload = function() {\n",
-       "            if (fig.image_mode == 'full') {\n",
-       "                // Full images could contain transparency (where diff images\n",
-       "                // almost always do), so we need to clear the canvas so that\n",
-       "                // there is no ghosting.\n",
-       "                fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n",
-       "            }\n",
-       "            fig.context.drawImage(fig.imageObj, 0, 0);\n",
-       "        };\n",
-       "\n",
-       "    this.imageObj.onunload = function() {\n",
-       "        fig.ws.close();\n",
-       "    }\n",
-       "\n",
-       "    this.ws.onmessage = this._make_on_message_function(this);\n",
-       "\n",
-       "    this.ondownload = ondownload;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_header = function() {\n",
-       "    var titlebar = $(\n",
-       "        '<div class=\"ui-dialog-titlebar ui-widget-header ui-corner-all ' +\n",
-       "        'ui-helper-clearfix\"/>');\n",
-       "    var titletext = $(\n",
-       "        '<div class=\"ui-dialog-title\" style=\"width: 100%; ' +\n",
-       "        'text-align: center; padding: 3px;\"/>');\n",
-       "    titlebar.append(titletext)\n",
-       "    this.root.append(titlebar);\n",
-       "    this.header = titletext[0];\n",
-       "}\n",
-       "\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n",
-       "\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n",
-       "\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_canvas = function() {\n",
-       "    var fig = this;\n",
-       "\n",
-       "    var canvas_div = $('<div/>');\n",
-       "\n",
-       "    canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n",
-       "\n",
-       "    function canvas_keyboard_event(event) {\n",
-       "        return fig.key_event(event, event['data']);\n",
-       "    }\n",
-       "\n",
-       "    canvas_div.keydown('key_press', canvas_keyboard_event);\n",
-       "    canvas_div.keyup('key_release', canvas_keyboard_event);\n",
-       "    this.canvas_div = canvas_div\n",
-       "    this._canvas_extra_style(canvas_div)\n",
-       "    this.root.append(canvas_div);\n",
-       "\n",
-       "    var canvas = $('<canvas/>');\n",
-       "    canvas.addClass('mpl-canvas');\n",
-       "    canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n",
-       "\n",
-       "    this.canvas = canvas[0];\n",
-       "    this.context = canvas[0].getContext(\"2d\");\n",
-       "\n",
-       "    var backingStore = this.context.backingStorePixelRatio ||\n",
-       "\tthis.context.webkitBackingStorePixelRatio ||\n",
-       "\tthis.context.mozBackingStorePixelRatio ||\n",
-       "\tthis.context.msBackingStorePixelRatio ||\n",
-       "\tthis.context.oBackingStorePixelRatio ||\n",
-       "\tthis.context.backingStorePixelRatio || 1;\n",
-       "\n",
-       "    mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n",
-       "\n",
-       "    var rubberband = $('<canvas/>');\n",
-       "    rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n",
-       "\n",
-       "    var pass_mouse_events = true;\n",
-       "\n",
-       "    canvas_div.resizable({\n",
-       "        start: function(event, ui) {\n",
-       "            pass_mouse_events = false;\n",
-       "        },\n",
-       "        resize: function(event, ui) {\n",
-       "            fig.request_resize(ui.size.width, ui.size.height);\n",
-       "        },\n",
-       "        stop: function(event, ui) {\n",
-       "            pass_mouse_events = true;\n",
-       "            fig.request_resize(ui.size.width, ui.size.height);\n",
-       "        },\n",
-       "    });\n",
-       "\n",
-       "    function mouse_event_fn(event) {\n",
-       "        if (pass_mouse_events)\n",
-       "            return fig.mouse_event(event, event['data']);\n",
-       "    }\n",
-       "\n",
-       "    rubberband.mousedown('button_press', mouse_event_fn);\n",
-       "    rubberband.mouseup('button_release', mouse_event_fn);\n",
-       "    // Throttle sequential mouse events to 1 every 20ms.\n",
-       "    rubberband.mousemove('motion_notify', mouse_event_fn);\n",
-       "\n",
-       "    rubberband.mouseenter('figure_enter', mouse_event_fn);\n",
-       "    rubberband.mouseleave('figure_leave', mouse_event_fn);\n",
-       "\n",
-       "    canvas_div.on(\"wheel\", function (event) {\n",
-       "        event = event.originalEvent;\n",
-       "        event['data'] = 'scroll'\n",
-       "        if (event.deltaY < 0) {\n",
-       "            event.step = 1;\n",
-       "        } else {\n",
-       "            event.step = -1;\n",
-       "        }\n",
-       "        mouse_event_fn(event);\n",
-       "    });\n",
-       "\n",
-       "    canvas_div.append(canvas);\n",
-       "    canvas_div.append(rubberband);\n",
-       "\n",
-       "    this.rubberband = rubberband;\n",
-       "    this.rubberband_canvas = rubberband[0];\n",
-       "    this.rubberband_context = rubberband[0].getContext(\"2d\");\n",
-       "    this.rubberband_context.strokeStyle = \"#000000\";\n",
-       "\n",
-       "    this._resize_canvas = function(width, height) {\n",
-       "        // Keep the size of the canvas, canvas container, and rubber band\n",
-       "        // canvas in synch.\n",
-       "        canvas_div.css('width', width)\n",
-       "        canvas_div.css('height', height)\n",
-       "\n",
-       "        canvas.attr('width', width * mpl.ratio);\n",
-       "        canvas.attr('height', height * mpl.ratio);\n",
-       "        canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n",
-       "\n",
-       "        rubberband.attr('width', width);\n",
-       "        rubberband.attr('height', height);\n",
-       "    }\n",
-       "\n",
-       "    // Set the figure to an initial 600x600px, this will subsequently be updated\n",
-       "    // upon first draw.\n",
-       "    this._resize_canvas(600, 600);\n",
-       "\n",
-       "    // Disable right mouse context menu.\n",
-       "    $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n",
-       "        return false;\n",
-       "    });\n",
-       "\n",
-       "    function set_focus () {\n",
-       "        canvas.focus();\n",
-       "        canvas_div.focus();\n",
-       "    }\n",
-       "\n",
-       "    window.setTimeout(set_focus, 100);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_toolbar = function() {\n",
-       "    var fig = this;\n",
-       "\n",
-       "    var nav_element = $('<div/>')\n",
-       "    nav_element.attr('style', 'width: 100%');\n",
-       "    this.root.append(nav_element);\n",
-       "\n",
-       "    // Define a callback function for later on.\n",
-       "    function toolbar_event(event) {\n",
-       "        return fig.toolbar_button_onclick(event['data']);\n",
-       "    }\n",
-       "    function toolbar_mouse_event(event) {\n",
-       "        return fig.toolbar_button_onmouseover(event['data']);\n",
-       "    }\n",
-       "\n",
-       "    for(var toolbar_ind in mpl.toolbar_items) {\n",
-       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
-       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
-       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
-       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
-       "\n",
-       "        if (!name) {\n",
-       "            // put a spacer in here.\n",
-       "            continue;\n",
-       "        }\n",
-       "        var button = $('<button/>');\n",
-       "        button.addClass('ui-button ui-widget ui-state-default ui-corner-all ' +\n",
-       "                        'ui-button-icon-only');\n",
-       "        button.attr('role', 'button');\n",
-       "        button.attr('aria-disabled', 'false');\n",
-       "        button.click(method_name, toolbar_event);\n",
-       "        button.mouseover(tooltip, toolbar_mouse_event);\n",
-       "\n",
-       "        var icon_img = $('<span/>');\n",
-       "        icon_img.addClass('ui-button-icon-primary ui-icon');\n",
-       "        icon_img.addClass(image);\n",
-       "        icon_img.addClass('ui-corner-all');\n",
-       "\n",
-       "        var tooltip_span = $('<span/>');\n",
-       "        tooltip_span.addClass('ui-button-text');\n",
-       "        tooltip_span.html(tooltip);\n",
-       "\n",
-       "        button.append(icon_img);\n",
-       "        button.append(tooltip_span);\n",
-       "\n",
-       "        nav_element.append(button);\n",
-       "    }\n",
-       "\n",
-       "    var fmt_picker_span = $('<span/>');\n",
-       "\n",
-       "    var fmt_picker = $('<select/>');\n",
-       "    fmt_picker.addClass('mpl-toolbar-option ui-widget ui-widget-content');\n",
-       "    fmt_picker_span.append(fmt_picker);\n",
-       "    nav_element.append(fmt_picker_span);\n",
-       "    this.format_dropdown = fmt_picker[0];\n",
-       "\n",
-       "    for (var ind in mpl.extensions) {\n",
-       "        var fmt = mpl.extensions[ind];\n",
-       "        var option = $(\n",
-       "            '<option/>', {selected: fmt === mpl.default_extension}).html(fmt);\n",
-       "        fmt_picker.append(option)\n",
-       "    }\n",
-       "\n",
-       "    // Add hover states to the ui-buttons\n",
-       "    $( \".ui-button\" ).hover(\n",
-       "        function() { $(this).addClass(\"ui-state-hover\");},\n",
-       "        function() { $(this).removeClass(\"ui-state-hover\");}\n",
-       "    );\n",
-       "\n",
-       "    var status_bar = $('<span class=\"mpl-message\"/>');\n",
-       "    nav_element.append(status_bar);\n",
-       "    this.message = status_bar[0];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.request_resize = function(x_pixels, y_pixels) {\n",
-       "    // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n",
-       "    // which will in turn request a refresh of the image.\n",
-       "    this.send_message('resize', {'width': x_pixels, 'height': y_pixels});\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.send_message = function(type, properties) {\n",
-       "    properties['type'] = type;\n",
-       "    properties['figure_id'] = this.id;\n",
-       "    this.ws.send(JSON.stringify(properties));\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.send_draw_message = function() {\n",
-       "    if (!this.waiting) {\n",
-       "        this.waiting = true;\n",
-       "        this.ws.send(JSON.stringify({type: \"draw\", figure_id: this.id}));\n",
-       "    }\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype.handle_save = function(fig, msg) {\n",
-       "    var format_dropdown = fig.format_dropdown;\n",
-       "    var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n",
-       "    fig.ondownload(fig, format);\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.figure.prototype.handle_resize = function(fig, msg) {\n",
-       "    var size = msg['size'];\n",
-       "    if (size[0] != fig.canvas.width || size[1] != fig.canvas.height) {\n",
-       "        fig._resize_canvas(size[0], size[1]);\n",
-       "        fig.send_message(\"refresh\", {});\n",
-       "    };\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_rubberband = function(fig, msg) {\n",
-       "    var x0 = msg['x0'] / mpl.ratio;\n",
-       "    var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n",
-       "    var x1 = msg['x1'] / mpl.ratio;\n",
-       "    var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n",
-       "    x0 = Math.floor(x0) + 0.5;\n",
-       "    y0 = Math.floor(y0) + 0.5;\n",
-       "    x1 = Math.floor(x1) + 0.5;\n",
-       "    y1 = Math.floor(y1) + 0.5;\n",
-       "    var min_x = Math.min(x0, x1);\n",
-       "    var min_y = Math.min(y0, y1);\n",
-       "    var width = Math.abs(x1 - x0);\n",
-       "    var height = Math.abs(y1 - y0);\n",
-       "\n",
-       "    fig.rubberband_context.clearRect(\n",
-       "        0, 0, fig.canvas.width, fig.canvas.height);\n",
-       "\n",
-       "    fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_figure_label = function(fig, msg) {\n",
-       "    // Updates the figure title.\n",
-       "    fig.header.textContent = msg['label'];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_cursor = function(fig, msg) {\n",
-       "    var cursor = msg['cursor'];\n",
-       "    switch(cursor)\n",
-       "    {\n",
-       "    case 0:\n",
-       "        cursor = 'pointer';\n",
-       "        break;\n",
-       "    case 1:\n",
-       "        cursor = 'default';\n",
-       "        break;\n",
-       "    case 2:\n",
-       "        cursor = 'crosshair';\n",
-       "        break;\n",
-       "    case 3:\n",
-       "        cursor = 'move';\n",
-       "        break;\n",
-       "    }\n",
-       "    fig.rubberband_canvas.style.cursor = cursor;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_message = function(fig, msg) {\n",
-       "    fig.message.textContent = msg['message'];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_draw = function(fig, msg) {\n",
-       "    // Request the server to send over a new figure.\n",
-       "    fig.send_draw_message();\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_image_mode = function(fig, msg) {\n",
-       "    fig.image_mode = msg['mode'];\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.updated_canvas_event = function() {\n",
-       "    // Called whenever the canvas gets updated.\n",
-       "    this.send_message(\"ack\", {});\n",
-       "}\n",
-       "\n",
-       "// A function to construct a web socket function for onmessage handling.\n",
-       "// Called in the figure constructor.\n",
-       "mpl.figure.prototype._make_on_message_function = function(fig) {\n",
-       "    return function socket_on_message(evt) {\n",
-       "        if (evt.data instanceof Blob) {\n",
-       "            /* FIXME: We get \"Resource interpreted as Image but\n",
-       "             * transferred with MIME type text/plain:\" errors on\n",
-       "             * Chrome.  But how to set the MIME type?  It doesn't seem\n",
-       "             * to be part of the websocket stream */\n",
-       "            evt.data.type = \"image/png\";\n",
-       "\n",
-       "            /* Free the memory for the previous frames */\n",
-       "            if (fig.imageObj.src) {\n",
-       "                (window.URL || window.webkitURL).revokeObjectURL(\n",
-       "                    fig.imageObj.src);\n",
-       "            }\n",
-       "\n",
-       "            fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n",
-       "                evt.data);\n",
-       "            fig.updated_canvas_event();\n",
-       "            fig.waiting = false;\n",
-       "            return;\n",
-       "        }\n",
-       "        else if (typeof evt.data === 'string' && evt.data.slice(0, 21) == \"data:image/png;base64\") {\n",
-       "            fig.imageObj.src = evt.data;\n",
-       "            fig.updated_canvas_event();\n",
-       "            fig.waiting = false;\n",
-       "            return;\n",
-       "        }\n",
-       "\n",
-       "        var msg = JSON.parse(evt.data);\n",
-       "        var msg_type = msg['type'];\n",
-       "\n",
-       "        // Call the  \"handle_{type}\" callback, which takes\n",
-       "        // the figure and JSON message as its only arguments.\n",
-       "        try {\n",
-       "            var callback = fig[\"handle_\" + msg_type];\n",
-       "        } catch (e) {\n",
-       "            console.log(\"No handler for the '\" + msg_type + \"' message type: \", msg);\n",
-       "            return;\n",
-       "        }\n",
-       "\n",
-       "        if (callback) {\n",
-       "            try {\n",
-       "                // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n",
-       "                callback(fig, msg);\n",
-       "            } catch (e) {\n",
-       "                console.log(\"Exception inside the 'handler_\" + msg_type + \"' callback:\", e, e.stack, msg);\n",
-       "            }\n",
-       "        }\n",
-       "    };\n",
-       "}\n",
-       "\n",
-       "// from http://stackoverflow.com/questions/1114465/getting-mouse-location-in-canvas\n",
-       "mpl.findpos = function(e) {\n",
-       "    //this section is from http://www.quirksmode.org/js/events_properties.html\n",
-       "    var targ;\n",
-       "    if (!e)\n",
-       "        e = window.event;\n",
-       "    if (e.target)\n",
-       "        targ = e.target;\n",
-       "    else if (e.srcElement)\n",
-       "        targ = e.srcElement;\n",
-       "    if (targ.nodeType == 3) // defeat Safari bug\n",
-       "        targ = targ.parentNode;\n",
-       "\n",
-       "    // jQuery normalizes the pageX and pageY\n",
-       "    // pageX,Y are the mouse positions relative to the document\n",
-       "    // offset() returns the position of the element relative to the document\n",
-       "    var x = e.pageX - $(targ).offset().left;\n",
-       "    var y = e.pageY - $(targ).offset().top;\n",
-       "\n",
-       "    return {\"x\": x, \"y\": y};\n",
-       "};\n",
-       "\n",
-       "/*\n",
-       " * return a copy of an object with only non-object keys\n",
-       " * we need this to avoid circular references\n",
-       " * http://stackoverflow.com/a/24161582/3208463\n",
-       " */\n",
-       "function simpleKeys (original) {\n",
-       "  return Object.keys(original).reduce(function (obj, key) {\n",
-       "    if (typeof original[key] !== 'object')\n",
-       "        obj[key] = original[key]\n",
-       "    return obj;\n",
-       "  }, {});\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.mouse_event = function(event, name) {\n",
-       "    var canvas_pos = mpl.findpos(event)\n",
-       "\n",
-       "    if (name === 'button_press')\n",
-       "    {\n",
-       "        this.canvas.focus();\n",
-       "        this.canvas_div.focus();\n",
-       "    }\n",
-       "\n",
-       "    var x = canvas_pos.x * mpl.ratio;\n",
-       "    var y = canvas_pos.y * mpl.ratio;\n",
-       "\n",
-       "    this.send_message(name, {x: x, y: y, button: event.button,\n",
-       "                             step: event.step,\n",
-       "                             guiEvent: simpleKeys(event)});\n",
-       "\n",
-       "    /* This prevents the web browser from automatically changing to\n",
-       "     * the text insertion cursor when the button is pressed.  We want\n",
-       "     * to control all of the cursor setting manually through the\n",
-       "     * 'cursor' event from matplotlib */\n",
-       "    event.preventDefault();\n",
-       "    return false;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._key_event_extra = function(event, name) {\n",
-       "    // Handle any extra behaviour associated with a key event\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.key_event = function(event, name) {\n",
-       "\n",
-       "    // Prevent repeat events\n",
-       "    if (name == 'key_press')\n",
-       "    {\n",
-       "        if (event.which === this._key)\n",
-       "            return;\n",
-       "        else\n",
-       "            this._key = event.which;\n",
-       "    }\n",
-       "    if (name == 'key_release')\n",
-       "        this._key = null;\n",
-       "\n",
-       "    var value = '';\n",
-       "    if (event.ctrlKey && event.which != 17)\n",
-       "        value += \"ctrl+\";\n",
-       "    if (event.altKey && event.which != 18)\n",
-       "        value += \"alt+\";\n",
-       "    if (event.shiftKey && event.which != 16)\n",
-       "        value += \"shift+\";\n",
-       "\n",
-       "    value += 'k';\n",
-       "    value += event.which.toString();\n",
-       "\n",
-       "    this._key_event_extra(event, name);\n",
-       "\n",
-       "    this.send_message(name, {key: value,\n",
-       "                             guiEvent: simpleKeys(event)});\n",
-       "    return false;\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.toolbar_button_onclick = function(name) {\n",
-       "    if (name == 'download') {\n",
-       "        this.handle_save(this, null);\n",
-       "    } else {\n",
-       "        this.send_message(\"toolbar_button\", {name: name});\n",
-       "    }\n",
-       "};\n",
-       "\n",
-       "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n",
-       "    this.message.textContent = tooltip;\n",
-       "};\n",
-       "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to  previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\" [...]
-       "\n",
-       "mpl.extensions = [\"eps\", \"jpeg\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\"];\n",
-       "\n",
-       "mpl.default_extension = \"png\";var comm_websocket_adapter = function(comm) {\n",
-       "    // Create a \"websocket\"-like object which calls the given IPython comm\n",
-       "    // object with the appropriate methods. Currently this is a non binary\n",
-       "    // socket, so there is still some room for performance tuning.\n",
-       "    var ws = {};\n",
-       "\n",
-       "    ws.close = function() {\n",
-       "        comm.close()\n",
-       "    };\n",
-       "    ws.send = function(m) {\n",
-       "        //console.log('sending', m);\n",
-       "        comm.send(m);\n",
-       "    };\n",
-       "    // Register the callback with on_msg.\n",
-       "    comm.on_msg(function(msg) {\n",
-       "        //console.log('receiving', msg['content']['data'], msg);\n",
-       "        // Pass the mpl event to the overridden (by mpl) onmessage function.\n",
-       "        ws.onmessage(msg['content']['data'])\n",
-       "    });\n",
-       "    return ws;\n",
-       "}\n",
-       "\n",
-       "mpl.mpl_figure_comm = function(comm, msg) {\n",
-       "    // This is the function which gets called when the mpl process\n",
-       "    // starts-up an IPython Comm through the \"matplotlib\" channel.\n",
-       "\n",
-       "    var id = msg.content.data.id;\n",
-       "    // Get hold of the div created by the display call when the Comm\n",
-       "    // socket was opened in Python.\n",
-       "    var element = $(\"#\" + id);\n",
-       "    var ws_proxy = comm_websocket_adapter(comm)\n",
-       "\n",
-       "    function ondownload(figure, format) {\n",
-       "        window.open(figure.imageObj.src);\n",
-       "    }\n",
-       "\n",
-       "    var fig = new mpl.figure(id, ws_proxy,\n",
-       "                           ondownload,\n",
-       "                           element.get(0));\n",
-       "\n",
-       "    // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n",
-       "    // web socket which is closed, not our websocket->open comm proxy.\n",
-       "    ws_proxy.onopen();\n",
-       "\n",
-       "    fig.parent_element = element.get(0);\n",
-       "    fig.cell_info = mpl.find_output_cell(\"<div id='\" + id + \"'></div>\");\n",
-       "    if (!fig.cell_info) {\n",
-       "        console.error(\"Failed to find cell for figure\", id, fig);\n",
-       "        return;\n",
-       "    }\n",
-       "\n",
-       "    var output_index = fig.cell_info[2]\n",
-       "    var cell = fig.cell_info[0];\n",
-       "\n",
-       "};\n",
-       "\n",
-       "mpl.figure.prototype.handle_close = function(fig, msg) {\n",
-       "    var width = fig.canvas.width/mpl.ratio\n",
-       "    fig.root.unbind('remove')\n",
-       "\n",
-       "    // Update the output cell to use the data from the current canvas.\n",
-       "    fig.push_to_output();\n",
-       "    var dataURL = fig.canvas.toDataURL();\n",
-       "    // Re-enable the keyboard manager in IPython - without this line, in FF,\n",
-       "    // the notebook keyboard shortcuts fail.\n",
-       "    IPython.keyboard_manager.enable()\n",
-       "    $(fig.parent_element).html('<img src=\"' + dataURL + '\" width=\"' + width + '\">');\n",
-       "    fig.close_ws(fig, msg);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.close_ws = function(fig, msg){\n",
-       "    fig.send_message('closing', msg);\n",
-       "    // fig.ws.close()\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.push_to_output = function(remove_interactive) {\n",
-       "    // Turn the data on the canvas into data in the output cell.\n",
-       "    var width = this.canvas.width/mpl.ratio\n",
-       "    var dataURL = this.canvas.toDataURL();\n",
-       "    this.cell_info[1]['text/html'] = '<img src=\"' + dataURL + '\" width=\"' + width + '\">';\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.updated_canvas_event = function() {\n",
-       "    // Tell IPython that the notebook contents must change.\n",
-       "    IPython.notebook.set_dirty(true);\n",
-       "    this.send_message(\"ack\", {});\n",
-       "    var fig = this;\n",
-       "    // Wait a second, then push the new image to the DOM so\n",
-       "    // that it is saved nicely (might be nice to debounce this).\n",
-       "    setTimeout(function () { fig.push_to_output() }, 1000);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._init_toolbar = function() {\n",
-       "    var fig = this;\n",
-       "\n",
-       "    var nav_element = $('<div/>')\n",
-       "    nav_element.attr('style', 'width: 100%');\n",
-       "    this.root.append(nav_element);\n",
-       "\n",
-       "    // Define a callback function for later on.\n",
-       "    function toolbar_event(event) {\n",
-       "        return fig.toolbar_button_onclick(event['data']);\n",
-       "    }\n",
-       "    function toolbar_mouse_event(event) {\n",
-       "        return fig.toolbar_button_onmouseover(event['data']);\n",
-       "    }\n",
-       "\n",
-       "    for(var toolbar_ind in mpl.toolbar_items){\n",
-       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
-       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
-       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
-       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
-       "\n",
-       "        if (!name) { continue; };\n",
-       "\n",
-       "        var button = $('<button class=\"btn btn-default\" href=\"#\" title=\"' + name + '\"><i class=\"fa ' + image + ' fa-lg\"></i></button>');\n",
-       "        button.click(method_name, toolbar_event);\n",
-       "        button.mouseover(tooltip, toolbar_mouse_event);\n",
-       "        nav_element.append(button);\n",
-       "    }\n",
-       "\n",
-       "    // Add the status bar.\n",
-       "    var status_bar = $('<span class=\"mpl-message\" style=\"text-align:right; float: right;\"/>');\n",
-       "    nav_element.append(status_bar);\n",
-       "    this.message = status_bar[0];\n",
-       "\n",
-       "    // Add the close button to the window.\n",
-       "    var buttongrp = $('<div class=\"btn-group inline pull-right\"></div>');\n",
-       "    var button = $('<button class=\"btn btn-mini btn-primary\" href=\"#\" title=\"Stop Interaction\"><i class=\"fa fa-power-off icon-remove icon-large\"></i></button>');\n",
-       "    button.click(function (evt) { fig.handle_close(fig, {}); } );\n",
-       "    button.mouseover('Stop Interaction', toolbar_mouse_event);\n",
-       "    buttongrp.append(button);\n",
-       "    var titlebar = this.root.find($('.ui-dialog-titlebar'));\n",
-       "    titlebar.prepend(buttongrp);\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._root_extra_style = function(el){\n",
-       "    var fig = this\n",
-       "    el.on(\"remove\", function(){\n",
-       "\tfig.close_ws(fig, {});\n",
-       "    });\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._canvas_extra_style = function(el){\n",
-       "    // this is important to make the div 'focusable\n",
-       "    el.attr('tabindex', 0)\n",
-       "    // reach out to IPython and tell the keyboard manager to turn it's self\n",
-       "    // off when our div gets focus\n",
-       "\n",
-       "    // location in version 3\n",
-       "    if (IPython.notebook.keyboard_manager) {\n",
-       "        IPython.notebook.keyboard_manager.register_events(el);\n",
-       "    }\n",
-       "    else {\n",
-       "        // location in version 2\n",
-       "        IPython.keyboard_manager.register_events(el);\n",
-       "    }\n",
-       "\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype._key_event_extra = function(event, name) {\n",
-       "    var manager = IPython.notebook.keyboard_manager;\n",
-       "    if (!manager)\n",
-       "        manager = IPython.keyboard_manager;\n",
-       "\n",
-       "    // Check for shift+enter\n",
-       "    if (event.shiftKey && event.which == 13) {\n",
-       "        this.canvas_div.blur();\n",
-       "        // select the cell after this one\n",
-       "        var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n",
-       "        IPython.notebook.select(index + 1);\n",
-       "    }\n",
-       "}\n",
-       "\n",
-       "mpl.figure.prototype.handle_save = function(fig, msg) {\n",
-       "    fig.ondownload(fig, null);\n",
-       "}\n",
-       "\n",
-       "\n",
-       "mpl.find_output_cell = function(html_output) {\n",
-       "    // Return the cell and output element which can be found *uniquely* in the notebook.\n",
-       "    // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n",
-       "    // IPython event is triggered only after the cells have been serialised, which for\n",
-       "    // our purposes (turning an active figure into a static one), is too late.\n",
-       "    var cells = IPython.notebook.get_cells();\n",
-       "    var ncells = cells.length;\n",
-       "    for (var i=0; i<ncells; i++) {\n",
-       "        var cell = cells[i];\n",
-       "        if (cell.cell_type === 'code'){\n",
-       "            for (var j=0; j<cell.output_area.outputs.length; j++) {\n",
-       "                var data = cell.output_area.outputs[j];\n",
-       "                if (data.data) {\n",
-       "                    // IPython >= 3 moved mimebundle to data attribute of output\n",
-       "                    data = data.data;\n",
-       "                }\n",
-       "                if (data['text/html'] == html_output) {\n",
-       "                    return [cell, data, j];\n",
-       "                }\n",
-       "            }\n",
-       "        }\n",
-       "    }\n",
-       "}\n",
-       "\n",
-       "// Register the function which deals with the matplotlib target/channel.\n",
-       "// The kernel may be null if the page has been refreshed.\n",
-       "if (IPython.notebook.kernel != null) {\n",
-       "    IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n",
-       "}\n"
-      ],
-      "text/plain": [
-       "<IPython.core.display.Javascript object>"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/html": [
-       "<img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABDgAAAIcCAYAAAAT/R6VAAAgAElEQVR4XuydB5hURfbFz+QhDVlyDpJBkogCYlgzBnQXA2bd/7qYWXMAE8bVNSu6Zl0jCmIkCEhOkqMEyUPOTP5/5/V70LQdXs90z1R3n/q+kXG6Xr1bv6qZd9+pW7eSoCICIiACIiACIiACIiACIiACIiACIiACMU4gKcbtl/kiIAIiIAIiIAIiIAIiIAIiIAIiIAIiAAkcmgSmEuDc7A/gEgDHAzjGNnQzgJkAPgPwNYACrw6sAdAIQBMA/N7E0hjAagBrAfB733ITgP8D0AJAple9IQAeBjAUAL83rfwCoA+AvgD4vcmFc+t3e55wPjUAkG+ywbJNBERABETAGALF8U+MMT4Chjh+TKim5gHoFKqSPg9JwPH/3gNwdcjaqiACIiCBQ3PASAL1AXw [...]
-      ],
-      "text/plain": [
-       "<IPython.core.display.HTML object>"
-      ]
-     },
-     "metadata": {},
-     "output_type": "display_data"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "<matplotlib.legend.Legend at 0x1570e6a50>"
-      ]
-     },
-     "execution_count": 13,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,21,'Iteration')"
-      ]
-     },
-     "execution_count": 13,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,1,'Classification Accuracy')"
-      ]
-     },
-     "execution_count": 13,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,21,'Iteration')"
-      ]
-     },
-     "execution_count": 13,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "Text(0.5,1,'Cross Entropy Loss')"
-      ]
-     },
-     "execution_count": 13,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n",
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x157191790>]"
-      ]
-     },
-     "execution_count": 13,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x157191c10>]"
-      ]
-     },
-     "execution_count": 13,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x1571912d0>]"
-      ]
-     },
-     "execution_count": 13,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[<matplotlib.lines.Line2D at 0x157184890>]"
-      ]
-     },
-     "execution_count": 13,
-     "metadata": {},
-     "output_type": "execute_result"
-    },
-    {
-     "data": {
-      "text/plain": [
-       "<matplotlib.legend.Legend at 0x15719c810>"
-      ]
-     },
-     "execution_count": 13,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "# mst tuple(s) to plot\n",
-    "mst_key_to_plot = 10\n",
-    "df_results = %sql SELECT * FROM cifar10_multi_model_info WHERE mst_key = $mst_key_to_plot;\n",
-    "df_results = df_results.DataFrame()\n",
-    "\n",
-    "df_summary = %sql SELECT * FROM cifar10_multi_model_summary;\n",
-    "df_summary = df_summary.DataFrame()\n",
-    "\n",
-    "#set up plots\n",
-    "fig, axs = plt.subplots(nrows=1, ncols=2, figsize=(10,5))\n",
-    "fig.legend(ncol=4)\n",
-    "fig.tight_layout()\n",
-    "\n",
-    "ax_metric = axs[0]\n",
-    "ax_loss = axs[1]\n",
-    "\n",
-    "ax_metric.xaxis.set_major_locator(MaxNLocator(integer=True))\n",
-    "ax_metric.set_xlabel('Iteration')\n",
-    "#ax_metric.set_ylabel('Accuracy')\n",
-    "ax_metric.set_title('Classification Accuracy')\n",
-    "\n",
-    "ax_loss.xaxis.set_major_locator(MaxNLocator(integer=True))\n",
-    "ax_loss.set_xlabel('Iteration')\n",
-    "#ax_loss.set_ylabel('Loss')\n",
-    "ax_loss.set_title('Cross Entropy Loss')\n",
-    "\n",
-    "iters = df_summary['metrics_iters'][0]\n",
-    "\n",
-    "for mst_key in df_results['mst_key']:\n",
-    "    \n",
-    "    #train\n",
-    "    df_output_info = %sql SELECT training_metrics,training_loss FROM cifar10_multi_model_info WHERE mst_key = $mst_key\n",
-    "    df_output_info = df_output_info.DataFrame()\n",
-    "    training_metrics = df_output_info['training_metrics'][0]\n",
-    "    training_loss = df_output_info['training_loss'][0]\n",
-    "    \n",
-    "    #test\n",
-    "    df_output_info = %sql SELECT validation_metrics,validation_loss FROM cifar10_multi_model_info WHERE mst_key = $mst_key\n",
-    "    df_output_info = df_output_info.DataFrame()\n",
-    "    validation_metrics = df_output_info['validation_metrics'][0]\n",
-    "    validation_loss = df_output_info['validation_loss'][0]\n",
-    "    \n",
-    "    label_train = str(mst_key) + '-train'\n",
-    "    #ax_metric.plot(iters, training_metrics, label=label_train, marker='x')\n",
-    "    #ax_loss.plot(iters, training_loss, label=label_train, marker='x')\n",
-    "    ax_metric.plot(iters, training_metrics, label=label_train)\n",
-    "    ax_loss.plot(iters, training_loss, label=label_train)\n",
-    "    \n",
-    "    \n",
-    "    label_test = str(mst_key) + '-test'\n",
-    "    #ax_metric.plot(iters, validation_metrics, label=label_test, marker='o')\n",
-    "    #ax_loss.plot(iters, validation_loss, label=label_test, marker='o')\n",
-    "    ax_metric.plot(iters, validation_metrics, label=label_test)\n",
-    "    ax_loss.plot(iters, validation_loss, label=label_test)\n",
-    "\n",
-    "\n",
-    "plt.legend()\n",
-    "# fig.savefig('./lc_keras_fit.png', dpi = 300)"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "<a id=\"predict\"></a>\n",
-    "# 7. Inference\n",
-    "\n",
-    "## 7a. Run predict on the whole validation dataset\n",
-    "\n",
-    "Pick a reasonable model from the previous run."
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 14,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>mst_key</th>\n",
-       "        <th>model_id</th>\n",
-       "        <th>compile_params</th>\n",
-       "        <th>fit_params</th>\n",
-       "        <th>model_type</th>\n",
-       "        <th>model_size</th>\n",
-       "        <th>metrics_elapsed_time</th>\n",
-       "        <th>metrics_type</th>\n",
-       "        <th>training_metrics_final</th>\n",
-       "        <th>training_loss_final</th>\n",
-       "        <th>training_metrics</th>\n",
-       "        <th>training_loss</th>\n",
-       "        <th>validation_metrics_final</th>\n",
-       "        <th>validation_loss_final</th>\n",
-       "        <th>validation_metrics</th>\n",
-       "        <th>validation_loss</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>10</td>\n",
-       "        <td>2</td>\n",
-       "        <td>loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']</td>\n",
-       "        <td>batch_size=128,epochs=5</td>\n",
-       "        <td>madlib_keras</td>\n",
-       "        <td>2159.70019531</td>\n",
-       "        <td>[158.506701946259, 323.779083013535, 491.302199840546, 660.148201942444, 829.340363025665, 999.844955921173, 1169.83032798767, 1340.5411260128, 1513.8498609066, 1687.69545793533]</td>\n",
-       "        <td>[u'accuracy']</td>\n",
-       "        <td>0.867579996586</td>\n",
-       "        <td>0.380911707878</td>\n",
-       "        <td>[0.576640009880066, 0.66431999206543, 0.707199990749359, 0.749520003795624, 0.778980016708374, 0.799520015716553, 0.820659995079041, 0.839940011501312, 0.854659974575043, 0.867579996585846]</td>\n",
-       "        <td>[1.20035827159882, 0.945839285850525, 0.823047578334808, 0.703792750835419, 0.624295234680176, 0.566677749156952, 0.511338114738464, 0.459649682044983, 0.418204575777054, 0.380911707878113]</td>\n",
-       "        <td>0.799700021744</td>\n",
-       "        <td>0.571797966957</td>\n",
-       "        <td>[0.572700023651123, 0.655099987983704, 0.69980001449585, 0.731299996376038, 0.756399989128113, 0.771399974822998, 0.778999984264374, 0.791599988937378, 0.798200011253357, 0.799700021743774]</td>\n",
-       "        <td>[1.20565474033356, 0.964107036590576, 0.849484860897064, 0.752416431903839, 0.691979646682739, 0.65268349647522, 0.628291726112366, 0.599337160587311, 0.586054861545563, 0.571797966957092]</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(10, 2, u\"loss='categorical_crossentropy',optimizer='adam(lr=0.0001)',metrics=['accuracy']\", u'batch_size=128,epochs=5', u'madlib_keras', 2159.70019531, [158.506701946259, 323.779083013535, 491.302199840546, 660.148201942444, 829.340363025665, 999.844955921173, 1169.83032798767, 1340.5411260128, 1513.8498609066, 1687.69545793533], [u'accuracy'], 0.867579996586, 0.380911707878, [0.576640009880066, 0.66431999206543, 0.707199990749359, 0.749520003795624, 0.778980016708374, 0.7995 [...]
-      ]
-     },
-     "execution_count": 14,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "SELECT * FROM cifar10_multi_model_info WHERE mst_key=10;"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 15,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "Done.\n",
-      "1 rows affected.\n",
-      "5 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>id</th>\n",
-       "        <th>estimated_y</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>1</td>\n",
-       "        <td>3</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>2</td>\n",
-       "        <td>8</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>3</td>\n",
-       "        <td>8</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>4</td>\n",
-       "        <td>8</td>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>5</td>\n",
-       "        <td>6</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(1, 3), (2, 8), (3, 8), (4, 8), (5, 6)]"
-      ]
-     },
-     "execution_count": 15,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "DROP TABLE IF EXISTS cifar10_val_predict;\n",
-    "\n",
-    "SELECT madlib.madlib_keras_predict('cifar10_multi_model', -- model\n",
-    "                                   'cifar10_val',         -- test_table\n",
-    "                                   'id',                  -- id column\n",
-    "                                   'x',                   -- independent var\n",
-    "                                   'cifar10_val_predict', -- output table\n",
-    "                                    'response',           -- prediction type\n",
-    "                                    TRUE,                 -- use gpus\n",
-    "                                    10                    -- mst_key to use\n",
-    "                                   );\n",
-    "\n",
-    "SELECT * FROM cifar10_val_predict ORDER BY id LIMIT 5;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Count missclassifications"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 16,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>count</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>2003</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(2003L,)]"
-      ]
-     },
-     "execution_count": 16,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "SELECT COUNT(*) FROM cifar10_val_predict JOIN cifar10_val USING (id) \n",
-    "WHERE cifar10_val_predict.estimated_y != cifar10_val.y;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Accuracy"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 17,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>test_accuracy_percent</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>79.97</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(Decimal('79.97'),)]"
-      ]
-     },
-     "execution_count": 17,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "SELECT round(count(*)*100.0/10000.0,2) as test_accuracy_percent from\n",
-    "    (select cifar10_val.y as actual, cifar10_val_predict.estimated_y as predicted\n",
-    "     from cifar10_val_predict inner join cifar10_val\n",
-    "     on cifar10_val.id=cifar10_val_predict.id) q\n",
-    "WHERE q.actual=q.predicted;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "## 7b. Select a random image from the validation dataset and run predict\n",
-    "\n",
-    "Label map"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 18,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "label_names = {\n",
-    "    0 :\"airplane\",\n",
-    "    1 :\"automobile\",\n",
-    "    2 :\"bird\",\n",
-    "    3 :\"cat\",\n",
-    "    4 :\"deer\",\n",
-    "    5 :\"dog\",\n",
-    "    6 :\"frog\",\n",
-    "    7 :\"horse\",\n",
-    "    8 :\"ship\",\n",
-    "    9 :\"truck\"\n",
-    "}"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Pick a random image"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 19,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "Done.\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "[]"
-      ]
-     },
-     "execution_count": 19,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "DROP TABLE IF EXISTS cifar10_val_random;\n",
-    "CREATE TABLE cifar10_val_random AS\n",
-    "    SELECT * FROM cifar10_val ORDER BY random() LIMIT 1;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Predict"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 20,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "Done.\n",
-      "1 rows affected.\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>id</th>\n",
-       "        <th>prob_0</th>\n",
-       "        <th>prob_1</th>\n",
-       "        <th>prob_2</th>\n",
-       "        <th>prob_3</th>\n",
-       "        <th>prob_4</th>\n",
-       "        <th>prob_5</th>\n",
-       "        <th>prob_6</th>\n",
-       "        <th>prob_7</th>\n",
-       "        <th>prob_8</th>\n",
-       "        <th>prob_9</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>5221</td>\n",
-       "        <td>1.0724234e-06</td>\n",
-       "        <td>1.4683914e-07</td>\n",
-       "        <td>1.5451868e-06</td>\n",
-       "        <td>2.83348e-07</td>\n",
-       "        <td>6.203704e-05</td>\n",
-       "        <td>4.6814375e-06</td>\n",
-       "        <td>6.654035e-09</td>\n",
-       "        <td>0.99993</td>\n",
-       "        <td>1.17486385e-08</td>\n",
-       "        <td>5.6579474e-08</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[(5221, 1.0724234e-06, 1.4683914e-07, 1.5451868e-06, 2.83348e-07, 6.203704e-05, 4.6814375e-06, 6.654035e-09, 0.99993, 1.17486385e-08, 5.6579474e-08)]"
-      ]
-     },
-     "execution_count": 20,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "DROP TABLE IF EXISTS cifar10_val_random_predict;\n",
-    "\n",
-    "SELECT madlib.madlib_keras_predict('cifar10_multi_model', -- model\n",
-    "                                   'cifar10_val_random',  -- test_table\n",
-    "                                   'id',                  -- id column\n",
-    "                                   'x',                   -- independent var\n",
-    "                                   'cifar10_val_random_predict', -- output table\n",
-    "                                    'prob',               -- prediction type\n",
-    "                                    TRUE,                 -- use gpus\n",
-    "                                    10                    -- mst_key to use\n",
-    "                                   );\n",
-    "\n",
-    "SELECT * FROM cifar10_val_random_predict;"
-   ]
-  },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "Format output and display"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 21,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "Done.\n",
-      "1 rows affected.\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/html": [
-       "<table>\n",
-       "    <tr>\n",
-       "        <th>feature_vector</th>\n",
-       "    </tr>\n",
-       "    <tr>\n",
-       "        <td>[1.0724234e-06, 1.4683914e-07, 1.5451868e-06, 2.83348e-07, 6.203704e-05, 4.6814375e-06, 6.654035e-09, 0.99993, 1.17486385e-08, 5.6579474e-08]</td>\n",
-       "    </tr>\n",
-       "</table>"
-      ],
-      "text/plain": [
-       "[([1.0724234e-06, 1.4683914e-07, 1.5451868e-06, 2.83348e-07, 6.203704e-05, 4.6814375e-06, 6.654035e-09, 0.99993, 1.17486385e-08, 5.6579474e-08],)]"
-      ]
-     },
-     "execution_count": 21,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "%%sql\n",
-    "DROP TABLE IF EXISTS cifar10_val_random_predict_array, cifar10_val_random_predict_array_summary;\n",
-    "SELECT madlib.cols2vec(\n",
-    "    'cifar10_val_random_predict',\n",
-    "    'cifar10_val_random_predict_array',\n",
-    "    '*',\n",
-    "    'id'\n",
-    ");\n",
-    "select * from cifar10_val_random_predict_array;"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 22,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      " * postgresql://gpadmin@localhost:8000/cifar_places\n",
-      "1 rows affected.\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "<matplotlib.image.AxesImage at 0x15724d350>"
-      ]
... 13052 lines suppressed ...