Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Bahria University CSL-411: Artificial Intelligence Lab

Department of Computer Semester 06 (A)


Science Muhammad Farooq
02-134191-104

LAB 10:Neural Netowork


EXERCISE:

Download the dataset of fashion mnsit from the given link.

https://www.kaggle.com/zalando-research/fashionmnist

Train the model using neural networks with appropriate input/output layers and dense layers
according to the data and calculate the accuracy score of our trained model.

This study source was downloaded by 100000856308168 from CourseHero.com on 12-20-2022 13:28:28 GMT -06:00

https://www.coursehero.com/file/178051984/02-134191-077-9557668879-24052022-101712pmdocx/
CS Department, BUKC 2/8 Semester 6 (Fall 2021)
CSL-411: AI Lab Lab 10: Neural Neworks

import tensorflow as tf
fashion_mnist = tf.keras.datasets.fashion_mnist
(x_train,y_train),(x_test,y_test)=fashion_mnist.load_data()
x_train=tf.keras.utils.normalize(x_train, axis=1)
x_test=tf.keras.utils.normalize(x_test, axis=1)
model=tf.keras.models.Sequential()
model.add(tf.keras.layers. Flatten())
model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))
model.add(tf.keras.layers. Dense(128, activation=tf.nn.relu))
model.add(tf.keras.layers. Dense(10, activation=tf.nn.softmax))

model.compile(optimizer="adam",loss="sparse_categorical_crossentropy",metrics
=["accuracy"])

model.fit(x=x_train,y=y_train,epochs=10)
test_loss, test_accuracy = model.evaluate(x=x_test,y=y_test)
print("Test Accuracy", test_accuracy)

This study source was downloaded by 100000856308168 from CourseHero.com on 12-20-2022 13:28:28 GMT -06:00

https://www.coursehero.com/file/178051984/02-134191-077-9557668879-24052022-101712pmdocx/
Powered by TCPDF (www.tcpdf.org)

You might also like