Created
May 17, 2020 07:40
-
-
Save gchhablani/70f24486b007b3799efcc55d1655182b to your computer and use it in GitHub Desktop.
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
vae = VAE() | |
vae.to(device) | |
criterion = nn.MSELoss() | |
optimizer = optim.Adamax(vae.parameters(),lr = 1e-4) | |
l = None | |
for epoch in range(100): | |
for i, data in enumerate(loader,0): | |
inputs,classes = data | |
inputs,classes = Variable(inputs.resize_(batch_size,784)).to(device),Variable(classes).to(device) | |
optimizer.zero_grad() | |
out = vae(inputs) | |
ll = latent_loss(vae.z_mean,vae.z_sigma) | |
loss = criterion(out,inputs)+ll | |
loss.backward() | |
optimizer.step() | |
l = loss.item() | |
print(epoch,l) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment