Giter VIP home page Giter VIP logo

mnist's Introduction

Train MNIST dataset with different CNN structures, then export the trained parameters.

Terminology

W: input width / input size
F: filter width / filter size / kernel size
S: stride
P: padding size on the border
O: output width / output size
O = (W + 2P โˆ’ F) / S + 1
output size = (input size + 2 * padding - kernel size) / stride + 1

CONV: convolutional layer
FC: fully connected layer / linear layer
input depth = input layer / dimension, MNIST default 1
in_channle = input size / input width, MNIST default 28 (28x28 image size)
out_channel = filter num / output depth / layer / dimension
kernel_size = filter size / filter width
stride = stride
padding = padding

Output width will be floor down to integer if the calculate value is not integer.
As there are only 10 categories for the MNIST dataset, the last FC output neuron is 10.

CNN structure

CNN 1-2

1 CONV, 2 FC
CONV1, there are 4 filters, with filter size 7, stride 3
Activation function
FC1, output neuron 64
Activation function
FC2, output neuron 10

CNN1_2
input width input depth filter num filter width stride padding output width
CONV 28 1 4 7 3 0 (28+2*0-7)/3+1=8
in_feature out_feature
FC1 8^2*4=256 64
FC2 64 10

CNN 2-1

2 CONV, 1 FC
CONV1, 16 filters, each with filter size 7 and stride 2
Activation function
CONV2, 4 filters, each with filter size 5 and stride 2
Activation function
FC, output neuron is 10

CNN2_1
input width input depth filter num filter width stride padding output width
CONV1 28 1 16 7 2 0 (28+2*0-7)/2+1=11
CONV2 11 16 4 5 2 0 (11+2*0-5)/2+1=4
in_feature out_feature
FC1 4^2*4=64 10

CNN 3-2

3 CONV, 2 FC
CONV1, 16 filters, filter size 3 and stride 2
Activation function
CONV2, 4 filters, filter size 3 and stride 2
Activation function
CONV3, 16 filters, filter size 3 and stride 1
Activation function
FC1, output neurons 64
FC2, output neuron 10

CNN3_2
input width input depth filter num filter width stride padding output width
CONV1 28 1 16 3 2 0 (28+2*0-3)/2+1=13
CONV2 13 16 4 3 2 0 (13+2*0-3)/2+1=6
CONV3 6 4 16 3 1 0 (6+2*0-3)/1+1=4
in_feature out_feature
FC1 4^2*16=256 64
FC2 64 10

CNN 4-2

4 CONV, 2 FC
CONV1, 16 filters, filter size 5, stride 2
Activation function
CONV2, 4 filters, filter size 3, stride 1
Activation function
CONV3, 16 filters, filter size 3, stride 2
Activation function
CONV4, 4 filters, filter size 3, stride 1
FC1, output neuron 64
FC2, output neuron 10

CNN4_2
input width input depth filter num filter width stride padding output width
CONV1 28 1 16 5 2 0 (28+2*0-5)/2+1=12
CONV2 12 16 4 3 1 0 (12+2*0-3)/1+1=10
CONV3 10 4 16 3 2 0 (10+2*0-3)/2+1=4
CONV4 4 16 4 3 1 0 (4+2*0-3)/1+1=2
in_feature out_feature
FC1 2^2*4=16 64
FC2 64 10

mnist's People

Contributors

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