This Gist was automatically created by Carbide, a free online programming environment.
You can view a live, interactive version of this Gist here.(http://alpha.trycarbide.com/anonymous/754803dd54a226e4eaf6d99f203a4b9b).
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) | |
import visualize from './visualize.js' | |
if(!require('@backprop')) visualize(XOR); |
This Gist was automatically created by Carbide, a free online programming environment.
You can view a live, interactive version of this Gist here.(http://alpha.trycarbide.com/anonymous/754803dd54a226e4eaf6d99f203a4b9b).
import zeros from "zeros" | |
import fill from "ndarray-fill" | |
export default function visualize(fn){ | |
return fill(zeros([100, 100]), (i, j) => fn(i/100, j/100)) | |
} |
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\nbugs@trycarbide.com!\n\nSend hellos to\nhello@trycarbide.com!" || ' '}) |