0% found this document useful (0 votes)
55 views

Ai Lab 9

This document provides instructions for an AI lab exercise on building and evaluating a neural network model for fashion MNIST image classification. Students are asked to download the fashion MNIST dataset, preprocess the data, build a sequential model with input, hidden and output layers, compile the model using Adam optimizer and categorical crossentropy loss, train the model for 10 epochs, and evaluate the test accuracy. The code provided loads the data, normalizes it, defines the sequential model with Flatten, Dense and softmax layers, compiles and fits the model, and prints the test accuracy.

Uploaded by

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

Ai Lab 9

This document provides instructions for an AI lab exercise on building and evaluating a neural network model for fashion MNIST image classification. Students are asked to download the fashion MNIST dataset, preprocess the data, build a sequential model with input, hidden and output layers, compile the model using Adam optimizer and categorical crossentropy loss, train the model for 10 epochs, and evaluate the test accuracy. The code provided loads the data, normalizes it, defines the sequential model with Flatten, Dense and softmax layers, compiles and fits the model, and prints the test accuracy.

Uploaded by

Ali Rajpoot
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy