简体   繁体   中英

How can I access each elements in tensor?

Let me assume that I have an tensor like

test = tf.constant([1,2,3],[4,5,6],[7,8,9])

I want to get some value(not row or col) in this tensor. How can I do this? I want to get (2,3) value which is 6 in here.

Also I want to do this in multi-dimensional array.

'slice' or other tensor functions does not fit for me because I want to deal with multi dimensional array(not only 2x2 but 2x3x4x10 etc..)

please help

What you want is tf.gather or tf.gather_nd

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM