projector_plugin_test.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:tensorboard 作者: tensorflow 项目源码 文件源码
def _GenerateProjectorTestData(self):
    config_path = os.path.join(self.log_dir, 'projector_config.pbtxt')
    config = projector_config_pb2.ProjectorConfig()
    embedding = config.embeddings.add()
    # Add an embedding by its canonical tensor name.
    embedding.tensor_name = 'var1:0'

    with tf.gfile.GFile(os.path.join(self.log_dir, 'bookmarks.json'), 'w') as f:
      f.write('{"a": "b"}')
    embedding.bookmarks_path = 'bookmarks.json'

    config_pbtxt = text_format.MessageToString(config)
    with tf.gfile.GFile(config_path, 'w') as f:
      f.write(config_pbtxt)

    # Write a checkpoint with some dummy variables.
    with tf.Graph().as_default():
      sess = tf.Session()
      checkpoint_path = os.path.join(self.log_dir, 'model')
      tf.get_variable('var1', [1, 2], initializer=tf.constant_initializer(6.0))
      tf.get_variable('var2', [10, 10])
      tf.get_variable('var3', [100, 100])
      sess.run(tf.global_variables_initializer())
      saver = tf.train.Saver(write_version=tf.train.SaverDef.V1)
      saver.save(sess, checkpoint_path)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号