Esempio n. 1
0
def main():
	images, labels = dataset.load_test_images()
	num_scatter = len(images)

	y_distribution, z = aae.encode_x_yz(images, apply_softmax=False, test=True)
	y = aae.argmax_onehot_from_unnormalized_distribution(y_distribution)
	representation = aae.to_numpy(aae.encode_yz_representation(y, z, test=True))

	plot.scatter_labeled_z(representation, labels, dir=args.plot_dir)
Esempio n. 2
0
def main():
	# load MNIST images
	images, labels = dataset.load_test_images()

	# config
	config = aae.config
	num_scatter = len(images)

	x, _, label_ids = dataset.sample_labeled_data(images, labels, num_scatter, config.ndim_x, config.ndim_y)
	z = aae.to_numpy(aae.encode_x_z(x, test=True))
	visualizer.plot_labeled_z(z, label_ids, dir=args.plot_dir)
def main():
    # load MNIST images
    images, labels = dataset.load_test_images()

    # config
    config = aae.config

    # settings
    num_analogies = 10
    pylab.gray()

    # generate style vector z
    x = dataset.sample_unlabeled_data(images,
                                      num_analogies,
                                      config.ndim_x,
                                      binarize=False)
    _, z = aae.encode_x_yz(x, apply_softmax=True)
    z = aae.to_numpy(z)

    # plot original image on the left
    for m in xrange(num_analogies):
        pylab.subplot(num_analogies, config.ndim_y + 2, m * 12 + 1)
        pylab.imshow(x[m].reshape((28, 28)), interpolation="none")
        pylab.axis("off")

    all_y = np.identity(config.ndim_y, dtype=np.float32)
    for m in xrange(num_analogies):
        # copy z as many as the number of classes
        fixed_z = np.repeat(z[m].reshape(1, -1), config.ndim_y, axis=0)
        gen_x = aae.to_numpy(aae.decode_yz_x(all_y, fixed_z))
        # plot images generated from each label
        for n in xrange(config.ndim_y):
            pylab.subplot(num_analogies, config.ndim_y + 2, m * 12 + 3 + n)
            pylab.imshow(gen_x[n].reshape((28, 28)), interpolation="none")
            pylab.axis("off")

    fig = pylab.gcf()
    fig.set_size_inches(num_analogies, config.ndim_y)
    pylab.savefig("{}/analogy.png".format(args.plot_dir))
def main():
    # load MNIST images
    images, labels = dataset.load_test_images()

    # config
    config = aae.config
    num_scatter = len(images)

    x, _, labels = dataset.sample_labeled_data(images, labels, num_scatter,
                                               config.ndim_x, config.ndim_y)
    y_distribution, z = aae.encode_x_yz(x, apply_softmax=False, test=True)
    y = aae.argmax_onehot_from_unnormalized_distribution(y_distribution)
    representation = aae.to_numpy(aae.encode_yz_representation(y, z,
                                                               test=True))

    visualizer.plot_labeled_z(representation, labels, dir=args.plot_dir)
Esempio n. 5
0
except:
	pass

images, labels = dataset.load_test_images()
config = aae.config
num_clusters = config.ndim_y
num_plots_per_cluster = 11
image_width = 28
image_height = 28
ndim_x = image_width * image_height
pylab.gray()

# plot cluster head
head_y = np.identity(config.ndim_y, dtype=np.float32)
zero_z = np.zeros((config.ndim_y, config.ndim_z), dtype=np.float32)
head_x = aae.to_numpy(aae.decode_yz_x(head_y, zero_z, test=True))
head_x = (head_x + 1.0) / 2.0
for n in xrange(num_clusters):
	pylab.subplot(num_clusters, num_plots_per_cluster + 2, n * (num_plots_per_cluster + 2) + 1)
	pylab.imshow(head_x[n].reshape((image_width, image_height)), interpolation="none")
	pylab.axis("off")

# plot elements in cluster
counts = [0 for i in xrange(num_clusters)]
indices = np.arange(len(images))
np.random.shuffle(indices)
batchsize = 500

i = 0
x_batch = np.zeros((batchsize, ndim_x), dtype=np.float32)
for n in xrange(len(images) / batchsize):
Esempio n. 6
0
def main():
	images, labels = dataset.load_test_images()
	num_scatter = len(images)
	x, _, label_ids = dataset.sample_labeled_data(images, labels, num_scatter)
	z = aae.to_numpy(aae.encode_x_z(x, test=True))
	plot.scatter_labeled_z(z, label_ids, dir=args.plot_dir)