ut3weights_to_t3weights#

t3toolbox.backend.ut3_conversions.ut3weights_to_t3weights(weights)#
def ut3weights_to_t3weights(
        weights: typ.Tuple[
            NDArray,                      # tucker_weight_supercore, (d,)  +stack_shape+(n,)
            NDArray,                      # tt_weight_supercore,     (d+1,)+stack_shape+(r,)
            typ.Tuple[NDArray, NDArray],  # (tucker_edge_mask, tt_edge_mask)
        ],
) -> typ.Union[
    typ.Tuple[typ.Tuple[NDArray, ...], typ.Tuple[NDArray, ...]],  # (tucker_weights, tt_weights), if unstacked
    typ.Tuple,                                                     # else a nested tree (shaped stack_shape)
]:

Convert uniform weight supercores + masks back to ragged T3Weights core pairs.

The weight twin of ut3_to_t3(). Two things to know: an edge mask may be gappy after concat/Kronecker (docs/uniform_masks_vs_ranks.md), so the real slots are selected through the mask rather than by slicing a prefix – boolean indexing does exactly that, in ascending order; and a stacked weight returns a tree of ragged weights rather than one stacked weight, since a varying-rank stack has no single ragged representation (docs/uniform_ranks_and_varieties.md).

Parameters:

weights (t3toolbox.backend.common.typ.Tuple[NDArray, NDArray, t3toolbox.backend.common.typ.Tuple[NDArray, NDArray]])

Return type:

t3toolbox.backend.common.typ.Union[t3toolbox.backend.common.typ.Tuple[t3toolbox.backend.common.typ.Tuple[NDArray, Ellipsis], t3toolbox.backend.common.typ.Tuple[NDArray, Ellipsis]], t3toolbox.backend.common.typ.Tuple]