Example #1
0
    IMAGE_SIZE = 32
    DATASET_LEN = 20000
    EPOCHS = 30000
    device = 'cuda'
    gloss_cfg = LossConfig('BCE')
    dloss_cfg = LossConfig('BCE')

    sampler_cfg = SamplerConfig(
        name='Onehot',
        out_shape=DATASET_LEN,
        latent_dim=LATENT_DIM
    )
    goptim_cfg = OptimConfig('Adam', lr=1e-3)
    doptim_cfg = OptimConfig('Adam', lr=1e-3)

    dataset_cfg = DatasetConfig('MNIST', train=True, stack=False, along_width=False, size=32)
    loader_cfg = LoaderConfig('naive', batch_size=128, shuffle=True)

    gen_cfg = ModelConfig('EDCG', input_size=LATENT_DIM, hidden_size=128, output_size=1, data_num=DATASET_LEN)
    dis_cfg = ModelConfig('DCD', input_size=1, hidden_size=128, output_size=1)

    train_data_cfg = DatasetConfig('MNIST', stack=False, train=True, along_width=False)
    test_data_cfg = DatasetConfig('MNIST', stack=False, train=False, along_width=False)

    train_loader = LoaderConfig('naive', batch_size=128, shuffle=True)
    test_loader = LoaderConfig('naive', batch_size=128, shuffle=True)

    util_cfg = UtilityModelConfig('NaiveClassifier', False, '/home/bourgan/gan_dev/checkpoints/mnist_naive.pth.tar',
                                  15, train_loader, test_loader, train_data_cfg, test_data_cfg, 32, 'cuda')
    gan_cfg = GanConfig(
        name='StackMNISTLPG', gen_cfg=gen_cfg, dis_cfg=dis_cfg,
Example #2
0
    PRELOAD_LEN = 20000
    EPOCHS = 50000
    device = 'cuda'
    gloss_cfg = LossConfig('BCE')
    dloss_cfg = LossConfig('BCE')

    sampler_cfg = SamplerConfig(
        name='Onehot',
        out_shape=PRELOAD_LEN,
        latent_dim=LATENT_DIM,
        random_sampling=False
    )
    goptim_cfg = OptimConfig('Adam', lr=0.0002)
    doptim_cfg = OptimConfig('Adam', lr=0.0002)

    dataset_cfg = DatasetConfig('CelebA', dataset_len=DATASET_LEN, image_size=IMAGE_SIZE, preload_len=PRELOAD_LEN)
    loader_cfg = LoaderConfig('naive', batch_size=128, shuffle=True)

    gen_cfg = ModelConfig(
        'EDCG', input_size=LATENT_DIM,
        hidden_size=128, output_size=3,
        data_num=PRELOAD_LEN, out_64=IMAGE_SIZE == 64
    )
    dis_cfg = ModelConfig('DCD', input_size=3, hidden_size=64, output_size=1, out_64=IMAGE_SIZE == 64)

    gan_cfg = GanConfig(
        name='CelebAGAN', gen_cfg=gen_cfg, dis_cfg=dis_cfg,
        gen_step=1, dis_step=1, gan_epoch=EPOCHS, loader_cfg=loader_cfg,
        dataset_cfg=dataset_cfg, gloss_cfg=gloss_cfg, dloss_cfg=dloss_cfg,
        goptim_cfg=goptim_cfg, doptim_cfg=doptim_cfg, label_smooth=False,
        sampler_cfg=sampler_cfg, dist_loss=False, device=device
Example #3
0
    device = 'cuda'
    gloss_cfg = LossConfig('BCE')
    dloss_cfg = LossConfig('BCE')

    sampler_cfg = SamplerConfig(
        name='Onehot',
        out_shape=dataset_len,
    )

    goptim_cfg = OptimConfig('Adam', lr=1e-3)
    doptim_cfg = OptimConfig('Adam', lr=1e-3)

    dataset_cfg = DatasetConfig('Spiral',
                                mode=mode,
                                sig=1,
                                num_per_mode=dataset_len // mode,
                                return_idx=True)
    # dataset_cfg = DatasetConfig('GMM', mode=mode, sig=1, num_per_mode=dataset_len // mode, return_idx=True)
    loader_cfg = LoaderConfig('naive', batch_size=128, shuffle=True)

    gen_cfg = ModelConfig('MLG',
                          input_size=latent_dim,
                          hidden_size=32,
                          output_size=2)
    dis_cfg = ModelConfig('MLD', input_size=2, hidden_size=32, output_size=1)

    gan_cfg = GanConfig(name='LearningPrior2',
                        gen_cfg=gen_cfg,
                        dis_cfg=dis_cfg,
                        gen_step=1,
    device = 'cuda'
    gloss_cfg = LossConfig('BCE')
    dloss_cfg = LossConfig('BCE')

    sampler_cfg = SamplerConfig(
        name='Onehot',
        out_shape=DATASET_LEN,
    )

    goptim_cfg = OptimConfig('Adam', lr=1e-3)
    doptim_cfg = OptimConfig('Adam', lr=1e-3)

    dataset_cfg = DatasetConfig('Spiral',
                                mode=MODE,
                                sig=1,
                                num_per_mode=DATASET_LEN // MODE,
                                return_idx=True)
    # dataset_cfg = DatasetConfig('GMM', mode=mode, sig=1, num_per_mode=dataset_len // mode, return_idx=True)
    loader_cfg = LoaderConfig('naive', batch_size=128, shuffle=True)

    gen_cfg = ModelConfig('EMLG',
                          input_size=LATENT_DIM,
                          hidden_size=32,
                          output_size=2,
                          data_num=DATASET_LEN)
    dis_cfg = ModelConfig('MLD', input_size=2, hidden_size=32, output_size=1)

    gan_cfg = GanConfig(name='Embedding',
                        gen_cfg=gen_cfg,
                        dis_cfg=dis_cfg,
Example #5
0
    BATCH_SIZE = 1
    label_len = int(args.label_len)

    EXP_NAME = 'refocus_final_' + str(label_len)
    # logger = SummaryWriter('./log/' + EXP_NAME)

    LR = 2e-4

    gloss_cfg = LossConfig('MSE')
    dloss_cfg = LossConfig('MSE')

    goptim_cfg = OptimConfig('Adam', lr=LR, beta=(0.5, 0.999))
    doptim_cfg = OptimConfig('Adam', lr=LR, beta=(0.5, 0.999))

    dataset_cfg = DatasetConfig('FlowerFull',
                                size=IMG_SIZE,
                                num=label_len,
                                train=False)
    loader_cfg = LoaderConfig('naive', batch_size=1, shuffle=False)

    # gen_cfg = ModelConfig('ResNetGen', input_nc=3, output_nc=3, ngf=64, n_blocks=6)
    gen_cfg = ModelConfig('UNetGen',
                          input_nc=3,
                          output_nc=3,
                          num_downs=6,
                          ngf=64,
                          use_resizeconv=True,
                          ex_label=True,
                          label_len=label_len)
    dis_cfg = ModelConfig('PatchDis', input_nc=6)

    gan_cfg = GanConfig(name='Pix2Pix',
Example #6
0
    mode = 20
    latent_dim = 10

    device = 'cuda'
    gloss_cfg = LossConfig('BCE')
    dloss_cfg = LossConfig('BCE')

    sampler_cfg = SamplerConfig(
        name='Gaussian',
        out_shape=latent_dim,
    )

    goptim_cfg = OptimConfig('Adam', lr=1e-3)
    doptim_cfg = OptimConfig('Adam', lr=1e-3)

    dataset_cfg = DatasetConfig('Spiral', mode=mode, sig=1, num_per_mode=dataset_len // mode)
    # dataset_cfg = DatasetConfig('GMM', mode=mode, sig=1, num_per_mode=dataset_len // mode)
    loader_cfg = LoaderConfig('naive', batch_size=128, shuffle=True)

    gen_cfg = ModelConfig('MLG', input_size=latent_dim, hidden_size=32, output_size=2)
    dis_cfg = ModelConfig('MLD', input_size=2, hidden_size=32, output_size=1)

    gan_cfg = GanConfig(
        name='Vanilla', gen_cfg=gen_cfg, dis_cfg=dis_cfg,
        gen_step=1, dis_step=1, gan_epoch=15000, loader_cfg=loader_cfg,
        dataset_cfg=dataset_cfg, gloss_cfg=gloss_cfg, dloss_cfg=dloss_cfg,
        goptim_cfg=goptim_cfg, doptim_cfg=doptim_cfg, label_smooth=False,
        sampler_cfg=sampler_cfg, device=device
    )
    gan_schema = GanSchema()
    gan_desc = gan_schema.dump(gan_cfg)
Example #7
0
if __name__ == '__main__':
    device = 'cuda'
    GAN_EPOCHS = 10000
    IMG_SIZE = 256
    BATCH_SIZE = 2
    # gloss_cfg = LossConfig('BCEWithLogits')
    # dloss_cfg = LossConfig('BCEWithLogits')
    gloss_cfg = LossConfig('MSE')
    dloss_cfg = LossConfig('MSE')

    goptim_cfg = OptimConfig('Adam', lr=1e-3)
    doptim_cfg = OptimConfig('Adam', lr=1e-3)

    dataset_cfg = DatasetConfig('Flower',
                                suffix=('_center', '_1'),
                                size=IMG_SIZE)
    loader_cfg = LoaderConfig('naive', batch_size=BATCH_SIZE, shuffle=True)

    # gen_cfg = ModelConfig('ResNetGen', input_nc=3, output_nc=3, ngf=64, n_blocks=6)
    gen_cfg = ModelConfig('UNetGen',
                          input_nc=3,
                          output_nc=3,
                          num_downs=8,
                          ngf=64)
    dis_cfg = ModelConfig('PatchDis', input_nc=6)

    gan_cfg = GanConfig(name='Pix2Pix',
                        gen_cfg=gen_cfg,
                        dis_cfg=dis_cfg,
                        gen_step=1,