pangolin.interface.compose_transforms#
- pangolin.interface.compose_transforms(transforms, log_det_direction='forward')#
Compose zero or more Transforms in left-to-right application order.
compose_transforms([a, b])appliesafirst and thenb. The resulting Transform captures the union of their external RVs.log_det_directionselects whether its log-Jacobian graph reconstructs the intermediate values in forward or inverse order; both choices represent the same mathematical quantity.An empty sequence produces the identity Transform.
- Parameters:
transforms (Sequence[Transform]) – Transforms to apply in sequence.
transforms[0]is applied first.log_det_direction (Literal["forward", "inverse"]) – Whether the combined log-Jacobian reconstructs intermediate values by following the transforms forward from
xor backward fromy.
- Returns:
A single
Transformequivalent to applying every input Transform in order.- Return type:
- Raises:
TypeError – If any item in
transformsis not aTransform.ValueError – If
log_det_directionis neither"forward"nor"inverse".
Examples
>>> from pangolin import interface as pi >>> transform = compose_transforms([pi.tforms.scale_by(2), pi.tforms.shift_by(3)]) >>> y = transform(pi.normal)(0, 1) >>> y.shape ()