0% found this document useful (0 votes)
24 views11 pages

21MCI1126 - Nikhil - Raj 2.1

1. The document describes using an artificial neural network (ANN) to solve a classification problem on the Fashion MNIST dataset. 2. It loads and preprocesses the data, builds a sequential ANN model with dense and dropout layers, trains the model over 10 epochs, and evaluates the model accuracy on the test set. 3. The student learns about the MNIST dataset, performs exploratory data analysis, manipulates the data, and builds and trains an ANN classifier on the Fashion MNIST dataset to solve a classification problem.

Uploaded by

nikhilsinghraj11
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
24 views11 pages

21MCI1126 - Nikhil - Raj 2.1

1. The document describes using an artificial neural network (ANN) to solve a classification problem on the Fashion MNIST dataset. 2. It loads and preprocesses the data, builds a sequential ANN model with dense and dropout layers, trains the model over 10 epochs, and evaluates the model accuracy on the test set. 3. The student learns about the MNIST dataset, performs exploratory data analysis, manipulates the data, and builds and trains an ANN classifier on the Fashion MNIST dataset to solve a classification problem.

Uploaded by

nikhilsinghraj11
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 11

Solve Classification problem with ANN

Student Name: Nikhil Raj UID: 21MCI1126


Branch: MCA (AI&ML) Section/Group – B
Semester: 3rd Date of Performance: 18-10-2022
Subject Name: Deep Learning Lab Subject Code: 21CAH-724

Aim/Overview of the practical: Take a image data set from any online repository and use
ANN for classification

1. Task to be done: Solve Classification problem

2. Dataset if you are using: Fashion Mnist dataset

import pandas as pd
import numpy as np
import keras
import matplotlib.pyplot as plt
%matplotlib inline

from keras.datasets import fashion_mnist


from keras.utils.np_utils import
to_categorical from keras.models import
Sequential
from keras.layers import Dense
from keras.layers import Dropout

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

print(x_train.shape)
print(y_train.shape)
print(x_test.shape)
print(y_test.shape)
x_train[0].shape

plt.imshow(x_train[0],cmap='gray')

y_train[0]

image_height,image_width=28,28

x_train = x_train.reshape(60000,image_height*image_width)

x_test=x_test.reshape(10000,image_height*image_width)
print(x_train.shape)
print(x_test.shape)
print(x_train[0])
x_train=x_train.astype('float32')
x_test=x_test.astype('float32')

x_train/=255.0
x_test/=255.0
print(x_train[0])

print(y_train.shape)
print(y_test.shape)

y_train = to_categorical(y_train,10)
print(y_train.shape)
y_test= to_categorical(y_test,10)
print(y_test)

model=Sequential()
model.add(Dense(512, input_shape=(784,), name='HiddenLayer-1', activation='relu'))
model.add(Dense(512, name='HiddenLayer-2', activation='relu'))
model.add(Dense(10, name='OutputLayer', activation='softmax'))

model.compile(optimizer='adam',loss='categorical_crossentropy',metrics=['accuracy'])
model.summary()

#Make it verbose so we can see the progress


VERBOSE=1

#Setup Hyper Parameters for training

#Set Batch size


BATCH_SIZE=16
#Set number of epochs
EPOCHS=10
#Set validation split. 10% of the training data will be used for validation
#after each epoch
VALIDATION_SPLIT=0.1

print("\nTraining Progress:\n------------------------------------")

#Fit the model. This will perform the entire training cycle, including
#forward propagation, loss computation, backward propagation and gradient descent.
#Execute for the specified batch sizes and epoch
#Perform validation after each epoch
history=model.fit(x_train,
y_train,
batch_size=BATCH_SIZE,
epochs=EPOCHS,
verbose=VERBOSE,
validation_split=VALIDATION_SPLIT)

plt.plot(history.history["accuracy"])

plt.plot(history.history["accuracy"])
plt.plot(history.history["val_accuracy"])

plt.plot(history.history["accuracy"])
plt.plot(history.history["val_accuracy"])
plt.plot(history.history["loss"])
score=model.evaluate(x_test,y_test)
# Returns the loss and metrics value of the model
Score

3. Result/Output/Writing Summary:
Learning outcomes (What I have learnt):

1. Learnt about MNIST dataset

2. Leant how to perform EDA

3. Learnt how to do data manipulation

Evaluation Grid:

Sr. No. Parameters Marks Obtained Maximum Marks


1. Demonstration/Performance/Pre 5
Lab Quiz
2. Worksheet 10
3. Post Lab Quiz 5

You might also like