stack 会在axis指定的位置多生成一个维度
import tensorflow as tf
A = [[[1, 2, 3], [4, 5, 6]]]
B = [[[7, 8, 9], [10, 11, 12]]]
A_tf = tf.constant(A, dtype=tf.int32)
B_tf = tf.constant(B, dtype=tf.int32)
concat_0_tf = tf.concat([A_tf, B_tf], axis=0)
stack_0_tf = tf.stack([A_tf, B_tf], axis=0)
print('concat:\n', concat_0_tf.get_shape())
print('stack:\n', stack_0_tf.get_shape())
# 输出为:
# concat:
# (2, 2, 3)
# stack:
# (2, 1, 2, 3)