Optimal way to assign a value to an individual index of a tensor

3,594 views
Skip to first unread message

Afzalul Haque

unread,
May 8, 2016, 11:34:37 PM5/8/16
to Discuss
Assume a tensor like x = tf.constant([[0.0, 0.0], [0.0, 0.0]])

Is there an easier way to assign values to a specific index of x(assume X[1]) other than creating a complete sparse tensor around some values to be changed and then added to X? This stackoverflow answer says that there is no other easier method.

https://stackoverflow.com/questions/34685947/adjust-single-value-within-tensor-tensorflow

Warm Regards,
Afzalul Haque

Eugene Brevdo

unread,
May 9, 2016, 12:23:33 AM5/9/16
to Afzalul Haque, Discuss
Think of Tensors as read-only objects.  You can only create new Tensors that are modified versions of existing ones.  You can't modify a value inside a Tensor.  This is only possible with Variable objects.  For Variables, you can use scatter_update; but remember that Variables are stateful objects and things get weird if you're trying to use them deep inside a parallel computation (they're mostly useful for storing and updating parameters).

--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+u...@tensorflow.org.
To post to this group, send email to dis...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/CAMiG5sDLET5xxa69he5wWH1M%3DrDcK9tozrTN33LZNkkeX3xZqA%40mail.gmail.com.

Reply all
Reply to author
Forward
0 new messages