when I runlearn.get_preds(ds_type=DatasetType.Test, with_loss=True)
I get an IndexError
IndexError Traceback (most recent call last)
in
----> 1 learn.get_preds(ds_type=DatasetType.Test, with_loss=True)
/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/basic_train.py in get_preds(self, ds_type, activ, with_loss, n_batch, pbar)
337 callbacks = [cb(self) for cb in self.callback_fns + listify(defaults.extra_callback_fns)] + listify(self.callbacks)
338 return get_preds(self.model, self.dl(ds_type), cb_handler=CallbackHandler(callbacks),
--> 339 activ=activ, loss_func=lf, n_batch=n_batch, pbar=pbar)
340
341 def pred_batch(self, ds_type:DatasetType=DatasetType.Valid, batch:Tuple=None, reconstruct:bool=False,
/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/basic_train.py in get_preds(model, dl, pbar, cb_handler, activ, loss_func, n_batch)
42 "Tuple of predictions and targets, and optional losses (if `loss_func`) using `dl`, max batches `n_batch`."
43 res = [to_float(torch.cat(o).cpu()) for o in
---> 44 zip(*validate(model, dl, cb_handler=cb_handler, pbar=pbar, average=False, n_batch=n_batch))]
45 if loss_func is not None:
46 with NoneReduceOnCPU(loss_func) as lf: res.append(lf(res[0], res[1]))
/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/basic_train.py in validate(model, dl, loss_func, cb_handler, pbar, average, n_batch)
55 val_losses,nums = [],[]
56 if cb_handler: cb_handler.set_dl(dl)
---> 57 for xb,yb in progress_bar(dl, parent=pbar, leave=(pbar is not None)):
58 if cb_handler: xb, yb = cb_handler.on_batch_begin(xb, yb, train=False)
59 val_loss = loss_batch(model, xb, yb, loss_func, cb_handler=cb_handler)
/opt/conda/envs/fastai/lib/python3.6/site-packages/fastprogress/fastprogress.py in __iter__(self)
70 self.update(0)
71 try:
---> 72 for i,o in enumerate(self._gen):
73 if i >= self.total: break
74 yield o
/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/basic_data.py in __iter__(self)
73 def __iter__(self):
74 "Process and returns items from `DataLoader`."
---> 75 for b in self.dl: yield self.proc_batch(b)
76
77 @classmethod
/opt/conda/envs/fastai/lib/python3.6/site-packages/torch/utils/data/dataloader.py in __next__(self)
817 else:
818 del self.task_info[idx]
--> 819 return self._process_data(data)
820
821 next = __next__ # Python 2 compatibility
/opt/conda/envs/fastai/lib/python3.6/site-packages/torch/utils/data/dataloader.py in _process_data(self, data)
844 self._try_put_index()
845 if isinstance(data, ExceptionWrapper):
--> 846 data.reraise()
847 return data
848
/opt/conda/envs/fastai/lib/python3.6/site-packages/torch/_utils.py in reraise(self)
367 # (https://bugs.python.org/issue2651), so we work around it.
368 msg = KeyErrorMessage(msg)
--> 369 raise self.exc_type(msg)
IndexError: Caught IndexError in DataLoader worker process 0.
Original Traceback (most recent call last):
File "/opt/conda/envs/fastai/lib/python3.6/site-packages/torch/utils/data/_utils/worker.py", line 178, in _worker_loop
data = fetcher.fetch(index)
File "/opt/conda/envs/fastai/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/opt/conda/envs/fastai/lib/python3.6/site-packages/torch/utils/data/_utils/fetch.py", line 44, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/data_block.py", line 651, in __getitem__
if self.item is None: x,y = self.x[idxs],self.y[idxs]
File "/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/data_block.py", line 120, in __getitem__
if isinstance(idxs, Integral): return self.get(idxs)
File "/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/vision/data.py", line 270, in get
fn = super().get(i)
File "/opt/conda/envs/fastai/lib/python3.6/site-packages/fastai/data_block.py", line 75, in get
return self.items[i]
IndexError: index 0 is out of bounds for axis 0 with size 0