X.reshape(0, 3, 4) vs. x.reshape( (0,3,4) )

When I use ndarray like this:

In [2]: x = mx.nd.ones((2, 12))

In [3]: x.shape
Out[3]: (2, 12)

In [4]: y1 = x.reshape(0, 3, 4)

In [5]: y2 = x.reshape( ( 0, 3, 4) )

In [6]: y1.shape
Out[6]: (2, 3, 4)

In [7]: y2.shape
Out[7]: (2, 3, 4)

It seems that y1 and y2 have no differences.

However, when I use the reshape(0, 3, 4) format in a HybridBlock after hybridize(), I always get the error:

ValueError: Deferred initialization failed because shape cannot be inferred.

but with the reshape( ( 0, 3, 4) ) , everything will be OK.

I am quite curious about the difference between reshape( (0,3,4) ) and reshape(0,3,4) , i.e. how does the additional ( ) work?

Always prefer the tuple format, reshape((0,3,4))

1 Like