Giter VIP home page Giter VIP logo

nn_mnist's Introduction

NN (Neural Network) MNIST

C++ CMake Linux

  • This project implements a NN(Neural Network) to classify handwritten digits from the MNIST dataset.

Use

  • clone the project and add the sub-model(spdlog)
git clone https://github.com/Jungle430/NN_MNIST.git
git submodule init
git submodule update

Design idea

NN_Layer

  • prepare the data
cd script
python3 read_mnist.py <train_data_set_size(0~60000)> <test_data_set_size(0~10000)>
  • You can safely set the scale of large datasets because the asynchronous data reading feature has been implemented. Therefore, you don't need to worry about memory overflow issues.

  • Set the scale of the neural network

NeuralNetwork<long double, 4> neural_network(
      MNIST::IMAGE_DOMAIN, {{NN::DEFAULT_NODE_SIZE, "Sigmoid"},
                      {NN::DEFAULT_NODE_SIZE, "Sigmoid"},
                      {NN::DEFAULT_NODE_SIZE, "Sigmoid"},
                      {MNIST::NUMBER_SIZE, "Sigmoid"}});
  • The last layer is output layer, so the size must equal to kind of MNIST number(0~9)

  • Two active function can be chosen

    • Sigmoid
    • ReLU
  • The number of the layers must equal with N (NeuralNetwork<dtype, N>)

  • make the program

mkdir build
cd build
cmake ..
make
  • Then you can train and test your Neural Network Model!

Attetion

  • This neural network is written using C++'s STL library without any special optimizations, so its computational efficiency is much lower compared to PyTorch. The code for this neural network is primarily intended for understanding the structure of neural networks.

Training effect

  • network scale: $3 \times 100$

Training effect

Picture

  • Remove irrelevant information from the log (like nohup), modify the log file path in picture.py, Then run the picture script
cd script
python3 picture.py

picture

Thanks

nn_mnist's People

Contributors

jungle430 avatar

Stargazers

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