Demo code for linear re-gression

Take the demo code for linear regression available at https://github.com/pytorch/examples/blob/master/regression/main.py. This demo implements Stochastic Gradient Descent for estimating the parameters of the linear model. Your task is to familiarize yourself with every step of the code, and understand what it is doing.

(a) Modify the simplistic implementation of Gradient Descent to use SGD class in the torch.optim package (http://pytorch.org/docs/master/optim.html#torch.optim.SGD). Modify the learning rate and comment on its eect.

(b) You are provided with a toy dataset in qn2 data.csv. The data relates to the amount of corn produced (column 3) with respect to the amount of fertilizers and insecticides that are used (column 1 and column 2). Fit a linear regression model on this data, trained with SGD. Report the parameters of the trained model(weights[w1, w2] and the bias). Report the values of the number of corn produced with the following testset:test_set = torch.

Tensor([[6,4],[10,5],[14,8]])Submit your code along with the weight, biases and the predicted values.(c) Implement the least squares solution = (XTX)????1XTy using the same dataset. What are the predictions for the above test set? How do they compare to the predictions of the linear neuron trained with SGD? How do the parameters compare?

We help you get better grades, improve your productivity and get more fun out of college!!

Do my Assignment for me

Day(s)

:

Hour(s)

:

Minute(s)

:

Second(s)

How it works – it’s easy

Y

Place your Order

Submit your requirements through our small easy order form. Be sure to include and attach any relevant materials.

Make a payment

The total price of your order is based on number of pages, academic level and deadline.

i

Writing process

We assign the assignment to the most qualified tutor. When the tutor completes the assignment, it is transferred to one of our professional editors to make sure that the assignment meets all of your requirements.

Once complete, we’ll send your assignment via the email provided on the order form.

 

 

Achieve academic success with the best online tutors.