python - 无法打开 TensorBoard 以仅使用矢量数据从 Google Cloud DataLab 嵌入可视化

标签 python tensorflow tensorboard google-cloud-datalab

我计划在中进行嵌入可视化 TensorBoard Projector 使用来自 Google Cloud DataLab 笔记本的准备好的矢量数据(不是由 TensorFlow 训练的数据)(而不是在网络浏览器中上传 TSV 文件)。

我已经尝试过 this tutorial 中提供的代码:

from tensorflow.contrib.tensorboard.plugins import projector

LOG_DIR='test_log'

# Create randomly initialized embedding weights which will be trained.
N = 10000 # Number of items (vocab size).
D = 200 # Dimensionality of the embedding.
embedding_var = tf.Variable(tf.random_normal([N,D]), name='word_embedding')

# Format: tensorflow/tensorboard/plugins/projector/projector_config.proto
config = projector.ProjectorConfig()

# You can add multiple embeddings. Here we add only one.
embedding = config.embeddings.add()
embedding.tensor_name = embedding_var.name
# Link this tensor to its metadata file (e.g. labels).
# embedding.metadata_path = os.path.join(LOG_DIR, 'metadata.tsv')

# Use the same LOG_DIR where you stored your checkpoint.
summary_writer = tf.summary.FileWriter(LOG_DIR)

# The next line writes a projector_config.pbtxt in the LOG_DIR. TensorBoard will
# read this file during startup.
projector.visualize_embeddings(summary_writer, config)

LOG_DIR 是与笔记本文件位于同一文件夹中的空文件夹。

由于嵌入可视化不需要元数据,因此我没有设置 embedding.metadata_path

然后我运行代码:

from google.datalab.ml import TensorBoard as tb
tb.start('test_log')

可以打开TensorBoard的新页面,但它说:

No checkpoint was found.

当我切换到投影仪 View 时。

但是如上面的代码所示,数据是随机创建的,不应该有任何检查点文件。

此外,在下一阶段,我需要使用自己的矢量数据进行嵌入可视化,这些数据未经 Tensorflow 训练,没有任何检查点文件。

在网络浏览器中使用投影仪时,只需要矢量数据的 TSV 文件,不需要任何检查点文件。

所以问题是:仅使用矢量数据集在 Google Cloud DataLab 的 TensorBoard Projector 中进行嵌入可视化的正确方法是什么?

谢谢。

最佳答案

查看该教程,您需要运行代码来定期保存检查点。这些应该是张量板上显示的信息的基础。

saver = tf.train.Saver()
saver.save(session, os.path.join(LOG_DIR, "model.ckpt"), step)

关于python - 无法打开 TensorBoard 以仅使用矢量数据从 Google Cloud DataLab 嵌入可视化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55813661/

相关文章:

python - 没有名为 examples.tutorials.mnist 的模块

tensorflow - 模块 'tensorflow' 没有属性 'get_default_graph'

python - 在找到 GPU 后,如何强制 tensorflow 忘记它?

python - 更新 Tensorboard,同时使用 conda 保持 Tensorflow 旧版

python - 使用 Keras Tensorflow 2.0 获取梯度

python - Python 以什么顺序解析函数? (为什么 string.join(lst.append ('a' )) 失败了?)

python - 使用 SQLAlchemy 在关联表中插入数据时出现 IntegrityError

python - 使用 Flask-Migrate 在多个分支上工作

python - 在卡住图上使用 optimize_for_inference.py 后使用模型时出错

python - 模拟父类 __init__ 方法