當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python tensorflow.math.bessel_i1()用法及代碼示例

TensorFlow是Google設計的開源Python庫,用於開發機器學習模型和深度學習神經網絡。 bessel_i1()是tensorflow數學模塊中的函數。該函數用於查找元素明智的一階修改的Bessel函數。

用法:tensorflow.math.bessel_i1( x, name)

參數:

  • x:這是一個張量,該張量的允許dtypes是bfloat16,half,float32,float64。
  • name:這是一個可選參數,用於指定操作名稱。

返回值:它返回張量或稀疏張量,具體取決於與x具有相同dtype的x。

範例1:



Python3

# 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_i1(a) 
  
# printing the result 
print("Result:",r)

輸出:

a: tf.Tensor([1. 2. 3. 4. 5.], shape=(5,), dtype=float64)
Result: tf.Tensor([ 0.5651591   1.59063685  3.95337022  9.75946515 24.33564214], shape=(5,), dtype=float64)

範例2:可視化

Python3

# 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_i1(a) 
  
#plotting the graph 
plt.plot(a, r, color = 'green', marker = "o")   
plt.title("tensorflow.math.bessel_i1")   
plt.xlabel("Input")   
plt.ylabel("Result")   
plt.show() 

輸出:




相關用法


注:本文由純淨天空篩選整理自aman neekhara大神的英文原創作品 Python – tensorflow.math.bessel_i1() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。