- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can Tensorflow be used with premade estimator to download the Iris dataset?
Tensorflow can be used with premade estimator to download the iris dataset using the ‘get_file’ method present in Keras package. A Google API holds the iris dataset, which can be passed as parameter to the ‘get_file’ method.
Read More: What is TensorFlow and how Keras work with TensorFlow to create Neural Networks?
We will use the Keras Sequential API, which is helpful in building a sequential model that is used to work with a plain stack of layers, where every layer has exactly one input tensor and one output tensor.
A neural network that contains at least one layer is known as a convolutional layer. We can use the Convolutional Neural Network to build learning model.
TensorFlow Text contains collection of text related classes and ops that can be used with TensorFlow 2.0. The TensorFlow Text can be used to preprocess sequence modelling.
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.
Let us understand how Estimators can be used.
An Estimator is TensorFlow's high-level representation of a complete model. It is designed for easy scaling and asynchronous training.
The model is trained using iris data set. There are 4 features, and one label.
- sepal length
- sepal width
- petal length
- petal width
Based on this information, some constants can be defined that help in parsing data.
Example
import tensorflow as tf import pandas as pd print("Column names defined") CSV_COLUMN_NAMES = ['SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth', 'Species'] SPECIES = ['Setosa', 'Versicolor', 'Virginica'] print("Iris training data is being downloaded") train_path = tf.keras.utils.get_file( "iris_training.csv", "https://storage.googleapis.com/download.tensorflow.org/data/iris_training.csv") print("Iris test data is being downloaded") test_path = tf.keras.utils.get_file( "iris_test.csv", "https://storage.googleapis.com/download.tensorflow.org/data/iris_test.csv") train = pd.read_csv(train_path, names=CSV_COLUMN_NAMES, header=0) test = pd.read_csv(test_path, names=CSV_COLUMN_NAMES, header=0) print("Sample data is being displayed") train.head()
Code credit −https://www.tensorflow.org/tutorials/estimator/premade#first_things_first
Output
Column names defined Iris training data is being downloaded Downloading data from https://storage.googleapis.com/download.tensorflow.org/data/iris_training.csv 8192/2194 [================================================================================================================] - 0s 0us/step Iris test data is being downloaded Downloading data from https://storage.googleapis.com/download.tensorflow.org/data/iris_test.csv 8192/573 [============================================================================================================================================================================================================================================================================================================================================================================================================================================] - 0s 0us/step Sample data is being displayed SepalLength SepalWidth PetalLength PetalWidth Species 0 6.4 2.8 5.6 2.2 2 1 5.0 2.3 3.3 1.0 1 2 4.9 2.5 4.5 1.7 2 3 4.9 3.1 1.5 0.1 0 4 5.7 3.8 1.7 0.3 0
Explanation
- Column names are defined.
- The data is downloaded.
- Some sample data is displayed on the console.
- Related Articles
- How can Tensorflow be used with Estimators to split the iris dataset?
- How can Tensorflow be used to download flower dataset into the environment?
- How can Tensorflow and Estimator be used to find the ROC curve on titanic dataset?
- How can Tensorflow be used to download and explore IMDB dataset in Python?
- How can Tensorflow and Python be used to download and prepare the CIFAR dataset?
- How can Tensorflow be used to download the flower dataset using keras sequential API?
- How can Tensorflow be used to download and explore the Illiad dataset using Python?
- How can Tensorflow be used with Estimator to transform the feature column?
- How can TensorFlow be used to download and explore the Fashion MNIST dataset using Python?
- How can Tensorflow be used with Estimator to compile the model using Python?
- How can Tensorflow be used with Estimator to predict the output using Python?
- How can Tensorflow and Estimator be used to define input function for training and evaluation of dataset?
- How can Tensorflow be used with Estimator to make predictions from trained model?
- How can Tensorflow be used to instantiate an estimator using Python?
- How can Tensorflow be used to standardize the flower dataset?
