treeflow.traversal.ratio_transform module

treeflow.traversal.ratio_transform.move_outside_axis_to_inside(x)
treeflow.traversal.ratio_transform.ratios_to_node_heights(topology: TensorflowTreeTopology, ratios: Tensor, anchor_heights: Tensor, unroll: bool | str = 'auto')

Node-height ratio transform, on the generic preorder_traversal.

The node axis of ratios/anchor_heights is the last axis, indexed by internal-node id.

unroll

Forwarded to preorder_traversal(): "auto" unrolls when the topology is statically known (it is when topology is a constant/eager object, even captured inside a tf.function), True forces it (raising otherwise), False keeps the dynamic tf.while_loop.