Training Methods

Learn how you can update the implementation of your mini-batch and training loop to make it more flexible.

Updating mini-batch

The next method we need is to add corresponds to the helper function #2 in the chapter, Rethinking the Training Loop: the mini-batch loop. We need to modify it a bit before incorporating it in our StepByStep class.

Inside the previous function, both the data loader and the step function were arguments. However, this is not the case anymore since we have both of them as attributes: self.train_loader and self.train_step for training; self.val_loader and self.val_step for validation. The only thing this method needs to know is if it is handling training or validation data. The updated code should look like this:

Get hands-on with 1400+ tech skills courses.