Created
December 17, 2021 14:58
-
-
Save vinimonteiro/4e4f1b55dcd724b63abdd9bbcf2bf74a to your computer and use it in GitHub Desktop.
nn_pytorch_training
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
optimizer = optim.Adam(model.parameters(), lr=0.001) | |
EPOCHS = 3 | |
for epoch in range(EPOCHS): | |
for data in trainset: | |
X, y = data | |
model.zero_grad() | |
output = model(X.view(-1, 28 * 28)) | |
loss = F.nll_loss(output, y) | |
loss.backward() | |
optimizer.step() | |
print(loss) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment