{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8f9f0e7b",
   "metadata": {},
   "source": [
    "Display fashion_mnist dataset of clothes from Zalando"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cc829d9a",
   "metadata": {},
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "from tensorflow import keras\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "63348efe",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Load the MNIST Fashion dataset\n",
    "(x_train, y_train), (x_test, y_test) = keras.datasets.fashion_mnist.load_data()\n",
    "# Set the class names\n",
    "class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', \n",
    "               'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot']\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a6c86027",
   "metadata": {},
   "outputs": [],
   "source": [
    "# print the shape of the numpy arrays\n",
    "print ('Print shape of pixel data')\n",
    "print(x_train.shape)\n",
    "print ('Print shape of labels')\n",
    "print(y_train.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cc58b142",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Normalize pixel values to between 0 and 1\n",
    "x_train = x_train.astype(\"float32\") / 255.0\n",
    "x_test = x_test.astype(\"float32\") / 255.0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c7976111",
   "metadata": {},
   "outputs": [],
   "source": [
    "# choose an image num  to print\n",
    "num = 20\n",
    "image = x_train[num]\n",
    "label = y_train[num]\n",
    "\n",
    "print ('Print normailzed pixel data of image ',num, ' :')\n",
    "print(x_train[num])\n",
    "print ('Print label of image ',num ,  ' :' )\n",
    "print(y_train[num])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "64a46625",
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.figure(figsize=(10,10))\n",
    "for i in range(25):\n",
    "    plt.subplot(5,5,i+1)\n",
    "    plt.xticks([])\n",
    "    plt.yticks([])\n",
    "    plt.grid(False)\n",
    "    plt.imshow(x_train[i], cmap=plt.cm.binary)\n",
    "    plt.xlabel(class_names[y_train[i]])\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
