provo a fare funzionare questo codice:TypeError: oggetto 'Tensor' non supporta l'assegnazione elemento in 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)
Ma ottengo errore nell'ultima riga: TypeError: 'Tensor' object does not support item assignment
Sembra che io non posso assegnare al tensore, come posso ripararlo?
WoW, grazie mille :) –
Nota che 'tf.pack()' è stato sostituito da [tf.stack()] (https://www.tensorflow.org/api_docs/python/tf/stack) da TensorFlow 1.0. – CNugteren
Ho aggiornato la risposta per riflettere la nuova API. – mrry