megengine.Parameter.shape#

property Parameter.shape#

Returns a tuple or a Tensor represents tensor dimensions.

Note

The shape of a tensor was usually represented by a tuple. But if a tensor was treated as symbolic placeholder with tracing, it’s shape could also be a Tensor. See trace for more details.

The shape property is usually used to get the current shape of a tensor, but may also be used to reshape the tensor in-place by assigning a tuple of tensor dimensions to it. As with reshape, one of the new shape dimensions can be -1, in which case its value is inferred from the size of the tensor and the remaining dimensions.

Return type:

Union[tuple, Tensor]