给tensor增加维度
代码语言:javascript复制import tensorflow as tf
a = tf.range(10,dtype=tf.int32)
print(a)
b = a[:,tf.newaxis]
print(b)
a的shape为(10,) b的shape为(10,1) 若b = a[tf.newaxis,:],则b的shape为(1,10)
给tensor增加维度
代码语言:javascript复制import tensorflow as tf
a = tf.range(10,dtype=tf.int32)
print(a)
b = a[:,tf.newaxis]
print(b)
a的shape为(10,) b的shape为(10,1) 若b = a[tf.newaxis,:],则b的shape为(1,10)