4

I ran this code snippet:

import os
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
from tensorflow.contrib.tensorboard.plugins import projector

LOG_DIR = 'logs'
metadata = os.path.join(LOG_DIR, 'metadata.tsv')

mnist = input_data.read_data_sets('MNIST_data')
input_1 = mnist.train.next_batch(10)
images = tf.Variable(input_1[0], name='images')

with open(metadata, 'w') as metadata_file:
    for row in input_1[1]:
        metadata_file.write('%d\n' % row)

with tf.Session() as sess:
    saver = tf.train.Saver([images])

    sess.run(images.initializer)
    saver.save(sess, os.path.join(LOG_DIR, 'images.ckpt'))

    config = projector.ProjectorConfig()
    # One can add multiple embeddings.
    # Link this tensor to its metadata file (e.g. labels).
    embedding = config.embeddings.add()
    embedding.tensor_name = images.name

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

And after this, I opened tensorboard embedding tab and it showed parsing metadata. However, it kept on loading that way endlessly. I tried another code and in that case, it kept loading on fetching spite Image. Is there something wrong with my tensorboard?

1 Answer 1

4

The problem is that TensorBoard couldn't find your metadata file, because it looks for the metadata file relative to the directory that you have specified with your '--logdir' parameter of the 'tensorboard' command.

So if you are opening TensorBoard with 'tensorboard --logdir logs', it will look for the metadata file in 'logs/logs/metadata.tsv'.

A possible fix for your code is to replace this line

embedding.metadata_path = metadata  

with this one:

 embedding.metadata_path = 'metadata.tsv'

In general, in order to debug errors TensorBoard you have to look at the response of the error messages in your browser console when looking at TensorBoard.

Not the answer you're looking for? Browse other questions tagged or ask your own question.