Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unpack tensorflow Tensor columns into separate variables

Given a tensor of the form

T = tf.placeholder(tf.float32, [None, 2])

How can I separate T into two separate tensors of shape (?, 1), one for each column?

like image 699
leppy Avatar asked Feb 24 '26 09:02

leppy


1 Answers

You can slice out tensors using python's slice notation.

x = T[:, 0, None]
y = T[:, 1, None]

Internally, this delegates to Tensor.__getitem__, and is evaluated as part of the graph.

like image 163
cs95 Avatar answered Feb 25 '26 23:02

cs95



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!