Add intro paragraph, tx to Daniel and minor formatting fixes

main
Aurélien Geron 2018-09-17 11:51:05 +02:00
parent de6678beb1
commit dc16446c5f
1 changed files with 28 additions and 7 deletions

View File

@ -1,5 +1,19 @@
{ {
"cells": [ "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", "cell_type": "code",
"execution_count": 1, "execution_count": 1,
@ -159,7 +173,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 11,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -174,7 +188,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": 12,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -202,23 +216,30 @@
" cost_ax.set_ylim([0, 5])\n", " cost_ax.set_ylim([0, 5])\n",
"\n", "\n",
" data_ax.set_xlabel(r'$x_1$')\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_xlabel(r'$\\theta_0$')\n",
" cost_ax.set_ylabel(r'$\\theta_1$')\n", " cost_ax.set_ylabel(r'$\\theta_1$')\n",
"\n", "\n",
" data_ax.legend(('Data', 'BGD', 'SGD', 'MBGD'))\n", " data_ax.legend(('Data', 'BGD', 'SGD', 'MBGD'), loc=\"upper left\")\n",
" cost_ax.legend(('Normal Equation', 'BGD', 'SGD', 'MBGD'))" " cost_ax.legend(('Normal Equation', 'BGD', 'SGD', 'MBGD'), loc=\"upper left\")"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": 13,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"animation = FuncAnimation(fig, animate, frames=n_iter)\n", "animation = FuncAnimation(fig, animate, frames=n_iter)\n",
"plt.show()" "plt.show()"
] ]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
} }
], ],
"metadata": { "metadata": {
@ -237,7 +258,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.2" "version": "3.6.6"
} }
}, },
"nbformat": 4, "nbformat": 4,