Last active
January 14, 2020 12:59
-
-
Save AFAgarap/6b1d67dc7ecb34032e1ae2f7100fef65 to your computer and use it in GitHub Desktop.
Object instantiation for training an autoencoder written in PyTorch.
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
# use gpu if available | |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | |
# create a model from `AE` autoencoder class | |
# load it to the specified device, either gpu or cpu | |
model = AE(input_shape=784).to(device) | |
# create an optimizer object | |
# Adam optimizer with learning rate 1e-3 | |
optimizer = optim.Adam(model.parameters(), lr=1e-3) | |
# mean-squared error loss | |
criterion = nn.MSELoss() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment