Jame
Jame

Reputation: 3854

How to print the value of shape of the tensor?

I was used the function

print tf.shape(image)

The output likes

Tensor("Shape:0", shape=(3,), dtype=int32, device=/device:CPU:0)

I want to know what is the value inside the shape (like the dimensions). How can I access it to print?

Upvotes: 1

Views: 2592

Answers (1)

Maxim
Maxim

Reputation: 53758

tf.shape returns a tensor that contains the shape of an argument. This is useful when one of the dimensions is dynamic, i.e., is None statically.

You can use image.shape (or image.get_shape()) to get the static shape, or can also evaluate tf.shape(image) in a session.

See also this answer.

Upvotes: 2

Related Questions