Skip to content

Instantly share code, notes, and snippets.

@WillKoehrsen
Created November 26, 2018 16:14
Show Gist options
  • Save WillKoehrsen/70a9819ad855bee07d00a7980c0d6e18 to your computer and use it in GitHub Desktop.
Save WillKoehrsen/70a9819ad855bee07d00a7980c0d6e18 to your computer and use it in GitHub Desktop.
for epoch in range(n_epochs):
for data, targets in trainloader:
# Generate predictions
out = model(data)
# Calculate loss
loss = criterion(out, targets)
# Backpropagation
loss.backward()
# Update model parameters
optimizer.step()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment