espnet2.enh.layers.complex_utils.is_complex
Less than 1 minute
espnet2.enh.layers.complex_utils.is_complex
espnet2.enh.layers.complex_utils.is_complex(c)
Check if the input is a complex tensor.
This function determines whether the given input c is of type ComplexTensor or a native PyTorch complex tensor. It is useful for differentiating between complex and real tensor types in operations involving complex numbers.
- Parameters:c (Union *[*torch.Tensor , ComplexTensor ]) – The input tensor to check.
- Returns: Returns True if c is a complex tensor; otherwise, False.
- Return type: bool
Examples
>>> import torch
>>> from torch_complex.tensor import ComplexTensor
>>> c1 = ComplexTensor(torch.tensor([1.0]), torch.tensor([2.0]))
>>> c2 = torch.tensor([1.0, 2.0], dtype=torch.complex64)
>>> c3 = torch.tensor([1.0, 2.0])
>>> is_complex(c1)
True
>>> is_complex(c2)
True
>>> is_complex(c3)
False