TensorFlow ``bessel_i0e()`` 贝塞尔函数计算用法


发布日期 : 2021-04-05 21:21:47 UTC

访问量: 10 次浏览

Python – tensorflow.math.bessel\_i0e() 函数

TensorFlow是谷歌设计的开源Python库,用于开发机器学习模型和深度学习神经网络。
bessel\_i0e() 是tensorflow数学模块中的函数。这个函数是用来寻找元素的指数级修改的0阶贝塞尔函数。

bessel_i0e(x) = exp(-abs(x)) bessel_i0(x)

bessel\_i0e(x)bessel\_i0(x) 更快,数值上更稳定。

语法:
tensorflow.math.bessel_i0e( x, name)

参数:

  • x:这是一个张量,这个张量允许的d类型是bfloat16, half, float32, float64。
  • name: 这是一个可选的参数,用于给出操作名称。

返回:
它返回一个张量或稀疏张量,取决于与x相同 dtype 的x。

示例 1:

# importing the library
import tensorflow as tf

# initializing the input
a = tf.constant([1,2,3,4,5], dtype = tf.float64)

# printing the input 
print('a: ',a)

# evaluating the result
r = tf.math.bessel_i0e(a)

# printing the result
print("Result: ",r)

输出:

a: tf.Tensor([1. 2. 3. 4. 5.], shape=(5,), dtype=float64)
Result: tf.Tensor([0.46575961 0.30850832 0.24300035 0.20700192 0.18354081], shape=(5,), dtype=float64)

例子2:
视觉化

# importing the library
import tensorflow as tf
import matplotlib.pyplot as plt 

# initializing the input
a = tf.constant([1,2,3,4,5], dtype = tf.float64)

# evaluating the result
r = tf.math.bessel_i0e(a)

#plotting the graph
plt.plot(a, r, color = 'green', marker = "o")  
plt.title("tensorflow.math.bessel_i0e")  
plt.xlabel("Input")  
plt.ylabel("Result")  
plt.show() 

输出:

Python - tensorflow.math.bessel_i0e()函数函数")