I excluded the model.cuda() and I got all the way to line 23 but it fails at the first Epoch with the following error
RuntimeError Traceback (most recent call last)
in ()
13 # forward pass
14 loss = model(b_input_ids, token_type_ids=None,
—> 15 attention_mask=b_input_mask, labels=b_labels)
16 # backward pass
17 loss.backward()
D:\Anaconda3\envs\kerasenv\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
487 result = self._slow_forward(*input, **kwargs)
488 else:
–> 489 result = self.forward(*input, **kwargs)
490 for hook in self._forward_hooks.values():
491 hook_result = hook(self, input, result)
D:\Anaconda3\envs\kerasenv\lib\site-packages\pytorch_pretrained_bert\modeling.py in forward(self, input_ids, token_type_ids, attention_mask, labels)
1018
1019 def forward(self, input_ids, token_type_ids=None, attention_mask=None, labels=None):
-> 1020 sequence_output, _ = self.bert(input_ids, token_type_ids, attention_mask, output_all_encoded_layers=False)
1021 sequence_output = self.dropout(sequence_output)
1022 logits = self.classifier(sequence_output)
D:\Anaconda3\envs\kerasenv\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
487 result = self._slow_forward(*input, **kwargs)
488 else:
–> 489 result = self.forward(*input, **kwargs)
490 for hook in self._forward_hooks.values():
491 hook_result = hook(self, input, result)
D:\Anaconda3\envs\kerasenv\lib\site-packages\pytorch_pretrained_bert\modeling.py in forward(self, input_ids, token_type_ids, attention_mask, output_all_encoded_layers)
624 extended_attention_mask = (1.0 – extended_attention_mask) * -10000.0
625
–> 626 embedding_output = self.embeddings(input_ids, token_type_ids)
627 encoded_layers = self.encoder(embedding_output,
628 extended_attention_mask,
D:\Anaconda3\envs\kerasenv\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
487 result = self._slow_forward(*input, **kwargs)
488 else:
–> 489 result = self.forward(*input, **kwargs)
490 for hook in self._forward_hooks.values():
491 hook_result = hook(self, input, result)
D:\Anaconda3\envs\kerasenv\lib\site-packages\pytorch_pretrained_bert\modeling.py in forward(self, input_ids, token_type_ids)
191 token_type_ids = torch.zeros_like(input_ids)
192
–> 193 words_embeddings = self.word_embeddings(input_ids)
194 position_embeddings = self.position_embeddings(position_ids)
195 token_type_embeddings = self.token_type_embeddings(token_type_ids)
D:\Anaconda3\envs\kerasenv\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
487 result = self._slow_forward(*input, **kwargs)
488 else:
–> 489 result = self.forward(*input, **kwargs)
490 for hook in self._forward_hooks.values():
491 hook_result = hook(self, input, result)
D:\Anaconda3\envs\kerasenv\lib\site-packages\torch\nn\modules\sparse.py in forward(self, input)
116 return F.embedding(
117 input, self.weight, self.padding_idx, self.max_norm,
–> 118 self.norm_type, self.scale_grad_by_freq, self.sparse)
119
120 def extra_repr(self):
D:\Anaconda3\envs\kerasenv\lib\site-packages\torch\nn\functional.py in embedding(input, weight, padding_idx, max_norm, norm_type, scale_grad_by_freq, sparse)
1452 # remove once script supports set_grad_enabled
1453 _no_grad_embedding_renorm_(weight, input, max_norm, norm_type)
-> 1454 return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
1455
1456
RuntimeError: Expected tensor for argument #1 ‘indices’ to have scalar type Long; but got torch.IntTensor instead (while checking arguments for embedding)