Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Neural Logic Gates

This repository contains implementations of basic logic gates (AND, OR, NOT, XOR) using artificial neural networks (ANNs) with TensorFlow/Keras. Each script trains a neural network to approximate the behavior of its respective logic gate.

📌 Overview

Each Python script defines, trains, and evaluates a neural network to mimic a specific logic gate:

  • and.py – Simulates an AND gate.
  • or.py – Simulates an OR gate.
  • not.py – Simulates a NOT gate.
  • xor.py – Simulates an XOR gate.

The models use a simple feedforward neural network architecture with fully connected layers.

🚀 Requirements

Ensure you have the following dependencies installed before running the scripts:

pip install numpy tensorflow keras

🏗️ Model Architecture

  • Each model consists of one or more dense (fully connected) layers.
  • Activation functions used: ReLU, Tanh, and Sigmoid.
  • Optimizer: Adam.
  • Loss function: binary_crossentropy (for classification tasks).

🔧 Usage

Run the desired logic gate script to train and evaluate the neural network:

python and.py
python or.py
python not.py
python xor.py

After training, the model evaluates its accuracy and prints predictions based on the input dataset.

📊 Example Output (AND Gate)

binary_accuracy: 100.00%
[[0.]
 [0.]
 [0.]
 [1.]]

Releases

Packages

Contributors

Languages