Your first step towards deep learning

Image for post

(Source:https://luckyhasae.com/installing-pytorch-anaconda/)

In my previous posts we have gone through

  1. Deep Learning — Artificial Neural Network(ANN)
  2. Tensors — Basics of pytorch programming

Here we will try to solve the classic linear regression problem using pytorch tensors.

1 What is Linear regression ?

y = Ax + B.

A = slope of curve

B = bias (point that intersect y-axis)

y=target variable

x=feature variable

Image for post

Linear regression matrix (Source : https://online.stat.psu.edu/stat462/node/132/)

1.1 Linear regression example 1:

We’ll create a model that predicts crop yields for apples and oranges (target variables) by looking at the average temperature, rainfall and humidity (input variables or features) in a region. Here’s the training data:

Image for post

(Source: https://www.kaggle.com/aakashns/pytorch-basics-linear-regression-from-scratch)

yield_apple = w11 * temp + w12 * rainfall + w13 * humidity + b1

yield_orange = w21 * temp + w22 * rainfall + w23 * humidity + b2

Learning rate of linear regression is to find out these w,b values to make accurate predictions on unseen data. This optimization technique for linear regression is gradient descent which slightly adjusts weights many times to make better predictions.Below is the matrix representation

Image for post

#python #pytorch #linear-regression #neural-networks #deep-learning

Linear Regression with PyTorch
4.95 GEEK