Skip to content

Instantly share code, notes, and snippets.

@sobamchan
Created November 10, 2019 12:35
Show Gist options
  • Save sobamchan/5141da606662b30a7b2464473b823150 to your computer and use it in GitHub Desktop.
Save sobamchan/5141da606662b30a7b2464473b823150 to your computer and use it in GitHub Desktop.
def training_step(self, batch, batch_idx):
labels = batch["label"]
input_ids = batch["input_ids"]
attention_mask = batch["attention_mask"]
token_type_ids = batch["token_type_ids"]
loss, _ = self.model(
input_ids,
token_type_ids=token_type_ids,
attention_mask=attention_mask,
labels=labels
)
tqdm_dict = {"train_loss": loss}
output = OrderedDict({
"loss": loss,
"progress_bar": tqdm_dict,
"log": tqdm_dict
})
return output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment