flow_utilities

This file contains a set of utilities operating on flows.

tensiometer.synthetic_probability.flow_utilities.KL_divergence(flow_1, flow_2, num_samples=1000, num_batches=100)[source]

Calculates the Kullback-Leibler (KL) divergence between two flows:

D_KL(flow_1 || flow_2) = E_{x ~ flow_1} [log(flow_1(x)) - log(flow_2(x))]

Parameters:
  • flow_1 – flow used as the sampling distribution.

  • flow_2 – flow compared against flow_1.

  • num_samples – number of samples drawn per batch.

  • num_batches – number of batches used to estimate the statistics.

Returns:

mean and standard deviation of the estimated KL divergence.

tensiometer.synthetic_probability.flow_utilities.get_samples_bijectors(flow, feedback=False, extra_samples=None)[source]

Extract samples at each stage of a flow transformation.

Parameters:
  • flow – trained flow object exposing samples, weights, and bijectors.

  • feedback – whether to print bijector names during traversal.

  • extra_samples – optional additional samples to propagate through the bijectors.

Returns:

training and validation MCSamples lists, and optionally transformed extra_samples when provided.