Giter Site home page Giter Site logo

numpy_cnn's Introduction

NumPy CNN

This is a small NeuralNet-Framework implemented only with NumPy. It contains Linear-, Convolution-, TransposedConv- and Pooling-Layers. The Framework is not really intended to be used, because you can't save the model (yet) and it's poorly optimized, but more for curious GitHub-user, who want to learn more about the popular Layers/Activations/etc. in NeuralNets.

Requirements

For the core CNN-Frame you only need NumPy.

pip install numpy

If you want to run the FashionNet example, you need Matplotlib (for live-plotting), tqdm (loading-bar) and gzip (read compressed trainings data).

pip install matplotlib
pip install tqdm
(gzip is part of the python standard library)

For the test_CNN script you will also need PyTorch, because I confirmed my results with the PyTorch-Autograd Engine.

pip install torch===1.4.0

Alternatively use the PyTorch website.

Testing and Example

Testing: The test_CNN.py script runs the forward- and backwardpass of all Layers, Activations and Losses with random shaped inputs and checks the results with the PyTorch-Autograd Engine.

Example: I also wrote a small Network in the FashionNet.py file, which trains a small Model with the FashionMNIST dataset. The Model was trained for only one epoch and returned some descend results. They aren't the best, but my test with the same Model in PyTorch got a similar result, so it must be the bad architecture and the short training of only one epoch. Plot of Loss and Accuracy NOTE: The Testing Loss and Accuracy is more stable because the testing batch was four times the size of the training batch.

Features

Layers:

  • Linear
  • Convolution (2D)
  • Transposed Convolution (2D) - MaxPool (2D)

Activations:

  • ReLU
  • LeakyReLU
  • Tanh
  • Sigmoid
  • Softmax
  • LogSoftmax

Losses:

  • MSELoss, MAELoss (L1-Loss)
  • BinaryCrossEntropyLoss
  • CrossEntropyLoss
  • SoftmaxLoss (Softmax + CrossEntropy)

Optimizer:

  • SGD (Momentum, Nesterov)
  • Adagrad
  • RMSprop
  • Adam

Future Updates

  • update BinaryCrossEntropyLoss for more numerical stability
  • add BatchNorm and Dropout-Layer
  • add CELU and ELU activations

Acknowledgments

For the Softmax, LogSoftmax and CrossEntropyLoss-Module I used the numerical more stable functions implemented in the PyTorch Library! You should definetly check this amazing Library out! ;) luv u :*

Also a great source for Convolutions and Optimizer were the CS231n course notes.

To learn more about Transposed Convolutions: Paper and Animations.

numpy_cnn's People

Contributors

akutzer avatar

Stargazers

 avatar

Watchers

 avatar  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.