Lesson 1 error: IndexError: invalid index to scalar variable

Hello,

I am running the course on my home computer with ubuntu 16.04, cuda 8 cudnn 6, I set up a new environment with pyenv for python 3.6.5 and then installed the requirements from a git-clone of fastai master. Lastly I downloaded the dogs and cats file and extracted it into /data. I keep getting this error and I have no idea how to resolve it, anyone experienced something similar?


IndexError Traceback (most recent call last)
in ()
2 data = ImageClassifierData.from_paths(PATH+"", tfms=tfms_from_model(arch, 100))
3 learn = ConvLearner.pretrained(arch, data, precompute=False)
----> 4 learn.fit(0.01, 2)

~/NN/Python/fastai/courses/dl1/fastai/learner.py in fit(self, lrs, n_cycle, wds, **kwargs)
285 self.sched = None
286 layer_opt = self.get_layer_opt(lrs, wds)
–> 287 return self.fit_gen(self.model, self.data, layer_opt, n_cycle, **kwargs)
288
289 def warm_up(self, lr, wds=None):

~/NN/Python/fastai/courses/dl1/fastai/learner.py in fit_gen(self, model, data, layer_opt, n_cycle, cycle_len, cycle_mult, cycle_save_name, best_save_name, use_clr, use_clr_beta, metrics, callbacks, use_wd_sched, norm_wds, wds_sched_mult, use_swa, swa_start, swa_eval_freq, **kwargs)
232 metrics=metrics, callbacks=callbacks, reg_fn=self.reg_fn, clip=self.clip, fp16=self.fp16,
233 swa_model=self.swa_model if use_swa else None, swa_start=swa_start,
–> 234 swa_eval_freq=swa_eval_freq, **kwargs)
235
236 def get_layer_groups(self): return self.models.get_layer_groups()

~/NN/Python/fastai/courses/dl1/fastai/model.py in fit(model, data, n_epochs, opt, crit, metrics, callbacks, stepper, swa_model, swa_start, swa_eval_freq, **kwargs)
150 vals = validate(model_stepper, cur_data.val_dl, metrics)
151 stop=False
–> 152 for cb in callbacks: stop = stop or cb.on_epoch_end(vals)
153 if swa_model is not None:
154 if (epoch + 1) >= swa_start and ((epoch + 1 - swa_start) % swa_eval_freq == 0 or epoch == tot_epochs - 1):

~/NN/Python/fastai/courses/dl1/fastai/sgdr.py in on_epoch_end(self, metrics)
64 def on_epoch_end(self, metrics):
65 self.epoch += 1
—> 66 self.save_metrics(metrics)
67
68 def on_batch_end(self, loss):

~/NN/Python/fastai/courses/dl1/fastai/sgdr.py in save_metrics(self, vals)
77
78 def save_metrics(self,vals):
—> 79 self.val_losses.append(vals[0][0])
80 if len(vals) > 2: self.rec_metrics.append(vals[1:])
81 elif len(vals) == 2: self.rec_metrics.append(vals[1])

IndexError: invalid index to scalar variable.

I believe there was an error introduced in the code. Just pull again from the repository and it should have been fixed!

1 Like

Thank you Farbod! It works now.

1 Like

I got the 0.7 version and I run it on a my machine and it was working fine. (lesson4-mnist_sgd.ipynb) but then I try to run it on a linux server (so I can run .cuda) and I have this error coming up.

1 Like

Hi Pavlos,
I am facing the same problem. Were you able to solve it?

1 Like