How item_tfms and batch_tfms modify underlying Data Structure?

Hi all,
This is something I’ve been failing to understand for a while. I’m on Chapter 2 of the book and following the course along, but one thing I can’t wrap my head around is when we call an item_tfms like RandomResizedCrop or a batch_tfms like aug_transforms they are supposed to produce multiple variations of a single training image. What I dont understand is how the underlying structure works, like does it create multiple copies of the the same image with these transforms applied and stores them in memory or is it something else? I understand how a transform like Resize will change each image, but don’t understand how these transforms that are supposed to modify an image into its multiple variations work, as in where are these modified images stored? Or if one is randomly selected upon each epoch?

Extremely sorry if its a really naive question and something that’s been explained already, I just cannot wrap my head around it.
Thanks.

Yes, randomly selected each time, then copied into GPU (if used)

1 Like

Thanks for the reply. But does it also apply to btach_tfms=aug_transform, correct me if I’m wrong, but aren’t they all supposed to be applied? Randomly selectling some does not gurantee it.

Yes, and sorry for the need for clarification : both item and batch transforms are always applied, but some transforms have a random factor, e.g. RandomCrop(). The random or probability factor ensures that the outcome is different each time when serving as input for a training step

1 Like

That’s not accurate. Some transforms, like image resizing and normalization, are always applied, but the rest have an argument p which controls the probability that they are applied.

And to add to that, those batch transforms with randomness are generally not applied to the validation set. The only exception to this rule is if it resizes or normalizes. Resize will always center crop and normalize needs to always happen

1 Like