Giter Site home page Giter Site logo

dapper-magician / nn_example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from josstorer/nn_example

0.0 0.0 0.0 393 KB

This repository is related to a video about principles of neural networks, which demonstrates how to write a simple neural network in 100 lines of code and implement handwritten digit recognition without using a framework. 这是一个与神经网络原理讲解视频, 相配套的项目, 演示在不使用框架的情况下, 用约100行代码编写简易的神经网络, 并借此实现手写数字识别.

Python 100.00%

nn_example's Introduction

简体中文 | English

This repository is related to the video about principles of neural networks, which demonstrates how to write a simple neural network and implement handwritten digit recognition without using a framework.

The neural network has a single hidden layer, and one output, you can change some arguments in the config file to adjust the settings for model training/simplification/preview detection

Start

git clone https://github.com/josStorer/nn_example.git --depth=1
cd nn_example
pip install -r requirements.txt
python cli.py -h

Command example

python cli.py -h                 # get help
python cli.py -test              # test accuracy
python cli.py -m                 # mini example test
python cli.py -train             # start training the model
python cli.py -s                 # simplify trained weights
python cli.py -p                 # start the real-time preview detection, open img.jpg in usps folder with a paint software, then edit and save, the result will be automatically refreshed
python cli.py -p -pycharm        # pycharm preview mode, automatically refresh with SciView. When "right-click" running ./usps/realtime_predict.py in pycharm, this mode is True
python cli.py -p -pf [filename]  # specify the image filename of the real-time preview

Notes

The number of classes can be modified in config.py, and the data source and data annotation can be modified in train.py

The data label value starts from 1, indicating category 1, 2, 3, ... 99, 100 ...

Finally, networks with the number of [class_num] are generated, each of which is used to predict whether the given data is of category 1, 2, 3, ... 99, 100 ...

When implementing classification, the network index with the prediction result closest to 1 is the currently judged category. The implementation code is as follows:

results = np.zeros(config.class_num)
for i in range(config.class_num):
    results[i] = network[i].predict(data)
return results.argmax() # This result starts from 0, so you have to add 1 to get the above category labelled value

reference: https://victorzhou.com/blog/intro-to-neural-networks/

nn_example's People

Contributors

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