Skip to content

TravorLZH/intelligent-stuff

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MNIST Classifier

My "Hello world" project of Neural Networks. It is currently based on the Keras API, but I am going implement one literally from scratch after I mastered the section of back propagation.

Prerequisites

Before trying the programs, make sure numpy, opencv-python are properly installed.

To run derivative.py, you also need matplotlib since it is using pyplot to graph functions.

  • mnist_test.py: This is the simplest fully-connected network implemented to classify the MNIST handwriting digits. Due to my limitation in mathematics, the program is written using Keras API.

MNIST classifier

Programs that are implemented from scratch

  • fnn_xor.py: It seems to be redundant to let a feedforward neural network learn to do XOR operation, but it is my first neural network made from scratch.

  • gd_linearfunc.py: This script demonstrates Gradient Descent in Machine Learning by fitting a linear function. Though it does some apparently useless jobs, it is probably the simplest learning that makes use of Gradient Descent.

Install MathJax Plugin for Github to view the formulas

This is the form of the linear function to fit:

$$\displaystyle{f(x)=kx+b}$$

And the formula below is how we do gradient descent to the parameters (knowledge of multivariable calculus may be required to understand this):

$$\displaystyle{\begin{bmatrix}k \\ b\end{bmatrix}=\begin{bmatrix}k_0 \\ b_0\end{bmatrix}-\alpha \begin{bmatrix}\frac{\partial C}{\partial k} \\ \frac{\partial C}{\partial b}\end{bmatrix}}$$

I recently discovered that the program above can also help solve the problem of Linear Regression, I will make a separate program later

  • mnist_interpreter.py: This is a script that helps you view the labeled images from either of the training or testing data sets. It is well-documented, so developers are easy to understand the format of IDX file and can implement new interpreters by themselves.

MNIST interpreter

  • derivative.py: This script shows the relationship between a function and its derivative by using tangent line. This is a fundamental concept for Gradient Descent algorithm.

Derivative plot

Releases

No releases published

Packages

No packages published

Languages