PyTorch torch.cos function
PyTorch torch reference manual
torch.cos is a PyTorch function for computing the cosine element-wise.
Function definition
torch.cos(input, out=None)
Usage examples
Example
import
torch
x
=
torch.
tensor
(
[
0
,
torch.
pi
/
2
,
torch.
pi
,
3
*torch.
pi
/
2
]
)
(
torch.
cos
(
x
)
)
The output is:
tensor([ 1.0000e+00, -8.7423e-08, -1.0000e+00, -8.7423e-08])