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


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

TensorFlow是Google設計的開源Python庫,用於開發機器學習模型和深度學習神經網絡。

lbeta()用於計算ln(| Beta(x)|)。沿最後一維減小張量。如果一維z是[z1,…,zk],則Beta(z)定義為

如果x是形狀為[N的n + 1維張量1 ,。 。 。,Nn ,k],最後一個維度被視為z向量,並且



如果z = [u,v],則傳統的雙變量beta函數定義為

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

參數:

  • x:它是輸入張量,等級為n + 1,其中n> = 0。允許的dtype為float或double。
  • name(optinal):它定義了操作的名稱。

返回值:

它返回| Beta(x)|的對數沿最後一個尺寸減小。

範例1:

Python3

# Importing the libraray 
import tensorflow as tf 
  
# Initializing the input tensor 
a = tf.constant([[7, 8], [13, 11]], dtype = tf.float64) 
  
# Printing the input tensor 
print('a:', a) 
  
# Calculating the result 
res = tf.math.lbeta(x = a) 
  
# Printing the result 
print('Result:', res)

輸出:

a: tf.Tensor(
[[ 7.  8.]
 [13. 11.]], shape=(2, 2), dtype=float64)
Result: tf.Tensor([-10.08680861 -16.5150485 ], shape=(2, ), dtype=float64)

範例2:

Python3

# Importing the libraray 
import tensorflow as tf 
  
# Initializing the input tensor 
a = tf.constant([7, 8, 13, 11], dtype = tf.float64) 
  
# Printing the input tensor 
print('a:', a) 
  
# Calculating the result 
res = tf.math.lbeta(x = a) 
  
# Printing the result 
print('Result:', res)

輸出:

a: tf.Tensor([ 7.  8. 13. 11.], shape=(4, ), dtype=float64)
Result: tf.Tensor(-52.77215897270088, shape=(), dtype=float64)



相關用法


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