Skip to content

Instantly share code, notes, and snippets.

@williamFalcon
Created July 29, 2019 17:49
Show Gist options
  • Save williamFalcon/012def1be85abd79d9fdfb9fdd34c8dc to your computer and use it in GitHub Desktop.
Save williamFalcon/012def1be85abd79d9fdfb9fdd34c8dc to your computer and use it in GitHub Desktop.
# enable 16-bit on the model and the optimizer
model, optimizers = amp.initialize(model, optimizers, opt_level='O2')
# when doing .backward, let amp do it so it can scale the loss
with amp.scale_loss(loss, optimizer) as scaled_loss:
scaled_loss.backward()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment