# Simple TensorFlow Model To Predict a Linear Regression

### In this article, we will learn to create a simple TensorFlow model to predict value based on the linear regression equation.

· AI Zone · Code Snippet
Save
4.72K Views

## Introduction

In this article, we will learn to create a simple TensorFlow model to predict value based on the linear regression equation.

### Steps To Build the Model

Let us first generate the data needed for the model, although I am using less data so it won't be much accurate. Below is a screenshot of the snippet to generate data; in order to view the complete code, visit my git repo here.

Now we have generated some data based on the equation `y=mx+c`.

Next, let us create a simple model where we provide `units` and `input_shape` as 1 because we are only providing one number in the input and expecting one number as the output.

Following is the snippet for creating a model:

Now let us predict something new: we have the equation `y=mx+c` where we will have `x= 40`, and we know while generating data, we passed `m=2`, and `c=1`, so as per the equation, the value should be `y =2*40+1=81`

Following is the snippet for the predicted value:

## Conclusion

We have learned the very basic model for predicting Linear regression values.

Topics:
artifical intelligence, machine learning, data science, tensorflow, tensorflow tutorial, linear regression

Opinions expressed by DZone contributors are their own.