看代码:
import tensorflow as tf
import numpy as np
t=np.random.randint(1,10,(3,5))
ustack1=tf.unstack(t,axis=1)
ustack2=tf.unstack(t,axis=0)
sess=tf.Session()
print(t)
print(sess.run(ustack1))
print(sess.run(ustack2))
输出结果如下:
[[4 7 3 5 5] [3 5 8 4 1] [2 2 9 8 7]] [array([4, 3, 2]), array([7, 5, 2]), array([3, 8, 9]), array([5, 4, 8]), array([5, 1, 7])] [array([4, 7, 3, 5, 5]), array([3, 5, 8, 4, 1]), array([2, 2, 9, 8, 7])]
import tensorflow as tf
import numpy as np
t=np.random.randint(1,10,(3,5))
ustack1=tf.unstack(t,axis=1)
ustack2=tf.unstack(t,axis=0)
sess=tf.Session()
print(t)
print(sess.run(ustack1))
print(sess.run(ustack2))
输出结果如下:
[[4 7 3 5 5] [3 5 8 4 1] [2 2 9 8 7]] [array([4, 3, 2]), array([7, 5, 2]), array([3, 8, 9]), array([5, 4, 8]), array([5, 1, 7])] [array([4, 7, 3, 5, 5]), array([3, 5, 8, 4, 1]), array([2, 2, 9, 8, 7])]
Comments
Post a Comment