TensorBoard Embedding Example?

后端 未结 7 829
谎友^
谎友^ 2020-12-24 02:55

I\'m looking for a tensorboard embedding example, with iris data for example like the embedding projector http://projector.tensorflow.org/

But unfortunately i couldn

7条回答
  •  醉梦人生
    2020-12-24 03:19

    To take pretrained embeddings and visualize it on tensorboard.

    embedding -> trained embedding

    metadata.tsv -> metadata information

    max_size -> embedding.shape[0]

    import tensorflow as tf
    from tensorflow.contrib.tensorboard.plugins import projector
    
    sess = tf.InteractiveSession()
    
    with tf.device("/cpu:0"):
        tf_embedding = tf.Variable(embedding, trainable = False, name = "embedding")
    
    tf.global_variables_initializer().run()
    path = "tensorboard"
    saver = tf.train.Saver()
    writer = tf.summary.FileWriter(path, sess.graph)
    config = projector.ProjectorConfig()
    embed = config.embeddings.add()
    embed.tensor_name = "embedding"
    embed.metadata_path = "metadata.tsv"
    projector.visualize_embeddings(writer, config)
    saver.save(sess, path+'/model.ckpt' , global_step=max_size )
    

    $ tensorboard --logdir="tensorboard" --port=8080

提交回复
热议问题