tf.stack()

import tensorflow as tf
a = tf.constant([1,2,3])
b = tf.constant([4,5,6])
c = tf.stack([a,b],axis=1)
d = tf.unstack(c,axis=0)
e = tf.unstack(c,axis=1)
print(c.get_shape())
with tf.Session() as sess:
    print(sess.run(c))
    print(sess.run(d))
    print(sess.run(e))

(3, 2)

[[1 4] 
[2 5] 
[3 6]]

[array([1, 4]), array([2, 5]), array([3, 6])]

[array([1, 2, 3]), array([4, 5, 6])]

猜你喜欢

转载自blog.csdn.net/zlrai5895/article/details/80465905
tf