import numpy as np import tensorflow as tf a=[[2,2,3,3],[4,5,6,4]] t1=tf.expand_dims(a,0,name="t1") t2=tf.expand_dims(a,1,name="t2") with tf.Session() as sess: print(sess.run(t1).shape) print(sess.run(tf.squeeze(t1,0)).shape) print(sess.run(t2).shape) print(sess.run(tf.squeeze(t2,1)).shape)
输出如下:
(1, 2, 4) (2, 4) (2, 1, 4) (2, 4)
Comments
Post a Comment