The simplest neural network I was able to create
It so simple that it only has two weights. A neural network implementation in less than 30 lines of code. It's great.
The intelligence of the network will be an AND gate. 1,1 is 1, 0,0 is 0, and 0,1 or 1,0 is 0. Lets go:
The interesting lines in this code are:
output = input[0] * weights[0] + input[1] * weights[1]
We just multiply each input by the barbell. We have 2 inputs and 2 weights. that all.
The traning looks like this:
error = training_outputs[i] - output
weights[0] += learning_rate * error * training_inputs[i][0]
weights[1] += learning_rate * error * training_inputs[i][1]
So a neural network is just multiplying the input with weights…
If the problem is more complex, we will add bias and activation functions and more weights. But here we illustrated nicely what a neuron network is, training and predicting.
First of all the base.
Input: [0, 0] Predicted Output: 0 Input: [1, 1] Predicted Output: 1 Input: [0, 1] Predicted Output: 0 Input: [1, 0] Predicted Output: 0