GithubHelp home page GithubHelp logo

linbinyang / yannpp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ribtoks/yannpp

0.0 0.0 0.0 12.57 MB

Deep Neural Network from scratch in C++ for learning purposes

License: MIT License

CMake 2.82% C++ 96.85% Shell 0.33%

yannpp's Introduction

yannpp

Build status Build Status license copyright language c++

This is an educational effort to help understand how deep neural networks work.

In order to achieve this goal I prepared a small number of selected educational materials and heavily documented pure C++ implementation of CNN that classifies MNIST digits.

Understand

In order to fully understand what is going on, I would recommend doing following:

After this you will be able to understand code in the repo.

Get in

C++ code in the repo is simple enough to work in Windows/Mac/Linux. You can use CMake to compile it (check out .travis.yml or appveyor.yml to see how it's done in Linux or Windows).

In order to use MNIST data you will need to unzip archives in the data/ directory first. Also compiled executable accepts path to this data/ directory as first command line argument.

See

Main learning loop (as defined in network2_t::backpropagate()) looks like this:

// feedforward input
for (size_t i = 0; i < layers_size; i++) {
    input = layers_[i]->feedforward(input);
}

// backpropagate error
array3d_t error(result);
for (size_t i = layers_size; i-- > 0;) {
    error = layers_[i]->backpropagate(error);
}

Because of this simplicity most interesting things are located in src/layers/ directory that contains implementations of those feedforward() and backpropagate() methods for each layer.

This codebase contains it's own greatly simplified ndarray as in Numpy and it's called array3d_t. Most useful feature of the array is the ability to slice parts of it's data as subarrays.

network1_t as used in examples/mnist_simple.cpp is all-in-one implementation of network with fully-connected layers while network2_t is more "abstract" implementation that uses arbitrary layers in other examples.

Do

Codebase should encourage you to experiment. For example, examples/mnist_deeplearning.cpp file specifically contains lots of experimental code (e.g. reducing size of the input to be able to experiement with network topology, commented layers in the network itself etc.) that can show you how to experiment. Experimentation is required to select hyperparameters, to see if your network converges etc.

Cope

Feel free to say thank you if it was useful. Also this code (as any other) may contain bugs or other problems - all contributions are highly welcome.

  • Fork yannpp repository on GitHub
  • Clone your fork locally
  • Configure the upstream repo (git remote add upstream [email protected]:ribtoks/yannpp.git)
  • Create local branch (git checkout -b your_feature)
  • Work on your feature
  • Push the branch to GitHub (git push origin your_feature)
  • Send a pull request on GitHub

Get out

There are many other similar efforts on GitHub. Their common problems are: code that is hard to read or code with too much magic inside (mainly related to python). Here's a short list with similar efforts with very easy code to understand:

yannpp's People

Contributors

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