Search code examples
tensorflow

How to merge two tensor?


I want to merge two tensors a and b into c. What I've tried is:

enter image description here

But my expectation is c = [1, 2, 3, 4, 5, 6]. How can I get it?


Solution

  • tf.stack concatenate the given tensors along a new dimension. If you want to concatenate across an existing dimension, use tf.concat:

    c = tf.concat([a, b], axis=0)