GitXplorerGitXplorer
H

NeuroNet

public
0 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
2e210740d8e1a02e8ed4719cd10b7e4e62f8bcf2

fix link

HHO-COOH committed 5 years ago
Unverified
05ce7d9177cd3a58d6f191466d655e1041719a1c

Update Readme

HHO-COOH committed 5 years ago
Unverified
f47cfc043b1a8ada9559cf79c01639542b35e40d

Delete Summary.txt

HHO-COOH committed 5 years ago
Unverified
fdada5af643e0ba900a547b047fb681864af63e0

Delete NeuroNet.zip

HHO-COOH committed 5 years ago
Unverified
1a32be1039c9b2ac5db4b905e53a5f689a4b72eb

add executable

HHO-COOH committed 5 years ago
Unverified
38c67c292df23810553a4bb571c9dcadf768b565

Add opencv dependency

HHO-COOH committed 5 years ago

README

The README file for this repository.

NeuroNet

Introduction

This is a neural network course project, building a nerual network from scratch. Using only C++ standard library. The training algorithm is back-propagation. Two examples are included in main.cpp.

  • A 2-4-2 neural network, simulating the XOR gate.
  • The MNIST hand-written digit recognition. Images visualizing the original MNIST data is using OpenCV. You can remove this feature to get pure standard c++ implementation.

Note:

For MNIST, I also implement a data reader to read the binary encoding into the neural networl. The original MNIST data is structured as 784 pixels per number. In our course project, we are asked to down-sampled to 196 pixels (4:1) to reduce processing time.

MNIST

As mentioned in the Note, the neural network structure used is 196-100-10. The MNIST testing is utilizing all the datas in the two files (One epoch => 60,000 training samples + 10,000 testing samples. Output of the neural net uses one-hot-encoding. After 20 epochs, the accuracy gets to around 96%.

Result

My machine run one epoch in less than 25 seconds. There are plenty of rooms to improve the performance, such as use std::valarray or even std::array instead of std::vector as the internal data for Matrix class. And using a specialization for vector instead of 1 element per std::vector (huge overhead) as a matrix. But it's good enough for learning purpose. The specs of my machine:

  • CPU: AMD Ryzen 7 1700
  • RAM: 64GB DDR4 2400

Compiling

This project is written in C++11. This is a Visual Studio 2019 solution, if you have visual studio installed, simply open the .sln file and hit ctrl+F5 to run. If you are on Windows, you can run the executable file in ./Release/NeuroNet.exe If you are using another operating system, use g++ to compile. I only used standard C++ library, so no extra flags are needed. The OpenCV binaries are Windows Only.

Directory Structure:

./NeuroNet.sln          Visual studio solution file
./Release/              ...The executable file
./NeuroNet/             The source code
./Dependency/           OpenCV lib to display MNIST digits