Linear Regression with TensorFlow from Scratch
Create Model from scratch by TensoFlow

Linear Regression with TensorFlow from Scratch

A Linear Regression model’s main aim is to find the best fit linear line and the optimal values of intercept and coefficients such that the error is minimized.

Tensor flow Versions and Differences:

  • TensorFlow defines computations as Graphs, and these are made with operations (also known as “ops”). So, when we work with TensorFlow, it is the same as defining a series of operations in a Graph.
  • Verison one: version one was the running done statically which is mean when the program executed should the graph of the computations done first(the graph defined first) and then passed to a session which is will run or execute, so TensorFlow 'v1' is static not as Kares which is dynamic execution.
  • Version two: it's not dynamic like what you think or expects in your reading in the last point XD ...... it's 'eagerly executing' which is run line by line as dynamic executing.
  • TensorFlow used in deep learning

Steps of creating any machine or deep learning model:

1-Data gathering and importing it in your model

2-Preprocessing your data, cleaning it, extracting new features, normalize

3-Train your model and get your weights

4- Test your model by your unseen data

5- validate it

Loading the data

No alt text provided for this image


DataFrame:

No alt text provided for this image






No alt text provided for this image






Linear regression Steps:

Hypothes

No alt text provided for this image
No alt text provided for this image

  • where bo(technically)?is the intercept, b1(weights)?is coefficient or slope, x(features) is the independent variable, and y(target) is the dependent variable.
  • mostly it's defined randomly normalized

No alt text provided for this image

Loss function:

By achieving the best-fit regression line, the model aims to predict they value such that the error difference between the predicted value and the true value is minimum. So, it is very important to update the θ1?and θ2?values, to reach the best value that minimizes the error between the predicted y value (pred) and the true y value (y).

No alt text provided for this image
No alt text provided for this image

Optimizers:

  • determining the number of epochs
  • the learning_Rate alpha
  • create lists to contain the weights and bias
  • get the gradients of the weights or the partial derivative of it

No alt text provided for this image
No alt text provided for this image

Visualize the losses:

No alt text provided for this image

Visualize all fitted Line:

  • show all the fit lines with green in all epochs and show the last and the most accurate line with black color

No alt text provided for this image


Thank You



ElSayed Mustafa

GM @ NeuroTech | Leading Artificial Intelligence Solutions

3 年

Thanks belal,keep going ??????

Ahmed Mohamed Abdelaziz

Technology development engineer

3 年

??????

要查看或添加评论,请登录

Belal Aboelkher的更多文章

社区洞察

其他会员也浏览了