Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
786 lines (785 sloc) 93.6 KB
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>MNIST dataset in Keras library</h2>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Load data</h2>"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Training instances: 60000\n",
"Test instances: 10000\n",
"\n",
"Structure of training set: (60000, 28, 28)\n",
"Structure of labels set: (60000, 10)\n"
]
}
],
"source": [
"# Imports\n",
"# - Dataset\n",
"from keras.datasets import mnist\n",
"# - Helper libraries\n",
"import numpy as np\n",
"import pandas as pd\n",
"import time\n",
"from sklearn.metrics import confusion_matrix\n",
"from keras.utils import np_utils\n",
"# - Graph plots\n",
"%matplotlib inline\n",
"from matplotlib import pyplot as plt\n",
"# - Keras models and layers\n",
"from keras.models import Sequential\n",
"from keras.layers import Dense, Flatten, Dropout, BatchNormalization, Convolution2D, MaxPooling2D\n",
"from keras.callbacks import EarlyStopping\n",
"\n",
"# Ignore warnings\n",
"import tensorflow as tf\n",
"tf.logging.set_verbosity(tf.logging.ERROR)\n",
"\n",
"# Load pre-shuffled MNIST data into train and test sets\n",
"(X_train, y_train_raw), (X_test, y_test_raw) = mnist.load_data()\n",
"\n",
"# Convert to float values and normalize between 0...1\n",
"X_train = X_train.astype(\"float32\")\n",
"X_test = X_test.astype(\"float32\")\n",
"X_train /= 255 \n",
"X_test /= 255\n",
"\n",
"# Preprocess class labels\n",
"# Convert labels to 10-dimensional one-hot vectors\n",
"y_train = np_utils.to_categorical(y_train_raw, 10)\n",
"y_test = np_utils.to_categorical(y_test_raw, 10)\n",
"\n",
"print(\"Training instances: {}\".format(X_train.shape[0]))\n",
"print(\"Test instances: {}\".format(X_test.shape[0]))\n",
"print()\n",
"print(\"Structure of training set: {}\".format(X_train.shape))\n",
"print(\"Structure of labels set: {}\".format(y_train.shape))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Pre-process data for 1D or 2D inputs</h2>"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1D shape: (60000, 784)\n",
"2D shape: (60000, 28, 28, 1)\n"
]
}
],
"source": [
"# Preprocess for 1D input data\n",
"X_train_1D = X_train.reshape(X_train.shape[0], 784)\n",
"X_test_1D = X_test.reshape(X_test.shape[0], 784)\n",
"print(\"1D shape:\", X_train_1D.shape)\n",
"\n",
"# Preprocess for 2D input data\n",
"X_train_2D = X_train.reshape(X_train.shape[0], 28, 28, 1)\n",
"X_test_2D = X_test.reshape(X_test.shape[0], 28, 28, 1)\n",
"print(\"2D shape:\", X_train_2D.shape)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Build Linear model</h2>"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"_________________________________________________________________\n",
"Layer (type) Output Shape Param # \n",
"=================================================================\n",
"dense_1 (Dense) (None, 10) 7850 \n",
"=================================================================\n",
"Total params: 7,850\n",
"Trainable params: 7,850\n",
"Non-trainable params: 0\n",
"_________________________________________________________________\n",
"None\n"
]
}
],
"source": [
"# Create Linear Softmax model\n",
"lin_clf = Sequential()\n",
"lin_clf.add(Dense(10, input_dim=784, activation=\"softmax\"))\n",
"\n",
"# Compile model\n",
"lin_clf.compile(loss=\"categorical_crossentropy\", optimizer=\"adam\", metrics=[\"accuracy\"])\n",
"print(lin_clf.summary())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Train and evaluate Linear model on test data</h2>"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Epoch 1/8\n",
"60000/60000 [==============================] - 2s 34us/step - loss: 0.4718 - acc: 0.8769\n",
"Epoch 2/8\n",
"60000/60000 [==============================] - 2s 31us/step - loss: 0.3042 - acc: 0.9155\n",
"Epoch 3/8\n",
"60000/60000 [==============================] - 2s 32us/step - loss: 0.2831 - acc: 0.9204\n",
"Epoch 4/8\n",
"60000/60000 [==============================] - 2s 30us/step - loss: 0.2730 - acc: 0.9238\n",
"Epoch 5/8\n",
"60000/60000 [==============================] - 2s 30us/step - loss: 0.2668 - acc: 0.9260\n",
"Epoch 6/8\n",
"60000/60000 [==============================] - 2s 31us/step - loss: 0.2619 - acc: 0.9270\n",
"Epoch 7/8\n",
"60000/60000 [==============================] - 2s 37us/step - loss: 0.2578 - acc: 0.9288\n",
"Epoch 8/8\n",
"60000/60000 [==============================] - 2s 41us/step - loss: 0.2556 - acc: 0.9300\n",
"\n",
"Test Accuracy: 92.87%\n",
"Time elapsed: 16.27 sec\n"
]
}
],
"source": [
"# Start timer\n",
"start = time.time()\n",
"\n",
"# Train model on training data\n",
"lin_clf.fit(X_train_1D, y_train, batch_size=32, epochs=8, verbose=1)\n",
"# Evaluate model on test data\n",
"score = lin_clf.evaluate(X_test_1D, y_test, verbose=0)\n",
"\n",
"# Stop timer\n",
"end = time.time()\n",
"\n",
"# Print results\n",
"print(\"\\nTest Accuracy: {0:0.2f}%\".format(score[1] * 100))\n",
"print(\"Time elapsed: {0:0.2f} sec\".format(end - start))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Build Neural Net model</h2>"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"_________________________________________________________________\n",
"Layer (type) Output Shape Param # \n",
"=================================================================\n",
"dense_24 (Dense) (None, 128) 100480 \n",
"_________________________________________________________________\n",
"dropout_17 (Dropout) (None, 128) 0 \n",
"_________________________________________________________________\n",
"dense_25 (Dense) (None, 128) 16512 \n",
"_________________________________________________________________\n",
"dropout_18 (Dropout) (None, 128) 0 \n",
"_________________________________________________________________\n",
"dense_26 (Dense) (None, 10) 1290 \n",
"=================================================================\n",
"Total params: 118,282\n",
"Trainable params: 118,282\n",
"Non-trainable params: 0\n",
"_________________________________________________________________\n",
"None\n"
]
}
],
"source": [
"# Create Neural Net Softmax model\n",
"nn_clf = Sequential()\n",
"# - first Dense\n",
"nn_clf.add(Dense(128, input_dim=784, activation=\"elu\", kernel_initializer=\"he_normal\"))\n",
"nn_clf.add(Dropout(0.2))\n",
"# - second Dense\n",
"nn_clf.add(Dense(128, activation=\"elu\", kernel_initializer=\"he_normal\"))\n",
"nn_clf.add(Dropout(0.2))\n",
"# - output\n",
"nn_clf.add(Dense(10, activation=\"softmax\"))\n",
"\n",
"# Compile model\n",
"nn_clf.compile(loss=\"categorical_crossentropy\", optimizer=\"adam\", metrics=[\"accuracy\"])\n",
"print(nn_clf.summary())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Train and evaluate Neural Net model on test data</h2>"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train on 48000 samples, validate on 12000 samples\n",
"Epoch 1/15\n",
"48000/48000 [==============================] - 3s 65us/step - loss: 0.1707 - acc: 0.9480 - val_loss: 0.1290 - val_acc: 0.9633\n",
"Epoch 2/15\n",
"48000/48000 [==============================] - 3s 62us/step - loss: 0.1464 - acc: 0.9541 - val_loss: 0.1188 - val_acc: 0.9657\n",
"Epoch 3/15\n",
"48000/48000 [==============================] - 3s 63us/step - loss: 0.1261 - acc: 0.9612 - val_loss: 0.1035 - val_acc: 0.9688\n",
"Epoch 4/15\n",
"48000/48000 [==============================] - 4s 80us/step - loss: 0.1129 - acc: 0.9649 - val_loss: 0.0965 - val_acc: 0.9696\n",
"Epoch 5/15\n",
"48000/48000 [==============================] - 3s 70us/step - loss: 0.0993 - acc: 0.9690 - val_loss: 0.0958 - val_acc: 0.9709\n",
"Epoch 6/15\n",
"48000/48000 [==============================] - 3s 70us/step - loss: 0.0928 - acc: 0.9711 - val_loss: 0.0853 - val_acc: 0.9739\n",
"Epoch 7/15\n",
"48000/48000 [==============================] - 4s 77us/step - loss: 0.0828 - acc: 0.9739 - val_loss: 0.0903 - val_acc: 0.9743\n",
"Epoch 8/15\n",
"48000/48000 [==============================] - 3s 69us/step - loss: 0.0757 - acc: 0.9754 - val_loss: 0.0804 - val_acc: 0.9762\n",
"Epoch 9/15\n",
"48000/48000 [==============================] - 3s 69us/step - loss: 0.0716 - acc: 0.9766 - val_loss: 0.0893 - val_acc: 0.9747\n",
"Epoch 10/15\n",
"48000/48000 [==============================] - 3s 68us/step - loss: 0.0653 - acc: 0.9782 - val_loss: 0.0845 - val_acc: 0.9772\n",
"\n",
"Test Accuracy: 97.95%\n",
"Time elapsed: 33.77 sec\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAecAAAEzCAYAAAALosttAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3XuYXHWd7/v3t+59y/0GSTAgGARiuIvjJgQZBR2FGUdEvIzybOGM43WY45GtjjrK7Lkwe+bMPIetO4+DiscLEfUMs2WLo6SNjoABBEISkp2JXDqQkGsnfan79/yxVlVXdXfS1Z1KanXl83qeemqt3/qttX6/6qQ+9Vtr1Spzd0RERCQ6Yq1ugIiIiNRTOIuIiESMwllERCRiFM4iIiIRo3AWERGJGIWziIhIxEwYzmZ2l5m9bGZPH2G5mdk/mdl2M3vKzC5sfjNFREROHo2MnL8OXHOU5W8GzgoftwBfPvZmiYiInLwmDGd3Xw/sP0qV64C7PfAwMMvMTmlWA0VERE42zTjnvBh4oWa+LywTERGRKUicyJ2Z2S0Eh77JZDIXnXbaaSdy98dFuVwmFpve19W1Qx+gPfrRDn0A9SNK2qEP0B792LZt2153n99I3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000Dw1aevfe1rY+rcdttt3HZb/U9KXH311Vx99dVTaXbDdM5ZREQkYjRyFhGRtrZx40be97731ZWl0+njcmewZlE4i4hIW1uxYgVPPPFEq5sxKTqsLSIiEjEKZxERkYhROIuIiESMwllERCRiFM4iItK2puvvcSucRUREIkZfpRIRkcn7X7fBro0T15uMRSvgzX991CrN/D3ngYEBrrvuunHXu/vuu/m7v/s7zIzXvOY1fPOb32T37t388R//MTt27ADgy1/+Mr/zO79zjJ0en8JZRESmjWb+nnMmk+GHP/zhmPU2b97M7bffzq9+9SvmzZvH/v37AfjYxz7GFVdcwQ9/+ENKpdJRbw16rBTOIiIyeROMcI+XZv6es7vz6U9/esx6Dz74INdffz3z5s0DYM6cOQA8+OCD3H333QDE43Fmzpx53PqpcBYRkWml8nvOu3btGvN7zslkkmXLljX0e85TXe9E0AVhIiIyrdxwww1897vf5d577+X666+nv79/Sr/nfKT13vCGN/C9732Pffv2AVQPa1911VXVn4cslUr09/cfh94FFM4iIjKtjPd7zo8++igrVqzg7rvvbvj3nI+03rnnnstnPvMZrrjiClauXMmtt94KwD/+4z+ybt06VqxYwUUXXcTmzZuPWx91WFtERKadZvye89HWe//738/73//+urKFCxfyL//yL1No7eRp5CwiIhIxGjmLiEhb0+85i4iIRIx+z1lERESOmcJZREQkYhTOIiIiEaNwFhGRaWO6/gTkZCmcRUREIkbhLCIi046788lPfpLzzjuPFStWcM899wDw0ksvsWrVKs4//3zOO+88fvGLX1AqlfjABz5QrfsP//APLW79xPRVKhERmbS/+fXf8Mz+Z5q6zbPnnM2nLv1UQ3V/8IMf8MQTT/Dkk0+yd+9eLrnkElatWsW3v/1trr76aj7zmc9QKpUYGhriiSeeYOfOnTz99NMAHDx4sKntPh40chYRkWnnl7/8JTfeeCPxeJyFCxdyxRVXsGHDBi655BK+9rWv8YUvfIGNGzfS09PDGWecwY4dO/joRz/Kj3/8Y2bMmNHq5k9II2cREZm0Rke4J9qqVatYv349P/rRj/jABz7Arbfeyh/90R/x5JNP8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YB95nZtaMD2t3XAGsAli9f7qtXr26kjZHW29vLdO9HO/QB2qMf7dAHUD+ipJl92LJlCz09PU3Z1mQdPny4ZfueikwmwwUXXDDl9Rs5rL0BOMvMTjezFPAu4L7KQnfvd/d57r7M3ZcBDwNjgllEREQaM2E4u3sR+AjwALAFWOvum8zsi2Z27fFuoIiIRMdEp0KlOa9RQzchcff7gftHlX3uCHVXH3OrREQkcjKZDPv27WPu3LmEpzFlFHdn3759ZDKZY9qO7hAmIiINWbJkCX19fezZs+eE7zubzR5z4J0omUyGJUuWHNM2FM4iItKQZDJZvQvXidbb23tMF1hNN/rhCxERkYhROIuIiESMwllERCRiFM4iIiIRo3AWERGJGIWziIhIxCicRUREIkbhLCIiEjEKZxERkYhROIuIiESMwllERCRiFM4iIiIRo3AWERGJGIWziIhIxCicRUREIkbhLCIiEjEKZxERkYhROIuIiESMwllERCRiFM4iIiIRo3AWERGJGIWziIhIxCicRUREIkbhLCIiEjEKZxERkYhROIuIiESMwllERCRiFM4iIiIRo3AWERGJGIWziIhIxCicRUREIkbhLCIiEjEKZxERkYhROIuIiESMwllERCRiFM4iIiIRo3AWERGJGIWziIhIxCicRUREIkbhLCIiEjEKZxERkYhROIuIiESMwllERCRiFM4iIiIR01A4m9k1ZrbVzLab2W3jLL/VzDab2VNm9jMze0XzmyoiInJymDCczSwO3Am8GTgHuNHMzhlV7TfAxe7+GuBe4G+b3VAREZGTRSMj50uB7e6+w93zwHeB62oruPs6dx8KZx8GljS3mSIiIicPc/ejVzB7B3CNu38wnH8f8Fp3/8gR6v8/wC53v32cZbcAtwDMnz//orVr1x5j81tvYGCA7u7uVjfjmLRDH6A9+tEOfQD1I0raoQ/QHv248sorH3P3ixupm2jmjs3svcDFwBXjLXf3NcAagOXLl/vq1aubufuW6O3tZbr3ox36AO3Rj3boA6gfUdIOfYD26UejGgnnncDSmvklYVkdM/td4DPAFe6ea07zRERETj6NnHPeAJxlZqebWQp4F3BfbQUzuwD4H8C17v5y85spIiJy8pgw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CKcG7kdqBygoW/JHYB8EhrWzJ54aHgJ4CXgX9z92nXh9D/DfxfQLnVDTlGDvzEzB4L7wo43ZwO7AG+Fp5i+KqZdbW6UcfoXcB3Wt2IyXL3ncDfAc8DLwH97v6T1rZqSp4GLjezuWbWCbyF+pt7jaELwgQz6wa+D3zC3Q+1uj2T5e4ldz+f4O51l4aHkKYVM3sr8LK7P9bqtjTBf3L3Cwl+ye7D4Smg6SQBXAh82d0vAAaBaXltDEB4WP5a4HutbstkmdlsgiOrpwOnAl1m9t7Wtmry3H0Lwa81/oTgkPYTQOlo67QinBu5HaicIOF52u8D33L3H7S6PcciPPS4Drim1W2ZgtcD14bna78LvMHM/t/WNmlqwtEO7v4y8EOCU1nTSR/QV3ME5l6CsJ6u3gw87u67W92QKfhd4LfuvsfdC8APgN9pcZumxN3/2d0vcvdVwAGCa6+OqBXh3MjtQOUECC+m+mdgi7v/favbMxVmNt/MZoXTHQQXGj7T2lZNnrv/F3df4u7LCP5PPOju026EYGZd4cWFhIeC30RwSG/acPddwAtmVvmRgquAaXOR5DhuZBoe0g49D1xmZp3h+9VVBNfGTDtmtiB8Po3gfPO3j1b/hP4qFRz5dqAnuh3Hysy+A6wG5plZH/B5d//n1rZq0l4PvA/YGJ6zBfh0eEe46eIU4Bvh1agxYK27T9uvIbWBhcAPw59zTwDfdvcft7ZJU/JR4FvhAGIHcFOL2zMl4QekNwL/R6vbMhXu/oiZ3Qs8DhSB3zB97xT2fTObCxSAD090kaHuECYiIhIxuiBMREQkYhTOIiIiEaNwFhERiRiFs4iISMQonEVERCJG4SwiIhIxCmcREZGIUTiLiIhEzP8PCTyvsJM9vY0AAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 576x360 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Early stopping\n",
"cp = EarlyStopping(patience=2, restore_best_weights=True)\n",
"\n",
"# Start timer\n",
"start = time.time()\n",
"\n",
"# Train model on training data\n",
"history = nn_clf.fit(X_train_1D, y_train, batch_size=64, epochs=15, validation_split=0.2, callbacks=[cp], verbose=1)\n",
"# Evaluate model on test data\n",
"score = nn_clf.evaluate(X_test_1D, y_test, verbose=0)\n",
"\n",
"# Stop timer\n",
"end = time.time()\n",
"\n",
"# Print results\n",
"print(\"\\nTest Accuracy: {0:0.2f}%\".format(score[1] * 100))\n",
"print(\"Time elapsed: {0:0.2f} sec\".format(end - start))\n",
"\n",
"# Plot training history\n",
"pd.DataFrame(history.history).plot(figsize=(8, 5)) \n",
"plt.grid(True)\n",
"plt.gca().set_ylim(0, 1)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Build ConvNet model</h2>"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"_________________________________________________________________\n",
"Layer (type) Output Shape Param # \n",
"=================================================================\n",
"conv2d_13 (Conv2D) (None, 28, 28, 32) 320 \n",
"_________________________________________________________________\n",
"max_pooling2d_13 (MaxPooling (None, 14, 14, 32) 0 \n",
"_________________________________________________________________\n",
"dropout_22 (Dropout) (None, 14, 14, 32) 0 \n",
"_________________________________________________________________\n",
"conv2d_14 (Conv2D) (None, 14, 14, 32) 9248 \n",
"_________________________________________________________________\n",
"max_pooling2d_14 (MaxPooling (None, 7, 7, 32) 0 \n",
"_________________________________________________________________\n",
"dropout_23 (Dropout) (None, 7, 7, 32) 0 \n",
"_________________________________________________________________\n",
"flatten_7 (Flatten) (None, 1568) 0 \n",
"_________________________________________________________________\n",
"dense_29 (Dense) (None, 128) 200832 \n",
"_________________________________________________________________\n",
"batch_normalization_4 (Batch (None, 128) 512 \n",
"_________________________________________________________________\n",
"dropout_24 (Dropout) (None, 128) 0 \n",
"_________________________________________________________________\n",
"dense_30 (Dense) (None, 10) 1290 \n",
"=================================================================\n",
"Total params: 212,202\n",
"Trainable params: 211,946\n",
"Non-trainable params: 256\n",
"_________________________________________________________________\n",
"None\n"
]
}
],
"source": [
"# Create ConvNet model\n",
"cnn_clf = Sequential()\n",
"# - first conv/pool \n",
"cnn_clf.add(Convolution2D(32, (3,3), input_shape=(28,28,1), activation=\"elu\", padding=\"same\", kernel_initializer=\"he_normal\"))\n",
"cnn_clf.add(MaxPooling2D(pool_size=(2,2))) # reduces size to 14x14\n",
"cnn_clf.add(Dropout(0.3))\n",
"# - second conv/pool\n",
"cnn_clf.add(Convolution2D(32, (3,3), activation=\"elu\", padding=\"same\", kernel_initializer=\"he_normal\"))\n",
"cnn_clf.add(MaxPooling2D(pool_size=(2,2))) # reduces size to 7x7\n",
"cnn_clf.add(Dropout(0.3))\n",
"# - fully connected\n",
"cnn_clf.add(Flatten())\n",
"cnn_clf.add(Dense(128, activation=\"elu\"))\n",
"cnn_clf.add(BatchNormalization())\n",
"cnn_clf.add(Dropout(0.3))\n",
"# - output\n",
"cnn_clf.add(Dense(10, activation=\"softmax\"))\n",
"\n",
"# Compile model\n",
"cnn_clf.compile(loss=\"categorical_crossentropy\", optimizer=\"adam\", metrics=[\"accuracy\"])\n",
"print(cnn_clf.summary())"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Train and evaluate ConvNet model on test data</h2>"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train on 48000 samples, validate on 12000 samples\n",
"Epoch 1/15\n",
"48000/48000 [==============================] - 51s 1ms/step - loss: 0.2584 - acc: 0.9188 - val_loss: 0.0669 - val_acc: 0.9795\n",
"Epoch 2/15\n",
"48000/48000 [==============================] - 48s 993us/step - loss: 0.0998 - acc: 0.9689 - val_loss: 0.0570 - val_acc: 0.9825\n",
"Epoch 3/15\n",
"48000/48000 [==============================] - 49s 1ms/step - loss: 0.0767 - acc: 0.9760 - val_loss: 0.0509 - val_acc: 0.9855\n",
"Epoch 4/15\n",
"48000/48000 [==============================] - 56s 1ms/step - loss: 0.0652 - acc: 0.9793 - val_loss: 0.0427 - val_acc: 0.9872\n",
"Epoch 5/15\n",
"48000/48000 [==============================] - 49s 1ms/step - loss: 0.0565 - acc: 0.9822 - val_loss: 0.0358 - val_acc: 0.9894\n",
"Epoch 6/15\n",
"48000/48000 [==============================] - 65s 1ms/step - loss: 0.0521 - acc: 0.9833 - val_loss: 0.0378 - val_acc: 0.9890\n",
"Epoch 7/15\n",
"48000/48000 [==============================] - 53s 1ms/step - loss: 0.0479 - acc: 0.9842 - val_loss: 0.0343 - val_acc: 0.9890\n",
"Epoch 8/15\n",
"48000/48000 [==============================] - 51s 1ms/step - loss: 0.0427 - acc: 0.9860 - val_loss: 0.0373 - val_acc: 0.9890\n",
"Epoch 9/15\n",
"48000/48000 [==============================] - 56s 1ms/step - loss: 0.0398 - acc: 0.9874 - val_loss: 0.0368 - val_acc: 0.9905\n",
"\n",
"Test Accuracy: 99.12%\n",
"Time elapsed: 482.22 sec\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAecAAAEzCAYAAAALosttAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3XmcHHWd//HXp7p7pjOZkJsESJCIISEkhJCEyyUMoALKoawQEBF5SFDkctmfmgVkPVjXBX/uT3dZMOtyyjWCKCtZUCRDxEVICIGQEDBGjgnkPpjJXH18f390dU93T89MT9KTrul5Px+PflTVt771re93jn5XVXdXm3MOERERCQ6v3B0QERGRXApnERGRgFE4i4iIBIzCWUREJGAUziIiIgGjcBYREQmYXsPZzO40s81m9lo3683MfmJm68zsVTM7uvTdFBERGTyKOXO+Gzi9h/VnAJP9x+XA7XvfLRERkcGr13B2zi0FtvdQ5RzgXpfyJ2CEmR1Qqg6KiIgMNqV4zfkg4N2s5Ua/TERERPZAeF/uzMwuJ3Xpm2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g7kSmBmjR49my5Yte9VO2cK5UiRbWmhduZKW5ctpeXEZra++iuvoYARQ6C3rOUFZXd0ZhtHqrKCsypR56akflFZd1aUs1Ua6vWhekFb1yz9SLB6jZvbskrcrIsGmYO5dKX5GCuc+SjQ10bpiRWcYr14N8Th4HtFp0xj5uc9RM3cOKzdu5NgTT0wFZnVWUAbksruIiASXwrkX8R07aH3pJVqWLadl2TLa1q5NXWKORBgyfTqjL72UmmPmMmTWLEK1tZntEg0NVFXwHdBERAaC2tpampubC6576623OPPMM3nttYJfulhWCuc88S1bUmfFfhi3//nPQOpy9JCZMxnzla+kwnjmTLwhQ8rcWxERqUSDPpxj772XE8Ydb70FgNXUUDNrFvt96lPUzJ1DdMaMsr1DUkREUhYuXMjEiRO58sorAfj2t79NOBxmyZIl7Nixg1gsxs0338w555zTp3bb2tq44oorWL58OeFwmB/96EecfPLJrF69mksvvZSOjg6SySSPPvooBx54IOeffz6NjY0kEgm+9a1vMX/+/JKOc1CFs3OO2DvvZF4vblm+nNiG1G3AvWHDqJk9mxHnnZcK48MPx/biM2oiIpXsO/+9mjXvfVDSNqcduB/X1fX8cuD8+fP52te+lgnn+vp6nnrqKa655hr2228/tm7dynHHHcfZZ5/dpzdm3XbbbZgZq1atYu3atXziE5/gzTff5I477uDaa6/loosuoqOjg0QiweLFiznwwAN54oknANi1a9eeD7obFR3Ozjk6/vKXnDCOb07dPi00ciQ1c+Yw6pJLqJk7h+rDDkt9xEdERAJr1qxZbN68mffee48tW7YwcuRIxo8fz9/93d+xdOlSPM9jw4YNbNq0yb9NbXGee+45rr76agCmTp3Khz70Id58802OP/54/umf/onGxkbOPfdcJk+ezIwZM/j7v/97vvnNb3LmmWdy4oknlnycFRXOLpGg/c03M5eoW5YvJ7FjBwDhsWOpmTuXmmPmUjNnDlWHHqqPBIiI7KF/POuIfmm3qamp1zrnnXcejzzyCBs3bmT+/Pncf//9bNmyhZdeeolIJMIhhxxSsruYfe5zn+PYY4/liSee4JOf/CQ//elPOeWU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58eAkGXJjCWUREBpRSfZ9zf34P9N7SG8JERGRAmT9/Pg899BCPPPII5513Hrt27dqj73PubrtTTjmFX/ziF2zbtg0gc1n71FNPzXw9ZCKRYNeuXf0wuhSFs4iIDCiFvs95+fLlzJgxg3vvvbfo73PubrsjjjiCG264gZNOOomZM2dy3XXXAfDjH/+YJUuWMGPGDGbPns2aNWv6bYy6rC0iIgNOKb7PuaftLrnkEi655JKcsnHjxvHrX/96D3rbdzpzFhERCRidOYuISEXT9zmLiIgEzED8Pmdd1hYREQkYhbOIiEjAKJxFREQCRuEsIiIDxkD9Csi+UjiLiIgEjMJZREQGHOccX//615k+fTozZszg4YcfBuD9999n3rx5HHXUUUyfPp0//OEPJBIJvvjFL2bq/uu//muZe987fZRKRET67F9e/BfWbl9b0janjprKVw//alF1f/nLX7Jy5UpeeeUVtm7dyty5c5k3bx4PPPAAp512GjfccAOJRIKWlhZWrlzJhg0beO211wDYuXNnSfvdH3TmLCIiA85zzz3HhRdeSCgUYty4cZx00kksW7aMuXPnctddd/Htb3+bVatWMWzYMD784Q+zfv16rr76ap588kn222+/cne/VzpzFhGRPvvmMd/sl3abevk+597MmzePpUuX8sQTT/DFL36R6667ji984Qu88sorPPXUU9xxxx3U19dz5513lqjH/UNnziIiMuCceOKJPPzwwyQSCbZs2cLSpUs55phjePvttxk3bhwLFizgsssuY8WKFWzdupVkMsnf/u3fcvPNN7NixYpyd79XOnMWEZEB5zOf+QzPP/88M2fOxMy45ZZbGD9+PPfccw+33norkUiE2tpa7r33XjZs2MCll15KMpkE4J//+Z/L3PveKZxFRGTASH8FpJlx6623cuutt+asL/RVj8CAOFvOpsvaIiIiAVNUOJvZ6Wb2hpmtM7OFBdYfbGZLzOxlM3vVzD5Z+q6KiIgMDr2Gs5mFgNuAM4BpwIVmNi2v2o1AvXNuFnAB8B+l7qiIiMhgUcyZ8zHAOufceudcB/AQcE5eHQekPzg2HHivdF0UEREZXMw513MFs88CpzvnLvOXLwaOdc5dlVXnAOC3wEhg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n",
"text/plain": [
"<Figure size 576x360 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Start timer\n",
"start = time.time()\n",
"\n",
"# Store best model\n",
"cp = EarlyStopping(patience=2, monitor=\"val_loss\", restore_best_weights=True)\n",
"\n",
"# Train model on training data\n",
"# Note: uses 20% of the training set for validation\n",
"history = cnn_clf.fit(X_train_2D, y_train, batch_size=64, epochs=15, validation_split=0.2, callbacks=[cp], verbose=1)\n",
"# Evaluate model on test data\n",
"score = cnn_clf.evaluate(X_test_2D, y_test, verbose=0)\n",
"\n",
"# Stop timer\n",
"end = time.time()\n",
"\n",
"# Print results\n",
"print(\"\\nTest Accuracy: {0:0.2f}%\".format(score[1] * 100))\n",
"print(\"Time elapsed: {0:0.2f} sec\".format(end - start))\n",
"\n",
"# Plot training history\n",
"pd.DataFrame(history.history).plot(figsize=(8, 5)) \n",
"plt.grid(True)\n",
"plt.gca().set_ylim(0, 1)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Confusion matrix</h2>"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 978 0 0 0 0 0 0 1 1 0]\n",
" [ 0 1134 0 0 0 1 0 0 0 0]\n",
" [ 1 4 1021 1 0 0 0 4 1 0]\n",
" [ 0 0 1 1003 0 5 0 0 1 0]\n",
" [ 0 0 0 0 973 0 0 0 1 8]\n",
" [ 2 1 0 4 0 883 1 0 1 0]\n",
" [ 9 2 0 0 1 1 945 0 0 0]\n",
" [ 0 1 7 1 0 0 0 1016 1 2]\n",
" [ 3 1 1 1 1 0 0 1 963 3]\n",
" [ 2 1 0 1 4 3 0 2 0 996]]\n"
]
}
],
"source": [
"# Make predictions\n",
"y_pred = cnn_clf.predict(X_test_2D)\n",
"\n",
"# Confusion matrix\n",
"conf_mx = confusion_matrix(\n",
" np.argmax(y_test,axis=1),\n",
" np.argmax(y_pred, axis=1))\n",
"print(conf_mx)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Dimensionality Reduction</h2>"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Training set: (60000, 154)\n",
"Test set: (10000, 154)\n"
]
}
],
"source": [
"from sklearn.decomposition import PCA\n",
"\n",
"# Create PCA\n",
"pca = PCA(n_components=0.95)\n",
"pca.fit(X_train_1D)\n",
"# Reduce dimensionality on training and test sets\n",
"X_train_1D_dr = pca.transform(X_train_1D)\n",
"X_test_1D_dr = pca.transform(X_test_1D)\n",
"# Show dataset shape\n",
"print(\"Training set:\",X_train_1D_dr.shape)\n",
"print(\"Test set:\",X_test_1D_dr.shape)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Train and evaluate reduced dataset with a neural network</h2>"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Train on 48000 samples, validate on 12000 samples\n",
"Epoch 1/20\n",
"48000/48000 [==============================] - 3s 58us/step - loss: 0.4524 - acc: 0.8607 - val_loss: 0.2064 - val_acc: 0.9399\n",
"Epoch 2/20\n",
"48000/48000 [==============================] - 2s 42us/step - loss: 0.2446 - acc: 0.9256 - val_loss: 0.1540 - val_acc: 0.9553\n",
"Epoch 3/20\n",
"48000/48000 [==============================] - 2s 41us/step - loss: 0.1888 - acc: 0.9436 - val_loss: 0.1251 - val_acc: 0.9626\n",
"Epoch 4/20\n",
"48000/48000 [==============================] - 2s 42us/step - loss: 0.1560 - acc: 0.9519 - val_loss: 0.1106 - val_acc: 0.9677\n",
"Epoch 5/20\n",
"48000/48000 [==============================] - 2s 42us/step - loss: 0.1357 - acc: 0.9583 - val_loss: 0.0971 - val_acc: 0.9709\n",
"Epoch 6/20\n",
"48000/48000 [==============================] - 2s 41us/step - loss: 0.1186 - acc: 0.9629 - val_loss: 0.0918 - val_acc: 0.9715\n",
"Epoch 7/20\n",
"48000/48000 [==============================] - 2s 44us/step - loss: 0.1119 - acc: 0.9655 - val_loss: 0.0867 - val_acc: 0.9733\n",
"Epoch 8/20\n",
"48000/48000 [==============================] - 2s 43us/step - loss: 0.1020 - acc: 0.9674 - val_loss: 0.0845 - val_acc: 0.9738\n",
"Epoch 9/20\n",
"48000/48000 [==============================] - 2s 41us/step - loss: 0.0928 - acc: 0.9699 - val_loss: 0.0852 - val_acc: 0.9762\n",
"Epoch 10/20\n",
"48000/48000 [==============================] - 2s 42us/step - loss: 0.0852 - acc: 0.9725 - val_loss: 0.0745 - val_acc: 0.9773\n",
"Epoch 11/20\n",
"48000/48000 [==============================] - 2s 43us/step - loss: 0.0819 - acc: 0.9733 - val_loss: 0.0763 - val_acc: 0.9785\n",
"Epoch 12/20\n",
"48000/48000 [==============================] - 2s 43us/step - loss: 0.0784 - acc: 0.9741 - val_loss: 0.0738 - val_acc: 0.9788\n",
"Epoch 13/20\n",
"48000/48000 [==============================] - 2s 41us/step - loss: 0.0737 - acc: 0.9765 - val_loss: 0.0747 - val_acc: 0.9789\n",
"Epoch 14/20\n",
"48000/48000 [==============================] - 2s 42us/step - loss: 0.0728 - acc: 0.9767 - val_loss: 0.0740 - val_acc: 0.9784\n",
"\n",
"Test Accuracy: 97.84%\n",
"Time elapsed: 30.13 sec\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAecAAAEzCAYAAAALosttAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xl8VOWh//HPM3v2BUISdlCEgsgqS10A91ort1ar1nq1v6terdb22ustVdtff9YuVm93q5fbWutSFbfWVqvVKtJFkEUUWaXBQFhDyL7N9vz+OJPJTBJIgMB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7URgDnDzAN8eib4MbEx1I9LIT4BXrLUTgCkM4G1jjBkG3ArMtNaejHOy6kA8EfUR4IIOZYuAv1hrxwF/iU0PJI/QeZu8BpxsrT0F2AJ8/Xg36nCloufck9uBDhjW2t3W2jWx8XqcL9yOd2AbcIwxw4FPAr9MdVvSgTEmDzgT58oIrLVBa21NaluVch4gI3ZvhUxgV4rbc9xZa5fhXCGTKPF2yr8B/uW4NirFutom1to/x+5eCbAc534daS0V4dyT24EOSLGneU0DVqS2JWnhx8B/AdFUNyRNjAEqgV/HdvX/0hiTlepGpYq1didwP7Ad2A3UWmv/nNpWpY1ia+3u2PgeoDiVjUlD/wf4U6ob0R2dEJYmjDHZwHPAV6y1daluTyoZYy4C9llrV6e6LWnEA0wHHrTWTgMaGXi7K+Nix1EX4vxoGQpkGWM+n9pWpZ/YzaB0SU6MMeZOnEOJT6S6Ld1JRTj35HagA4oxxosTzE9Ya59PdXvSwGnAxcaYj3AOe5xljHk8tU1KuQqgwlrbtlflWZywHqjOAbZZayuttSHgeeDjKW5TuthrjCkFiA33pbg9acEYcy1wEXBVX7iDZSrCuSe3Ax0wYo/W/BWw0Vr7w1S3Jx1Ya79urR1urR2N8+/jDWvtgO4VWWv3ADuMMeNjRWcDG1LYpFTbDswxxmTG/h86mwF8glwHibdTvgb4fQrbkhaMMRfgHCa72FrblOr29MRxD+fYQfm224FuBJZYa9cf73akkdOAq3F6h2tjrwtT3ShJS18CnjDGvA9MBb6b4vakTGwPwrPAGmAdzndZn7sL1NEyxjwJvA2MN8ZUGGP+Dfg+cK4x5kOcPQzfT2Ubj7eDbJOfAznAa7Hv2IdS2sge0B3CRERE0oxOCBMREUkzCmcREZE0o3AWERFJMwpnERGRNKNwFhERSTMKZxERkTSjcBYREUkzCmcREZE08/8BtLXkvXitEZUAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 576x360 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Create Neural Net Softmax model for the reduced size dataset\n",
"snn_clf = Sequential()\n",
"# - first Dense\n",
"snn_clf.add(Dense(128, input_dim=154, activation=\"elu\", kernel_initializer=\"he_normal\"))\n",
"snn_clf.add(Dropout(0.2))\n",
"# - second Dense\n",
"snn_clf.add(Dense(128, activation=\"elu\", kernel_initializer=\"he_normal\"))\n",
"snn_clf.add(Dropout(0.2))\n",
"# - output\n",
"snn_clf.add(Dense(10, activation=\"softmax\"))\n",
"\n",
"# Early stopping\n",
"cp = EarlyStopping(patience=2, restore_best_weights=True)\n",
"\n",
"# Compile model\n",
"snn_clf.compile(loss=\"categorical_crossentropy\", optimizer=\"adam\", metrics=[\"accuracy\"])\n",
"\n",
"# Start timer\n",
"start = time.time()\n",
"\n",
"# Train model on training data\n",
"history = snn_clf.fit(X_train_1D_dr, y_train, batch_size=64, epochs=20, validation_split=0.2, callbacks=[cp], verbose=1)\n",
"# Evaluate model on test data\n",
"score = snn_clf.evaluate(X_test_1D_dr, y_test, verbose=0)\n",
"\n",
"# Stop timer\n",
"end = time.time()\n",
"\n",
"# Print results\n",
"print(\"\\nTest Accuracy: {0:0.2f}%\".format(score[1] * 100))\n",
"print(\"Time elapsed: {0:0.2f} sec\".format(end - start))\n",
"\n",
"# Plot training history\n",
"pd.DataFrame(history.history).plot(figsize=(8, 5)) \n",
"plt.grid(True)\n",
"plt.gca().set_ylim(0, 1) # set the vertical range to [0-1] \n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h2>Predict examples</h2>"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Predicted: 7\n",
"Actual: 7\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAP8AAAD8CAYAAAC4nHJkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuM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J+fqWXZm6ebmZp9cC566UZr6sI/+OSVth+u+25kq6VtK2CPt7A9pnFBzGyfaakD6r3Zh/eJmlj8XijpPsr7OXX9MrMzbVmllbF567nZryOiK7/SLpCk5/4/7ekz1bRQ42+lkv6UfGzr+reJN2jyZeBr2jys5HrJJ0raYekpyV9X9LCHurtXyTtkbRbk0FbVFFvazX5kn63pF3FzxVVn7uSvio5b3zDD0iKD/yApAg/kBThB5Ii/EBShB9IivADSRF+ICnCDyT1/zhI/TrK0un2AAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Predicted: 2\n",
"Actual: 2\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAP8AAAD8CAYAAAC4nHJkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAADcBJREFUeJzt3X2MXHW9x/HPt4VSeVCou9RNKS2Xi2JpZKtjQeEivQihXE2LxkKNpibENRGSy40mYq9GjA8hRuSaSPRWaaheRdTy0BhQan0gokG2tVJKy4PccmmztLuW2OUq0Javf+ypWWHPb4Y5Z86Z7ff9SjY7c77n4cuwn56Z85uZn7m7AMQzpe4GANSD8ANBEX4gKMIPBEX4gaAIPxAU4QeCIvxAUIQfCOqIKg/W09Pjc+bMrfKQQChPPrlDIyMj1sq6hcJvZhdL+qqkqZK+5e7XpdafM2eu7rt/sMghASScc1aj5XXbftpvZlMl3ShpsaR5kpab2bx29wegWkVe8y+U9Li7P+HuL0j6vqQl5bQFoNOKhH+WpKfG3d+ZLfsHZjZgZoNmNjg8MlzgcADK1PGr/e6+yt0b7t7o7ent9OEAtKhI+HdJmj3u/knZMgCTQJHwPyDpN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nC1bKWm5mfVLckk7JH2kIx0C6IhWrvb/WpJNULqr/HYAVIV3+AFBEX4gKMIPBEX4gaAIPxAU4QeCIvxAUIQfCIrwA0ERfiAowg8ERfiBoAg/EBThB4Iyd6/uYGbDkp4ct6hH0khlDbwy3dpbt/Yl0Vu7yuxtjru39H15lYb/ZQc3G3T3Rm0NJHRrb93al0Rv7aqrN572A0ERfiCousO/qubjp3Rrb93al0Rv7aqlt1pf8wOoT91nfgA1qSX8ZnaxmT1iZo+b2TV19JDHzHaY2ZZs5uHBmntZbWZ7zOyhcctmmNl6M3ss+z3hNGk19dYVMzcnZpau9bHrthmvK3/ab2ZTJT0q6UJJOyU9IGm5uz9caSM5zGyHpIa71z4mbGbnSXpW0rfdfX627EuS9rr7ddk/nCe4+ye6pLdrJT1b98zN2YQyfeNnlpa0VNKHVONjl+hrmWp43Oo48y+U9Li7P+HuL0j6vqQlNfTR9dz9Xkl7X7J4iaQ12e01GvvjqVxOb13B3YfcfVN2e1TSoZmla33sEn3Voo7wz5L01Lj7O9VdU367pHvMbKOZDdTdzARmZtOmS9LTkmbW2cwEms7cXKWXzCzdNY9dOzNel40Lfi93rru/WdJiSVdmT2+7ko+9Zuum4ZqWZm6uygQzS/9dnY9duzNel62O8O+SNHvc/ZOyZV3B3Xdlv/dIul3dN/vw7kOTpGa/99Tcz99108zNE80srS547Lppxus6wv+ApNPM7BQzmybpcknraujjZczsmOxCjMzsGEkXqftmH14naUV2e4WkO2vs5R90y8zNeTNLq+bHrutmvHb3yn8kXaKxK/5/lPSfdfSQ09c/SfpD9rO17t4k3aKxp4H7NXZt5ApJr5W0QdJjkn4maUYX9fYdSVskPaixoPXV1Nu5GntK/6CkzdnPJXU/dom+annceIcfEBQX/ICgCD8QFOEHgiL8QFCEHwiK8ANBEX4gKMIPBPU3XSwbtXrY1qcAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Predicted: 1\n",
"Actual: 1\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAP8AAAD8CAYAAAC4nHJkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAADFhJREFUeJzt3V2MXPV5x/Hvg4G+ENIaduO6hOCUuEQWagzaOkgQlDSFOm4kww0KF5EroToXIAUplYLoRblEVUmE+oLkFDdORQmVAsJSSBOw2lpJKspCCDYhlBctxa6xd2uSGKUtwXl6scfRYnZm1zNnXtbP9yONdub8z9nz08i/PTPnjOcfmYmkes4YdQBJo2H5paIsv1SU5ZeKsvxSUZZfKsryS0VZfqkoyy8VdeYwdzYxMZEXXbRumLuUSnnllRnm5uZiOev2Vf6I2AzcDawC/jYz7+y2/kUXreM7j0/3s0tJXVz54allr9vzy/6IWAX8NfAJYANwY0Rs6PX3SRquft7zbwJezMyXM/NN4KvA1nZiSRq0fsp/AfDqgscHmmVvExHbI2I6IqZn52b72J2kNg38bH9m7sjMqcycmpyYHPTuJC1TP+U/CFy44PF7m2WSVoB+yv8EsD4i3h8RZwOfAna3E0vSoPV8qS8z34qIW4BvMn+pb2dmPttaMkkD1dd1/sx8BHikpSyShsiP90pFWX6pKMsvFWX5paIsv1SU5ZeKsvxSUZZfKsryS0VZfqkoyy8VZfmloiy/VJTll4qy/FJRll8qyvJLRVl+qSjLLxVl+aWiLL9U1FCn6FY9/zn3045jH9ry+a7b3nHXrV3HP/uRi3vKpHke+aWiLL9UlOWXirL8UlGWXyrK8ktFWX6pqL6u80fEDHAMOA68lZlTbYTS6eN7h17vPHjGqq7bXnL+r7acRgu18SGfj2XmXAu/R9IQ+bJfKqrf8ifwrYh4MiK2txFI0nD0+7L/qsw8GBHvAR6NiB9m5t6FKzR/FL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l/Gfgz5s+N3AScD+wBXgAeA84bo2x/D+wDnmG+aGtHlO0q5l/SPwM83dy2jPq565JrJM+bn/CTivKEn1SU5ZeKsvxSUZZfKsryS0VZfqkoyy8VZfmlov4fHSLAFlJq87MAAAAASUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"# Examples to classify\n",
"examples = X_test_2D[:3]\n",
"\n",
"res = np.argmax(cnn_clf.predict(examples), axis=1)\n",
"\n",
"for i in range(0,len(res)):\n",
" print(\"Predicted:\",res[i])\n",
" print(\"Actual:\",y_test_raw[i])\n",
" plt.imshow(X_test[i], cmap=plt.cm.Blues)\n",
" plt.show()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
You can’t perform that action at this time.