Snehal
Snehal

Reputation: 757

How to perform np.append() type operation on tensors in tensorflow?

I want to add a new tensor in an existing tensor as last column. With numpy I can use np.append(), but I'm not sure how to do this on tensors in tensorflow. Any suggestion?

>> a = np.array([[1,2], [3,4], [5,6]])
>> b = np.array([[9], [99], [999]])
>> np.append(a, b, axis=1)
array([[  1,   2,   9],
       [  3,   4,  99],
       [  5,   6, 999]])

in tensorflow..?

>> x = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]], tf.float32)
>> y = tf.constant([[9.0], [99.0], [999.0]], tf.float32)
>> ???

Upvotes: 1

Views: 1658

Answers (1)

Snehal
Snehal

Reputation: 757

solved: tf.concat((x, y), axis=-1)

Upvotes: 1

Related Questions