Question: Exercise 8 (10 points) - y_hat = + Code + Text # TODO: Calculate the predictions of the model on batch_x y_hat = [] >


![[] > # TODO: Find the mean squared error for y_hat and](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f0beb229186_48966f0beb1c0295.jpg)
Exercise 8 (10 points) - y_hat = + Code + Text # TODO: Calculate the predictions of the model on batch_x y_hat = [] > # TODO: Find the mean squared error for y_hat and batch_y and append the # result to the losses list. loss = # TODO: Update the parameters. weights, biases = ######################################################## losses.append(np.sqrt(loss)) avg_loss.append(np.mean(losses)) y_hat = forward_pass(x_test, weights, biases) val_loss = np.sqrt(mean_squared_error(y_hat, y_test)) val_losses.append(val_loss) print("Epoch %i, Validation loss %f, Training loss %f" %(epoch, val_loss, np.mean(losses ))) plt.plot(val_losses, label = "Validation loss") plt.plot(avg_loss, label = "Training loss") plt.ylabel('Loss') plt.xlabel('Epochs') plt.legendo plt.title("Learning rate =" + str(learning rate) + " Batch size =" + str(batch_size)) plt.show [ ] Weights, biases Let's see how the model is doing by comparing the predictions of the model and the labels for the first 10 data points in the test set. [] forward_pass(x_test[:10), weights, biases) [] y_test[:10] [] Exercise 8 (10 points) - y_hat = + Code + Text # TODO: Calculate the predictions of the model on batch_x y_hat = [] > # TODO: Find the mean squared error for y_hat and batch_y and append the # result to the losses list. loss = # TODO: Update the parameters. weights, biases = ######################################################## losses.append(np.sqrt(loss)) avg_loss.append(np.mean(losses)) y_hat = forward_pass(x_test, weights, biases) val_loss = np.sqrt(mean_squared_error(y_hat, y_test)) val_losses.append(val_loss) print("Epoch %i, Validation loss %f, Training loss %f" %(epoch, val_loss, np.mean(losses ))) plt.plot(val_losses, label = "Validation loss") plt.plot(avg_loss, label = "Training loss") plt.ylabel('Loss') plt.xlabel('Epochs') plt.legendo plt.title("Learning rate =" + str(learning rate) + " Batch size =" + str(batch_size)) plt.show [ ] Weights, biases Let's see how the model is doing by comparing the predictions of the model and the labels for the first 10 data points in the test set. [] forward_pass(x_test[:10), weights, biases) [] y_test[:10] []
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
