Skip to content

Instantly share code, notes, and snippets.

@taoyds
Last active March 20, 2020 12:46
Show Gist options
  • Save taoyds/66dbf8a4cfc433267d8a8fb657c17f42 to your computer and use it in GitHub Desktop.
Save taoyds/66dbf8a4cfc433267d8a8fb657c17f42 to your computer and use it in GitHub Desktop.
model.train()
model.set_num_updates(update_num)
loss, sample_size, logging_output = criterion(model, sample)
if ignore_grad:
loss *= 0
optimizer.backward(loss)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment