Skip to content

KPlanisphere/neural-logic-gates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

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

No releases published

Packages

No packages published

Languages