
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How can Tensorflow be used to configure the flower dataset for performance?
The flower dataset would have given a certain percentage of accuracy when a model is created. If it is required to configure the model for performance, a function is defined that performs the buffer prefetch for the second time, and then it is shuffled. This function is called on the training dataset to improve the performance of the model.
Read More: What is TensorFlow and how Keras work with TensorFlow to create Neural Networks?
We will be using the flowers dataset, which contains images of several thousands of flowers. It contains 5 sub-directories, and there is one sub-directory for every class.
We are using the Google Colaboratory to run the below code. Google Colab or Colaboratory helps run Python code over the browser and requires zero configuration and free access to GPUs (Graphical Processing Units). Colaboratory has been built on top of Jupyter Notebook.
print("A function is defined that configures the dataset for perfromance") def configure_for_performance(ds): ds = ds.cache() ds = ds.shuffle(buffer_size=1000) ds = ds.batch(batch_size) ds = ds.prefetch(buffer_size=AUTOTUNE) return ds print("The function is called on training dataset") train_ds = configure_for_performance(train_ds) print("The function is called on validation dataset") val_ds = configure_for_performance(val_ds)
Code credit: https://www.tensorflow.org/tutorials/load_data/images
Output
A function is defined that configures the dataset for perfromance The function is called on training dataset The function is called on validation dataset
Explanation
- A model needs to be trained with the dataset.
- The model is first well shuffled, then batched, and then these batches are made available.
- These features are added using the 'tf.data' API.
- Related Articles
- How can Tensorflow configure the flower dataset for performance?
- How can Tensorflow be used to configure the dataset for performance?
- How can Tensorflow and pre-trained model be used to configure the dataset for performance?
- How can Tensorflow be used to standardize the flower dataset?
- How can TensorFlow be used to configure the IMDB dataset to give good performance and create a model?
- How can Tensorflow be used to download flower dataset into the environment?
- How can Tensorflow be used to visualize the flower dataset using Python?
- How can Tensorflow be used to pre-process the flower training dataset?
- How can Tensorflow be used to configure the stackoverflow question dataset using Python?
- How can Tensorflow be used with flower dataset to continue training the model?
- How can Tensorflow be used to load the flower dataset and work with it?
- How can Tensorflow be used to download the flower dataset using keras sequential API?
- How can Tensorflow be used to explore the flower dataset using keras sequential API?
- How can Tensorflow be used to split the flower dataset into training and validation?
- How can Tensorflow be used to create a pair using a file path for the flower dataset?
