Skip to content
Merged
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
64 changes: 64 additions & 0 deletions content/pytorch/concepts/tensor-operations/terms/i0/i0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
Title: '.i0()'
Description: 'Computes the modified Bessel function of the first kind of order zero.'
Subjects:
- 'AI'
- 'Data Science'
- 'Machine Learning'
Tags:
- 'AI'
- 'Deep Learning'
- 'Functions'
- 'Machine Learning'
- 'PyTorch'
CatalogContent:
- 'intro-to-py-torch-and-neural-networks'
- 'paths/computer-science'
---

In PyTorch, the **`.i0()`** function (an alias of `torch.special.i0()`) computes the modified Bessel function of the first kind of order zero (I₀). This function is commonly used in signal processing, physics simulations, and statistical distributions such as the von Mises distribution for circular data.

## Syntax

```pseudo
torch.i0(input, *, out=None)
```

Or, alternatively:

```pseudo
torch.special.i0(input, *, out=None)
```

**Parameters:**

- `input` (Tensor): The input tensor whose elements are the values at which to compute the modified Bessel function I₀.
- `out` (Tensor, optional): The output tensor to store the result.

**Return value:**

Returns a tensor containing the computed modified Bessel function of the first kind, order zero (I₀), for each element of the input tensor.

## Example

In this example, `torch.i0()` calculates the modified Bessel function I₀ for each element in a 1D tensor:

```py
import torch

# Create input tensor
x = torch.tensor([0.0, 1.0, 2.0, 3.0, 4.0])

# Compute the modified Bessel function
result = torch.i0(x)

print("Input values:", x)
print("I₀(x) values:", result)
```

The above code produces the following output:

```shell
Input values: tensor([0., 1., 2., 3., 4.])
I₀(x) values: tensor([1.0000, 1.2661, 2.2796, 4.8808, 11.3019])
```