Trouble with Interpretation.from_learner on win10

I’m having trouble with the Interpretation.from_learner on my win10 machine.

When I try to call interp = ClassificationInterpretation.from_learner(learn) on a text learner I created, I get the following massive error:

RuntimeError Traceback (most recent call last)
c:\users\jasko\environments\first\lib\site-packages\fastai\torch_core.py in to_concat(xs, dim)
270 # in this case we return a big list
–> 271 try: return retain_type(torch.cat(xs, dim=dim), xs[0])
272 except: return sum([L(retain_type(o_.index_select(dim, tensor(i)).squeeze(dim), xs[0])

c:\users\jasko\environments\first\lib\site-packages\fastai\torch_core.py in torch_function(self, func, types, args, kwargs)
324 if _torch_handled(args, self._opt, func): convert,types = type(self),(torch.Tensor,)
–> 325 res = super().torch_function(func, types, args=args, kwargs=kwargs)
326 if convert: res = convert(res)

c:\users\jasko\environments\first\lib\site-packages\torch\tensor.py in torch_function(cls, func, types, args, kwargs)
994 with _C.DisableTorchFunction():
–> 995 ret = func(*args, **kwargs)
996 return _convert(ret, cls)

RuntimeError: Sizes of tensors must match except in dimension 0. Got 1038 and 686 in dimension 1 (The offending index is 1)

During handling of the above exception, another exception occurred:

RuntimeError Traceback (most recent call last)
in
----> 1 interp = ClassificationInterpretation.from_learner(learn)
2 interp.plot_confusion_matrix()

c:\users\jasko\environments\first\lib\site-packages\fastai\interpret.py in from_learner(cls, learn, ds_idx, dl, act)
27 “Construct interpretation object from a learner”
28 if dl is None: dl = learn.dls[ds_idx]
—> 29 return cls(dl, *learn.get_preds(dl=dl, with_input=True, with_loss=True, with_decoded=True, act=None))
30
31 def top_losses(self, k=None, largest=True):

c:\users\jasko\environments\first\lib\site-packages\fastai\learner.py in get_preds(self, ds_idx, dl, with_input, with_decoded, with_loss, act, inner, reorder, cbs, **kwargs)
241 if with_loss: ctx_mgrs.append(self.loss_not_reduced())
242 with ContextManagers(ctx_mgrs):
–> 243 self._do_epoch_validate(dl=dl)
244 if act is None: act = getattr(self.loss_func, ‘activation’, noop)
245 res = cb.all_tensors()

c:\users\jasko\environments\first\lib\site-packages\fastai\learner.py in _do_epoch_validate(self, ds_idx, dl)
191 if dl is None: dl = self.dls[ds_idx]
192 self.dl = dl
–> 193 with torch.no_grad(): self._with_events(self.all_batches, ‘validate’, CancelValidException)
194
195 def _do_epoch(self):

c:\users\jasko\environments\first\lib\site-packages\fastai\learner.py in with_events(self, f, event_type, ex, final)
160 try: self(f’before
{event_type}’); f()
161 except ex: self(f’after_cancel_{event_type}’)
–> 162 self(f’after_{event_type}’); final()
163
164 def all_batches(self):

c:\users\jasko\environments\first\lib\site-packages\fastai\learner.py in call(self, event_name)
139
140 def ordered_cbs(self, event): return [cb for cb in self.cbs.sorted(‘order’) if hasattr(cb, event)]
–> 141 def call(self, event_name): L(event_name).map(self._call_one)
142
143 def _call_one(self, event_name):

c:\users\jasko\environments\first\lib\site-packages\fastcore\foundation.py in map(self, f, gen, *args, **kwargs)
152 def range(cls, a, b=None, step=None): return cls(range_of(a, b=b, step=step))
153
–> 154 def map(self, f, *args, gen=False, **kwargs): return self._new(map_ex(self, f, *args, gen=gen, **kwargs))
155 def argwhere(self, f, negate=False, **kwargs): return self._new(argwhere(self, f, negate, **kwargs))
156 def filter(self, f=noop, negate=False, gen=False, **kwargs):

c:\users\jasko\environments\first\lib\site-packages\fastcore\basics.py in map_ex(iterable, f, gen, *args, **kwargs)
664 res = map(g, iterable)
665 if gen: return res
–> 666 return list(res)
667
668 # Cell

c:\users\jasko\environments\first\lib\site-packages\fastcore\basics.py in call(self, *args, **kwargs)
649 if isinstance(v,_Arg): kwargs[k] = args.pop(v.i)
650 fargs = [args[x.i] if isinstance(x, _Arg) else x for x in self.pargs] + args[self.maxi+1:]
–> 651 return self.func(*fargs, **kwargs)
652
653 # Cell

c:\users\jasko\environments\first\lib\site-packages\fastai\learner.py in _call_one(self, event_name)
143 def _call_one(self, event_name):
144 if not hasattr(event, event_name): raise Exception(f’missing {event_name}’)
–> 145 for cb in self.cbs.sorted(‘order’): cb(event_name)
146
147 def _bn_bias_state(self, with_bias): return norm_bias_params(self.model, with_bias).map(self.opt.state)

c:\users\jasko\environments\first\lib\site-packages\fastai\callback\core.py in call(self, event_name)
42 (self.run_valid and not getattr(self, ‘training’, False)))
43 res = None
—> 44 if self.run and _run: res = getattr(self, event_name, noop)()
45 if event_name==‘after_fit’: self.run=True #Reset self.run to True at each end of fit
46 return res

c:\users\jasko\environments\first\lib\site-packages\fastai\callback\core.py in after_validate(self)
132 “Concatenate all recorded tensors”
133 if not hasattr(self, ‘preds’): return
–> 134 if self.with_input: self.inputs = detuplify(to_concat(self.inputs, dim=self.concat_dim))
135 if not self.save_preds: self.preds = detuplify(to_concat(self.preds, dim=self.concat_dim))
136 if not self.save_targs: self.targets = detuplify(to_concat(self.targets, dim=self.concat_dim))

c:\users\jasko\environments\first\lib\site-packages\fastai\torch_core.py in to_concat(xs, dim)
265 “Concat the element in xs (recursively if they are tuples/lists of tensors)”
266 if not xs: return xs
–> 267 if is_listy(xs[0]): return type(xs[0])([to_concat([x[i] for x in xs], dim=dim) for i in range_of(xs[0])])
268 if isinstance(xs[0],dict): return {k: to_concat([x[k] for x in xs], dim=dim) for k in xs[0].keys()}
269 #We may receive xs that are not concatenable (inputs of a text classifier for instance),

c:\users\jasko\environments\first\lib\site-packages\fastai\torch_core.py in (.0)
265 “Concat the element in xs (recursively if they are tuples/lists of tensors)”
266 if not xs: return xs
–> 267 if is_listy(xs[0]): return type(xs[0])([to_concat([x[i] for x in xs], dim=dim) for i in range_of(xs[0])])
268 if isinstance(xs[0],dict): return {k: to_concat([x[k] for x in xs], dim=dim) for k in xs[0].keys()}
269 #We may receive xs that are not concatenable (inputs of a text classifier for instance),

c:\users\jasko\environments\first\lib\site-packages\fastai\torch_core.py in to_concat(xs, dim)
270 # in this case we return a big list
271 try: return retain_type(torch.cat(xs, dim=dim), xs[0])
–> 272 except: return sum([L(retain_type(o_.index_select(dim, tensor(i)).squeeze(dim), xs[0])
273 for i in range_of(o_)) for o_ in xs], L())
274

c:\users\jasko\environments\first\lib\site-packages\fastai\torch_core.py in (.0)
270 # in this case we return a big list
271 try: return retain_type(torch.cat(xs, dim=dim), xs[0])
–> 272 except: return sum([L(retain_type(o_.index_select(dim, tensor(i)).squeeze(dim), xs[0])
273 for i in range_of(o_)) for o_ in xs], L())
274

c:\users\jasko\environments\first\lib\site-packages\fastcore\foundation.py in call(cls, x, *args, **kwargs)
95 def call(cls, x=None, *args, **kwargs):
96 if not args and not kwargs and x is not None and isinstance(x,cls): return x
—> 97 return super().call(x, *args, **kwargs)
98
99 # Cell

c:\users\jasko\environments\first\lib\site-packages\fastcore\foundation.py in init(self, items, use_list, match, *rest)
103 def init(self, items=None, *rest, use_list=False, match=None):
104 if (use_list is not None) or not is_array(items):
–> 105 items = listify(items, *rest, use_list=use_list, match=match)
106 super().init(items)
107

c:\users\jasko\environments\first\lib\site-packages\fastcore\basics.py in listify(o, use_list, match, *rest)
54 elif isinstance(o, list): res = o
55 elif isinstance(o, str) or is_array(o): res = [o]
—> 56 elif is_iter(o): res = list(o)
57 else: res = [o]
58 if match is not None:

c:\users\jasko\environments\first\lib\site-packages\fastai\torch_core.py in (.0)
270 # in this case we return a big list
271 try: return retain_type(torch.cat(xs, dim=dim), xs[0])
–> 272 except: return sum([L(retain_type(o_.index_select(dim, tensor(i)).squeeze(dim), xs[0])
273 for i in range_of(o_)) for o_ in xs], L())
274

c:\users\jasko\environments\first\lib\site-packages\fastai\torch_core.py in torch_function(self, func, types, args, kwargs)
323 convert=False
324 if _torch_handled(args, self._opt, func): convert,types = type(self),(torch.Tensor,)
–> 325 res = super().torch_function(func, types, args=args, kwargs=kwargs)
326 if convert: res = convert(res)
327 if isinstance(res, TensorBase): res.set_meta(self, as_copy=True)

c:\users\jasko\environments\first\lib\site-packages\torch\tensor.py in torch_function(cls, func, types, args, kwargs)
993
994 with _C.DisableTorchFunction():
–> 995 ret = func(*args, **kwargs)
996 return _convert(ret, cls)
997

RuntimeError: index_select(): Expected dtype int64 for index

I think the offending line is this:

RuntimeError: Sizes of tensors must match except in dimension 0. Got 1038 and 686 in dimension 1 (The offending index is 1)

But I don’t know how to troubleshoot it since those numbers don’t seem to have anything to do with my dataloader. Even more wierd is that this works on colab, but not on my desktop.

Any thoughts/ideas/help would be much appreciated.

Thanks!