Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lexfridman committed Feb 17, 2019
2 parents a4a6642 + 5e58a70 commit 68089a7
Showing 1 changed file with 29 additions and 30 deletions.
59 changes: 29 additions & 30 deletions tutorial_deep_learning_basics/deep_learning_basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "S5Uhzt6vVIB2"
"id": ""
},
"source": [
"<table align=\"center\">\n",
Expand All @@ -33,7 +33,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "FbVhjPpzn6BM"
"id": ""
},
"source": [
"# Deep Learning Basics\n",
Expand Down Expand Up @@ -80,7 +80,7 @@
"metadata": {
"colab": {},
"colab_type": "code",
"id": "dzLKpmZICaWN"
"id": ""
},
"outputs": [
{
Expand Down Expand Up @@ -149,7 +149,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "59veuiEZCaW4"
"id": ""
},
"source": [
"### Build the model\n",
Expand All @@ -169,7 +169,7 @@
"metadata": {
"colab": {},
"colab_type": "code",
"id": "Lhan11blCaW7"
"id": ""
},
"outputs": [],
"source": [
Expand All @@ -189,7 +189,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "qKF6uW-BCaW-"
"id": ""
},
"source": [
"### Train the model\n",
Expand All @@ -209,7 +209,7 @@
"metadata": {
"colab": {},
"colab_type": "code",
"id": "xvwvpA64CaW_"
"id": ""
},
"outputs": [
{
Expand Down Expand Up @@ -295,7 +295,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "oEw4bZgGCaXB"
"id": ""
},
"source": [
"Next, compare how the model performs on the test dataset:"
Expand All @@ -307,7 +307,7 @@
"metadata": {
"colab": {},
"colab_type": "code",
"id": "VflXLEeECaXC"
"id": ""
},
"outputs": [
{
Expand All @@ -330,7 +330,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "yWfgsmVXCaXG"
"id": ""
},
"source": [
"Compare the RMSE measure you get to the [Kaggle leaderboard](https://www.kaggle.com/c/boston-housing/leaderboard). An RMSE of 2.651 puts us in 5th place."
Expand Down Expand Up @@ -360,7 +360,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "DLdCchMdCaWQ"
"id": ""
},
"source": [
"The MNIST dataset containss 70,000 grayscale images of handwritten digits at a resolution of 28 by 28 pixels. The task is to take one of these images as input and predict the most likely digit contained in the image (along with a relative confidence in this prediction):\n",
Expand All @@ -376,7 +376,7 @@
"metadata": {
"colab": {},
"colab_type": "code",
"id": "7MqDQO0KCaWS"
"id": ""
},
"outputs": [],
"source": [
Expand All @@ -391,7 +391,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "Wz7l27Lz9S1P"
"id": ""
},
"source": [
"We scale these values to a range of 0 to 1 before feeding to the neural network model. For this, we divide the values by 255. It's important that the *training set* and the *testing set* are preprocessed in the same way:"
Expand All @@ -403,7 +403,7 @@
"metadata": {
"colab": {},
"colab_type": "code",
"id": "bW5WzIPlCaWv"
"id": ""
},
"outputs": [],
"source": [
Expand All @@ -420,7 +420,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "Ee638AlnCaWz"
"id": ""
},
"source": [
"Display the first 5 images from the *training set* and display the class name below each image. Verify that the data is in the correct format and we're ready to build and train the network."
Expand All @@ -432,7 +432,7 @@
"metadata": {
"colab": {},
"colab_type": "code",
"id": "oZTImqg_CaW1"
"id": ""
},
"outputs": [
{
Expand Down Expand Up @@ -461,7 +461,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "59veuiEZCaW4"
"id": ""
},
"source": [
"### Build the model\n",
Expand All @@ -475,7 +475,7 @@
"metadata": {
"colab": {},
"colab_type": "code",
"id": "9ODch-OFCaW4"
"id": ""
},
"outputs": [],
"source": [
Expand All @@ -502,7 +502,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "gut8A_7rCaW6"
"id": ""
},
"source": [
"Before the model is ready for training, it needs a few more settings. These are added during the model's *compile* step:\n",
Expand All @@ -518,7 +518,7 @@
"metadata": {
"colab": {},
"colab_type": "code",
"id": "Lhan11blCaW7"
"id": ""
},
"outputs": [],
"source": [
Expand All @@ -531,7 +531,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "qKF6uW-BCaW-"
"id": ""
},
"source": [
"### Train the model\n",
Expand All @@ -551,7 +551,7 @@
"metadata": {
"colab": {},
"colab_type": "code",
"id": "xvwvpA64CaW_"
"id": ""
},
"outputs": [
{
Expand Down Expand Up @@ -579,7 +579,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "W3ZVOhugCaXA"
"id": ""
},
"source": [
"As the model trains, the loss and accuracy metrics are displayed. This model reaches an accuracy of about 98.68% on the training data."
Expand All @@ -589,7 +589,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "oEw4bZgGCaXB"
"id": ""
},
"source": [
"### Evaluate accuracy\n",
Expand All @@ -603,7 +603,7 @@
"metadata": {
"colab": {},
"colab_type": "code",
"id": "VflXLEeECaXC"
"id": ""
},
"outputs": [
{
Expand All @@ -627,7 +627,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "yWfgsmVXCaXG"
"id": ""
},
"source": [
"Often times, the accuracy on the test dataset is a little less than the accuracy on the training dataset. This gap between training accuracy and test accuracy is an example of *overfitting*. In our case, the accuracy is better at 99.19%! This is, in part, due to successful regularization accomplished with the Dropout layers."
Expand All @@ -637,7 +637,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "xsoS7CPDCaXH"
"id": ""
},
"source": [
"### Make predictions\n",
Expand All @@ -653,7 +653,7 @@
"metadata": {
"colab": {},
"colab_type": "code",
"id": "Gl91RPhdCaXI"
"id": ""
},
"outputs": [
{
Expand Down Expand Up @@ -771,7 +771,7 @@
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "x9Kk1voUCaXJ"
"id": ""
},
"source": [
"The above shows the prediction of the network by choosing the neuron with the highest output. While the output layer values add 1 to one, these do not reflect well-calibrated measures of \"uncertainty\". Often, the network is overly confident about the top choice that does not reflect a learned measure of probability. If everything ran correctly you should get an animation like this:\n",
Expand All @@ -793,7 +793,6 @@
"colab": {
"collapsed_sections": [],
"name": "tutorial_deep_learning_basics.ipynb",
"private_outputs": true,
"provenance": [],
"toc_visible": true,
"version": "0.3.2"
Expand Down

0 comments on commit 68089a7

Please sign in to comment.