Coder Social home page Coder Social logo

aadityasikder / neural-network-from-scratch- Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5.51 MB

This notebook demonstrates a neural network implementation using NumPy, without TensorFlow or PyTorch. Trained on the MNIST dataset, it features an architecture with input layer (784 neurons), two hidden layers (132 and 40 neurons), and an output layer (10 neurons) with sigmoid activation.

Jupyter Notebook 100.00%
backward-propagation evaluation forward-propagation mnist-dataset neural-network neural-networks-from-scratch numpy training

neural-network-from-scratch-'s Introduction

Neural Network from Scratch

Overview

This notebook implements a neural network from scratch using only NumPy, without relying on libraries like TensorFlow or PyTorch. The neural network architecture consists of an input layer with 784 neurons, two hidden layers with 132 and 40 neurons, respectively, and an output layer with 10 neurons. The sigmoid function is used as the activation function for each neuron.

Features

  • Neural Network Architecture: The network has an input layer with 784 neurons, two hidden layers with 132 and 40 neurons, and an output layer with 10 neurons.
  • Activation Function: The sigmoid function is used as the activation function for each neuron.
  • Forward Propagation: The forward pass computes the weighted sum of inputs and applies the activation function to get the output for each layer.
  • Backpropagation: The backward pass propagates the error through the layers to compute the gradients of the cost function with respect to weights and biases.
  • Weight and Bias Update: The weights and biases are updated using gradient descent to minimize the error between predicted and actual outputs.
  • Training: The network is trained on the MNIST dataset, which consists of handwritten digit images.
  • Evaluation: The trained model's accuracy is evaluated on both the training and test sets.

Process Flow

The following flow chart illustrates the overall process of training and evaluating the neural network:

             ┌───────────────┐
             │  Initialize   │
             │   Weights,    │
             │  Biases, and  │
             │ Hyperparameters│
             └──────┬─────────┘
                    │
             ┌───────▼─────────┐
             │    Preprocess  │
             │     Data       │
             └──────┬─────────┘
                    │
             ┌───────▼─────────┐
             │    Training    │
             │     Loop       │
             └──────┬─────────┘
                    │
          ┌────────┴────────┐
          │    Forward     │
          │   Propagation  │
          └──────┬─────────┘
                 │
          ┌──────┴─────────┐
          │  Backpropagation│
          └──────┬─────────┘
                 │
          ┌──────┴─────────┐
          │  Update Weights│
          │   and Biases   │
          └──────┬─────────┘
                 │
                 │
          ┌──────┴─────────┐
          │    Evaluate    │
          │    Accuracy    │
          └─────────────────┘

Description:

  1. Initialize weights, biases, and hyperparameters for the neural network.
  2. Preprocess the data (e.g., normalize, reshape).
  3. Start the training loop:
    • Perform forward propagation to compute outputs.
    • Perform backpropagation to compute gradients.
    • Update weights and biases using the gradients.
    • Evaluate the accuracy of the model.
  4. Repeat the training loop for the specified number of epochs.

Dependencies

The following libraries are required to run this notebook:

  • NumPy
  • Pandas
  • Matplotlib

Usage

  1. Clone the repository or download the notebook file.
  2. Install the required dependencies.
  3. Open the notebook in your preferred environment (e.g., Jupyter Notebook, Google Colab).
  4. Run the cells to train the neural network and evaluate its performance.

neural-network-from-scratch-'s People

Contributors

aadityasikder avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.