espnet2.enh.layers.complex_utils.to_double
Less than 1 minute
espnet2.enh.layers.complex_utils.to_double
espnet2.enh.layers.complex_utils.to_double(c)
Convert a tensor to double precision.
This function converts the input tensor to double precision (float64). If the input tensor is a complex tensor, it converts the real and imaginary parts to double precision. If the input tensor is a native complex tensor, it will be converted to complex128.
- Parameters:c (Union *[*torch.Tensor , ComplexTensor ]) – The input tensor to convert.
- Returns: The converted tensor in double precision.
- Return type: Union[torch.Tensor, ComplexTensor]
Examples
>>> import torch
>>> from torch_complex.tensor import ComplexTensor
>>> real_tensor = torch.tensor([1.0, 2.0])
>>> complex_tensor = ComplexTensor(torch.tensor([1.0, 2.0]),
... torch.tensor([3.0, 4.0]))
>>> to_double(real_tensor)
tensor([1., 2.], dtype=torch.float64)
>>> to_double(complex_tensor)
ComplexTensor(real=tensor([1., 2.], dtype=torch.float64),
imag=tensor([3., 4.], dtype=torch.float64))
NOTE
The function assumes that PyTorch’s complex support is available.