Skip to content

Commit 55fcbcc

Browse files
author
Luke Rucks
committed
Change wording in learning rate starting point explanation to reflect project update
1 parent 8d5a1a4 commit 55fcbcc

File tree

1 file changed

+13
-37
lines changed

1 file changed

+13
-37
lines changed

first-neural-network/Your_first_neural_network.ipynb

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
{
1414
"cell_type": "code",
1515
"execution_count": null,
16-
"metadata": {
17-
"collapsed": false
18-
},
16+
"metadata": {},
1917
"outputs": [],
2018
"source": [
2119
"%matplotlib inline\n",
@@ -38,9 +36,7 @@
3836
{
3937
"cell_type": "code",
4038
"execution_count": null,
41-
"metadata": {
42-
"collapsed": false
43-
},
39+
"metadata": {},
4440
"outputs": [],
4541
"source": [
4642
"data_path = 'Bike-Sharing-Dataset/hour.csv'\n",
@@ -51,9 +47,7 @@
5147
{
5248
"cell_type": "code",
5349
"execution_count": null,
54-
"metadata": {
55-
"collapsed": false
56-
},
50+
"metadata": {},
5751
"outputs": [],
5852
"source": [
5953
"rides.head()"
@@ -73,9 +67,7 @@
7367
{
7468
"cell_type": "code",
7569
"execution_count": null,
76-
"metadata": {
77-
"collapsed": false
78-
},
70+
"metadata": {},
7971
"outputs": [],
8072
"source": [
8173
"rides[:24*10].plot(x='dteday', y='cnt')"
@@ -92,9 +84,7 @@
9284
{
9385
"cell_type": "code",
9486
"execution_count": null,
95-
"metadata": {
96-
"collapsed": false
97-
},
87+
"metadata": {},
9888
"outputs": [],
9989
"source": [
10090
"dummy_fields = ['season', 'weathersit', 'mnth', 'hr', 'weekday']\n",
@@ -121,9 +111,7 @@
121111
{
122112
"cell_type": "code",
123113
"execution_count": null,
124-
"metadata": {
125-
"collapsed": false
126-
},
114+
"metadata": {},
127115
"outputs": [],
128116
"source": [
129117
"quant_features = ['casual', 'registered', 'cnt', 'temp', 'hum', 'windspeed']\n",
@@ -147,9 +135,7 @@
147135
{
148136
"cell_type": "code",
149137
"execution_count": null,
150-
"metadata": {
151-
"collapsed": false
152-
},
138+
"metadata": {},
153139
"outputs": [],
154140
"source": [
155141
"# Save data for approximately the last 21 days \n",
@@ -174,9 +160,7 @@
174160
{
175161
"cell_type": "code",
176162
"execution_count": null,
177-
"metadata": {
178-
"collapsed": false
179-
},
163+
"metadata": {},
180164
"outputs": [],
181165
"source": [
182166
"# Hold out the last 60 days or so of the remaining data as a validation set\n",
@@ -336,9 +320,7 @@
336320
{
337321
"cell_type": "code",
338322
"execution_count": null,
339-
"metadata": {
340-
"collapsed": false
341-
},
323+
"metadata": {},
342324
"outputs": [],
343325
"source": [
344326
"import unittest\n",
@@ -415,7 +397,7 @@
415397
"This is the number of batches of samples from the training data we'll use to train the network. The more iterations you use, the better the model will fit the data. However, if you use too many iterations, then the model with not generalize well to other data, this is called overfitting. You want to find a number here where the network has a low training loss, and the validation loss is at a minimum. As you start overfitting, you'll see the training loss continue to decrease while the validation loss starts to increase.\n",
416398
"\n",
417399
"### Choose the learning rate\n",
418-
"This scales the size of weight updates. If this is too big, the weights tend to explode and the network fails to fit the data. A good choice to start at is 0.1. If the network has problems fitting the data, try reducing the learning rate. Note that the lower the learning rate, the smaller the steps are in the weight updates and the longer it takes for the neural network to converge.\n",
400+
"This scales the size of weight updates. If this is too big, the weights tend to explode and the network fails to fit the data. Normally a good choice to start at is 0.1; however, if you effectively divide the learning rate by n_records, try starting out with a learning rate of 1. In either case, if the network has problems fitting the data, try reducing the learning rate. Note that the lower the learning rate, the smaller the steps are in the weight updates and the longer it takes for the neural network to converge.\n",
419401
"\n",
420402
"### Choose the number of hidden nodes\n",
421403
"The more hidden nodes you have, the more accurate predictions the model will make. Try a few different numbers and see how it affects the performance. You can look at the losses dictionary for a metric of the network performance. If the number of hidden units is too low, then the model won't have enough space to learn and if it is too high there are too many options for the direction that the learning can take. The trick here is to find the right balance in number of hidden units you choose."
@@ -424,9 +406,7 @@
424406
{
425407
"cell_type": "code",
426408
"execution_count": null,
427-
"metadata": {
428-
"collapsed": false
429-
},
409+
"metadata": {},
430410
"outputs": [],
431411
"source": [
432412
"import sys\n",
@@ -463,9 +443,7 @@
463443
{
464444
"cell_type": "code",
465445
"execution_count": null,
466-
"metadata": {
467-
"collapsed": false
468-
},
446+
"metadata": {},
469447
"outputs": [],
470448
"source": [
471449
"plt.plot(losses['train'], label='Training loss')\n",
@@ -486,9 +464,7 @@
486464
{
487465
"cell_type": "code",
488466
"execution_count": null,
489-
"metadata": {
490-
"collapsed": false
491-
},
467+
"metadata": {},
492468
"outputs": [],
493469
"source": [
494470
"fig, ax = plt.subplots(figsize=(8,4))\n",

0 commit comments

Comments
 (0)