Skip to content

Commit c004e54

Browse files
committed
cnn_mnist.py: For the Convolutional Neural Network (CNN) model.
1 parent 99a58be commit c004e54

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

machine_learning/neural_networks/cnn_mnist.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""
22
Convolutional Neural Network (CNN) for MNIST Classification
33
4-
Goal: This script builds a deep CNN to classify the MNIST dataset using TensorFlow and Keras. It leverages
5-
convolutional layers for feature extraction and pooling layers for down-sampling, followed by fully connected layers
6-
for classification.
4+
Goal: This script builds a deep CNN to classify the MNIST dataset using
5+
TensorFlow and Keras. It leverages convolutional layers for feature
6+
extraction and pooling layers for down-sampling, followed by fully
7+
connected layers for classification.
78
89
Objectives:
910
- Load and preprocess MNIST data (reshape for CNN input).
@@ -12,7 +13,7 @@
1213
1314
"""
1415

15-
import tensorflow as tf
16+
# import tensorflow as tf
1617
from tensorflow.keras import layers, models
1718
from tensorflow.keras.datasets import mnist
1819
from tensorflow.keras.utils import to_categorical
@@ -56,7 +57,8 @@
5657
model.add(layers.Dense(10, activation="softmax"))
5758

5859
# Compile the model
59-
model.compile(optimizer="adam", loss="categorical_crossentropy", metrics=["accuracy"])
60+
model.compile(optimizer="adam", loss="categorical_crossentropy",
61+
metrics=["accuracy"])
6062

6163
# Display the model summary
6264
model.summary()

0 commit comments

Comments
 (0)