-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcnn-model-1.3.2.py
executable file
·30 lines (27 loc) · 896 Bytes
/
cnn-model-1.3.2.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
'''A sample CNN network for classification
'''
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
# keras modules
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Conv2D, Flatten
from tensorflow.keras.optimizers import RMSprop
n_digits = 10
model = Sequential()
model.add(Conv2D(filters=64,
kernel_size=3,
activation='relu',
strides=2,
input_shape=(28, 28, 1),
padding='same'))
model.add(Conv2D(filters=128,
kernel_size=3,
activation='relu',
strides=2))
model.add(Flatten())
model.add(Dense(n_digits, activation='softmax'))
model.compile(loss='categorical_crossentropy',
optimizer=RMSprop(),
metrics=['accuracy'])
model.summary()