Normalize is missing in learner.dls.valid.after_batch

I am using fastai 2.2.7

I found that when I initiated a cnn learner with cnn_learner and pretrained=True, validation set’s dataloader is missing Normalize in its after_batch (i.e. learner.dls.valid), while it is present in both learner.dls.after_batch and learner.dls.train.after_batch.

Below is an example:

from import *

path = untar_data(URLs.IMAGENETTE_160)
dls = ImageDataLoaders.from_folder(path, item_tfms=Resize(128),
learn = cnn_learner(dls, resnet18)


I tried the fastai installed in my local laptop and also the fastai in kaggle kernel, they all have the above issue. I recalled I came across a similar discussion on this before, but for some reasons I couldnt find back the thread. How could I resolve this?

I tested the same code in fastai version 2.3.1. The normalize transform is present. May be upgrading will fix the issue.

1 Like

I tried upgrading fastai to 2.3.1, but Normalize is still absent in dls.valid
You can reproduce it in the kernel here:

I am able to see Normalize in both, am I missing something?

Umm its strange, I can see it now :sweat_smile:
probably because I didnt run the session from scratch by the time (I kept uninstall, reinstall, upgrade in the session)
thanks! upgrading to 2.3.1 works :grinning_face_with_smiling_eyes:

additionally would be great if someone could give me a pointer to the fix. I couldnt find out what was breaking the code.

There was some issues with _add_tfms, which got solved in the latest version


Thanks for the update!
With the @BobMcDear 's help, I found the related PR fix: Updated to support adding transforms to multiple dataloaders by marii-moe · Pull Request #3268 · fastai/fastai · GitHub