train=True,
                          transform=transforms.ToTensor())
    trainLoader = torch.utils.data.DataLoader(trainDataset,
                                              batch_size=opts.batchSize,
                                              shuffle=True)

    testDataset = CELEBA(root=opts.root,
                         train=False,
                         transform=transforms.ToTensor())
    testLoader = torch.utils.data.DataLoader(testDataset,
                                             batch_size=opts.batchSize,
                                             shuffle=False)

    ####### Create VAE model and classifier model #######
    vae = VAE(nz=opts.nz, imSize=64, fSize=opts.fSize, sig=opts.sig)
    classer = CLASSIFIER(imSize=64, fSize=opts.fSize)
    print vae
    print classer

    if vae.useCUDA:
        print 'using CUDA'
        vae.cuda()
        classer.cuda()
    else:
        print '\n *** NOT USING CUDA ***\n'

    #eval or train
    if opts.evalMode:
        opts.loadCLASSER = True
        opts.loadDELTAZ = True
        opts.loadVAE = True
    trainLoader = torch.utils.data.DataLoader(trainDataset,
                                              batch_size=opts.batchSize,
                                              shuffle=True)

    testDataset = CELEBA(root=opts.root,
                         train=False,
                         transform=transforms.ToTensor(),
                         label=opts.label)
    testLoader = torch.utils.data.DataLoader(testDataset,
                                             batch_size=opts.batchSize,
                                             shuffle=False)
    print 'Data loaders ready.'

    ####### Create model #######
    cvae = CVAE1(nz=opts.nz, imSize=64, fSize=opts.fSize)
    dis = DISCRIMINATOR(imSize=64, fSize=opts.fSize)
    aux = AUX(nz=opts.nz)
    classer = CLASSIFIER(imSize=64, fSize=64)  #for eval only!

    if cvae.useCUDA:
        print 'using CUDA'
        cvae.cuda()
        dis.cuda()
        aux.cuda()
        classer.cuda()
    else:
        print '\n *** NOT USING CUDA ***\n'

    #load model is applicable
    if opts.load_VAE_from is not None:
        cvae.load_params(opts.load_VAE_from)
Esempio n. 3
0
                          transform=transforms.ToTensor())
    trainLoader = torch.utils.data.DataLoader(trainDataset,
                                              batch_size=opts.batchSize,
                                              shuffle=True)

    testDataset = CELEBA(root=opts.root,
                         train=False,
                         transform=transforms.ToTensor())
    testLoader = torch.utils.data.DataLoader(testDataset,
                                             batch_size=opts.batchSize,
                                             shuffle=False)
    print 'Data loaders ready.'

    ####### Create model #######
    cvae = CVAE(nz=opts.nz, imSize=64, fSize=opts.fSize)
    dis = DISCRIMINATOR(imSize=64, fSize=opts.fSize)

    if cvae.useCUDA:
        print 'using CUDA'
        cvae.cuda()
        dis.cuda()
    else:
        print '\n *** NOT USING CUDA ***\n'

    print cvae
    print dis

    ####### Define optimizer #######
    optimizerCVAE = optim.RMSprop(
        cvae.parameters(),
        lr=opts.lr)  #specify the params that are being upated
Esempio n. 4
0
	opts = get_args()

	####### Data set #######
	print 'Prepare data loaders...'
	transform = transforms.Compose([transforms.ToTensor(), transforms.RandomHorizontalFlip()])
	trainDataset = CELEBA(root=opts.root, train=True, transform=transforms.ToTensor(), label=opts.label)
	trainLoader = torch.utils.data.DataLoader(trainDataset, batch_size=opts.batchSize, shuffle=True)

	testDataset = CELEBA(root=opts.root, train=False, transform=transforms.ToTensor(), label=opts.label)
	testLoader = torch.utils.data.DataLoader(testDataset, batch_size=opts.batchSize, shuffle=False)
	print 'Data loaders ready.'


	####### Create model #######
	cvae = CVAE1(nz=opts.nz, imSize=64, fSize=opts.fSize)
	dis = DISCRIMINATOR(imSize=64, fSize=opts.fSize) 
	aux = AUX(nz=opts.nz)
	classer = CLASSIFIER(imSize=64, fSize=64) #for eval only! 

	if cvae.useCUDA:
		print 'using CUDA'
		cvae.cuda()
		dis.cuda()
		aux.cuda()
		classer.cuda()
	else: print '\n *** NOT USING CUDA ***\n'

	#load model is applicable
	if opts.load_VAE_from is not None:
		cvae.load_params(opts.load_VAE_from)