Simple Neural Network example
Posted: Tue Mar 31, 2026 7:45 am
Beginner Neural Network in C — A Tiny Perceptron That Learns OR
this example teaches:
inputs
weights
bias
weighted sum
activation function
training from examples
error correction
What is the neural network doing?
This tiny network receives two inputs:
x1
x2
It computes:
sum = x1*w1 + x2*w2 + bias
Then it decides:
if sum >= 0 → output 1
otherwise → output 0
During training:
if the answer is wrong, the weights are adjusted a little
after many examples, the network learns the rule
this example teaches:
inputs
weights
bias
weighted sum
activation function
training from examples
error correction
What is the neural network doing?
This tiny network receives two inputs:
x1
x2
It computes:
sum = x1*w1 + x2*w2 + bias
Then it decides:
if sum >= 0 → output 1
otherwise → output 0
During training:
if the answer is wrong, the weights are adjusted a little
after many examples, the network learns the rule