Esempio n. 1
0
        'num_hid': 20,
        'num_hid_dec': 100,
        'output_dist': 'Bernoulli',  # Bernoulli or Gaussian
        # 'output_dist': 'Gaussian',
        'non_linear': 'tf.nn.relu',
        # 'non_linear': 'tf.nn.tanh',
        'weight_decay': 5e-5
    }

    # Train loop options
    loop_config = {
        'num_steps': args.num_steps,
        'steps_per_ckpt': args.steps_per_ckpt
    }

    dataset = mnist.read_data_sets("../MNIST_data/", one_hot=True)
    m = get_train_model(opt)
    sess = tf.Session()
    sess.run(tf.initialize_all_variables())
    saver = tf.train.Saver(tf.all_variables())

    task_name = 'vae_mnist_half'
    time_obj = datetime.datetime.now()
    model_id = timestr = '{}-{:04d}{:02d}{:02d}{:02d}{:02d}{:02d}'.format(
        task_name, time_obj.year, time_obj.month, time_obj.day,
        time_obj.hour, time_obj.minute, time_obj.second)
    results_folder = args.results
    logs_folder = args.logs
    exp_folder = os.path.join(results_folder, model_id)
    exp_logs_folder = os.path.join(logs_folder, model_id)
Esempio n. 2
0
    filter_x = (1 / np.sqrt(np.exp(lg_var)) / np.sqrt(2 * np.pi) *
                np.exp(-0.5 * (span_x - mu_x) *
                       (span_x - mu_x) / np.exp(lg_var)))
    # [H, F]
    filter_y = (1 / np.sqrt(np.exp(lg_var)) / np.sqrt(2 * np.pi) *
                np.exp(-0.5 * (span_y - mu_y) *
                       (span_y - mu_y) / np.exp(lg_var)))

    read = filter_y.transpose().dot(img).dot(filter_x)

    return read


if not os.path.exists('img.npy'):
    from data_api import mnist
    dataset = mnist.read_data_sets("../MNIST_data/", one_hot=True)
    img = dataset.train.images[0].reshape([im_height, im_width])
    np.save('img.npy', img)
else:
    img = np.load('img.npy')
    # Controller variables.
    num_img = 8
    f, axarr = plt.subplots(2, num_img)

    for ii in xrange(num_img):
        gg_x = 0.0
        gg_y = 0.0
        ddelta = 0.1 * (ii + 1)
        log.info('ddelta: {}'.format(ddelta))
        lg_var = 0.01