tensorflow tf.stack tf.unstack 实例

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])]

你可能感兴趣的:(TensorFlow)