Skip to content

Instantly share code, notes, and snippets.

@danielcwq
Created November 28, 2021 07:09
Show Gist options
  • Save danielcwq/4e3f94110f1caf415ce15d1d61b193f8 to your computer and use it in GitHub Desktop.
Save danielcwq/4e3f94110f1caf415ce15d1d61b193f8 to your computer and use it in GitHub Desktop.
def calc_grad(xb, yb, model):
preds = model(xb)
loss = mnist_loss(preds, yb)
loss.backward()
weights.grad.zero_()
bias.grad.zero_();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment