📜  Python – tensorflow.math.lbeta()

📅  最后修改于: 2022-05-13 01:55:33.307000             🧑  作者: Mango

Python – tensorflow.math.lbeta()

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

lbeta()用于计算 ln(|Beta(x)|)。它减少了沿最后一维的张量。如果一维 z 是 [z1, …, zk],则 Beta(z) 定义为

如果 x 是 n+1 维张量,形状为 [N 1 , . . ., N n , k],最后一维被视为 z 向量,并且,

如果 z = [u, v] 则传统的二元 beta函数定义为

示例 1:

Python3
# Importing the library
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)


Python3
# Importing the library
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 library
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)