From e50a8541359bf1f472c6f9ec465936b857a6162b Mon Sep 17 00:00:00 2001 From: Ryuichi Yamamoto Date: Fri, 22 Sep 2017 15:10:44 +0900 Subject: [PATCH 1/3] vae: Fix UserWarning UserWarning: Using a target size (torch.Size([16, 1, 28, 28])) that is different to the input size (torch.Size([16, 784])) is deprecated. Please ensure they have the same size. --- vae/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vae/main.py b/vae/main.py index 19d6e53c38..68d7372e61 100644 --- a/vae/main.py +++ b/vae/main.py @@ -82,7 +82,7 @@ def forward(self, x): def loss_function(recon_x, x, mu, logvar): - BCE = reconstruction_function(recon_x, x) + BCE = reconstruction_function(recon_x, x.view(-1, 784)) # see Appendix B from VAE paper: # Kingma and Welling. Auto-Encoding Variational Bayes. ICLR, 2014 From 81791102d943975b1320c6f4ffd5bf5ea553efcf Mon Sep 17 00:00:00 2001 From: Ryuichi Yamamoto Date: Fri, 22 Sep 2017 15:12:59 +0900 Subject: [PATCH 2/3] vae: Remove unnecessary branch --- vae/main.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/vae/main.py b/vae/main.py index 68d7372e61..ed0a0bce06 100644 --- a/vae/main.py +++ b/vae/main.py @@ -56,11 +56,7 @@ def encode(self, x): def reparametrize(self, mu, logvar): std = logvar.mul(0.5).exp_() - if args.cuda: - eps = torch.cuda.FloatTensor(std.size()).normal_() - else: - eps = torch.FloatTensor(std.size()).normal_() - eps = Variable(eps) + eps = Variable(std.data.new(std.size()).normal_()) return eps.mul(std).add_(mu) def decode(self, z): From dc6e8ccb47bbc57d1fcb7c3a17af130d35b0aafb Mon Sep 17 00:00:00 2001 From: Ryuichi Yamamoto Date: Fri, 22 Sep 2017 15:27:26 +0900 Subject: [PATCH 3/3] Fix wrong help messages --- vae/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vae/main.py b/vae/main.py index ed0a0bce06..370ad579ce 100644 --- a/vae/main.py +++ b/vae/main.py @@ -9,9 +9,9 @@ parser = argparse.ArgumentParser(description='PyTorch MNIST Example') parser.add_argument('--batch-size', type=int, default=128, metavar='N', - help='input batch size for training (default: 64)') + help='input batch size for training (default: 128)') parser.add_argument('--epochs', type=int, default=10, metavar='N', - help='number of epochs to train (default: 2)') + help='number of epochs to train (default: 10)') parser.add_argument('--no-cuda', action='store_true', default=False, help='enables CUDA training') parser.add_argument('--seed', type=int, default=1, metavar='S',