tensorflow / tensorflow/tensorboard

Uncaught exception in projector for non-2D tensor

Open
#947 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

plugin:projector type:bug
Dominant language
TypeScript
Stars
7.2k
Forks
1.7k
Avg merge
4d 22h
Merged PRs (30d)
1

Description

If the tensor to-be-visualized in the embedding projector is not 2D, there appears to be an uncaught exception (from inspecting the JavaScript Console). This took me awhile to debug (I had singleton dimensions in my tensor). A friendly error message would be helpful.

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

x = np.random.rand(100, 256)
x = np.expand_dims(x, 1)  # will trigger the uncaught exception

x_var = tf.Variable(x, name='x')

config = projector.ProjectorConfig()
embedding = config.embeddings.add()
embedding.tensor_name = x_var.name

summary_writer = tf.summary.FileWriter('log')
saver = tf.train.Saver([x_var])

sess = tf.Session()
sess.run(x_var.initializer)
saver.save(sess, '{}/model.ckpt'.format('log'))
projector.visualize_embeddings(summary_writer, config)

From the JavaScript Console:

Uncaught TypeError: Cannot read property 'length' of undefined
    at (index):147378
    at Array.filter (<anonymous>)
    at (index):147376
    at XMLHttpRequest.xhr.onload ((index):143674)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the embedding projector and reproduce the failure using the provided Python example, then inspect the browser JavaScript Console for the uncaught exception. Trace the projector's handling of non-2D tensors and add a friendly error message; done means the example no longer produces an uncaught exception and clearly explains the invalid tensor shape.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, typescript
Domain
data-visualization, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.