1
votes

I have one question about tf.reshape

E.g. one tensor t1 whose shape is [None, h, c, w]. I want to reshape the tensor into 2D, just like:

shape = t1.get_shape().as_list()
t2 = tf.reshape(t1, [shape[0]*shape[1], shape[2]*shape[3]])

However, the first dimension of t1 is None.

How could I process this case, any suggestions?

1

1 Answers

1
votes

You can do:

shape = tf.shape(t1)
t2 = tf.reshape(t1, [-1, shape[2]*shape[3]])