Skip to content

Instantly share code, notes, and snippets.

@danielcwq
Created November 28, 2021 07:13
Show Gist options
  • Save danielcwq/35f03c46e4661bec2ada80659927c149 to your computer and use it in GitHub Desktop.
Save danielcwq/35f03c46e4661bec2ada80659927c149 to your computer and use it in GitHub Desktop.
#in pseudocode, this would be:
w -= gradient(w) *lr
#stepping learning function here
#converting this into a function:
def train_epoch(model, lr, params):
for xb,yb in dl:
calc_grad(xb, yb, model)
for p in params:
p.data -= p.grad*lr
p.grad.zero_()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment