Good day,
yesterday I executed most of Lesson 1 notebook on Google Collab all well with no issues,
today I’m getting this error right at the beginning when running the model:
invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number,
any tips? thank you
/usr/local/lib/python3.6/dist-packages/fastai/initializers.py:6: UserWarning: nn.init.kaiming_normal is now deprecated in favor of nn.init.kaiming_normal_.
if hasattr(m, ‘weight’): init_fn(m.weight)
HBox(children=(IntProgress(value=0, description=‘Epoch’, max=2, style=ProgressStyle(description_width='initial…
0%| | 0/360 [00:00<?, ?it/s]
IndexError Traceback (most recent call last)
in ()
2 data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, sz))
3 learn = ConvLearner.pretrained(arch, data, precompute=True)
----> 4 learn.fit(0.01, 2)
/usr/local/lib/python3.6/dist-packages/fastai/learner.py in fit(self, lrs, n_cycle, wds, **kwargs)
97 self.sched = None
98 layer_opt = self.get_layer_opt(lrs, wds)
—> 99 self.fit_gen(self.model, self.data, layer_opt, n_cycle, **kwargs)
100
101 def lr_find(self, start_lr=1e-5, end_lr=10, wds=None):
/usr/local/lib/python3.6/dist-packages/fastai/learner.py in fit_gen(self, model, data, layer_opt, n_cycle, cycle_len, cycle_mult, cycle_save_name, metrics, callbacks, **kwargs)
87 n_epoch = sum_geom(cycle_len if cycle_len else 1, cycle_mult, n_cycle)
88 fit(model, data, n_epoch, layer_opt.opt, self.crit,
—> 89 metrics=metrics, callbacks=callbacks, reg_fn=self.reg_fn, clip=self.clip, **kwargs)
90
91 def get_layer_groups(self): return self.models.get_layer_groups()
/usr/local/lib/python3.6/dist-packages/fastai/model.py in fit(model, data, epochs, opt, crit, metrics, callbacks, kwargs)
82 for (*x,y) in t:
83 batch_num += 1
—> 84 loss = stepper.step(V(x),V(y))
85 avg_loss = avg_loss * avg_mom + loss * (1-avg_mom)
86 debias_loss = avg_loss / (1 - avg_mombatch_num)
/usr/local/lib/python3.6/dist-packages/fastai/model.py in step(self, xs, y)
47 nn.utils.clip_grad_norm(trainable_params_(self.m), self.clip)
48 self.opt.step()
—> 49 return raw_loss.data[0]
50
51 def evaluate(self, xs, y):
IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number