Skip to content
Discussion options

You must be logged in to vote

Hi - the semantics of 0 in a dimension mean that the dimension is of size 0. I think you'll find that array operations have consistent semantics in this case. For example:

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?

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@pratnali-aws
Comment options

Answer selected by pratnali-aws
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants