項任務,我嘗試運行這段代碼:類型錯誤:「張量」對象不支持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