TF 2.0 is out! Get hands-on practice at TF World, Oct 28-31. Use code TF20 for 20% off select passes. Register now

Module: tfp.math

View source on GitHub

TensorFlow Probability math functions.


ode module: TensorFlow Probability ODE solvers.

psd_kernels module: Positive-semidefinite kernels package.


batch_interp_regular_1d_grid(...): Linear 1-D interpolation on a regular (constant spacing) grid.

batch_interp_regular_nd_grid(...): Multi-linear interpolation on a regular (constant spacing) grid.

cholesky_concat(...): Concatenates chol @ chol.T with additional rows and columns.

clip_by_value_preserve_gradient(...): Clips values to a specified min and max while leaving gradient unaltered.

custom_gradient(...): Embeds a custom gradient into a Tensor.

dense_to_sparse(...): Converts dense Tensor to SparseTensor, dropping ignore_value cells.

diag_jacobian(...): Computes diagonal of the Jacobian matrix of ys=fn(xs) wrt xs.

fill_triangular(...): Creates a (batch of) triangular matrix from a vector of inputs.

fill_triangular_inverse(...): Creates a vector from a (batch of) triangular matrix.

interp_regular_1d_grid(...): Linear 1-D interpolation on a regular (constant spacing) grid.

log1psquare(...): Numerically stable calculation of log(1 + x**2) for small or large |x|.

log_add_exp(...): Computes log(exp(x) + exp(y)) in a numerically stable way.

log_combinations(...): Multinomial coefficient.

lu_matrix_inverse(...): Computes a matrix inverse given the matrix's LU decomposition.

lu_reconstruct(...): The inverse LU decomposition, X == lu_reconstruct(*

lu_solve(...): Solves systems of linear eqns A X = RHS, given LU factorizations.

matrix_rank(...): Compute the matrix rank; the number of non-zero SVD singular values. (deprecated)

minimize(...): Minimize a loss function using a provided optimizer.

pinv(...): Compute the Moore-Penrose pseudo-inverse of a matrix. (deprecated)

pivoted_cholesky(...): Computes the (partial) pivoted cholesky decomposition of matrix.

random_rademacher(...): Generates Tensor consisting of -1 or +1, chosen uniformly at random.

random_rayleigh(...): Generates Tensor of positive reals drawn from a Rayleigh distributions.

reduce_logmeanexp(...): Computes log(mean(exp(input_tensor))).

reduce_weighted_logsumexp(...): Computes log(abs(sum(weight * exp(elements across tensor dimensions)))).

secant_root(...): Finds root(s) of a function of single variable using the secant method.

soft_threshold(...): Soft Thresholding operator.

softplus_inverse(...): Computes the inverse softplus, i.e., x = softplus_inverse(softplus(x)).

sparse_or_dense_matmul(...): Returns (batched) matmul of a SparseTensor (or Tensor) with a Tensor.

sparse_or_dense_matvecmul(...): Returns (batched) matmul of a (sparse) matrix with a column vector.

value_and_gradient(...): Computes f(*xs) and its gradients wrt to *xs.