1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Deep Learning with PyTorch

Exercise

RNN training loop

It's time to train the electricity consumption forecasting model!

You will use the LSTM network you have defined previously which is available to you as Net, as is the dataloader_train you built before. You will also need to use torch.nn which has already been imported as nn.

In this exercise, you will train the model for only three epochs to make sure the training progresses as expected. Let's get to it!

Instructions

100 XP
  • Set up the Mean Squared Error loss and assign it to criterion.
  • Reshape seqs to (batch size, sequence length, num features), which in our case is (16, 96, 1), and re-assign the result to seqs.
  • Pass seqs to the model to get its outputs.
  • Based on previously computed quantities, calculate the loss, assigning it to loss.