I loaded two learners saved by export function
learn_fwd = load_learner(path + '/fwd_learn_c')
learn_bwd = load_learner(path + '/bwd_learn_c')
When I tried to call predict on them
pred_fwd,lbl_fwd = learn_fwd.get_preds(ordered=True)
I recieve the following error:
IndexError Traceback (most recent call last)
in
----> 1 pred_fwd,lbl_fwd = learn_fwd.get_preds(ordered=True)
~/miniconda3/lib/python3.7/site-packages/fastai/text/learner.py in get_preds(self, ds_type, activ, with_loss, n_batch, pbar, ordered)
88 self.model.reset()
89 if ordered: np.random.seed(42)
—> 90 preds = super().get_preds(ds_type=ds_type, activ=activ, with_loss=with_loss, n_batch=n_batch, pbar=pbar)
91 if ordered and hasattr(self.dl(ds_type), ‘sampler’):
92 np.random.seed(42)
~/miniconda3/lib/python3.7/site-packages/fastai/basic_train.py in get_preds(self, ds_type, activ, with_loss, n_batch, pbar)
339 callbacks = [cb(self) for cb in self.callback_fns + listify(defaults.extra_callback_fns)] + listify(self.callbacks)
340 return get_preds(self.model, self.dl(ds_type), cb_handler=CallbackHandler(callbacks),
–> 341 activ=activ, loss_func=lf, n_batch=n_batch, pbar=pbar)
342
343 def pred_batch(self, ds_type:DatasetType=DatasetType.Valid, batch:Tuple=None, reconstruct:bool=False,
~/miniconda3/lib/python3.7/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]))
~/miniconda3/lib/python3.7/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)
~/miniconda3/lib/python3.7/site-packages/fastprogress/fastprogress.py in iter(self)
45 except Exception as e:
46 self.on_interrupt()
—> 47 raise e
48
49 def update(self, val):
~/miniconda3/lib/python3.7/site-packages/fastprogress/fastprogress.py in iter(self)
39 if self.total != 0: self.update(0)
40 try:
—> 41 for i,o in enumerate(self.gen):
42 if i >= self.total: break
43 yield o
~/miniconda3/lib/python3.7/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
~/miniconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py in iter(self)
277 return _SingleProcessDataLoaderIter(self)
278 else:
–> 279 return _MultiProcessingDataLoaderIter(self)
280
281 @property
~/miniconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py in init(self, loader)
744 # prime the prefetch loop
745 for _ in range(2 * self._num_workers):
–> 746 self._try_put_index()
747
748 def _try_get_data(self, timeout=_utils.MP_STATUS_CHECK_INTERVAL):
~/miniconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py in _try_put_index(self)
859 assert self._tasks_outstanding < 2 * self._num_workers
860 try:
–> 861 index = self._next_index()
862 except StopIteration:
863 return
~/miniconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py in _next_index(self)
337
338 def _next_index(self):
–> 339 return next(self._sampler_iter) # may raise StopIteration
340
341 def _next_data(self):
~/miniconda3/lib/python3.7/site-packages/torch/utils/data/sampler.py in iter(self)
198 def iter(self):
199 batch = []
–> 200 for idx in self.sampler:
201 batch.append(idx)
202 if len(batch) == self.batch_size:
~/miniconda3/lib/python3.7/site-packages/fastai/text/data.py in iter(self)
103 def len(self) -> int: return len(self.data_source)
104 def iter(self):
–> 105 return iter(sorted(range_of(self.data_source), key=self.key, reverse=True))
106
107 class SortishSampler(Sampler):
IndexError: list index out of range