DEV Community

Cover image for How Calculations Happen in a Neural Network
Ganesh Kumar
Ganesh Kumar

Posted on • Edited on

How Calculations Happen in a Neural Network

Hello, I'm Ganesh. I'm building git-lrc, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on GitHub. Star git-lrc on GitHub to help more developers discover the project. Do give it a try and share your feedback for improving the product.

In the previous article, we discussed how action potentials are defined.

Let's take a simple example and plot a graph.

Using Softplus as the Activation Function

For our initial example of dosage, we can take Softplus as an activation function.

Now let's find the dosage and y values based on the formula:

( Dosage x -34.4 ) + 2.14

For dosage : 0
( 0 x -34.4 ) + 2.14 = 2.14

For dosage : 0.1
( 0.1 x -34.4 ) + 2.14 = -3.44 + 2.14 = -1.3

Now let's multiply all the values calculated in the top-most hidden layer with -1.3.

For dosage : 0
2.14 x -1.3 = -2.782

For dosage : 0.1
-1.3 x -1.3 = 1.69

Similar calculations can be done for the top-most node values.

Calculating the Bottom Node

Now for the bottom-most node:

( Dosage x -2.52 ) + 1.29

For dosage : 0
( 0 x -2.52 ) + 1.29 = 1.29

For dosage : 0.1
( 0.1 x -2.52 ) + 1.29 = -0.252 + 1.29 = 1.038

Now multiply all the values calculated in the bottom-most hidden layer with 2.28.

For dosage : 0
1.29 x 2.28 = 2.94

For dosage : 0.1
1.038 x 2.28 = 2.366

Combining Both Node Results

From both the top and bottom node results, we add them together.

Finally, we subtract 0.5690 from the final value.

Here is the final prediction made by the neural network.

Weights Used in the Neural Network

These are the weights:

Bias Values Used in the Neural Network

These are the bias values:

Support git-lrc

git-lrc

Any feedback or contributors are welcome! It’s online, source-available, and ready for anyone to use.

Star git-lrc on GitHub

Top comments (0)