Thursday, January 22, 2026
HomeLanguagesPython – tensorflow.math.polygamma()

Python – tensorflow.math.polygamma()

TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks.

polygamma() is used to compute polygamma function. Polygamma function is defined as:

This function is defined for only non-negative integer orders i.e. value of a should be non-negative.

Syntax: tensorflow.math.polygamma( a, x, name)

Parameters:

  • a: It’s a tensor of non-negative values. Allowed dtypes are  float32, float64.
  • x: It’s a tensor of same dtype as a.
  • name(optional): It defines the name for the operation.

Returns:

It returns a tensor of same dtype as a.

Example 1:

Python3




# importing the library
import tensorflow as tf
 
# Initializing the input tensor
a = tf.constant([1, 2, 3], dtype = tf.float64)
x = tf.constant([7, 9, 13], dtype = tf.float64)
 
# Printing the input tensor
print('a: ', a)
print('x: ', x)
 
# Calculating result
res = tf.math.polygamma(a, x)
 
# Printing the result
print('Result: ', res)


Output:

a:  tf.Tensor([1. 2. 3.], shape=(3, ), dtype=float64)
x:  tf.Tensor([ 7.  9. 13.], shape=(3, ), dtype=float64)
Result:  tf.Tensor([ 0.15354518 -0.01379332  0.00102074], shape=(3, ), dtype=float64)

Example 2: For negative value of a returned output is nan.

Python3




# importing the library
import tensorflow as tf
 
# Initializing the input tensor
a = tf.constant([-1, 2, 3], dtype = tf.float64)
x = tf.constant([7, 9, 13], dtype = tf.float64)
 
# Printing the input tensor
print('a: ', a)
print('x: ', x)
 
# Calculating Result
res = tf.math.polygamma(a, x)
 
# Printing the result
print('Result: ', res)


Output:

a:  tf.Tensor([-1.  2.  3.], shape=(3, ), dtype=float64)
x:  tf.Tensor([ 7.  9. 13.], shape=(3, ), dtype=float64)
Result:  tf.Tensor([        nan -0.01379332  0.00102074], shape=(3, ), dtype=float64)
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
119 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11977 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12064 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7221 POSTS0 COMMENTS
Thapelo Manthata
6934 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS