calculate_density

paddle.incubate.asp. calculate_density ( x ) [source]

Return the density of the input tensor.

Parameters

x (nparray) – The input tensor.

Returns

float, The density of x.

Examples

import paddle
import numpy as np

x = np.array([[0, 1, 3, 0],
            [1, 1, 0, 1]])
paddle.incubate.asp.calculate_density(x) # 0.625