参考: https://xiulian.blog.csdn.net/article/details/86100641
- import tensorflow as tf
- a = [1, 2, 3]
- b = [4, 5, 6]
- c = tf.concat([a, b], axis=0)
- sess = tf.InteractiveSession() #建立交互式会话
- print(sess.run(c))
- # 输出 [1 2 3 4 5 6]
- a = [[[1,1],[2,2]],[[3,3],[4,4]]]
- b = [[[5,5]],[[6,6]]]
- c = tf.concat([a, b], axis=1)
- print(sess.run(c))
- # 输出 [[[1 1]
- [2 2]
- [5 5]]
- [[3 3]
- [4 4]
- [6 6]]]
根据 tf.concat 的 axis 参数来去数组的 [],0 表示去掉最外面的一层, 1 去掉两层.
来源: http://www.bubuko.com/infodetail-2987510.html