Skip to content

kjd-dktech/perceptron-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Perceptron and Two-Layer Neural Network from Scratch

This project implements a single-layer Perceptron and a two-layer neural network (MLP) using only NumPy, without using any high-level machine learning libraries (like TensorFlow or PyTorch).
It serves as an educational demonstration of how neural networks work under the hood.


📌 Objectives

  • Understand and implement the basic components of a neural network:
    • Initialization of weights and biases
    • Activation functions
    • Cost/loss computation
    • Gradient descent (manual backpropagation)
    • Training loop

🧠 Implemented Models

  1. Perceptron (single layer)
    • Binary classification
    • Linear activation
  2. Two-layer neural network
    • Hidden layer with non-linear activation (ReLU or sigmoid)
    • Output layer with softmax or sigmoid (depending on the task)
    • Manual gradient calculation and training

🛠️ Technologies

  • Python 3.x
  • NumPy
  • Jupyter Notebook

🧪 How to Run

  1. Clone the repository:
    git clone https://github.com/your-username/perceptron-from-scratch.git
    cd perceptron-from-scratch
    
  2. Open the notebook:
    jupyter notebook perceptron.ipynb
    
  3. Follow the cells and run them step by step.

📝 File Structure

perceptron-lab/ ├── README.md
├── requirements.txt
├── notebook/ │ └── perceptron.ipynb
├── src/
│ ├── perceptron.py
│ └── mlp.py
├── data/
│ ├── testset.hdf5
│ └── trainset.hdf5
|
├── images/
│ └── └── .gitignore

📊 Dataset

The code includes toy data generated with NumPy (e.g. XOR, linearly separable datasets).

You can easily plug in any 2D dataset like sklearn.datasets.make_classification or make_moons.

🎓 Author

Kodjo Jean DEGBEVI Student in Artificial Intelligence & Big Data

About

Perceptron and Two-Layer Neural Network implemented from scratch

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors