Hi,
I am trying to practice multi label classification.
for that i have a csv file and train and test folders with images.
Then I do a normal training that works well:
src = (ImageItemList.from_csv(path, 'train.csv', folder='train', suffix='_green.png', test='test')
.random_split_by_pct(0.2)
.label_from_df(sep=' '))
data = (src.transform(tfms, size=128).databunch().normalize(imagenet_stats))
acc_02 = partial(accuracy_thresh, thresh=0.2)
f_score = partial(fbeta, thresh=0.2)
learn = create_cnn(data, arch, metrics=[acc_02, f_score])
Then I do
learn.fit_one_cycle(5, slice(lr))
and then I am trying to predict for my test data:
preds,y,losses = learn.get_preds(ds_type=DatasetType.Test, with_loss=True)
AttributeError Traceback (most recent call last)
in ()
----> 1 preds,y,losses = learn.get_preds(ds_type=DatasetType.Test, with_loss=True)~/anaconda3/lib/python3.6/site-packages/fastai/basic_train.py in get_preds(self, ds_type, with_loss, n_batch, pbar)
210 “Return predictions and targets on the valid, train, or test set, depending onds_type
.”
211 lf = self.loss_func if with_loss else None
→ 212 return get_preds(self.model, self.dl(ds_type), cb_handler=CallbackHandler(self.callbacks),
213 activ=_loss_func2activ(self.loss_func), loss_func=lf, n_batch=n_batch, pbar=pbar)
214~/anaconda3/lib/python3.6/site-packages/fastai/basic_train.py in dl(self, ds_type)
197 def dl(self, ds_type:DatasetType=DatasetType.Valid):
198 “Return DataLoader for DatasetTypeds_type
.”
→ 199 return self.data.dl(ds_type)
200
201 def load(self, name:PathOrStr, device:torch.device=None, strict:bool=True):~/anaconda3/lib/python3.6/site-packages/fastai/data_block.py in getattr(self, k)
339
340 def getattr(self, k):
→ 341 ft = getattr(self.train, k)
342 if not isinstance(ft, Callable): return ft
343 fv = getattr(self.valid, k)~/anaconda3/lib/python3.6/site-packages/fastai/data_block.py in getattr(self, k)
441 def getattr(self,k:str)->Any:
442 res = getattr(self.x, k, None)
→ 443 return res if res is not None else getattr(self.y, k)
444
445 def getitem(self,idxs:Union[int,np.ndarray])->‘LabelList’:AttributeError: ‘MultiCategoryList’ object has no attribute ‘dl’
I’ve search the forum but could not find the reason for that. What I am doing wrong?