Skip to content
fn

cos

→Tensor
cos(input: Tensor)

Implementing kernel

C++ engine symbols that back this Python API.

Element-wise cosine (input in radians).

Computes the cosine of each entry treating the input as an angle in radians.

Parameters

inputTensor
Input tensor.

Returns

Tensor

Element-wise result with the same shape as input.

Notes

Mathematical definition:

outi=cos⁡(inputi)\text{out}_i = \cos(\text{input}_i)

Gradient: −sin⁡(x)-\sin(x).

Examples

>>> import lucid
>>> x = lucid.tensor([1.0, 2.0, 3.0])
>>> lucid.cos(x)
Tensor([...])