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

训练+预测输入正常,单独预测输出就乱七八糟,请问这是什么原因? #9

Open
callwhl opened this issue Oct 29, 2017 · 6 comments

Comments

@callwhl
Copy link

callwhl commented Oct 29, 2017

单独使用
checkpoint = tf.train.latest_checkpoint('checkpoints')
samp = sample(checkpoint, 2000, lstm_size, prime="The")
print(samp)
输出的就乱七八糟

@92xianshen
Copy link

遇到了同样的问题~

@92xianshen
Copy link

还再纠结这个问题么?

@92xianshen
Copy link

@callwhl 问题解决了么?

@spiderHJS
Copy link

因为词汇表在训练的时候和预测时候使用的不是同一个,因为vocab是通过set建立的,set中的元素顺序不一样,所以在预测时候生成类似于乱码的文本。解决方法是,在训练的时候将得到的词汇表存储下来,在预测的时候使用训练时候的词汇表。

@am9x
Copy link

am9x commented Dec 19, 2018

在训练的时候将得到的词汇表存储下来,在预测的时候使用训练时候的词汇表。

注意:存的时候如果直接pkl.dump那个vocab set,继续会有同样问题
应该pkl.dump(list(vocab))

@RangHeng
Copy link

请问怎么把训练和测试代码分开。我用的pycharm,不是ipython,.

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

5 participants