Notice this code is only to educational purposes, do not use it to any type of production ready application
The activation from the first layer:
The activation to the second layer:
we can only multiply matrices if the number of columns of the first matrix is equal to the number of rows of the second matrix.
The main.c
file has a basic ML algorithm that can learn OR
, AND
and NAND
operations.
This algorithms is not capable to learn XOR
because XOR
cannot be linearly separated.
So, to do this job, we need more neurons.
So, the deep-learning.c
file has a "more complex" ML algorithm with 3 neurons and 9 parameters that can handle OR
, AND
, NAND
and XOR
.
We also have the dynamic-deep-learning.c
, that is a "improved" neural network that you can change the number of neurons dynamically by changing NUMBER_OF_NEURONS
.
Another improvement is that in dynamic-deep-learning.c
we don't need to forward
the neural network mannualy, we do this by iteration over the network.
Running main.c
:
gcc main.c -lm -o main && ./main
Output demonstration:
Running deep-learning.c
:
gcc deep-learning.c -lm -o deep-learning && ./deep-learning
Output demonstration:
Running dynamic-deep-learning.c
:
gcc dynamic-deep-learning.c -lm -o dynamic-deep-learning && ./dynamic-deep-learning
Output demonstration: