Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.cos function

PyTorch torch.cos function


PyTorch torch reference manual 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

]

)

print

(

torch.

cos

(

x

)

)

The output is:

tensor([ 1.0000e+00, -8.7423e-08, -1.0000e+00, -8.7423e-08])


PyTorch torch reference manual PyTorch torch reference manual