Skip to content

Instantly share code, notes, and snippets.

@lucabergamini
Created September 21, 2020 17:22
Show Gist options
  • Save lucabergamini/8883bcb707d3c62fd5626e41e4c35d0f to your computer and use it in GitHub Desktop.
Save lucabergamini/8883bcb707d3c62fd5626e41e4c35d0f to your computer and use it in GitHub Desktop.
optimizer = optim.Adam(model.parameters(), lr=1e-3)
criterion = nn.MSELoss(reduction="none")
outputs = model(torch.from_numpy(img)).reshape(translations.shape)
loss = criterion(outputs, translations)
optimizer.zero_grad()
loss.backward()
optimizer.step()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment