Week 2 - Pipeline CNN, eksperimen, laporan akhir
This commit is contained in:
@@ -80,3 +80,38 @@ def create_cnn_mnist_model(input_shape: tuple = (28, 28, 1), num_classes: int =
|
||||
)
|
||||
return model
|
||||
|
||||
|
||||
def create_deep_cnn_mnist_model(input_shape: tuple = (28, 28, 1), num_classes: int = 10) -> keras.Model:
|
||||
"""
|
||||
Membangun model CNN yang lebih dalam dengan 3 blok Conv2D + MaxPooling2D.
|
||||
Digunakan untuk Tugas 2 (Eksplorasi Kedalaman Arsitektur CNN).
|
||||
"""
|
||||
model = keras.Sequential(
|
||||
name="cnn_mnist_3blocks",
|
||||
layers=[
|
||||
layers.Input(shape=input_shape),
|
||||
# Block 1
|
||||
layers.Conv2D(32, (3, 3), activation="relu", padding="same"),
|
||||
layers.MaxPooling2D((2, 2)),
|
||||
# Block 2
|
||||
layers.Conv2D(64, (3, 3), activation="relu", padding="same"),
|
||||
layers.MaxPooling2D((2, 2)),
|
||||
# Block 3 (Blok tambahan)
|
||||
layers.Conv2D(128, (3, 3), activation="relu", padding="same"),
|
||||
layers.MaxPooling2D((2, 2)),
|
||||
# Classifier
|
||||
layers.Flatten(),
|
||||
layers.Dense(64, activation="relu"),
|
||||
layers.Dropout(0.3),
|
||||
layers.Dense(num_classes, activation="softmax"),
|
||||
]
|
||||
)
|
||||
|
||||
model.compile(
|
||||
optimizer="adam",
|
||||
loss="sparse_categorical_crossentropy",
|
||||
metrics=["accuracy"]
|
||||
)
|
||||
return model
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user