0% found this document useful (0 votes)
23 views4 pages

TensorFlow Basics - Classifying Images of Clothing

The document summarizes training a neural network model to classify images from the Fashion MNIST dataset. The dataset contains 70,000 grayscale images across 10 categories of clothing items. TensorFlow and Keras are used to build and train a neural network model. The images are preprocessed as 28x28 pixel Numpy arrays and labeled from 0-9. The model architecture is then defined by configuring and compiling the layers before training.

Uploaded by

evans kimathi
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)
23 views4 pages

TensorFlow Basics - Classifying Images of Clothing

The document summarizes training a neural network model to classify images from the Fashion MNIST dataset. The dataset contains 70,000 grayscale images across 10 categories of clothing items. TensorFlow and Keras are used to build and train a neural network model. The images are preprocessed as 28x28 pixel Numpy arrays and labeled from 0-9. The model architecture is then defined by configuring and compiling the layers before training.

Uploaded by

evans kimathi
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/ 4

TensorFlow Basics: Classifying Images of Clothing

March 25, 2020

1 Introduction
We are to train a neural network model to classify images of clothing, like sneakers and shirts.
tf.keras, high-level API to build and train models in Tensorflow

In [1]: from __future__ import absolute_import, division, print_function,unicode_literals

In [2]: # import tensorflow and keras


import tensorflow as tf
from tensorflow import keras

In [3]: #helpter libraries


import numpy as np
import matplotlib.pyplot as plt

In [4]: print(tf.__version__)

2.1.0

2 Import the Fashion MNIST Dataset


It contains 70,000 grayscale images in 10 categories„,

In [5]: fashion_mnist=keras.datasets.fashion_mnist
(train_images, train_labels),(test_images,test_labels)=fashion_mnist.load_data()

In [15]: plt.figure(figsize=(10,10))
for i in range(25):
plt.subplot(5,5,i+1)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.imshow(train_images[i],cmap=plt.cm.binary)
plt.xlabel(train_labels[i])
plt.show()

1
The images are 28x28 Numpy arrays, with pixel values rangng from 0 to 255. The labels are an
array of integers, ranging form 0 to 9.
labels class 0 T-shirt/top 1 trouser 2 pullover . . . 8 Bag 9 Ankle boot

In [17]: class_names=['T-shirt/top','Trouser','Pullover','Dress','Coat','Sandal','Shirt','Sneak

In [18]: class_names

Out[18]: ['T-shirt/top',
'Trouser',
'Pullover',
'Dress',
'Coat',
'Sandal',

2
'Shirt',
'Sneaker',
'Bag',
'Ankle boot']
In [19]: plt.figure(figsize=(10,10))
for i in range(25):
plt.subplot(5,5,i+1)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.imshow(train_images[i],cmap=plt.cm.binary)
plt.xlabel(class_names[train_labels[i]])
plt.show()

3
3 Build the model
Building the neural network requires configuring the layers of the model,then compiling the
model

4 Set-up the Layers


In [ ]:

You might also like