PyTorch torch.adjoint() method “returns a view of the tensor conjugated and with the last two dimensions transposed.”

## Syntax

``````torch.adjoint(Tensor)
``````

## Parameters

Tensor: It is an input tensor.

## Example 1: Basic usage with a 2D complex tensor

``````import torch

tensor_1 = torch.tensor([[1 + 1j, 2 + 2j], [3 + 3j, 4 + 4j]])

print("Original Tensor:")
print(tensor_1)
``````

Output ## Example 2: Using the method with higher-dimensional tensors

``````import torch

tensor_2 = torch.tensor([
[[1 + 1j, 2 + 2j], [3 + 3j, 4 + 4j]],
[[5 + 5j, 6 + 6j], [7 + 7j, 8 + 8j]]
])

print("Original Tensor:")
print(tensor_2)
``````

Output ## Example 3: Using the method with real numbers

``````import torch

tensor_3 = torch.tensor([[1, 2], [3, 4]])

print("Original Tensor:")
print(tensor_3)
``````

Output For real numbers, the adjoint is the same as the regular transpose since there’s no complex component to conjugate.

## Related posts

torch.polar()

torch.dequantize()

torch.eye()