예제 #1
0
def plot_cluster_head():
	parser = argparse.ArgumentParser()
	parser.add_argument("--model", "-m", type=str, default="model.hdf5")
	args = parser.parse_args()

	model = Model()
	assert model.load(args.model)

	all_y = np.identity(10, dtype=np.float32)
	head = model.cluster_head(all_y).data
	labels = [i for i in range(10)]
	plot.scatter_labeled_z(head, labels, "cluster_head.png")
예제 #2
0
def plot_mapped_cluster_head():
	parser = argparse.ArgumentParser()
	parser.add_argument("--model", "-m", type=str, default="model.hdf5")
	args = parser.parse_args()

	model = Model()
	assert model.load(args.model)

	identity = np.identity(model.ndim_y, dtype=np.float32)
	mapped_head = model.linear_transformation(identity)

	labels = [i for i in range(10)]
	plot.scatter_labeled_z(mapped_head.data, labels, "cluster_head.png")
예제 #3
0
def plot_scatter():
	parser = argparse.ArgumentParser()
	parser.add_argument("--model", "-m", type=str, default="model.hdf5")
	args = parser.parse_args()

	dataset_train, dataset_test = chainer.datasets.get_mnist()
	images_train, labels_train = dataset_train._datasets
	images_test, labels_test = dataset_test._datasets

	model = Model()
	assert model.load(args.model)

	# normalize
	images_train = (images_train - 0.5) * 2
	images_test = (images_test - 0.5) * 2

	with chainer.no_backprop_mode() and chainer.using_config("train", False):
		z = model.encode_x_z(images_test).data
	plot.scatter_labeled_z(z, labels_test, "scatter_gen.png")
예제 #4
0
def plot_scatter():
    parser = argparse.ArgumentParser()
    parser.add_argument("--model", "-m", type=str, default="model.hdf5")
    args = parser.parse_args()

    dataset_train, dataset_test = chainer.datasets.get_mnist()
    images_train, labels_train = dataset_train._datasets
    images_test, labels_test = dataset_test._datasets

    model = Model()
    assert model.load(args.model)

    # normalize
    images_train = (images_train - 0.5) * 2
    images_test = (images_test - 0.5) * 2

    with chainer.no_backprop_mode() and chainer.using_config("train", False):
        z = model.encode_x_yz(images_test)[1].data
    plot.scatter_labeled_z(z, labels_test, "scatter_gen.png")
예제 #5
0
def plot_representation():
	parser = argparse.ArgumentParser()
	parser.add_argument("--model", "-m", type=str, default="model.hdf5")
	args = parser.parse_args()

	dataset_train, dataset_test = chainer.datasets.get_mnist()
	images_train, labels_train = dataset_train._datasets
	images_test, labels_test = dataset_test._datasets

	model = Model()
	assert model.load(args.model)

	# normalize
	images_train = (images_train - 0.5) * 2
	images_test = (images_test - 0.5) * 2

	with chainer.no_backprop_mode() and chainer.using_config("train", False):
		y_onehot, z = model.encode_x_yz(images_test, apply_softmax_y=True)
		representation = model.encode_yz_representation(y_onehot, z).data
	plot.scatter_labeled_z(representation, labels_test, "scatter_r.png")
예제 #6
0
def plot_representation():
	parser = argparse.ArgumentParser()
	parser.add_argument("--model", "-m", type=str, default="model.hdf5")
	args = parser.parse_args()

	dataset_train, dataset_test = chainer.datasets.get_mnist()
	images_train, labels_train = dataset_train._datasets
	images_test, labels_test = dataset_test._datasets

	model = Model()
	assert model.load(args.model)

	# normalize
	images_train = (images_train - 0.5) * 2
	images_test = (images_test - 0.5) * 2

	with chainer.no_backprop_mode() and chainer.using_config("train", False):
		y_onehot, z = model.encode_x_yz(images_test, apply_softmax_y=True)
		representation = model.encode_yz_representation(y_onehot, z).data
	plot.scatter_labeled_z(representation, labels_test, "scatter_r.png")