.conj()
Published Nov 9, 2024
Contribute to Docs
In PyTorch, the .conj()
function is used to compute the complex conjugate of each element in a given tensor, returning a new tensor with the computed conjugate values.
Syntax
torch.conj(tensor)
tensor
: The input tensor for which the complex conjugate will be computed.
Example
The following example illustrates the usage of .conj()
:
import torchcomplex_tensor = torch.tensor([1 + 2j, 3 - 4j, 5 + 0j])print("Original Complex Tensor:")print(complex_tensor)# Applying .conj() on a complex tensorcomplex_conj = torch.conj(complex_tensor)print(f"\nReturn type of .conj() - {type(complex_conj)}")print("\nComplex Conjugate:")print(complex_conj)
The above program gives the following output:
Original Complex Tensor:tensor([1.+2.j, 3.-4.j, 5.+0.j])Return type of .conj() - <class 'torch.Tensor'>Complex Conjugate:tensor([1.-2.j, 3.+4.j, 5.-0.j])
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
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 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