python – Tensorflow reshape tensor
Im the author of one of the answers of the other question in Yaroslavs comment. You can use -1 for the None dimension.
You can do it easily with tf.reshape() without knowing the batch size.
x = tf.placeholder(tf.float32, shape=[None, 9,2]) shape = x.get_shape().as_list() # a list: [None, 9, 2] dim = numpy.prod(shape[1:]) # dim = prod(9,2) = 18 x2 = tf.reshape(x, [-1, dim]) # -1 means all
The -1 in the last line means the whole column no matter what the batchsize is in the runtime. You can see it in tf.reshape().