PyTorch torch.cos Function
Pytorch torch Reference Manual
torch.cosis a function in PyTorch used to compute the element-wise cosine.
Function Definition
torch.cos(input, out=None)
Usage Example
Example
import torch
x = torch.tensor([0, torch.pi/2, torch.pi, 3*torch.pi/2])
print(torch.cos(x))
x = torch.tensor([0, torch.pi/2, torch.pi, 3*torch.pi/2])
print(torch.cos(x))
The output result is:
tensor([ 1.0000e+00, -8.7423e-08, -1.0000e+00, -8.7423e-08])
Other Extensions