Site icon Learn C++

AI Techs :: Array Based Simple Artificial Neuron Model in C++

Do you want to develop your artificial intelligence application from the scratch? Want to learn how you can develop a simple artificial neuron model in C++? In this post, we will explain with a very simple artificial neuron example. We have released A Simple Artificial Neuron Model in C++ and Very Simple Artificial Neural Network (ANN) Example in C++ before. We highly recommend reading them if you are new to AI technology.

A Simple ANN Model

We have presented this Simple AI neuron before, let’s remember. A Minimum Artificial Neuron has an activation value (a), an activation function ( phi() ) and weighted (w) input net links. So it has one activation value, one activation function and one or more weights depend on the number of its input nets.

This is a very simple artificial neural network in AI technolgy . Now go with this example and improve our neuron models and lets create an artificial neuron model by using arrays.

Array Based Artificial Neuron Model in C++

This is another simple neuron example with arrays. This example is also good for C applications on IoTs. If you have a constant network and you know the trained data values, this model may be easy to check activation of neurons. Arrays are easy to allocate memory and easy to use on static neural networks.

Let’s define number of neurons, if it varies in your application use int,

[crayon-673f8dbb2db9c078994408/]

We should have an activation function, in other term transfer function phi(), linear, sigmoid, etc.. Let’s define very simple linear transfer function.

[crayon-673f8dbb2dba2231761926/]

First, we should define & initialize activity of neurons,

[crayon-673f8dbb2dba3744191285/]

Next, we should define & initialize weights of neural links,

[crayon-673f8dbb2dba4633628698/]

Finally we can calculate new activity values of output neuron by using our activation function as below,

Thus, output activation value of neuron 2 can be written as below,

[crayon-673f8dbb2dba6299481385/]

Here is the full example combined together,

[crayon-673f8dbb2dbac641041670/]

This is a good example and friendly with C and C++ codes, that means you can use it on IoTs with MicroC, Ardunio C, Dev C++ or you can go for GNU C/C++, Visual C++, or C++ Builder professionally.

Get started building powerful apps with C++Builder!

Exit mobile version