Pankaj Mathur
Published in

Pankaj Mathur

Quick Linear Regression with TensorFlow

A simple linear regression model builds with TensorFlow. We are using fake data and using numpy arrays to supply them to TensorFlow.

Here are the hyperparameters we choose to run initial model:

  • learning_rate = 0.01
  • training_epochs = 1000
  • display_step = 50

We achieved 0.079 training loss cost in 1000 epochs with a learning rate of 0.01 by running simple linear regression model build with Tensorflow on fake data.

Install

I am using Conda to install TensorFlow. You might already have a TensorFlow environment, but please check below to make sure you have all the necessary packages. If you have never used Conda environments before, please go through my other tutorial What is Anaconda and Why should I bother about it?

Assuming you have conda install on your machine, please run the following commands to have tensorflow-playground ready for you to play.

OS X or Linux

Run the following commands to setup your environment:

conda create -n tensorflow-playground python=3.5
source activate tensorflow-playground
conda install pandas matplotlib jupyter notebook scipy scikit-learn
pip install tensorflow

Windows

And installing on Windows. In your console or Anaconda shell:

conda create -n tensorflow-playground python=3.5
activate tensorflow-playground
conda install pandas matplotlib jupyter notebook scipy scikit-learn
pip install tensorflow

After creating conda environment, clone this repository on your local machine via Git or GitHub Desktop

under tensorflow-playground environment on your terminal or shell window, cd to the cloned directory and then run following command:

jupyter notebook

Please do let me know your thoughts, questions under the comments section. I would really appreciate getting some feedback on this article & ideas to improve it.

In the meanwhile, Happy Thinking…

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store