Tensorflow python : Accessing individual elements in a tensor

前端 未结 4 1884
日久生厌
日久生厌 2020-12-13 17:09

This question is with respect to accessing individual elements in a tensor, say [[1,2,3]]. I need to access the inner element [1,2,3] (This can be performed using .eval() or

4条回答
  •  渐次进展
    2020-12-13 18:02

    You simply can't get value of 0th element of [[1,2,3]] without run()-ning or eval()-ing an operation which would be getting it. Because before you 'run' or 'eval', you have only a description how to get this inner element(because TF uses symbolic graphs/calculations). So even if you would use tf.gather/tf.slice, you still would have to get values of these operations via eval/run. See @mrry's answer.

提交回复
热议问题