Created
November 1, 2020 00:05
-
-
Save SamratSahoo/e2304f6d17a6d62b3834899aa72455bd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def trainModel(self): | |
| for epoch in range(self.epochs): | |
| for data in self.dataLoader: | |
| image, _ = data | |
| image = image.view(image.size(0), -1) | |
| image = Variable(image) | |
| # Predictions | |
| output = self(image) | |
| # Calculate Loss | |
| loss = self.criterion(output, image) | |
| # Backpropagation | |
| self.optimizer.zero_grad() | |
| loss.backward() | |
| self.optimizer.step() | |
| print('epoch [{}/{}], loss:{:.4f}' | |
| .format(epoch + 1, self.epochs, loss.data)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment