Closed neozhaoliang closed 2 years ago
@neozhaoliang would you mind showing a small example code for this?
@ailzhang Example code and image are added.
The "usual convention" you said is not a usual convention in linear algebra. The dimension convention for images happens to be the transposed generic 2D matrix. For general linear algebra use cases, the first dimension of a matrix (generally a tensor) is just the first dimension and nothing else. Even if you see the convention in CV applications of PyTorch, it's not like what you usually expect to represent images. If you decide a 2D matrix to be an image, just transpose it yourself and please don't enforce any more conventions in the APIs.
The shape of the
numpy.ndarray
returned byfield.to_numpy()
method is(width, height)
, which haswidth
rows andheight
columns. This is the transposed version of the usual convention. Shall we do this transpose internally so that the returned shape is(height, width)
?For example:
shows the following image, which is the transposition of the intended image: