Skip to content

Instantly share code, notes, and snippets.

@thepurpleowl
Last active July 17, 2022 15:11
Show Gist options
  • Save thepurpleowl/a1caccc7554a0f38786f36a933ec34ce to your computer and use it in GitHub Desktop.
Save thepurpleowl/a1caccc7554a0f38786f36a933ec34ce to your computer and use it in GitHub Desktop.
Visualize embeddings in tensorboard: using Tensorboard projector
import numpy as np
import tensorboard as tb
from torch.utils.tensorboard import SummaryWriter
import tensorflow as tf
tf.io.gfile = tb.compat.tensorflow_stub.io.gfile
writer = SummaryWriter()
writer.add_embedding(<embeddings>, <labels>) # (doc_vector, Y_true[:TRAIN_SIZE_EVALS[-3]])
writer.close()
%load_ext tensorboard
%tensorboard --logdir=runs
# Taken from this answer: https://stackoverflow.com/a/41177133
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment