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


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。