Difference between tensor.t() and tensor.T?

Given a matrix A, say:

A = torch.randn(5,5)

What is the difference between A.T and A.t()?

From the docs:
tensor.t:

Expects input to be <= 2-D tensor and transposes dimensions 0 and 1.
0-D and 1-D tensors are returned as is. When input is a 2-D tensor this is equivalent to transpose(input, 0, 1).

tensor.T:

Returns a view of this tensor with its dimensions reversed.
If n is the number of dimensions in x, x.T is equivalent to x.permute(n-1, n-2, ..., 0).

In your use case both will yield the same result.

1 Like