config.optimizer = "Adam"
	config.learning_rate = 0.0002
	config.momentum = 0.5
	config.gradient_clipping = 5
	config.weight_decay = 0

	decoder = Sequential(weight_initializer=config.weight_initializer, weight_init_std=config.weight_init_std)
	decoder.add(Linear(None, 1000))
	decoder.add(Activation(config.nonlinearity))
	decoder.add(Linear(None, 1000))
	decoder.add(Activation(config.nonlinearity))
	decoder.add(Linear(None, config.ndim_x))
	decoder.add(sigmoid())

	discriminator = Sequential(weight_initializer=config.weight_initializer, weight_init_std=config.weight_init_std)
	discriminator.add(Merge(num_inputs=2, out_size=1000, nobias=True))
	discriminator.add(gaussian_noise(std=0.3))
	discriminator.add(Activation(config.nonlinearity))
	discriminator.add(Linear(None, 1000))
	discriminator.add(Activation(config.nonlinearity))
	discriminator.add(Linear(None, 1000))
	discriminator.add(Activation(config.nonlinearity))
	discriminator.add(Linear(None, 2))

	generator = Sequential(weight_initializer=config.weight_initializer, weight_init_std=config.weight_init_std)
	generator.add(Linear(config.ndim_x, 1000))
	generator.add(Activation(config.nonlinearity))
	generator.add(Linear(None, 1000))
	generator.add(Activation(config.nonlinearity))
	if config.distribution_z == "deterministic":
		generator.add(Linear(None, config.ndim_z))
예제 #2
0
파일: model.py 프로젝트: LynnHongLiu/adgm
    config.weight_init_std = 0.01
    config.weight_initializer = "Normal"
    config.nonlinearity = "elu"
    config.optimizer = "Adam"
    config.learning_rate = 0.0003
    config.momentum = 0.9
    config.gradient_clipping = 10
    config.weight_decay = 0
    config.use_weightnorm = False
    config.num_mc_samples = 1

    # p(x|y,z) - x ~ Bernoulli
    p_x_ayz = Sequential(weight_initializer=config.weight_initializer,
                         weight_init_std=config.weight_init_std)
    p_x_ayz.add(
        Merge(num_inputs=3, out_size=500,
              use_weightnorm=config.use_weightnorm))
    p_x_ayz.add(BatchNormalization(500))
    p_x_ayz.add(Activation(config.nonlinearity))
    p_x_ayz.add(Linear(None, 500, use_weightnorm=config.use_weightnorm))
    p_x_ayz.add(BatchNormalization(500))
    p_x_ayz.add(Activation(config.nonlinearity))
    p_x_ayz.add(Linear(None, 500, use_weightnorm=config.use_weightnorm))
    p_x_ayz.add(BatchNormalization(500))
    p_x_ayz.add(Activation(config.nonlinearity))
    p_x_ayz.add(
        Linear(None, config.ndim_x, use_weightnorm=config.use_weightnorm))

    # p(a|x,y,z) - a ~ Gaussian
    p_a_yz = Sequential(weight_initializer=config.weight_initializer,
                        weight_init_std=config.weight_init_std)
    p_a_yz.add(
예제 #3
0
    config.ndim_x = 28 * 28
    config.ndim_y = 10
    config.ndim_z = 10
    config.distribution_z = "deterministic"  # deterministic or gaussian
    config.weight_std = 0.01
    config.weight_initializer = "Normal"
    config.nonlinearity = "relu"
    config.optimizer = "Adam"
    config.learning_rate = 0.0001
    config.momentum = 0.1
    config.gradient_clipping = 5
    config.weight_decay = 0

    # x = decoder(y, z)
    decoder = Sequential()
    decoder.add(Merge(num_inputs=2, out_size=1000, nobias=True))
    decoder.add(Activation(config.nonlinearity))
    # decoder.add(BatchNormalization(1000))
    decoder.add(Linear(None, 1000))
    decoder.add(Activation(config.nonlinearity))
    # decoder.add(BatchNormalization(1000))
    decoder.add(Linear(None, 1000))
    decoder.add(Activation(config.nonlinearity))
    # decoder.add(BatchNormalization(1000))
    decoder.add(Linear(None, config.ndim_x))
    decoder.add(tanh())

    discriminator_z = Sequential()
    discriminator_z.add(gaussian_noise(std=0.3))
    discriminator_z.add(Linear(config.ndim_z, 1000))
    discriminator_z.add(Activation(config.nonlinearity))