-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.py
32 lines (23 loc) · 1.08 KB
/
model.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
31
32
import tensorflow as tf
def build_model():
model = tf.keras.Sequential([
# First convolutional layer
tf.keras.layers.Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28, 1)),
tf.keras.layers.MaxPooling2D((2, 2)),
# Second convolutional layer
tf.keras.layers.Conv2D(64, (3, 3), activation='relu'),
tf.keras.layers.MaxPooling2D((2, 2)),
# Third convolutional layer
tf.keras.layers.Conv2D(64, (3, 3), activation='relu'),
# Flattening the output for the fully connected layers
tf.keras.layers.Flatten(),
# First dense layer with 64 neurons
tf.keras.layers.Dense(64, activation='relu'),
# Dropout layer to prevent overfitting
tf.keras.layers.Dropout(0.5),
# Second dense layer with 64 neurons
tf.keras.layers.Dense(64, activation='relu'),
# Output layer with 10 neurons (one for each digit class) and softmax activation
tf.keras.layers.Dense(10, activation='softmax')
])
return model