0% found this document useful (0 votes)
2 views2 pages

Build A Convolution Neural Network For MNIST Hand Written Digit Classification Aim: Description

The document outlines the process of building a Convolution Neural Network (CNN) for classifying handwritten digits from the MNIST dataset. Key steps include data preprocessing, model architecture construction, compilation, training, evaluation, and making predictions. A sample program using TensorFlow is provided to illustrate the implementation of the CNN model.

Uploaded by

sahithidhanamjay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Build A Convolution Neural Network For MNIST Hand Written Digit Classification Aim: Description

The document outlines the process of building a Convolution Neural Network (CNN) for classifying handwritten digits from the MNIST dataset. Key steps include data preprocessing, model architecture construction, compilation, training, evaluation, and making predictions. A sample program using TensorFlow is provided to illustrate the implementation of the CNN model.

Uploaded by

sahithidhanamjay
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Exp No: Page No:

Date:
4. Build a Convolution Neural Network for MNIST Hand written Digit Classification.
Aim: To build a Convolution Neural Network for MNIST Hand written Digit
Classification. Description:
A Convolution Neural Network (CNN) is a type of deep learning model commonly used for
image classification tasks. CNNs are particularly effective for tasks like handwritten digit
recognition, as they are designed to automatically detect and learn features such as edges,
textures, and patterns from images.
Key Steps:
1. Data preprocessing
2. Building CNN Architecture
3. Model Compilation
4. Training the model
5. Model Evaluation
6. Making prediction
Program:
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D, MaxPooling2D,
Flatten, Dense, Dropout

#load the MNIST dataset


mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()

#Normalize the pixel values


x_train, x_test = x_train / 255.0, x_test / 255.0

# Build the CNN model


model = Sequential([
Conv2D(32, (3, 3), activation='relu', input_shape=(28, 28,
1)),MaxPooling2D((2, 2)),
Conv2D(64, (3, 3), activation='relu'),
MaxPooling2D((2, 2)),
Flatten(),
Dense(128, activation='relu'),
Dropout(0.2), # Dropout layer to prevent overfitting
Dense(10, activation='softmax') # 10 classes MNIST digits
])

# Compile the model


model.compile(optimizer='rmsprop',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])

# Train the model


import visualkeras
visualkeras.layered_view(model)

model.fit(x_train, y_train, epochs = 2)


model.evaluate(x_test, y_test)

ADITYA ENGINEERING COLLEGE(A) Roll No:


22A91A61B6
Exp No: Page No:
Date:

Output:

ADITYA ENGINEERING COLLEGE(A) Roll No:


22A91A61B6

You might also like