📜  Python| tensorflow.math.bessel_i0() 方法

📅  最后修改于: 2022-05-13 01:55:10.911000             🧑  作者: Mango

Python| tensorflow.math.bessel_i0() 方法

TensorFlow 是由 Google 设计的开源Python库,用于开发机器学习模型和深度学习神经网络。

bessel_io() 是 TensorFlow 数学模块中的方法。此方法用于计算张量的元素 Bessel i0。

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.

示例 1:

Python3
# 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)


Python3
# 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)


输出:

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

示例 2:

此示例使用 dtype int32 的张量,这将引发错误。只允许 dtype half、float32、float64 的张量。

Python3

# 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)

输出:

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

NotFoundError                             Traceback (most recent call last)

 in ()
----> 1 b = tf.math.bessel_i0(a)