polygamma

paddle. polygamma ( x: Tensor, n: int, name: str | None = None ) Tensor [source]

Calculates the polygamma of the given input tensor, element-wise.

The equation is:

\[\Phi^n(x) = \frac{d^n}{dx^n} [\ln(\Gamma(x))]\]
Parameters
  • x (Tensor) – Input Tensor. Must be one of the following types: float32, float64, uint8, int8, int16, int32, int64.

  • n (int) – Order of the derivative. Must be integral.

  • name (str|None, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.

Returns

  • out (Tensor), A Tensor. the polygamma of the input Tensor, the shape and data type is the same with input

    (integer types are autocasted into float32).

Examples

>>> import paddle

>>> data = paddle.to_tensor([2, 3, 25.5], dtype='float32')
>>> res = paddle.polygamma(data, 1)
>>> print(res)
Tensor(shape=[3], dtype=float32, place=Place(cpu), stop_gradient=True,
[0.64493412,  0.39493406,  0.03999467])