Problems in using the new fast.ai library

Hi,

I found this page that contains good ML code and that uses the fastai library.
https://github.com/dzlab/deepprojects/blob/master/timeseries/Timeseries_OliveOil_LSTM_FCN_pytorch.ipynb
But I’m having big problems in converting the usage of the library 0.7 to 0.10
The latest one is related to use the command:
learner.predict(data)

This is the error:


AttributeError Traceback (most recent call last)
in ()
----> 1 learner.predict(data)

/usr/local/lib/python3.6/dist-packages/fastai/basic_train.py in predict(self, img, pbar)
223 “Return prect class, label and probabilities for img.”
224 ds = self.data.single_dl.dataset
–> 225 ds.set_item(img)
226 res = self.pred_batch(ds_type=DatasetType.Single, pbar=pbar)
227 ds.clear_item()

AttributeError: ‘TensorDataset’ object has no attribute ‘set_item’

If I understood correctly, when creating the data and learner:

data = DataBunch(train_dl=train_dl, valid_dl=test_dl, path=path)
learner = Learner(data, model, loss_func=loss_func, metrics=acc_func, wd=0.1)

I should actually create my own dataBunch and implement the set_item. But I cannot find an example in how to do it.

Could you please help me?

Many thanks,
Joao Sauer

2 Likes