.adjoint()
Anonymous contributor
Published Dec 9, 2024
Contribute to Docs
The .adjoint()
method in PyTorch calculates the adjoint (conjugate transpose) of a 2D complex-valued tensor. This operation involves transposing the tensor and computing the complex conjugate of each element. The adjoint operation is commonly used in applications like quantum computing, signal processing, and complex linear algebra.
Syntax
tensor.adjoint()
The .adjoint()
method returns a tensor that is the adjoint (conjugate transpose) of the input tensor.
Example
This example shows how to use .adjoint()
to find the adjoint of a 2x2 complex tensor:
import torch# Define a 2x2 complex tensortensor = torch.tensor([[1 + 2j, 3 + 4j], [5 + 6j, 7 + 8j]])# Compute the adjoint of the tensoradjoint_tensor = tensor.adjoint()print("Original Tensor:")print(tensor)print("\nAdjoint Tensor:")print(adjoint_tensor)
This example results in the following output:
Original Tensor:tensor([[1.+2.j, 3.+4.j],[5.+6.j, 7.+8.j]])Adjoint Tensor:tensor([[1.-2.j, 5.-6.j],[3.-4.j, 7.-8.j]])
In this example:
- Original Tensor: Contains complex numbers.
- Adjoint Tensor: Transposes the tensor (swaps rows and columns) and computes the complex conjugate for each element (reverses the sign of the imaginary part).
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn PyTorch on Codecademy
- Career path
Data Scientist: Machine Learning Specialist
Machine Learning Data Scientists solve problems at scale, make predictions, find patterns, and more! They use Python, SQL, and algorithms.Includes 27 CoursesWith Professional CertificationBeginner Friendly95 hours - Free course
Intro to PyTorch and Neural Networks
Learn how to use PyTorch to build, train, and test artificial neural networks in this course.Intermediate3 hours