This Gist was automatically created by Carbide, a free online programming environment.
Last active
August 29, 2016 15:14
-
-
Save bijection/298f55b25fb548b10b729a6d2873570c to your computer and use it in GitHub Desktop.
Neural Network XOR
This file contains hidden or 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
function sigmoid(x) { ///A **sigmoid function** is a [++mathematical function++](https://en.wikipedia.org/wiki/Function_(mathematics%29) having an "S" shaped curve (**sigmoid curve**). Often, _sigmoid function_ refers to the special case of the [++logistic function++](https://en.wikipedia.org/wiki/Logistic_function) shown in the first figure and defined by the formula | |
return 1/(1 + Math.exp(-x)); | |
} | |
function XOR(a, b){ ///**Exclusive disjunction** or **exclusive or** is a [++logical operation++](https://en.wikipedia.org/wiki/Logical_connective) that outputs true only when inputs differ (one is true, the other is false). | |
let hidden = sigmoid(0.1 * a + 0.4 * b + 0.7) | |
return sigmoid(0.1 * a + 0.4 * b + 0.5 * hidden + 0.7) | |
} | |
var loss = ([ ///In [++mathematical optimization++](https://en.wikipedia.org/wiki/Mathematical_optimization), [++statistics++](https://en.wikipedia.org/wiki/Statistics), [++decision theory++](https://en.wikipedia.org/wiki/Decision_theory) and [++machine learning++](https://en.wikipedia.org/wiki/Machine_learning), a **loss function** or **cost function** is a function that maps an [++event++](https://en.wikipedia.org/wiki/Event_(probability_theory%29) or values of one or more variables onto a [++real number++](https://en.wikipedia.org/wiki/Real_number) intuitively representing some "cost" associated with the event. An [++optimization problem++](https://en.wikipedia.org/wiki/Optimization_problem) seeks to minimize a loss function. | |
XOR(0, 1) - 1, | |
XOR(1, 1) - 0, | |
XOR(1, 0) - 1, | |
XOR(0, 0) - 0 | |
]).map(x => x*x).reduce((a,b) => a+b, 0) |
This file contains hidden or 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
import {say} from 'cowsay' | |
say({text: "hello there! \n\nWelcome to the Carbide Alpha\nRelease XOR Example Notebook!\n\nTry dragging the Loss Slider!\n\nSend bugs to\[email protected]!\n\nSend hellos to\[email protected]!" || ' '}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment