Visualizing multiple embedding With Tensorflow


I would like to visualize my data based on multiple tensor variables, that is, based on different embedding variables. In other words what I need to do is the following:

I need to store the 100 dimensional vector (image feature/embeddings) into 5 different variables. Then I need to visualize my data based on the 5 different variables. That is, I need to visualize my data based on the first 20 features, and based on the second 20 features and so on…

While I was looking into the embedding visualization tutorial on, they say that we can add multiple embeddings. This is what I am looking for.

How to do this in tensorflow?

Any help is much appreciated!!


So the reason it didn’t work is because I was trying to divide the 100 dimensional embedding into 100 different variables. And that did not work. So when I divided my embeddings into 5 different parts, that is, dividing them into 5 different variables, it worked out. Below is my code:

import numpy as np
import tensorflow as tf
from tensorflow.contrib.tensorboard.plugins import projector

    'C:/Users/user/PycharmProjects/VariationalAutoEncoder/' \

feature_vectors = np.loadtxt('features.txt')
feature_vectors = feature_vectors[:5329]


sub_features = []
for i in range(20):
    features = tf.Variable(feature_vectors[:, 5 * i: 5 * (i + 1)], name=('features' + str(i)))

with tf.Session() as sess:

    saver = tf.train.Saver(), LOG_DIR)

    config = projector.ProjectorConfig()
    for i in range(20):
        embedding = config.embeddings.add()
        embedding.tensor_name = sub_features[i].name

        embedding.sprite.image_path = \
        embedding.sprite.single_image_dim.extend([112, 112])

    # Saves a config file that TensorBoard will read during startup.
    projector.visualize_embeddings(tf.summary.FileWriter(LOG_DIR), config)

Answered By – I. A

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published