Hello! I’ve completed rewriting parts of Lesson 4 to create my own Learner class. The link is on GitHub here https://github.com/nalhilal/ml_projects/blob/main/LearnerImplementation/Learner.ipynb
I ran into a few problems along the way, but I think I managed to get it to work, or at least it looks like it works.
I implemented my own validate loss function because I wasn’t sure exactly how to get the loss that prints using the fastai Learner so I made a guess in the function
_log_validation_loss as so: def _log_validation_loss(self, xb, yb, model):
def _log_validation_loss(self, xb, yb, model): preds = model(xb) loss = self.loss_func(preds, yb) self._vloss = round(loss.item(), 4) return self._vloss
The call for the function is run in the training loop in the
for xb, yb in self.valid_dl: self._log_validation_loss(xb, yb, model)
Does this function do what I want it to? Get the loss of the validation set?
I would really appreciate if someone can take a look over the code I posted for any advice. I’m hoping to use this code for the second research question.