sequince.flows#

Flow interfaces used by Sequince transforms and proposals.

Classes#

NormalizingFlow

Minimal interface for normalizing flows used by Sequince.

Functions#

flow_asarray(flow, array)

Cast array to the backend array type expected by flow.

flow_state_dict(flow)

Return persistent flow state when the adapter exposes it.

load_flow_state_dict(flow, state)

Restore persistent flow state when supported by the adapter.

clone_flow(flow)

Return a fresh copy of flow.

Module Contents#

class sequince.flows.NormalizingFlow[source]#

Bases: Protocol

Minimal interface for normalizing flows used by Sequince.

xp: Any#
fit(particles, context=None, *, rng=None, **kwargs)[source]#
Parameters:
Return type:

NormalizingFlow

forward(particles, context=None)[source]#

Map particles into a transformed space and return log-Jacobians.

Parameters:
Return type:

tuple[sequince.typing.Array, sequince.typing.Array]

inverse(particles, context=None)[source]#

Undo the transform applied by forward().

Parameters:
Return type:

tuple[sequince.typing.Array, sequince.typing.Array]

log_prob(particles, context=None)[source]#

Evaluate the flow log-density in the original particle space.

Parameters:
Return type:

sequince.typing.Array

sample(num_samples=1, context=None, *, rng=None)[source]#

Draw samples from the flow distribution.

Parameters:
Return type:

sequince.typing.Array

sequince.flows.flow_asarray(flow, array)[source]#

Cast array to the backend array type expected by flow.

Parameters:
sequince.flows.flow_state_dict(flow)[source]#

Return persistent flow state when the adapter exposes it.

Parameters:

flow (NormalizingFlow)

Return type:

dict[str, Any]

sequince.flows.load_flow_state_dict(flow, state)[source]#

Restore persistent flow state when supported by the adapter.

Parameters:
Return type:

None

sequince.flows.clone_flow(flow)[source]#

Return a fresh copy of flow.

External flow adapters can expose _init_args to control how the clone is reconstructed; otherwise deepcopy is used as a fallback.

Parameters:

flow (NormalizingFlow)

Return type:

NormalizingFlow