-
-
Save singhay/6356a22576774d42d3b8f0536c6cef67 to your computer and use it in GitHub Desktop.
Live loss plot for training models in Keras
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Live loss plots in Jupyter Notebook for Keras\n", | |
"\n", | |
"by [Piotr Migdał](http://p.migdal.pl/)\n", | |
"\n", | |
"* inspired by a Reddit discussion [Live loss plots inside Jupyter Notebook for Keras? - r/MachineLearning](https://www.reddit.com/r/MachineLearning/comments/65jelb/d_live_loss_plots_inside_jupyter_notebook_for/)\n", | |
"* my other Keras add-on: [Sequential model in Keras -> parameter ASCII diagram](https://github.com/stared/keras-sequential-ascii)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"name": "stderr", | |
"output_type": "stream", | |
"text": [ | |
"Using TensorFlow backend.\n" | |
] | |
} | |
], | |
"source": [ | |
"%matplotlib inline\n", | |
"\n", | |
"import keras\n", | |
"from keras.datasets import mnist\n", | |
"from keras.utils import to_categorical\n", | |
"from keras.models import Sequential\n", | |
"from keras.layers import Flatten, Dense, Activation\n", | |
"\n", | |
"import numpy as np\n", | |
"from matplotlib import pyplot as plt\n", | |
"from IPython.display import clear_output" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"'2.0.3'" | |
] | |
}, | |
"execution_count": 2, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"keras.__version__" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"# data loading\n", | |
"(X_train, y_train), (X_test, y_test) = mnist.load_data()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"# data preprocessing\n", | |
"Y_train = to_categorical(y_train)\n", | |
"Y_test = to_categorical(y_test)\n", | |
"X_train = X_train.reshape(-1, 28, 28, 1).astype('float32') / 255.\n", | |
"X_test = X_test.reshape(-1, 28, 28, 1).astype('float32') / 255." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [ | |
"# updatable plot\n", | |
"# a minimal example (sort of)\n", | |
"\n", | |
"class PlotLosses(keras.callbacks.Callback):\n", | |
" def on_train_begin(self, logs={}):\n", | |
" self.i = 0\n", | |
" self.x = []\n", | |
" self.losses = []\n", | |
" self.val_losses = []\n", | |
" \n", | |
" self.fig = plt.figure()\n", | |
" \n", | |
" self.logs = []\n", | |
"\n", | |
" def on_epoch_end(self, epoch, logs={}):\n", | |
" \n", | |
" self.logs.append(logs)\n", | |
" self.x.append(self.i)\n", | |
" self.losses.append(logs.get('loss'))\n", | |
" self.val_losses.append(logs.get('val_loss'))\n", | |
" self.i += 1\n", | |
" \n", | |
" clear_output(wait=True)\n", | |
" plt.plot(self.x, self.losses, label=\"loss\")\n", | |
" plt.plot(self.x, self.val_losses, label=\"val_loss\")\n", | |
" plt.legend()\n", | |
" plt.show();\n", | |
" \n", | |
"plot_losses = PlotLosses()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"metadata": { | |
"collapsed": false | |
}, | |
"outputs": [], | |
"source": [ | |
"# just logistic regression, to keep it simple and fast\n", | |
"\n", | |
"model = Sequential()\n", | |
"\n", | |
"model.add(Flatten(input_shape=(28, 28, 1)))\n", | |
"model.add(Dense(10))\n", | |
"model.add(Activation('softmax'))\n", | |
"\n", | |
"model.compile(optimizer='rmsprop',\n", | |
" loss='categorical_crossentropy',\n", | |
" metrics=['accuracy'])" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"metadata": { | |
"collapsed": false, | |
"scrolled": false | |
}, | |
"outputs": [ | |
{ | |
"data": { | |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl4XPV97/H3Vxpt1jLGWN5GBhswGFnjQCooSQokZIMk\n4KQkMVvSpE1oCASylEKzUELITUN6SfLcuqTcXNKEQI1L06fuxYEuARx6CbUxxrIwGGOwLRlsyasW\na5v53j/OkTwWWsbSiJFmPq8HPTPnzO+c+c4An3Pm/M7vHHN3REQkPxRkuwAREXnrKPRFRPKIQl9E\nJI8o9EVE8ohCX0Qkjyj0RUTyiEJfRCSPKPRFRPKIQl9EJI9Esl3AYDNnzvQFCxZkuwwRkSnl2Wef\nbXX36tHaTbrQX7BgAevXr892GSIiU4qZ7UinnQ7viIjkkbRC38wuNrOXzGybmd06QrvLzczNrH7Q\n/JPMrN3M/my8BYuIyNiNGvpmVgisAC4BaoErzax2iHaVwE3AM0Os5m7g1+MrVURExiudY/rnAtvc\nfTuAma0ElgEvDGr3HeD7wM2pM83so8CrQMe4qxWRnNXb20tTUxNdXV3ZLmVSKy0tpaamhqKiojEt\nn07ox4BdKdNNwO+nNjCztwPz3f0RM7s5ZX4FcAvwfkCHdkRkWE1NTVRWVrJgwQLMLNvlTEruzr59\n+2hqamLhwoVjWse4O3LNrIDg8M3Xhnj5duCH7t4+yjquNbP1Zra+paVlvCWJyBTU1dXFiSeeqMAf\ngZlx4oknjuvXUDp7+s3A/JTpmnBev0qgDngi/Jc1B1htZpcR/CL4uJndBUwHkmbW5e5/k/oG7n4v\ncC9AfX29buUlkqcU+KMb73eUTuivAxaZ2UKCsL8CuKr/RXc/BMxMKegJ4M/cfT1wfsr824H2wYGf\nKU0HOln537tYfs585s+YNhFvISI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939r4ZpdznwMHCOu683s/cDfwUUAz3Aze7+m4xU\nPoqlsSj3/24HfYkkkcKc3LaJ5K5f3wpvNGR2nXPicMmQ0QXArbfeyvz587n++usBuP3224lEIjz+\n+OMcOHCA3t5e7rzzTpYtW3Zcb9vV1cV1113H+vXriUQi3H333bznPe+hsbGRz372s/T09JBMJvmn\nf/on5s2bxyc/+UmamppIJBJ861vfYvny5eP62IONGvpmVgisAN4PNAHrzGy1u78wqF0lcBPwTMrs\nVuBSd99tZnUEt1yMZar4kcRronT3JXl5bztnzp3clzoVkexbvnw5X/7ylwdCf9WqVTz22GPceOON\nVFVV0draynnnncdll112XDcnX7FiBWZGQ0MDL774Ih/4wAfYunUrP/nJT7jpppu4+uqr6enpIZFI\nsGbNGubNm8cjjzwCwKFDmT9akc6e/rnANnffDmBmK4FlwAuD2n0H+D5wc/8Md38u5fVGoMzMSty9\ne1xVpyGe0pmr0BeZYkbYI58oZ599Nnv37mX37t20tLRwwgknMGfOHL7yla+wdu1aCgoKaG5uZs+e\nPcyZMyft9T711FN86UtfAmDx4sWcfPLJbN26lXe84x1897vfpampiT/8wz9k0aJFxONxvva1r3HL\nLbfwkY98hPPPPz/jnzOd4x4xYFfKdBOD9tbN7O3AfHd/ZIT1XA5seCsCH2DBieVUlER0XF9E0vaJ\nT3yChx9+mIceeojly5fzwAMP0NLSwrPPPsvGjRuZPXs2XV1dGXmvq666itWrV1NWVsaHPvQhfvOb\n33D66aezYcMG4vE43/zmN7njjjsy8l6pxn1pZTMrAO4GPjNCmyUEvwI+MMzr1wLXApx00knjLQkI\nOnPrYlVsUuiLSJqWL1/O5z//eVpbW3nyySdZtWoVs2bNoqioiMcff5wdO3Yc9zrPP/98HnjgAS66\n6CK2bt3Kzp07OeOMM9i+fTunnHIKN954Izt37mTTpk0sXryYGTNmcM011zB9+nR++tOfZvwzphP6\nzcD8lOmacF6/SqAOeCI8zjUHWG1ml4WduTXAPwOfdvdXhnoDd78XuBeCSysf96cYRjwW5edP76A3\nk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M\nppvZw2b2opltMbN3ZLumbDKzr4T/n2w2s38ws9Js1zSRciL0zawQWAFcAtQCV5pZbXaryqo+4Gvu\nXgucB1yf598HwE3AlmwXMUn8mOCGRouBt5HH34uZxYAbgXp3ryO4UdQV2a1qYuVE6APnAtvcfbu7\n9wArgWVZrilr3P11d98QPm8j+J86lt2qssfMaoAPAz/Ndi3ZZmZR4ALg/wC4e4+7H8xuVVkXAcrM\nLAJMA3ZnuZ4JlSuhHwN2pUw3kcchl8rMFgBnA89kt5Ks+hHw50Ay24VMAguBFuBn4eGun5pZebaL\nyhZ3bwb+muB+3q8Dh9z937Jb1cTKldCXIZhZBfBPwJfd/XC268kGM/sIsNfdn812LZNEBHg7cI+7\nnw10AHnbB2ZmJxAcFVgIzAPKzeya7FY1sXIl9JuB+SnTNeG8vGVmRQSB/4C7/yrb9WTRu4DLzOw1\ngsN+F5nZL7NbUlY1AU3u3v/L72GCjUC+eh/wqru3uHsv8CvgnVmuaULlSuivAxaZ2UIzKyboiFmd\n5ZqyxsyM4JjtFne/O9v1ZJO7/4W717j7AoL/Ln7j7jm9JzcSd38D2GVmZ4Sz3gu8kMWSsm0ncJ6Z\nTQv/v3kvOd6xHcl2AZng7n1mdgPwGEHv+33u3pjlsrLpXcCngAYz2xjO+7q7r8liTTJ5fAl4INxB\n2g58Nsv1ZI27P2NmDwMbCM56e44cH52rEbkiInkkVw7viIhIGhT6IiJ5RKEvIpJHFPoiInlEoS8i\nkkcU+iIieUShLyKSRxT6IiJ55P8DN3jd7uz/A58AAAAASUVORK5CYII=\n", | |
"text/plain": [ | |
"<matplotlib.figure.Figure at 0x126f27320>" | |
] | |
}, | |
"metadata": {}, | |
"output_type": "display_data" | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
"<keras.callbacks.History at 0x10986c710>" | |
] | |
}, | |
"execution_count": 7, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"# in this static viewer it is not obvious,\n", | |
"# but this plot grows step by step\n", | |
"\n", | |
"model.fit(X_train, Y_train,\n", | |
" epochs=10,\n", | |
" validation_data=(X_test, Y_test),\n", | |
" callbacks=[plot_losses],\n", | |
" verbose=0)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Further ideas\n", | |
"\n", | |
"* loss and accuracy side by side, as two plots\n", | |
"* time per epoch (plot title?)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"collapsed": true | |
}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"anaconda-cloud": {}, | |
"kernelspec": { | |
"display_name": "Python [default]", | |
"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.5.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment