Skip to content

Implements a neural network learning XOR gate in your favourite languages !

License

Notifications You must be signed in to change notification settings

Vinetos/neural-network-xor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

Neural-Network-XOR

Implement a Neural Network learning XOR gate in your favourite languages !

File architecture

To avoid problems, follow this architecture :

<root>
  |_ python
      |_ <username>
          |_ my file.py
          |_ network.py
  |_ java
      |_ <username>
          |_ Main.java
          |_ Test.java

To increase lisibility, I recommend to create only ONE FILE. For instance, main.py should contains all the code needed to run the project.

XOR gate

An XOR gate (sometimes referred to by its extended name, Exclusive OR gate) is a **digital logic gate** with two or more inputs and one output that performs exclusive disjunction. The output of an XOR gate is true only when exactly one of its inputs is true. If both of an XOR gate's inputs are false, or if both of its inputs are true, then the output of the XOR gate is false.
If an XOR gate has more than two inputs, then its behavior depends on its implementation. In the vast majority of cases, an XOR gate will output true if an odd number of its inputs is true.
Input Output
AB
00
01
10
11
Q = A ⊕ B
0
1
1
0

Logical Proof of XOR

A B A + B A' B' A' + B' A ⊕ B = (A+B).(A'+B')
0001110
0111011
1010111
1110000

In this table,

  • A + B represent OR operation between A and B
  • A' and B'represent A & B compliment respectively
  • dot(.) represent AND operation

Significance of XOR in Neural Network

Gates are the building blocks of Perceptron. XOR is a classification problem and one for which the expected outputs are known in advance. It is therefore appropriate to use a supervised learning approach. The XOR gate consists of an OR gate, NAND gate and an AND gate. This means we need to combine two perceptrons.