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

问一下关于字符长度的问题 #24

Closed
ww451575464 opened this issue Jan 24, 2019 · 4 comments
Closed

问一下关于字符长度的问题 #24

ww451575464 opened this issue Jan 24, 2019 · 4 comments

Comments

@ww451575464
Copy link

text = torch.LongTensor(opt.batchSize * 5)
text_rev = torch.LongTensor(opt.batchSize * 5)
length = torch.IntTensor(opt.batchSize)

你好,问一下,在这几行,5的含义指的是字符的最大长度么,如果我的字符长度超过5,是否需要更改为实际长度
length在网络中的attention中使用到,具体作用是什么啊

@Canjie-Luo
Copy link
Owner

1)这是网络初始化变量的过程,与PyTorch动态申请显存的过程无关。如果你的字符长度非常长,超过了5,那么PyTorch将会继续扩大显存,所以不需要担心这个问题;
2)length被用于attention的原因:加速训练和评估过程,只循环到该batch中最长的字符长度就停下。这个过程对于英文单词级别的任务的评估是没有问题的,但是请注意,本开源代码没有针对其他任务做优化,例如中文任务中计算AR的方式。

@ww451575464
Copy link
Author

非常感谢!还想问一下,字符长度和识别的准确率之间是否有必然的联系,您这边在训练的时候,有发现最佳长度是多少个字符么

@Canjie-Luo
Copy link
Owner

训练的字符长度和测试准确率没有必然关系。所有训练的单词来源于90K字典,在读取时末尾加入了终止符“$”,训练模型预测“$”表示结束。例如,在demo中,我们只显示了终止符前的预测结果。所以,长度这个因素在这个任务中不是关键变量。

@ww451575464
Copy link
Author

好的,,谢谢!

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