diff --git a/extra_gradient_descent_comparison.ipynb b/extra_gradient_descent_comparison.ipynb index 38da6f4..053ffd2 100644 --- a/extra_gradient_descent_comparison.ipynb +++ b/extra_gradient_descent_comparison.ipynb @@ -1,5 +1,19 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Comparison of Batch, Mini-Batch and Stochastic Gradient Descent" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This notebook displays an animation comparing Batch, Mini-Batch and Stochastic Gradient Descent (introduced in Chapter 4). Thanks to [Daniel Ingram](https://github.com/daniel-s-ingram) who contributed this notebook." + ] + }, { "cell_type": "code", "execution_count": 1, @@ -159,7 +173,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ @@ -174,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ @@ -202,23 +216,30 @@ " cost_ax.set_ylim([0, 5])\n", "\n", " data_ax.set_xlabel(r'$x_1$')\n", - " data_ax.set_ylabel(r'$y$')\n", + " data_ax.set_ylabel(r'$y$', rotation=0)\n", " cost_ax.set_xlabel(r'$\\theta_0$')\n", " cost_ax.set_ylabel(r'$\\theta_1$')\n", "\n", - " data_ax.legend(('Data', 'BGD', 'SGD', 'MBGD'))\n", - " cost_ax.legend(('Normal Equation', 'BGD', 'SGD', 'MBGD'))" + " data_ax.legend(('Data', 'BGD', 'SGD', 'MBGD'), loc=\"upper left\")\n", + " cost_ax.legend(('Normal Equation', 'BGD', 'SGD', 'MBGD'), loc=\"upper left\")" ] }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "animation = FuncAnimation(fig, animate, frames=n_iter)\n", "plt.show()" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -237,7 +258,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.2" + "version": "3.6.6" } }, "nbformat": 4,