Skip to content

Add torch.cos() term entry for PyTorch with syntax and example #7208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions content/pytorch/concepts/tensor-operations/terms/cos/cos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# torch.cos()

## Introduction
`torch.cos()` is a PyTorch tensor operation that computes the cosine of each element in the input tensor.

It is part of PyTorch’s extensive mathematical operations, which enable element-wise computations on tensors commonly used in scientific computing and deep learning.

## Syntax
```python
torch.cos(input, *, out=None) → Tensor

## Example

import torch

# Create a tensor with values in radians
x = torch.tensor([0, torch.pi / 2, torch.pi])

# Compute the cosine
y = torch.cos(x)

print(y)
# tensor([ 1.0000, 0.0000, -1.0000])
Loading