sequince.flows#
Flow interfaces used by Sequince transforms and proposals.
Classes#
Minimal interface for normalizing flows used by Sequince. |
Functions#
|
Cast |
|
Return persistent flow state when the adapter exposes it. |
|
Restore persistent flow state when supported by the adapter. |
|
Return a fresh copy of |
Module Contents#
- class sequince.flows.NormalizingFlow[source]#
Bases:
ProtocolMinimal interface for normalizing flows used by Sequince.
- xp: Any#
- fit(particles, context=None, *, rng=None, **kwargs)[source]#
- Parameters:
particles (sequince.typing.Array)
context (sequince.steps.context.StepContext | None)
rng (Any)
kwargs (Any)
- Return type:
- forward(particles, context=None)[source]#
Map particles into a transformed space and return log-Jacobians.
- Parameters:
particles (sequince.typing.Array)
context (sequince.steps.context.StepContext | None)
- Return type:
tuple[sequince.typing.Array, sequince.typing.Array]
- inverse(particles, context=None)[source]#
Undo the transform applied by
forward().- Parameters:
particles (sequince.typing.Array)
context (sequince.steps.context.StepContext | None)
- 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:
particles (sequince.typing.Array)
context (sequince.steps.context.StepContext | None)
- Return type:
sequince.typing.Array
- sample(num_samples=1, context=None, *, rng=None)[source]#
Draw samples from the flow distribution.
- Parameters:
num_samples (int)
context (sequince.steps.context.StepContext | None)
rng (Any)
- Return type:
sequince.typing.Array
- sequince.flows.flow_asarray(flow, array)[source]#
Cast
arrayto the backend array type expected byflow.- Parameters:
flow (NormalizingFlow)
array (Any)
- sequince.flows.flow_state_dict(flow)[source]#
Return persistent flow state when the adapter exposes it.
- Parameters:
flow (NormalizingFlow)
- Return type:
- sequince.flows.load_flow_state_dict(flow, state)[source]#
Restore persistent flow state when supported by the adapter.
- Parameters:
flow (NormalizingFlow)
state (collections.abc.Mapping[str, Any])
- Return type:
None
- sequince.flows.clone_flow(flow)[source]#
Return a fresh copy of
flow.External flow adapters can expose
_init_argsto control how the clone is reconstructed; otherwisedeepcopyis used as a fallback.- Parameters:
flow (NormalizingFlow)
- Return type: