AND / OR / XOR gates
Repo link
Here you can find all my code : https://github.com/AdrienTriquet/IA0
Introduction
This lab had for purpose to give us a first overview of Artificial Intelligence and to create a same work environment for all.
Being a user of Pycharm already, I did not have to prepare anything. I already work on a good virtual environment on Python 3.8.
First application
At first, we used an ANN (artificial neuron network) to learn the AND gate output. Here was my output :
To change the gate seeked, you simply have to change the labels as input.
Parameters :
Then, let’s see the impact of the different parameters on the network.
Epochs
I seek the epochs number so I got the good result : we see that 100 and 10 gives the same. By testing from 0 to 10, I saw that I had valid prediction at 5. This is very empirical.
Moreover, I made a function « error » in the file XOR. I then saw that the exact value of epochs to have a good enough result is not the same each time. Indeed, the value are taken randomly and results are not always the same. Before 3000, I sometimes had value > 0.01 but never after 3000.
Activation fonction :
- We were at first using step unit.
- With the sigmoid function, the prediction are no longer 0 and 1 but almost it :
We see this method is less accurate.
- Let’s compare the sigmoid to an hyperbolic tangent : We see the tangent is more accurate. Moreover, this activation function enables to go faster to the result, so the results are better.
Tensorflow
We finally had to implement the same network with tensorflow. I made this :
This model with 5000 epochs gave me 100 % accuracy. To change the gate, you simply have the change the labels as input again.