tensorflow-triplet-loss icon indicating copy to clipboard operation
tensorflow-triplet-loss copied to clipboard

How to use the projector?

Open FSet89 opened this issue 7 years ago • 4 comments

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?

FSet89 avatar Nov 12 '18 15:11 FSet89

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

omoindrot avatar Nov 15 '18 09:11 omoindrot

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

FSet89 avatar Nov 15 '18 13:11 FSet89

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])

batrlatom avatar Mar 19 '19 20:03 batrlatom

So it's in the metadata tsv file that you need to save: https://github.com/omoindrot/tensorflow-triplet-loss/blob/fc698369bb6c9acdc9f0e9e1ea00de0ddf782f12/visualize_embeddings.py#L83-L90

    # 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

omoindrot avatar Mar 28 '19 16:03 omoindrot