Languages
[Edit]
EN

JavaScript - artificial neuron model

7 points
Created by:
mkrieger1
726

In this short article, we would like to show an example of Artificial Neuron implementation in JavaScript.

Hint: the article describes McCulloch–Pitts (MCP) neuron that is commonly used in AI.

Quick solution:

 

Example Artificial Neuron implementation in JavaScript.
Example Artificial Neuron implementation in JavaScript.

Where:

nnumber of neuron inputs (number of neuron weights must be the same)
1was placed on the above model only to show bias/threshold concept
(multiplication by 1 is neutral but useful when we work on matrixes)
w(0)weight called bias/threshold that is used to stimulate or suppress neuron activity
x(1), ..., x(n)neuron input values (it is just an array of input values)
w(1), ..., w(n)neuron weight values that are used to describe how strong influence has related input to the neuron
Σdescribes summation process
Σ = 1*w(0) + x(1)*w(1) + ... + x(n-1)*w(n-1) + x(n)*w(n)
f(Σ)describes sum passing through a neuron activation function
(we can use different activation functions depending on the solved problem)
y neuron output value

 

Using equation notation

Edit

So, the above neuron uses formula.

 

Using matrix notation

Edit

The above model can be calculated using matrixes.

Where:

  • w is a column vector (array) of neuron weight values (from w(0) to w(n)),
  • x is a column vector (array) of neuron input values (from 1 to x(n)),
  • f is neuron activation function,
  • y is neuron output value.

Note: go to the following articles to know more about vectors and matrixes:

 

Simple JavaScript implementation

Edit

In this section, you can see simple step-by-step calculations made by artificial neurons.

Reusable code example

Edit

In this section, you will find simple Neuron class implementation that can be combined into layers.

 

References

Edit
  1. Artificial neuron - Wikipedia
  2. Activation function - Wikipedia

Alternative titles

  1. JavaScript - McCulloch–Pitts neuron
  2. JavaScript - MCP neuron
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join