Semantics of tensor-shape (2, 0, 1) #19589
Answered
by
jakevdp
pratnali-aws
asked this question in
Q&A
-
I came across this test - https://github.com/google/jax/blob/d0008fbe4ad67de2d7c5a9dccd6a28ab1ef03802/tests/lax_test.py#L1577 |
Beta Was this translation helpful? Give feedback.
Answered by
jakevdp
Jan 30, 2024
Replies: 1 comment 1 reply
-
Hi - the semantics of In [1]: import jax.numpy as jnp
In [2]: x = jnp.zeros((2, 0, 1))
In [3]: x.shape
Out[3]: (2, 0, 1)
In [4]: x.shape[1]
Out[4]: 0
In [5]: x.size # prod(shape)
Out[5]: 0
In [6]: x.ravel().shape # ravel() = reshape to (size,)
Out[6]: (0,)
In [7]: x.mT.shape # mT = matrix transpose
Out[7]: (2, 1, 0) Does that make sense? |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
pratnali-aws
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi - the semantics of
0
in a dimension mean that the dimension is of size0
. I think you'll find that array operations have consistent semantics in this case. For example:Does that make sense?