PyTorch .i0()
Published Oct 28, 2025
Contribute to Docs
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
torch.i0(input, *, out=None)
Or, alternatively:
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:
import torch# Create input tensorx = torch.tensor([0.0, 1.0, 2.0, 3.0, 4.0])# Compute the modified Bessel functionresult = torch.i0(x)print("Input values:", x)print("I₀(x) values:", result)
The above code produces the following output:
Input values: tensor([0., 1., 2., 3., 4.])I₀(x) values: tensor([1.0000, 1.2661, 2.2796, 4.8808, 11.3019])
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn PyTorch on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn how to use PyTorch to build, train, and test artificial neural networks in this course.
- Intermediate.3 hours