如何使用TensorBoard針對PyTorch的embedding輸出進行2D或3D的T-SNE視覺化?

import tensorboardX as tbx     # 本範例會使用到tensorboardX套件
writer = tbx.SummaryWriter()
  • mat (torch. Tensor or numpy.array): 一個矩陣,每行代表特徵空間的一個數據點。mat的維度是(N, D),其中N為圖片數量;D為特徵維度
  • metadata (list or torch. Tensor or numpy.array, optional): 一個一維清單,mat 中每行數據的 label,大小應和 mat 行數相同
  • label_img (torch. Tensor, optional): 一個形如 NxCxHxW 的張量,對應 mat 每一行數據顯示出的圖像,N 應和 mat 行數相同。N*W開根號後須小於或等於8192才能被Tensorboard正常載入,否則會出現Error: Sprite image of dimensions 16384px x 16384px exceeds maximum dimensions 8192px x 8192px
import tensorboardX as tbx
writer = tbx.SummaryWriter()
writer.add_embedding(mat=features, metadata=labels, label_img=label_imgs)
writer.close()
tensorboard --logdir=runs
1. 卡再Fetching sprite image…
[1]tensorboard fetching sprite image_UI_Shero的专栏-CSDN博客
[2]Tensorboard parsing metadata or fetching sprite images takes forever - Stack Overflow調整projector_config.pbtxt中的路徑:
embeddings {
tensor_name: "default:00000"
tensor_path: "00000/default/tensors.tsv"
metadata_path: "00000/default/metadata.tsv"
sprite {
image_path: "00000/default/sprite.png"
single_image_dim: 112
single_image_dim: 112
}
}

--

--

--

Machine Learning | Deep Learning | https://linktr.ee/yanwei

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yanwei Liu

Yanwei Liu

Machine Learning | Deep Learning | https://linktr.ee/yanwei

More from Medium

All About Pooling Layers for Convolutional Neural Networks (CNN)

Brain Tumor Detection & Transfer Learning using VGG16

Quantization In Neural Networks

Invasive Species Monitoring: Using a Convolutional Neural Network to identify hydrangeas