Here’s what I’ve discovered so far:
- It’s having the error when calculating the MSE during the step module- specifically, it fails at the pointwise loss step in the _pointwise_loss module of functional.py inside PyTorch
- I’ve tried setting the “y” variable to an “int” manually, but it doesn’t seem to help.
Here’s the error output:
RuntimeError Traceback (most recent call last)
<ipython-input-69-9888ade4ac74> in <module>()
----> 1 m.fit(lr, 1)
~/titanic/fastai/learner.py in fit(self, lrs, n_cycle, wds, **kwargs)
296 self.sched = None
297 layer_opt = self.get_layer_opt(lrs, wds)
--> 298 return self.fit_gen(self.model, self.data, layer_opt, n_cycle, **kwargs)
299
300 def warm_up(self, lr, wds=None):
~/titanic/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)
243 metrics=metrics, callbacks=callbacks, reg_fn=self.reg_fn, clip=self.clip, fp16=self.fp16,
244 swa_model=self.swa_model if use_swa else None, swa_start=swa_start,
--> 245 swa_eval_freq=swa_eval_freq, **kwargs)
246
247 def get_layer_groups(self): return self.models.get_layer_groups()
~/titanic/fastai/model.py in fit(model, data, n_epochs, opt, crit, metrics, callbacks, stepper, swa_model, swa_start, swa_eval_freq, visualize, **kwargs)
138 batch_num += 1
139 for cb in callbacks: cb.on_batch_begin()
--> 140 loss = model_stepper.step(V(x),V(y), epoch)
141 avg_loss = avg_loss * avg_mom + loss * (1-avg_mom)
142 debias_loss = avg_loss / (1 - avg_mom**batch_num)
~/titanic/fastai/model.py in step(self, xs, y, epoch)
52 if self.fp16: self.m.zero_grad()
53 else: self.opt.zero_grad()
---> 54 loss = raw_loss = self.crit(output, y)
55 if self.loss_scale != 1: assert(self.fp16); loss = loss*self.loss_scale
56 if self.reg_fn: loss = self.reg_fn(output, xtra, raw_loss)
/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in mse_loss(input, target, size_average, reduce)
1567 """
1568 return _pointwise_loss(lambda a, b: (a - b) ** 2, torch._C._nn.mse_loss,
-> 1569 input, target, size_average, reduce)
1570
1571
/usr/local/lib/python3.6/dist-packages/torch/nn/functional.py in _pointwise_loss(lambd, lambd_optimized, input, target, size_average, reduce)
1535 return torch.mean(d) if size_average else torch.sum(d)
1536 else:
-> 1537 return lambd_optimized(input, target, size_average, reduce)
1538
1539
RuntimeError: Expected object of type torch.FloatTensor but found type torch.LongTensor for argument #2 'target'
I’ll keep updating this thread as I find out more.