Цель состоит в том, чтобы добавить 2 тензора с одной совпадающей формой
import tensorflow as tf
x = tf.constant([1, 4])
y = tf.constant([2, 5])
z = tf.constant([3, 6])
res = tf.stack([x, y],axis=0)
print(res)
->tf.Tensor(
[[1 4]
[2 5]], shape=(2, 2), dtype=int32)
print(z)
->tf.Tensor([3 6], shape=(2,), dtype=int32)
result = tf.stack((res, z),axis=1)
->tensorflow.python.framework.errors_impl.InvalidArgumentError: Shapes of all inputs must match: values[0].shape = [2,2] != values[1].shape = [2] [Op:Pack] name: stack
что я ожидал
print(result)
->->tf.Tensor(
[[1 4]
[2 5]
[3,6]], shape=(2, 3), dtype=int32)
я пробовал различную комбинацию concat и стека. Как это возможно?