-
Notifications
You must be signed in to change notification settings - Fork 7.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated to support adding transforms to multiple dataloaders #3268
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
So I think we can rewrite and simplify this a bit more: @patch
def _add_tfm(self:DataLoaders, tfms, event, ds_idx):
"Adds `tfms` to `event` on `dl`"
dl_tfms = getattr(self[ds_idx], event)
apply(dl_tfms.add, tfms)
dl_tfms.fs = L(dl_tfms.fs).sorted(key='order') @patch
def add_tfms(self:DataLoaders, tfms, event, ds_idxs=None):
if ds_idxs is None: ds_idxs = range(len(self.loaders))
if not is_listy(ds_idxs): ds_idxs = listify(ds_idxs)
for idx in ds_idxs:
apply(self._add_tfm, tfms, event, idx)
Also we should likely check that Re: my adjustments here, we need that last little line in |
I am reviewing the code with @muellerzr s suggestions. I had forgotten about order and I do agree the code could be better. |
After this I will take a look at |
@jph00 Don't mean to bother you too much, but currently cnn_learner's valid loss and accuracy are incorrect due to this issue. |
Apologies @marii-moe I didn't realize it was ready to merge now. Thanks so much for the code and the ping. |
Fixes the issue here: https://forums.fast.ai/t/performance-degradation-between-fastai-2-2-5-and-2-2-7/86069
We add
add_tfms
in order to support adding the tfms to both dataloaders. Why?Previously dls.train.after_batch.fs == dls.valid.after_batch.fs, so adding a transform to the training dataloader automatically added it to the validation dataloader. Removing that requirement caused validation to break, so adding back that functionality here. (moving my analysis from discord into the forum thread now)