Now there’s a different error.
RuntimeError Traceback (most recent call last)
in ()
----> 1 learn.lr_find()
~/punchh/sensus/notebooks/chetan/fastai/fastai/train.py in lr_find(learn, start_lr, end_lr, num_it, stop_div, wd)
30 cb = LRFinder(learn, start_lr, end_lr, num_it, stop_div)
31 epochs = int(np.ceil(num_it/len(learn.data.train_dl)))
—> 32 learn.fit(epochs, start_lr, callbacks=[cb], wd=wd)
33
34 def to_fp16(learn:Learner, loss_scale:float=None, max_noskip:int=1000, dynamic:bool=True, clip:float=None,
~/punchh/sensus/notebooks/chetan/fastai/fastai/basic_train.py in fit(self, epochs, lr, wd, callbacks)
198 callbacks = [cb(self) for cb in self.callback_fns + listify(defaults.extra_callback_fns)] + listify(callbacks)
199 if defaults.extra_callbacks is not None: callbacks += defaults.extra_callbacks
–> 200 fit(epochs, self, metrics=self.metrics, callbacks=self.callbacks+callbacks)
201
202 def create_opt(self, lr:Floats, wd:Floats=0.)->None:
~/punchh/sensus/notebooks/chetan/fastai/fastai/basic_train.py in fit(epochs, learn, callbacks, metrics)
99 for xb,yb in progress_bar(learn.data.train_dl, parent=pbar):
100 xb, yb = cb_handler.on_batch_begin(xb, yb)
–> 101 loss = loss_batch(learn.model, xb, yb, learn.loss_func, learn.opt, cb_handler)
102 if cb_handler.on_batch_end(loss): break
103
~/punchh/sensus/notebooks/chetan/fastai/fastai/basic_train.py in loss_batch(model, xb, yb, loss_func, opt, cb_handler)
24 if not is_listy(xb): xb = [xb]
25 if not is_listy(yb): yb = [yb]
—> 26 out = model(*xb)
27 out = cb_handler.on_loss_begin(out)
28
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
491 result = self._slow_forward(*input, **kwargs)
492 else:
–> 493 result = self.forward(*input, **kwargs)
494 for hook in self._forward_hooks.values():
495 hook_result = hook(self, input, result)
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/modules/container.py in forward(self, input)
90 def forward(self, input):
91 for module in self._modules.values():
—> 92 input = module(input)
93 return input
94
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
491 result = self._slow_forward(*input, **kwargs)
492 else:
–> 493 result = self.forward(*input, **kwargs)
494 for hook in self._forward_hooks.values():
495 hook_result = hook(self, input, result)
~/punchh/sensus/notebooks/chetan/fastai/fastai/text/models/awd_lstm.py in forward(self, input, from_embeddings)
115 new_hidden,raw_outputs,outputs = [],[],[]
116 for l, (rnn,hid_dp) in enumerate(zip(self.rnns, self.hidden_dps)):
–> 117 raw_output, new_h = rnn(raw_output, self.hidden[l])
118 new_hidden.append(new_h)
119 raw_outputs.append(raw_output)
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
491 result = self._slow_forward(*input, **kwargs)
492 else:
–> 493 result = self.forward(*input, **kwargs)
494 for hook in self._forward_hooks.values():
495 hook_result = hook(self, input, result)
~/punchh/sensus/notebooks/chetan/fastai/fastai/text/models/qrnn.py in forward(self, inp, hid)
156 if self.bidirectional: inp_bwd = inp.clone()
157 for i, layer in enumerate(self.layers):
–> 158 inp, h = layer(inp, None if hid is None else hid[2*i if self.bidirectional else i])
159 new_hid.append(h)
160 if self.bidirectional:
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
491 result = self._slow_forward(*input, **kwargs)
492 else:
–> 493 result = self.forward(*input, **kwargs)
494 for hook in self._forward_hooks.values():
495 hook_result = hook(self, input, result)
~/punchh/sensus/notebooks/chetan/fastai/fastai/text/models/qrnn.py in forward(self, inp, hid)
99
100 def forward(self, inp, hid=None):
–> 101 y = self.linear(self._get_source(inp))
102 if self.output_gate: z_gate,f_gate,o_gate = y.chunk(3, dim=2)
103 else: z_gate,f_gate = y.chunk(2, dim=2)
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
491 result = self._slow_forward(*input, **kwargs)
492 else:
–> 493 result = self.forward(*input, **kwargs)
494 for hook in self._forward_hooks.values():
495 hook_result = hook(self, input, result)
~/punchh/sensus/notebooks/chetan/fastai/fastai/text/models/awd_lstm.py in forward(self, *args)
50 #To avoid the warning that comes because the weights aren’t flattened.
51 warnings.simplefilter(“ignore”)
—> 52 return self.module.forward(*args)
53
54 def reset(self):
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/modules/linear.py in forward(self, input)
90 @weak_script_method
91 def forward(self, input):
—> 92 return F.linear(input, self.weight, self.bias)
93
94 def extra_repr(self):
~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/torch/nn/functional.py in linear(input, weight, bias)
1406 ret = torch.addmm(bias, input, weight.t())
1407 else:
-> 1408 output = input.matmul(weight.t())
1409 if bias is not None:
1410 output += bias
RuntimeError: size mismatch, m1: [4480 x 575], m2: [1150 x 1725] at /pytorch/aten/src/THC/generic/THCTensorMathBlas.cu:268
I know we shouldn’t use bidirectional for language model, but error with tensor mismatch is still weird. So is this an error on my side or in the code for qrnn?