How to get Tensorflow tensor dimensions (shape) as int values?

The Solution to How to get Tensorflow tensor dimensions (shape) as int values? is


To get the shape as a list of ints, do tensor.get_shape().as_list().

To complete your tf.shape() call, try tensor2 = tf.reshape(tensor, tf.TensorShape([num_rows*num_cols, 1])). Or you can directly do tensor2 = tf.reshape(tensor, tf.TensorShape([-1, 1])) where its first dimension can be inferred.

~ Answered on 2016-11-17 22:41:41


Most Viewed Questions: