Sprint Chase Technologies
  • Home
  • About
    • Why Choose Us
    • Contact Us
    • Team Members
    • Testimonials
  • Services
    • Web Development
    • Web Application Development
    • Mobile Application Development
    • Web Design
    • UI/UX Design
    • Social Media Marketing
    • Projects
  • Blog
    • PyTorch
    • Python
    • JavaScript
  • IT Institute
menu
close

Need Help? Talk to an Expert

+91 8000107255
Sprint Chase Technologies
  • Home
  • About
    • Why Choose Us
    • Contact Us
    • Team Members
    • Testimonials
  • Services
    • Web Development
    • Web Application Development
    • Mobile Application Development
    • Web Design
    • UI/UX Design
    • Social Media Marketing
    • Projects
  • Blog
    • PyTorch
    • Python
    • JavaScript
  • IT Institute

Need Help? Talk to an Expert

+91 8000107255

torch.adjoint(): Conjugate Transpose of a Complex Tensor

Home torch.adjoint(): Conjugate Transpose of a Complex Tensor
PyTorch torch.adjoint() Method
  • Written by krunallathiya21
  • June 10, 2025
  • 0 Com
PyTorch

The torch.adjoint() method calculates the conjugate transpose (Hermitian transpose) of a 2D complex-valued tensor.

The output value is a view of the tensor conjugated and with the last two dimensions transposed.

You might be wondering, what is the meaning of conjugate transpose?

The conjugate transpose performs the following two steps:

  1. The transpose of the input matrix (flip rows and columns).
  2. Within each transposed matrix, each element is replaced by its complex conjugate.
Conjugate Transpose of 2D Matrix

As shown in the above figure, we divide the process into two steps:

  1. In the first step, we transposed a matrix by changing rows into columns and vice versa.
  2. In the second step, we changed the sign of the complex value’s imaginary part.
The final 2×2 matrix is a conjugate complex tensor.

Syntax

torch.adjoint(input)

Parameters

Argument Description
input (Tensor)

It is an input tensor of often type complex (torch.complex64 or torch.complex128).

However, it can also be a real tensor, but most of the time, it is just complex.

The tensor must have at least 2 dimensions, as the adjoint operation is defined for matrices or higher-dimensional tensors.

Adjoint of a complex 2D tensor

torch.adjoint() method

Let’s define a 2×2 matrix. First, transpose the matrix, and finally calculate the conjugate of each element.

import torch

# Define a 2x2 complex tensor
A = torch.tensor([[1 + 3j, 2 - 4j],
                  [3 + 5j, 4 - 6j]], dtype=torch.complex64)

print(A)
# Output:
# tensor([[1.+3.j, 2.-4.j],
#         [3.+5.j, 4.-6.j]])

# Compute the adjoint of the tensor
adjoint_tensor = torch.adjoint(A)

print(adjoint_tensor)
# Output:
# tensor([[1.-3.j, 3.-5.j],
#         [2.+4.j, 4.+6.j]])

You can see from the output that the signs have been changed from positive to negative and vice versa, and the matrix has been transposed. That is the adjoint tensor in PyTorch.

You can also use the A.adjoint() method, which returns the same result.

Adjoint of a real tensor

Adjoint of a real tensor

Even if you have a tensor filled with real values, and not complex, the adjoint is equivalent to the transpose of the last two dimensions.

import torch

# Create a real 2x3 tensor
B = torch.tensor([[1, 2, 3], [4, 5, 6]], dtype=torch.float32)
print(B)
# Output:
# tensor([[1., 2., 3.],
#         [4., 5., 6.]])

B_adjoint = torch.adjoint(B)

print(B_adjoint)
# Output:
# tensor([[1., 4.],
#         [2., 5.],
#         [3., 6.]])

In the above code, since there are no imaginary parts, conjugation has no effect. So, just the transposed matrix is returned.

Error case: Invalid dimensionality

RuntimeError Invalid dimensionality

If you pass 1D to the adjoint() method, it will throw RuntimeError: tensor.adjoint() is only supported on matrices or batches of matrices. Got 1-D tensor.

import torch

# Create a 1D complex tensor
D = torch.tensor([1+1j, 2+2j], dtype=torch.complex64)
try:
    D_adjoint = torch.adjoint(D)
except RuntimeError as e:
    print("Error:", e)

# Output: Error: tensor.adjoint() is only
# supported on matrices or batches of matrices. Got 1-D tensor.

The .adjoint() method requires a minimum of a two-dimensional tensor.

To avoid this type of error, ensure that your input has at least a matrix structure.

That’s all!
Post Views: 5
LEAVE A COMMENT Cancel reply
Please Enter Your Comments *

krunallathiya21

All Categories
  • JavaScript
  • Python
  • PyTorch
site logo

Address:  TwinStar, South Block – 1202, 150 Ft Ring Road, Nr. Nana Mauva Circle, Rajkot(360005), Gujarat, India

sprintchasetechnologies@gmail.com

(+91) 8000107255.

ABOUT US
  • About
  • Team Members
  • Testimonials
  • Contact

Copyright by @SprintChase  All Rights Reserved

  • PRIVACY
  • TERMS & CONDITIONS