state = cell.zero_state(batchsize, tf.float32).eval()
我正在尝试跟随这个示例 https://github.com/kvfrans/twitch/blob/master/sample.py#L45 解码和运行一个经过训练的TensorFlow模型,但似乎使用的TensorFlow代码是旧版本。我已经设法修复了大多数对v 1.0.0的调用,但是当上述代码行给出以下错误时,我卡住了:
Traceback (most recent call last):
File "server.py", line 1, in <module>
from sample import *
File "/home/user/twitch/sample.py", line 75, in <module>
print predict("this game is")
File "/home/user/twitch/sample.py", line 46, in predict
state = initialstate.eval()
AttributeError: 'tuple' object has no attribute 'eval'
有没有想法,我应该如何修复 .eval()
和 state
?它们后面被用于:
guessed_logits, state = sess.run([logits, final_state], feed_dict={input_data: primer, initialstate: state})
ValueError: 无法展开字典。键有4个元素,但值只有1个元素。键:[<tf.Tensor 'zeros:0' shape=(1, 200) dtype=float32>, <tf.Tensor 'zeros_1:0' shape=(1, 200) dtype=float32>, <tf.Tensor 'zeros_2:0' shape=(1, 200) dtype=float32>, <tf.Tensor 'zeros_3:0' shape=(1, 200) dtype=float32>],值:[<tf.Tensor 'packed:0' shape=(2, 2, 1, 200) dtype=float32>]。
- Blizzard