Get startedGet started for free

Evaluating forecasting models

It's evaluation time! The same LSTM network that you have trained in the previous exercise has been trained for you for a few more epochs and is available as net.

Your task is to evaluate it on a test dataset using the Mean Squared Error metric (torchmetrics has already been imported for you). Let's see how well the model is doing!

This exercise is part of the course

Intermediate Deep Learning with PyTorch

View Course

Exercise instructions

  • Define the Mean Squared Error metrics and assign it to mse.
  • Pass the input sequence to net, and squeeze the result before you assign it to outputs.
  • Compute the final value of the test metric assigning it to test_mse.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Define MSE metric
mse = ____

net.eval()
with torch.no_grad():
    for seqs, labels in dataloader_test:
        seqs = seqs.view(32, 96, 1)
        # Pass seqs to net and squeeze the result
        outputs = ____
        mse(outputs, labels)

# Compute final metric value
test_mse = ____
print(f"Test MSE: {test_mse}")
Edit and Run Code