Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何只打印句向量 #7

Closed
wingsyuan opened this issue Mar 12, 2019 · 2 comments
Closed

如何只打印句向量 #7

wingsyuan opened this issue Mar 12, 2019 · 2 comments

Comments

@wingsyuan
Copy link

wingsyuan commented Mar 12, 2019

您好,看了您代码后,受益匪浅,谢谢大佬的辛勤付出和分享!

这里能否问一个问题,我想打印出所生成的句向量,如下:

  with tf.gfile.GFile(tmp_file, 'wb') as f:
        f.write(tmp_g.SerializeToString())
        print(tmp_g.SerializeToString())

但看起来它非常大,请问是什么原因呢,每一个句子都可以转化成固定长度的词向量对吗,它的长度有多大?如何只打印出句向量呢?

@wingsyuan wingsyuan changed the title 句向量的大小 如何只打印句向量 Mar 12, 2019
@terrifyzhao
Copy link
Owner

隐层的节点是768个,所以生成的句向量是768维的,每一个句子生成的句向量都是768维,更多细节请参阅我的blog

@wingsyuan
Copy link
Author

wingsyuan commented Mar 12, 2019

@terrifyzhao
请问,是打印下面的output_tensor或pooled么,如果是要怎么打印出来,用各种方法都报错。。

以下代码是句向量的生成方法,可以理解为做了一个卷积的操作,但是没有把结果相加, 卷积核是

input_mask
pooled = masked_reduce_mean(encoder_layer, input_mask)
pooled = tf.identity(pooled, 'final_encodes')
output_tensors = [pooled]
#with tf.Session():
# print(output_tensors.eval())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants