Skip to content

Instantly share code, notes, and snippets.

@LeonFedotov
Created October 26, 2017 08:32
Show Gist options
  • Save LeonFedotov/e9d49fcbb3a61657a709e577111d0ff0 to your computer and use it in GitHub Desktop.
Save LeonFedotov/e9d49fcbb3a61657a709e577111d0ff0 to your computer and use it in GitHub Desktop.
map translation, sigmoid conversion, basic nuron implemntation
const map = (a, b, c, d) => (x) => (x-a)/(b-a) * (d-c) + c
const sigmoid = (x) => 1 / (1 + Math.exp(-x))
const nuron = (weights = [], bias = 0, ...inputs) => sigmoid(
inputs
.map((input, index) => input*weights[index])
.reduce(((sum, current) => sum+current), bias)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment