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

8.4.1 PTBModel中num_step的问题 #54

Closed
sfzhou5678 opened this issue Jul 11, 2017 · 3 comments
Closed

8.4.1 PTBModel中num_step的问题 #54

sfzhou5678 opened this issue Jul 11, 2017 · 3 comments

Comments

@sfzhou5678
Copy link

我参考的是1.0版本的代码,我想提一个小问题

P218说:在测试时不需要使用截断,所以可以将测试数据看成一个超长的序列。

那么按照这个思路,测试用的num_step应该是一个比较大的数,这样才符合'超长序列'的概念。
但是实际上书上采用的NUM_STEP=1,这和长序列好像并不一致。
那么这个表述和参数究竟应该如何理解?

在我目前的理解中,NUM_STEP=1在Model中就相当于每次只提供给模型长度为1的字符串,这就相当于预测单词时不提供任何上文信息直接开始预测,最终预测出来的可能会全都是词频最大的那个单词,而且经过我的实验,当train的NUM_STEP改成1是的确会让结果发生变化。

所以我想知道为什么测试时可以采用num_step=1这样的设置而不会影响结果?

@perhapszzy
Copy link
Collaborator

因为这里每次得到的final state会传入下一次调用,所以虽然截断长度为1,仍然可以保证所有的数据可以连在一起

@sfzhou5678
Copy link
Author

sfzhou5678 commented Jul 11, 2017

@perhapszzy 您好,感谢您的回复。

我还想问:因为train阶段的final_state也会传入下次调用,那train的num_steps的意义是什么呢?

因为无论多大的num_steps都可以完整的保留上文进state,那么是不是num_steps越小,loss更新的越频繁,最后的准确率越高?

@perhapszzy
Copy link
Collaborator

num_step影响梯度的计算,数字越大,一次更新累计的东西越多;数字越小,不同时刻的影响越小。

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