Question: Below, we have already initialized the hyper - parameters needed for this experiment. We have also provided several functions which you should fill out. At

Below, we have already initialized the hyper-parameters needed for this experiment. We have also provided several functions which you should fill out. At the bare minimum, you must implement the LMSE loss function (with no regularization, with l1 regularization, with l2 regularization) and the train function. The loss function must return a real-valued loss given data, labels, and parameters, and the training function should use batch SGD to train the model for a given set of epochs, and return the loss accumulated over each epoch.
Please refer to the following formula when implementing the loss function with no regularization, l1 regularization, and l2 regularization respectively.
LMSE with no regularizationLMSE with l1 regularizationLMSE with l2 regularization=12i=1m(yiwxi)2=12i=1m(yiwxi)2+\lambda j=1n|wj|=12i=1m(yiwxi)2+\lambda j=1nw2j
You are welcome to add additional functions as needed, but please make sure to thoroughly comment everything you add. Also do not import any additional functions from other libraries.
[]
DEFAULT_R=1e-3 # fixed
DEFAULT_EPOCHS=10
DEFAULT_LAMBDA=0.1
DEFAULT_BATCH_SIZE=32
NO_REGULARIZATION='no_reg'
L1_LOSS ='l1'
L2_LOSS ='l2'
# Loss function - MODIFY THIS
def loss(X, y, w, regularization_type=NO_REGULARIZATION, lam=DEFAULT_LAMBDA):

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!