Python | tensorflow.math.bessel_i0() method

TensorFlow is open-source python library designed by Google to develop Machine Learning models  and deep learning  neural networks.

bessel_io() is method in TensorFlow math module. This method is used to calculate element wise Bessel i0 of a tensor.

Syntax:
tensorflow.math.bessel_i0(
    input, name
)

Argument:
1. input: It's a tensor or SparseTensor for which element wise Bessel iO 
          need to be calculated. Allowed dtypes are half, float32, float64. 
2. name: It is an optional argument that defines the name for the operation.

Return:
A Tensor if Tensor is given as input otherwise SparseTensor having the same dtype as input.

Example 1:

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing the library
import tensorflow as tf
  
# initializing constant tensor 
a = tf.constant([-1.5, 3 ], dtype=tf.float64)
  
# calculating bessel io
b = tf.math.bessel_i0(a)
  
# printing the input
print('Input: ',a)
  
# printing the output
print('Output: ',b)

chevron_right


Output:

Input:  tf.Tensor([-1.5  3. ], shape=(2,), dtype=float64)
Output:  tf.Tensor([1.64672319 4.88079259], shape=(2,), dtype=float64)

Example 2: 



This example uses tensor with dtype int32 that will raise an error . Only tensor with dtype half, float32, float64 are allowed.

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# importing the library
import tensorflow as tf
  
# initializing constant tensor with dtype int32
a = tf.constant([1 , 3 ], dtype=tf.int32)
  
# printing the input
print('Input: ',a)
  
# calculating bessel io
b = tf.math.bessel_i0(a)

chevron_right


Output:

Input:  tf.Tensor([1 3], shape=(2,), dtype=int32)

NotFoundError                             Traceback (most recent call last)

<ipython-input-43-4c70ca866e4c> in <module>()
----> 1 b = tf.math.bessel_i0(a)

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.