项任务,我尝试运行这段代码:类型错误:“张量”对象不支持TensorFlow
outputs, states = rnn.rnn(lstm_cell, x, initial_state=initial_state, sequence_length=real_length)
tensor_shape = outputs.get_shape()
for step_index in range(tensor_shape[0]):
word_index = self.x[:, step_index]
word_index = tf.reshape(word_index, [-1,1])
index_weight = tf.gather(word_weight, word_index)
outputs[step_index, :, :]=tf.mul(outputs[step_index, :, :] , index_weight)
,但我得到的最后一行错误: TypeError: 'Tensor' object does not support item assignment
看来我不能分配给张量,我该如何解决它?
魔兽,谢谢你了:) –
注从TensorFlow 1.0开始,'tf.pack()'已被替换为[tf.stack()](https://www.tensorflow.org/api_docs/python/tf/stack)。 – CNugteren
我更新了答案以反映新的API。 – mrry