-
Notifications
You must be signed in to change notification settings - Fork 0
CNN Model: LeNet
Yang YueXiang edited this page Aug 18, 2019
·
2 revisions
a pioneering 7-level convolutional network by LeCun et al. in 1998,33 that classifies digits, was applied by several banks to recognize hand-written numbers on checks (British English: cheques) digitized in 32×32 pixel images
Refer to: 13.1 Built LeNet and test on MNIST
# create model
model = Sequential()
# 2 sets of CRP (Convolution, RELU, Pooling)
model.add(Conv2D(20, (5, 5),
padding = "same",
input_shape = input_shape))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size = (2, 2), strides = (2, 2)))
model.add(Conv2D(50, (5, 5),
padding = "same"))
model.add(Activation("relu"))
model.add(MaxPooling2D(pool_size = (2, 2), strides = (2, 2)))
# Fully connected layers (w/ RELU)
model.add(Flatten())
model.add(Dense(500))
model.add(Activation("relu"))
# Softmax (for classification)
model.add(Dense(num_classes))
model.add(Activation("softmax"))
model.compile(loss = 'categorical_crossentropy',
optimizer = keras.optimizers.Adadelta(),
metrics = ['accuracy'])
print(model.summary())
Layer (type) Output Shape Param #
=================================================================
conv2d_1 (Conv2D) (None, 28, 28, 20) 520
_________________________________________________________________
activation_1 (Activation) (None, 28, 28, 20) 0
_________________________________________________________________
max_pooling2d_1 (MaxPooling2 (None, 14, 14, 20) 0
_________________________________________________________________
conv2d_2 (Conv2D) (None, 14, 14, 50) 25050
_________________________________________________________________
activation_2 (Activation) (None, 14, 14, 50) 0
_________________________________________________________________
max_pooling2d_2 (MaxPooling2 (None, 7, 7, 50) 0
_________________________________________________________________
flatten_1 (Flatten) (None, 2450) 0
_________________________________________________________________
dense_1 (Dense) (None, 500) 1225500
_________________________________________________________________
activation_3 (Activation) (None, 500) 0
_________________________________________________________________
dense_2 (Dense) (None, 10) 5010
_________________________________________________________________
activation_4 (Activation) (None, 10) 0
=================================================================
Total params: 1,256,080
Trainable params: 1,256,080
Non-trainable params: 0
_________________________________________________________________