- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- 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 a sequential model be built on Auto MPG dataset using TensorFlow?

Tensorflow is a machine learning framework that is provided by Google. It is an open−source framework used in conjunction with Python to implement algorithms, deep learning applications and much more. It is used in research and for production purposes.

The ‘tensorflow’ package can be installed on Windows using the below line of code −

pip install tensorflow

Tensor is a data structure used in TensorFlow. It helps connect edges in a flow diagram. This flow diagram is known as the ‘Data flow graph’. Tensors are nothing but multidimensional array or a list. They can be identified using three main attributes −

**Rank**− It tells about the dimensionality of the tensor. It can be understood as the order of the tensor or the number of dimensions in the tensor that has been defined.**Type**− It tells about the data type associated with the elements of the Tensor. It can be a one dimensional, two dimensional or n dimensional tensor.**Shape**− It is the number of rows and columns together.

The aim behind a regression problem is to predict the output of a continuous or discrete variable, such as a price, probability, whether it would rain or not and so on. The dataset we use is called the ‘Auto MPG’ dataset. It contains fuel efficiency of 1970s and 1980s automobiles. It includes attributes like weight, horsepower, displacement, and so on. With this, we need to predict the fuel efficiency of specific vehicles.

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. Following is the code snippet −

## Example

def build_compile_model(norm): model = keras.Sequential([ norm, layers.Dense(64, activation='relu'), layers.Dense(64, activation='relu'), layers.Dense(1) ]) model.compile(loss='mean_absolute_error', optimizer=tf.keras.optimizers.Adam(0.001)) return model print("The model is being built and compiled") dnn_horsepower_model = build_compile_model(horsepower_normalizer) print("The statistical summary is being computed") dnn_horsepower_model.summary()

Code credit − https://www.tensorflow.org/tutorials/keras/regression

## Output

## Explanation

A function named ‘build_compile_model’ is defined that builds a sequential model and generates three dense layers.

The model is compiled and it is returned as output from function.

The statistical analysis of the model is displayed on the console, using the ‘summary’ method.

- Related Questions & Answers
- How can a sequential model be built on Auto MPG using TensorFlow?
- How can a DNN (deep neural network) model be built on Auto MPG dataset using TensorFlow?
- How can predictions be made on Auto MPG dataset using TensorFlow?
- How can model be evaluated based on Auto MPG using TensorFlow?
- How can model be fit to data with Auto MPG dataset using TensorFlow?
- How can a DNN (deep neural network) model be used to predict MPG values on Auto MPG dataset using TensorFlow?
- How can predictions be made about the fuel efficiency with Auto MPG dataset using TensorFlow?
- How can Tensorflow be used with abalone dataset to build a sequential model?
- Explain how a sequential model (Dense Layer) be built in Tensorflow using Python
- How can data be cleaned to predict the fuel efficiency with Auto MPG dataset using TensorFlow?
- How can data be normalized to predict the fuel efficiency with Auto MPG dataset using TensorFlow?
- How can Tensorflow be used to create a sequential model using Python?
- How can data be imported to predict the fuel efficiency with Auto MPG dataset (basic regression) using TensorFlow?
- How can data be split and inspected to predict the fuel efficiency with Auto MPG dataset using TensorFlow?
- How can Tensorflow be used to export the model built using Python?