Skip to content

Commit

Permalink
allow unsupervised model
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiaoyuan Liu [email protected] committed Nov 4, 2019
1 parent 4939322 commit f576632
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion allennlp_glue_patch/stsb_regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def forward(self, # type: ignore

if label is not None: # convert the label into a float number and update the metric
label_to_str = lambda l: self.vocab.get_index_to_token_vocabulary(self._label_namespace).get(l)
label_tensor = torch.tensor([float(label_to_str(int(label[i]))) for i in range(label.shape[0])], device=logits.device)
label_tensor = torch.tensor([float(label_to_str(int(label[i]))) for i in range(label.shape[0])], device=logits.device, requires_grad=True) # make sure loss.backward have something to update
loss = self._loss(logits.view(-1), label_tensor)
output_dict["loss"] = loss
self._metric(logits, label_tensor)
Expand Down

0 comments on commit f576632

Please sign in to comment.