Created
August 6, 2019 02:56
-
-
Save luiscarbonell/718dbd791b23f03c57695156c46c28a2 to your computer and use it in GitHub Desktop.
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
| const uid = require("cuid"); | |
| function Neuron() { | |
| this.id = uid(); // ID | |
| this.bias = bias == undefined ? Math.random() * 2 - 1 : bias; // this.bias ∈ ℝ && -1 < this.bias < 1 | |
| // Incoming Connections | |
| this.incoming = { | |
| neurons: {}, // new Map() | |
| weights: {} // new Map() | |
| } | |
| // Outgoing Connections | |
| this.outgoing = { | |
| neurons: {}, // new Map() | |
| weights: {} // new Map() | |
| } | |
| this._output; // f'(x) | |
| this.output; // f(x) | |
| this.error; // E'(f(x)) | |
| this.connect = function(neuron, weight) { | |
| this.outgoing.neurons[neuron.id] = neuron; | |
| neuron.incoming.neurons[this.id] = this; | |
| this.outgoing.weights[neuron.id] = neuron.incoming.weights[this.id] = weight == undefined ? Math.random() * 2 - 1 : weight; // weight ∈ ℝ && -1 < weight < 1 | |
| } | |
| } | |
| module.exports = Neuron; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
+ neuron.v0.0.2.js
+
neuron.connect()- enables the creation of neural networks