-
-
Save kiransair/c253c3304b7ae21b2e836a034f756087 to your computer and use it in GitHub Desktop.
TF_Forum_16323.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"authorship_tag": "ABX9TyPruzAmO7Aw8jL6U3xdveZa", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/kiransair/c253c3304b7ae21b2e836a034f756087/tf_forum_16323.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"id": "JxULNIKs0DQT" | |
}, | |
"outputs": [], | |
"source": [ | |
"import matplotlib.pyplot as plt\n", | |
"import numpy as np\n", | |
"import PIL\n", | |
"import tensorflow as tf\n", | |
"\n", | |
"from tensorflow import keras\n", | |
"from tensorflow.keras import layers\n", | |
"from tensorflow.keras.models import Sequential" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"import pathlib\n", | |
"dataset_url = \"https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz\"\n", | |
"data_dir = tf.keras.utils.get_file('flower_photos', origin=dataset_url, untar=True)\n", | |
"data_dir = pathlib.Path(data_dir)" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "fPxVlWji0DlH", | |
"outputId": "8f403f9d-7822-4861-ca35-2c6fabd761f8" | |
}, | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Downloading data from https://storage.googleapis.com/download.tensorflow.org/example_images/flower_photos.tgz\n", | |
"228813984/228813984 [==============================] - 2s 0us/step\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"batch_size = 32\n", | |
"img_height = 180\n", | |
"img_width = 180" | |
], | |
"metadata": { | |
"id": "zIOHJXI80FOf" | |
}, | |
"execution_count": 3, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"train_ds = tf.keras.utils.image_dataset_from_directory(\n", | |
" data_dir,\n", | |
" validation_split=0.2,\n", | |
" subset=\"training\",\n", | |
" seed=123,\n", | |
" image_size=(img_height, img_width),\n", | |
" batch_size=batch_size)" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "rxki177w0HZM", | |
"outputId": "ffdb49f8-13ac-425b-93aa-e6d93f84e1dd" | |
}, | |
"execution_count": 4, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Found 3670 files belonging to 5 classes.\n", | |
"Using 2936 files for training.\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"for x,y in train_ds:\n", | |
" print(x.shape)\n", | |
" print(y.shape)\n" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "IIfiY-aX0I8-", | |
"outputId": "6d339c10-d587-4cac-e103-609dd01cc1bd" | |
}, | |
"execution_count": 5, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(32, 180, 180, 3)\n", | |
"(32,)\n", | |
"(24, 180, 180, 3)\n", | |
"(24,)\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [], | |
"metadata": { | |
"id": "flQyeGKP0Lfq" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment