Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use the projector? #29

Open
FSet89 opened this issue Nov 12, 2018 · 4 comments
Open

How to use the projector? #29

FSet89 opened this issue Nov 12, 2018 · 4 comments

Comments

@FSet89
Copy link

FSet89 commented Nov 12, 2018

During training, the projector shows some points in the PCA space. Every point has the same color. What do they represent? What can I infer about the training process from this graph?

@omoindrot
Copy link
Owner

Normally you should be able to color by label if you provided the labels.

For MNIST, you will have one color for each digit.

Maybe this post can help your understanding? https://stackoverflow.com/questions/40849116/how-to-use-tensorboard-embedding-projector

@FSet89
Copy link
Author

FSet89 commented Nov 15, 2018

Thank you. Can you point me out where in your code you add the images for the projector summary?

@batrlatom
Copy link

It is in the visualize_embeddings.py
I think it is here


embedding.sprite.image_path = pathlib.Path(args.sprite_filename).name
    embedding.sprite.single_image_dim.extend([28, 28])

@omoindrot
Copy link
Owner

So it's in the metadata tsv file that you need to save:

# Specify where you find the metadata
# Save the metadata file needed for Tensorboard projector
metadata_filename = "mnist_metadata.tsv"
with open(os.path.join(eval_dir, metadata_filename), 'w') as f:
for i in range(params.eval_size):
c = labels[i]
f.write('{}\n'.format(c))
embedding.metadata_path = metadata_filename

    # Specify where you find the metadata
    # Save the metadata file needed for Tensorboard projector
    metadata_filename = "mnist_metadata.tsv"
    with open(os.path.join(eval_dir, metadata_filename), 'w') as f:
        for i in range(params.eval_size):
            c = labels[i]
            f.write('{}\n'.format(c))
    embedding.metadata_path = metadata_filename

If you want to visualize other colors, you can add it in the tsv file as a new column like this:

    metadata_filename = "mnist_metadata.tsv"
    with open(os.path.join(eval_dir, metadata_filename), 'w') as f:
        f.write("label\tother")
        for i in range(params.eval_size):
            c = labels[I]
            other = c % 2
            f.write('{}\t{}\n'.format(c, other))
    embedding.metadata_path = metadata_filename

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants