-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing Alpha
- Loading branch information
Showing
1 changed file
with
144 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"In fact, finding the appropriate alpha,even for state-of-the-art nerual networks,is often done simply by guessing.\n", | ||
"\n", | ||
"If learning is happening too slowly, then your alpha is too low and you increase it." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Iteration:0 Erroe: 0.04 Prediction: 1.0\n", | ||
"Iteration:1 Erroe: 0.0144 Prediction: 0.92\n", | ||
"Iteration:2 Erroe: 0.005184 Prediction: 0.872\n", | ||
"Iteration:3 Erroe: 0.00186624 Prediction: 0.8432\n", | ||
"Iteration:4 Erroe: 0.0006718464 Prediction: 0.82592\n", | ||
"Iteration:5 Erroe: 0.000241864704 Prediction: 0.815552\n", | ||
"Iteration:6 Erroe: 8.707129344e-05 Prediction: 0.8093312\n", | ||
"Iteration:7 Erroe: 3.13456656384e-05 Prediction: 0.80559872\n", | ||
"Iteration:8 Erroe: 1.12844396298e-05 Prediction: 0.803359232\n", | ||
"Iteration:9 Erroe: 4.06239826674e-06 Prediction: 0.8020155392\n", | ||
"Iteration:10 Erroe: 1.46246337603e-06 Prediction: 0.80120932352\n", | ||
"Iteration:11 Erroe: 5.26486815369e-07 Prediction: 0.800725594112\n", | ||
"Iteration:12 Erroe: 1.89535253533e-07 Prediction: 0.800435356467\n", | ||
"Iteration:13 Erroe: 6.82326912719e-08 Prediction: 0.80026121388\n", | ||
"Iteration:14 Erroe: 2.45637688579e-08 Prediction: 0.800156728328\n", | ||
"Iteration:15 Erroe: 8.84295678884e-09 Prediction: 0.800094036997\n", | ||
"Iteration:16 Erroe: 3.18346444398e-09 Prediction: 0.800056422198\n", | ||
"Iteration:17 Erroe: 1.14604719983e-09 Prediction: 0.800033853319\n", | ||
"Iteration:18 Erroe: 4.12576991939e-10 Prediction: 0.800020311991\n", | ||
"Iteration:19 Erroe: 1.48527717099e-10 Prediction: 0.800012187195\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"weight=0.5\n", | ||
"goal_pred=0.8\n", | ||
"inputs=2\n", | ||
"alpha=0.1\n", | ||
"\n", | ||
"for iteration in range(20):\n", | ||
" prediction=inputs*weight\n", | ||
" error=(prediction-goal_pred)**2\n", | ||
" derivative=(prediction-goal_pred)*inputs\n", | ||
" weight-=alpha*derivative\n", | ||
" \n", | ||
" print 'Iteration:'+str(iteration)+' Erroe: '+str(error)+' Prediction: '+str(prediction)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"And despite all the crazy advancements of deep learning in the past few years, most people just try several orders of magnitude of alpha(10,1,0.1,0.01,0.001,0.0001)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 8, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Iteration:0 Erroe: 0.04 Prediction: 1.0\n", | ||
"Iteration:1 Erroe: 0.036864 Prediction: 0.992\n", | ||
"Iteration:2 Erroe: 0.0339738624 Prediction: 0.98432\n", | ||
"Iteration:3 Erroe: 0.0313103115878 Prediction: 0.9769472\n", | ||
"Iteration:4 Erroe: 0.0288555831594 Prediction: 0.969869312\n", | ||
"Iteration:5 Erroe: 0.0265933054397 Prediction: 0.96307453952\n", | ||
"Iteration:6 Erroe: 0.0245083902932 Prediction: 0.956551557939\n", | ||
"Iteration:7 Erroe: 0.0225869324942 Prediction: 0.950289495622\n", | ||
"Iteration:8 Erroe: 0.0208161169867 Prediction: 0.944277915797\n", | ||
"Iteration:9 Erroe: 0.0191841334149 Prediction: 0.938506799165\n", | ||
"Iteration:10 Erroe: 0.0176800973552 Prediction: 0.932966527198\n", | ||
"Iteration:11 Erroe: 0.0162939777225 Prediction: 0.92764786611\n", | ||
"Iteration:12 Erroe: 0.0150165298691 Prediction: 0.922541951466\n", | ||
"Iteration:13 Erroe: 0.0138392339273 Prediction: 0.917640273407\n", | ||
"Iteration:14 Erroe: 0.0127542379874 Prediction: 0.912934662471\n", | ||
"Iteration:15 Erroe: 0.0117543057292 Prediction: 0.908417275972\n", | ||
"Iteration:16 Erroe: 0.0108327681601 Prediction: 0.904080584933\n", | ||
"Iteration:17 Erroe: 0.00998347913631 Prediction: 0.899917361536\n", | ||
"Iteration:18 Erroe: 0.00920077437202 Prediction: 0.895920667075\n", | ||
"Iteration:19 Erroe: 0.00847943366126 Prediction: 0.892083840392\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"weight=0.5\n", | ||
"goal_pred=0.8\n", | ||
"inputs=2\n", | ||
"alpha=0.01\n", | ||
"\n", | ||
"for iteration in range(20):\n", | ||
" prediction=inputs*weight\n", | ||
" error=(prediction-goal_pred)**2\n", | ||
" derivative=(prediction-goal_pred)*inputs\n", | ||
" weight-=alpha*derivative\n", | ||
" \n", | ||
" print 'Iteration:'+str(iteration)+' Erroe: '+str(error)+' Prediction: '+str(prediction)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python [conda root]", | ||
"language": "python", | ||
"name": "conda-root-py" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 2 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython2", | ||
"version": "2.7.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |