Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why use static shapes while converting the Tensor of rank 3 to rank 2? #20

Closed
hossein-amirkhani opened this issue Sep 22, 2017 · 2 comments

Comments

@hossein-amirkhani
Copy link

In the example for converting the Tensor of rank 3 to rank 2, a combination of static and dynamic shapes are used (based on the get_sahpe function). Is not it enough to use the dynamic shapes for this purpose as follows? What is the merit of using static shapes?

b = tf.placeholder(tf.float32, [None, 10, 32])
shape = tf.shape(b)
b = tf.reshape(b, [shape[0], shape[1] * shape[2]])
@vahidk
Copy link
Owner

vahidk commented Sep 23, 2017

It depends on the use case. Sometimes it's perfectly fine to use dynamic shapes. But some ops may need some dimensions of your tensors to be static. For example if you use tf.layers.dense, it needs to know the last dimension of your tensor so that it can allocate a variable for that. In these cases you'd want static shapes. I tend to use a custom get_shape function that prefers to return static shapes.

@vahidk vahidk closed this as completed Sep 23, 2017
@hossein-amirkhani
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants