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

关于数据预处理时,对长度不同的句子padding的问题 #48

Open
hningbo opened this issue Jan 11, 2020 · 4 comments
Open

Comments

@hningbo
Copy link

hningbo commented Jan 11, 2020

你好~
在数据预处理时,如果句子过短的话需要在句尾填充0,那在将填充的部分转换为word embedding的时候是直接找0的那个embedding吗?如果是这样的话不会导致学习到错误的特征吗?

@ShomyLiu
Copy link
Owner

对,补全0并寻找0对应的Embedding, 一般情况下,这样是没问题的。 如果觉得有问题的话,可以使用Mask Padding,就是记录0的index,然后直接mask掉。这样就不会计算0了。不过会加大计算量。

@hningbo
Copy link
Author

hningbo commented Jan 11, 2020

那我还有两个问题~

  • 如果mask掉以后,后面的卷积、max pooling 这些操作是不是不能用向量化直接操作了,需要循环处理,这样效率就比较低了?
  • 那对于position embedding就是按顺序往后填充吗?

@ShomyLiu
Copy link
Owner

(1)一般Mask的时候 卷积正常计算呀,pooling的时候根据index进行mask。而且绝大部分的mask都不用循环,而是用其他整合为向量运算。
(2)mask不影响 position embedding呀 即使填充了0,也没有关系,反正不会影响其他words的position

@hningbo
Copy link
Author

hningbo commented Jan 11, 2020

哦哦!是这样,明白了!想了好久还能这样实现,谢谢了😀!

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