Answer the question
In order to leave comments, you need to log in
How to calculate the output of a neural network (Synaptic.js)?
I'm trying to deal with neural networks, but it seems that I do not quite understand the calculation of the output of a neural network correctly. I'm using SynapticJS and as you can see in the picture, the network is trained and working correctly according to the output. But when I try to use the received network weights in manual recalculation, I get a different value. Please correct me if my algorithm for calculating the network output is wrong:
It may not be clear from the picture what the network looks like - it's just two input neurons, two neurons in a hidden layer and one output.
So,
1. the initial data goes from -100 to 100, so it is necessary to normalize the network, i.e. n[i] = n[i] / 200 + 0.5 => we get a range of values from 0 to 1. The same data is used as input.
2. Then I calculate the weighted sum for each hidden neuron: the sum of the products of each neuron and its weight to the hidden neuron for which the weighted sum is calculated. I take the sigmoid from the received number and assign the resulting value
3 to the hidden neuron. Similarly, I calculate the value of the output neuron, which will be considered the output of the network.
If the algorithm is correct, then I will assume that the error is either in the incorrect export of weights and they are not finite, or such network normalization is not suitable and it is better to use a hyperbolic tangent in the range [-1...1]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question