Not able to use learn.TTA

I would like to now do the test phase of my code.

I tried:

preds = learn.TTA(ds_type=DatasetType.Test)
which gives me:
AttributeError: 'NoneType' object has no attribute 'dataset'

log_preds_test= learn.get_preds(ds_type=DatasetType.Test)
which gives me:
AttributeError: 'NoneType' object has no attribute 'dataset'

preds,y,losses = learn.get_preds(ds_type=DatasetType.Test, with_loss=True)
which gives me:
AttributeError: 'NoneType' object has no attribute 'dataset'

Relevant info

torch.Size([193, 5])

data = ImageDataBunch.from_folder('./tmp',ds_tfms = tfms, test='test', size=sz,bs=bs)

I’m not sure what to do and I exhausted all answers related to the topic.

Hi alx,

preds, y = learn.TTA(ds_type=DatasetType.Test)

----> 1 preds, y = learn.TTA(ds_type=DatasetType.Test)

4 frames
/usr/local/lib/python3.6/dist-packages/fastai/ in set_dl(self, dl)
    254         "Set the current `dl` used."
    255         if hasattr(self, 'cb_dl'): self.callbacks.remove(self.cb_dl)
--> 256         if isinstance(dl.dataset, Callback):
    257             self.callbacks.append(dl.dataset)
    258             self.cb_dl = dl.dataset

AttributeError: 'NoneType' object has no attribute 'dataset'

@ alx, do you have something like this?

@alx, if yes, just write DatasetType.Valid instead of DatasetType.Test.
I think this should work.

1 Like

Amazing, it worked! but does that mean I have an error somewhere and I’m trying to test on the validation set instead of test?

@Neurosci please let me know, its quite urgent

Hey sorry for the late reply, i was in a rush
just do it this way:

data = ImageDataBunch.from_folder(PATH, train=“train”, test=“test”, ds_tfms=get_transforms(), size=112, bs=64, valid_pct=0.90)

It should work
Hope it helps