Using data augmentation in a callback

Hello everyone,

I’m trying to implement the Mixmatch algorithm ( as a way to familiarize myself with the inner workings of I stumbled upon several questions, the most critical of which is how to call data augmentation methods within a callback.

More specifically, when subclassing the on_batch_begin() method, I use the last_input object, but I am not sure if at this point the data is already augmented.

If I try to dig a bit deeper again, I find it hard to access the tensors that represent the images within the Databunch object.

If anyone has an idea, feel free to share!



I actually just published a blog post on implementing MixMatch in fastai – you can find it here:

As to your specific question, the data is indeed already augmented in the last_input object. I avoid applying augmentation in the callback altogether and instead modify LabelList to augment each image multiple times.