tf.shape

Returns a tensor containing the shape of the input tensor.

Used in the notebooks

Used in the guide Used in the tutorials

See also tf.size, tf.rank.

tf.shape returns a 1-D integer tensor representing the shape of input. For a scalar input, the tensor returned has a shape of (0,) and its value is the empty vector (i.e. []).

For example:

tf.shape(1.)
<tf.Tensor: shape=(0,), dtype=int32, numpy=array([], dtype=int32)>