avatarWired Wisdom

Summary

The provided content is a tutorial on using Tensorboard's Embedding Projector to visualize high-dimensional data, such as word embeddings and image feature vectors, through dimensionality reduction techniques like t-SNE or PCA.

Abstract

The article delves into the capabilities of Tensorflow's visualization toolkit, TensorBoard, with a focus on the Embedding Projector feature. It explains how TensorBoard aids in the visualization of machine learning experiments, including tracking metrics, visualizing model graphs, and plotting high-dimensional data to lower dimensions for better understanding. The tutorial outlines two methods for using the Embedding Projector: direct upload via a web interface and local installation with Tensorflow. It provides detailed instructions on formatting and uploading feature vectors and metadata for visualization, and it emphasizes the importance of understanding t-SNE for effective use of the tool. The article also includes examples and screenshots to guide users through the process of visualizing their own data.

Opinions

  • The author believes TensorBoard is an essential tool for various machine learning tasks, including visualization of metrics, model graphs, and high-dimensional data.
  • The article suggests that the Embedding Projector is user-friendly, offering both an easy direct upload method and a more customizable local tensorboard approach.
  • The author values the versatility of TensorBoard, noting its wide range of visualization capabilities beyond embedding projection.
  • There is an emphasis on the importance of proper data formatting (tsv for feature vectors and metadata) to ensure accurate visualization mapping.
  • The author encourages readers to explore further resources, such as a guide on using t-SNE effectively, indicating a commitment to comprehensive understanding and best practices in data visualization.
  • The overall tone conveys that mastering the Embedding Projector can significantly enhance the interpretability of complex machine learning models.

Tensorboard Embedding Projector — Visualizing High Dimensional Vectors with t-SNE or PCA.

Tutorial on Embedding Projector with our own feature vector.

Tensorflow is a one of the most popular free and open source machine learning library which helps you to do all kind of machine learning and deep learning projects. It can be used for various tasks including training, inferencing, visualising ML and DL models. It also comes up with wide variety of pretrained models.

Now TensorBoard is the visualization toolkit for tensorflow. It helps us for the visualization of various machine learning experiements.

What can we do with TensorBoard?

  • TB helps us to tracks various metrics such as loss and accuracy for ML training.
  • Model Graphs can be visualized.
  • We can view histograms of weights, biases, or other tensors.
  • Plot high dimensional embedding to a lower dimensional space. To visualize and understands it
  • Displaying images, text, and audio data
  • More n More..
Source

In this story as the title said we will be focusing on using Tensorboard embedding projector for our own use case with our own feature vector.

Before that let us see some examples of visualizations for word embedding and image feature vectors.

Word2Vec Embeddings Example

Generated By Author

MNIST with Images example.

Generated By Author

There are two ways you can use Embedding projector with tensorboard.

1) Direct Upload [EASY METHOD] You can upload the feature vector and metadata in the format that is specified in this link. Here there will be a load button.

Click on the load button <> Generate By Author

Now you can load the data that you want to visualize. Now we have to understand what is the format of loading the data. In order to visualize you need to upload the feature vector in a tsv format. Each line represents a feature vector with separated by ‘\t’ space. Then you have to add the metadata in a tsv format as well. The order of feature vectors and tags should be same that is how it maps the tags for visualization. Now if you want to give the class also then in the metadata with a tab separated column you can also specify the class. But if you add two columns it is necessary that you should add column names.

Generated By Author

2) Using local tensorboard

Using tensorboard Embedding projector on local machine, first of all you need to install tensorflow.

Now you need to import and load necessary packages and extensions.

Generated By Author

Here we import tensorboard extension. After that we load projector from tensorflow.plugins.

Now you have to set up a logs directory, so Tensorboard knows where to look for files.

For that you need metadata.tsv and also features.txt (vectors in txt format). You can make both of this whatever way you prefer.

Generated By Author

Here I am creating a log directory called test and inside test, I am copying metadata.tsv which I already created out of this notebook contains the metadata and features.txt which contains the feature vectors. For metadata it is the same as the above case on how you can make it. But for the features.txt I just appended every features in order to a list and saved it using np.savetxt function. Check below.

Generated By Author

Now atlast you need to run the tensorboard. That can be done with the below command.

Generated By Author

You can see the embedding projector on your notebook cell. But for better view go to your browser and look for localhost:6006 . If it shows some error just try to reload the dashboard it may help.

Now to use the t-SNE plot effectively checkout this link below.

I hope this story helped you for better understanding on how to use tensorboard. Thanks for reading and Thanks for your time.

Tensorboard
Embedding Projector
TensorFlow
Visualization
Dimensionality Reduction
Recommended from ReadMedium