From ee59378f652e87d8606b1ecc08fcd8a91b506b72 Mon Sep 17 00:00:00 2001 From: "labs-code-app[bot]" <161369871+labs-code-app[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 18:25:18 +0000 Subject: [PATCH] Make following changes to examples/demo_mnist_convnet.py: 1) Add 1 more Conv2D layer and MaxPooling2D layer to the model 2) Change the model optimizer to sgd and set learning rate as 0.001 --- examples/demo_mnist_convnet.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/demo_mnist_convnet.py b/examples/demo_mnist_convnet.py index f5f4e3f4d..d1d45a2eb 100644 --- a/examples/demo_mnist_convnet.py +++ b/examples/demo_mnist_convnet.py @@ -35,6 +35,8 @@ layers.MaxPooling2D(pool_size=(2, 2)), layers.Conv2D(64, kernel_size=(3, 3), activation="relu"), layers.MaxPooling2D(pool_size=(2, 2)), + layers.Conv2D(128, kernel_size=(3, 3), activation="relu"), + layers.MaxPooling2D(pool_size=(2, 2)), layers.Flatten(), layers.Dropout(0.5), layers.Dense(num_classes, activation="softmax"), @@ -44,7 +46,7 @@ model.summary() model.compile( - loss="categorical_crossentropy", optimizer="adam", metrics=["accuracy"] + loss="categorical_crossentropy", optimizer=keras_core.optimizers.SGD(learning_rate=0.001), metrics=["accuracy"] ) model.fit(