Created
March 21, 2021 08:01
-
-
Save merutak/9432e0cfeca8f4cfc9fd6210fa1081ef to your computer and use it in GitHub Desktop.
import numpy matrix to display in tensorboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from tensorboard.plugins import projector | |
import math | |
from django.conf import settings | |
log_dir='/logs/abcd/' | |
if not os.path.exists(log_dir): | |
os.makedirs(log_dir) | |
# Save Labels separately on a line-by-line manner. | |
with open(os.path.join(log_dir, 'metadata.tsv'), "w") as f: | |
f.write(f"name\tCategory\n") | |
for name, category in my_point_names: 10)) | |
f.write(f"{name}\t{category}\n") | |
weights = tf.Variable(embedding) # assumed to be in the same order as 'my_point_names' | |
checkpoint = tf.train.Checkpoint(embedding=weights) | |
checkpoint.save(os.path.join(log_dir, f"embedding.ckpt")) | |
config = projector.ProjectorConfig() | |
embedding = config.embeddings.add() | |
embedding.tensor_name = f"embedding/.ATTRIBUTES/VARIABLE_VALUE" | |
embedding.metadata_path = 'metadata.tsv' | |
projector.visualize_embeddings(log_dir, config) | |
%tensorboard --logdir /logs/abcd/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment