{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "15b270f5",
   "metadata": {},
   "outputs": [
    {
     "ename": "ModuleNotFoundError",
     "evalue": "No module named 'tensorflow'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mModuleNotFoundError\u001b[0m                       Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[1], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mtensorflow\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mkeras\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mdatasets\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m fashion_mnist\n\u001b[0;32m      2\u001b[0m \u001b[38;5;66;03m# Load the Fashion MNIST dataset\u001b[39;00m\n\u001b[0;32m      3\u001b[0m (x_train, y_train), (x_test, y_test) \u001b[38;5;241m=\u001b[39m fashion_mnist\u001b[38;5;241m.\u001b[39mload_data()\n",
      "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'tensorflow'"
     ]
    }
   ],
   "source": [
    "from tensorflow.keras.datasets import fashion_mnist\n",
    "# Load the Fashion MNIST dataset\n",
    "(x_train, y_train), (x_test, y_test) = fashion_mnist.load_data()\n",
    "print(\"Training data shape:\", x_train.shape)\n",
    "print(\"Training labels shape\",y_train.shape)\n",
    "print(\"Testing data shape:\", x_test.shape)\n",
    "print(\"Testing labels shape:\", y_test.shape)\n",
    "#This script uses the mnist.load_data() function from the tensorflow.keras.datasets to load the mnist dataset.\n",
    "#It then assigns the training and testing data to variables x_train y_train and x_test and y_test\n",
    "#finally it displays the shapes of the training and testing data and labels using shape.\n",
    "#Output the data\n",
    "\n",
    "(x_train, y_train), (x_test, y_test) = fashion_mnist.load_data()\n",
    "import matplotlib.pyplot as plt\n",
    "for i in range(10):\n",
    "    plt.imshow(x_train[i],cmap='gray')\n",
    "    plt.title(f\"Label:{y_train[i]}\")\n",
    "    plt.show()\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "print(\"Fashion MNIST Dataser Description:\")\n",
    "print(f\"Number of training samples:{len(x_train)}\")\n",
    "print(f\"Number of testing samples:{len(x_test)}\")\n",
    "print(f\"Shape of it image:{x_train[0].shape}\")\n",
    "print(f\"Number of Classes:{len(set(y_train))}\")\n",
    "\n",
    "#Show a sample of the data\n",
    "print(\"\\nSample Images\")\n",
    "sample_images = x_train[:5]\n",
    "sample_labels = y_train[:5]\n",
    "\n",
    "for i,image in enumerate(sample_images):\n",
    "    plt.subplot(1,5, i+1)\n",
    "    plt.imshow(image, cmap='gray')\n",
    "    plt.title(f\"Label:{sample_labels[i]}\")\n",
    "    plt.axis('off')\n",
    "plt.tight_layout()\n",
    "plt.show()\n",
    "\n",
    "#output 20 rows of image\n",
    "num_rows = 20\n",
    "num_cols = 10\n",
    "fig, axes = plt.subplots(num_rows,num_cols, figsize=(num_cols, num_rows))\n",
    "\n",
    "for row in range(num_rows):\n",
    "    for col in range(num_cols):\n",
    "        axes[row, col].imshow(x_train[row*num_cols + col],cmap='pink')\n",
    "        axes[row, col].axis('off')\n",
    "             \n",
    "plt.tight_layout()\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "16d5109b",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "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.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
