Artificial IntelligenceAuthor:

Logic Gate Prediction with TensorFlow

An experimental PyQt5 application for interactively testing a small neural network trained on AND and OR truth tables.

PythonTensorFlowKerasNumPyPyQt5
Logic Gate Prediction with TensorFlow

About the Project

This educational desktop experiment models the truth tables of two-input AND and OR gates with a small artificial neural network. Users choose two binary inputs and a gate type, then inspect the model output through the interface.

How It Works

gate_training.py defines all four input combinations and stores both AND and OR results in the same two-column target array. The Keras model uses ReLU layers with 8 and 4 neurons followed by two sigmoid outputs; it trains with Adam and binary cross-entropy. interface.py selects the first output for AND or the second for OR and rounds the prediction for display.

Technologies

  • TensorFlow / Keras: two-output dense network and training loop.
  • NumPy: truth-table data and test inputs.
  • PyQt5: gate selector, input fields, and result view.

Project Structure

  • gate_training.py: dataset, model architecture, compilation, and training.
  • interface.py: desktop interface that submits user inputs to the model.

Technical Notes

The dataset contains only four samples and the model trains for 10 epochs whenever the application starts. It is therefore an experiment that exposes neural-network input/output flow, not a production inference model.

Source Code

View the project on GitHub.