Hi All,
I have a question on sample generation from VAE.(need to generate only 1’s)
I am referring to VAE implementation in pytorch,
from __future__ import print_function
import argparse
import torch
import torch.utils.data
from torch import nn, optim
from torch.autograd import Variable
from torch.nn import functional as F
from torchvision import datasets, transforms
from torchvision.utils import save_image
parser = argparse.ArgumentParser(description='VAE MNIST Example')
parser.add_argument('--batch-size', type=int, default=128, metavar='N',
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: 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',
help='random seed (default: 1)')
This file has been truncated. show original
After training the code generates the samples
sample = Variable(torch.randn(64, 20))
sample = model.decode(sample).cpu()
save_image(sample.data.view(64, 1, 28, 28), ‘results/sample_’ + str(epoch) + ‘.png’)
But it generates all the images is there any possibility that i can only sample 1’s separately and 2’s separately and…so on
Thanks,
Jay
If by “only 1’s” you mean generating only sample images representing the digit 1, then it is (almost) impossible to do it perfectly if you trained your network on the whole MNIST dataset.
What you can do if you want to use a VAE to generate samples of 1’s and 2’s separately is to train one VAE for each digit.
Yeah,…i was hoping if there is anyway we can do it…
But thanks a lot for your response