model.py 文件源码

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

项目:tensorflow_tutorial 作者: lpty 项目源码 文件源码
def gen(self):
        embedding, _ = self.embedding()
        saver = tf.train.Saver()
        with tf.Session() as sess:
            sess.run(tf.global_variables_initializer())
            saver.restore(sess, tf.train.latest_checkpoint('.'))
            embedding = sess.run(embedding)
        # ???
        data = embedding[:self.viz_words, :]
        # ???????
        tsne = TSNE(n_components=2, init='pca', random_state=0)
        embed_tsne = tsne.fit_transform(data)
        # ??
        plt.subplots(figsize=(10, 10))
        for idx in range(self.viz_words):
            plt.scatter(*embed_tsne[idx, :], color='steelblue')
            plt.annotate(self.train_text.int_to_vocab[idx], (embed_tsne[idx, 0], embed_tsne[idx, 1]), alpha=0.7)
        plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号