当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python tensorflow.math.bessel_i0()用法及代码示例


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

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

用法:
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.

返回:
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)

输出:

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)

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

相关用法


注:本文由纯净天空筛选整理自aman neekhara大神的英文原创作品 Python | tensorflow.math.bessel_i0() method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。