I have 2 tensors of shape (100, 4)
and (100, 2)
.
I would like to perform a concatenation operation, in TensorFlow, similar to np.hstack
,
I have a similar problem. I try to concatenate two image Tensors with Keras. Tensor type and shape Both are identical but it says that Layer concatenate_X (The Number X changes)was called with an input that isn't a symbolic tensor. Received type: <class 'numpy.ndarray'> i try to concatenate them like this:
X=concatenate([X1,X2],axis=-1)
I tried the above code, I got some error. The following code runs fine with tf 1.15 version:
x = tf.constant( [[1, 2,4],[7,8,12]])
y = tf.constant([[88],[99]])
res=tf.concat([x, y],1)
You can use tf.concat
for this purpose as follows:
sess=tf.Session()
t1 = [[1, 2], [4, 5]]
t2 = [[7, 8, 9], [10, 11, 12]]
res=tf.concat(concat_dim=1,values=[t1, t2])
print(res.eval(session=sess))
This prints
[[ 1 2 7 8 9]
[ 4 5 10 11 12]]