Skip to content

Instantly share code, notes, and snippets.

@vaibhavkumar049
Created June 8, 2019 19:59
Show Gist options
  • Save vaibhavkumar049/54d6cf071325671b9e0650b46ce08cd2 to your computer and use it in GitHub Desktop.
Save vaibhavkumar049/54d6cf071325671b9e0650b46ce08cd2 to your computer and use it in GitHub Desktop.
def fit_v2(x, y, model, opt, loss_fn, epochs = 1000):
for epoch in range(epochs):
loss = loss_fn(model(x), y)
loss.backward()
opt.step()
opt.zero_grad()
return loss.item()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment