- 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 Estimators to return a two element tuple?

A two-element tuple can be returned by processing iris flower dataset by creating a method that takes the features and labels, and returns them as Numpy arrays.

**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.

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

## Example

print("Function that returns a two-element tuple") def input_evaluation_set(): features = {'SepalLength': np.array([6.4, 5.0]), 'SepalWidth': np.array([2.8, 2.3]), 'PetalLength': np.array([5.6, 3.3]), 'PetalWidth': np.array([2.2, 1.0])} labels = np.array([2, 1]) return features, labels

Code credit −https://www.tensorflow.org/tutorials/estimator/premade#first_things_first

## Output

Function that returns a two-element tuple

## Explanation

Once the data is set up, the model can be defined using Tensorflow estimator.

An Estimator is any class derived from tf.estimator.Estimator

One or more input functions are created.

The model's feature columns are defined.

An Estimator is instantiated, where the feature columns and various hyperparameters are specified.

One or more methods on the Estimator object is called, and appropriate inout function is passed as source.

- Related Articles
- How can Tensorflow be used with Estimators to perform data transformation?
- How can Tensorflow be used with Estimators to optimize the model?
- How can Tensorflow be used with Estimators to split the iris dataset?
- How can Tensorflow be used with Estimators to explore the titanic data?
- How can Tensorflow be used with estimators to visualize the titanic data?
- How can Tensorflow be used with Estimators to define a function that shuffles data?
- How can Tensorflow be used with Estimators to evaluate the model using Python?
- How can Tensorflow be used with Estimators to display metadata about the dataset?
- How can Tensorflow be used with Estimators for feature engineering the model?
- How can Tensorflow be used with Estimators to add a column to the titanic dataset?
- How can Tensorflow be used with Estimators to inspect a specific column of titanic dataset?
- How can Tensorflow be used with Estimators to inspect the titanic dataset using Python?
- How can Tensorflow be used with Estimators to train the model for titanic dataset?
- How can Tensorflow be used with Estimators to create feature columns and input functions?
- How can Tensorflow be used with Estimators to visualize the data, and the ROC curve?