Пример #1
0
opt.n_classes = 10
opt.nz = (100,1,1)
opt.num_disc_iters = 1
opt.checkpoints = [1000, 2000, 5000, 10000, 20000, 40000, 60000, 100000, 200000, 300000, 500000]

basedir = 'oneclass_gans/'

logger = Logger(base_dir=basedir, tag='oneclass_gans')

for digit in range(10):
    opt.path = basedir + '{}/'.format(digit)

    log_t = Logger()


    data = datasets.MNISTDataset(selected=digit)

    mydataloader = datasets.MyDataLoader()
    data_iter = mydataloader.return_iterator(DataLoader(data, batch_size=opt.batch_size, shuffle=True, num_workers=4), is_cuda=opt.cuda, conditional=opt.conditional, pictures=True)

    netG = mnistnet.mnistnet_G(nz=100, ngf=128)
    netD = mnistnet.mnistnet_D(nc=1, BN=True, ndf=128)
    # netG = mnistnet.mnistnet_G(nz=110)
    # netD = mnistnet.mnistnet_D(nc=11)


    optimizerD = optim.Adam(netD.parameters(), lr=2e-4, betas=(.5, .999))
    optimizerG = optim.Adam(netG.parameters(), lr=2e-4, betas=(.5, .999))


    gan1 = gan.GAN(netG=netG, netD=netD, optimizerD=optimizerD, optimizerG=optimizerG, opt=opt)
Пример #2
0
    return [
        name for name in os.listdir(dir)
        if os.path.isdir(os.path.join(dir, name))
    ]


# perform some custom validation
if args.TRAIN + args.TEST != 100:
    print "error: --train and --test must sum to 100%"
    sys.exit(1)

# determine parameters of dataset
if args.DATASET == "feret":
    dataset = datasets.FERETDataset()
elif args.DATASET == "mnist":
    dataset = datasets.MNISTDataset()
elif args.DATASET == "orl":
    dataset = datasets.ORLDataset()
elif args.DATASET == "gtex":
    subs = get_sub_dirs('datasets/GTEx_Data')
    subs.sort()
    dataset = datasets.GTEXDataset(subs)
elif args.DATASET == "gtex_30":
    subs = get_sub_dirs('datasets/GTEx_Data_30')
    subs.sort()
    dataset = datasets.GTEXDataset30(subs)
elif args.DATASET == "fctl":
    subs = get_sub_dirs('datasets/fctl')
    dataset = datasets.FCTLDataset(subs)

# initialize the training set and test set
Пример #3
0
# opt.path = 'test_GAN_GANc2st/'.format(i)
opt.path = 'test_GAN_GANc2st/'

writer = SummaryWriter(opt.path)

opt.checkpoints = [
    1000, 2000, 5000, 10000, 20000, 40000, 60000, 100000, 200000, 300000,
    500000
]
opt.checkpoints = [1000, 2000, 4000, 8000, 12000, 16000, 20000]

logger = Logger(base_dir=opt.path, tag=str(i))

for checkpoint in opt.checkpoints:

    real_dataset = datasets.MNISTDataset(selected=i, train=False)
    # print(len(real_dataset))

    # real_dataset = datasets.LINDataset(protein='Arp3', transform=transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)),
    #     basedir='/home/ubuntu/LIN/LIN_Normalized_WT_size-48-80_train/')

    log_t = Logger()

    loss, roc = c2st(mnistnet_G(nc=1),
                     'oneclass_gans/{}/gen_{}.pth'.format(i, checkpoint),
                     mnistnet_D(nc=1),
                     gan.GAN,
                     opt,
                     real_dataset,
                     logger=log_t)