We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
这个代码的主要目的是预测下一个char。
def sample(self, n_samples, prime, vocab_size): samples = [c for c in prime] sess = self.session new_state = sess.run(self.initial_state) preds = np.ones((vocab_size, )) # for prime=[] for c in prime: x = np.zeros((1, 1)) # 输入单个字符 x[0, 0] = c feed = {self.inputs: x, self.keep_prob: 1., self.initial_state: new_state} preds, new_state = sess.run([self.proba_prediction, self.final_state], feed_dict=feed) c = pick_top_n(preds, vocab_size) # 添加字符到samples中 samples.append(c)
但是在这里,直接将c值赋给x[0,0]可以么?x开始初始化是int,但是c是str。我建立了个小程序跑这一段,
import numpy as np prime = "beauty" for c in prime: x = np.zeros((1,1)) #x[0,0] = vocab_to_int[c] x[0,0] = c print("c",c) print("x",x)
报错说ValueError: could not convert string to float: 'b'。 请问您是怎么解决这个问题的?
The text was updated successfully, but these errors were encountered:
请查看sample函数的调用,prime已经是原始start_string经过 converter.text_to_arr转换成了对应的数字了,是一个数组,不是string
Sorry, something went wrong.
No branches or pull requests
这个代码的主要目的是预测下一个char。
但是在这里,直接将c值赋给x[0,0]可以么?x开始初始化是int,但是c是str。我建立了个小程序跑这一段,
报错说ValueError: could not convert string to float: 'b'。
请问您是怎么解决这个问题的?
The text was updated successfully, but these errors were encountered: