Skip to content

TransitionSpec

Describe an extra transition group to include during evaluation.

Attributes:

Name Type Description
kind Literal['pair', 'identity']

Either "pair" for contrastive transitions or "identity" for self/self transitions.

source str

Source class id.

target str

Target class id. For kind="identity", this must equal source.

symmetric bool

Whether to include both source -> target and target -> source. This is meaningful for kind="pair" and ignored for kind="identity".

kind instance-attribute

kind

source instance-attribute

source

symmetric class-attribute instance-attribute

symmetric = True

target instance-attribute

target

edges

edges()

Expand the spec into concrete directed transitions.

Returns:

Type Description
FrozenSet[TransitionEdge]

A frozenset of (source, target) tuples.

Source code in gradiend/trainer/core/transition_selection.py
def edges(self) -> FrozenSet[TransitionEdge]:
    """
    Expand the spec into concrete directed transitions.

    Returns:
        A frozenset of ``(source, target)`` tuples.
    """
    if self.kind == "identity":
        return frozenset({(self.source, self.source)})
    if self.symmetric:
        return frozenset({(self.source, self.target), (self.target, self.source)})
    return frozenset({(self.source, self.target)})

Related helpers: [pair()][gradiend.trainer.core.transition_selection.pair], [identity()][gradiend.trainer.core.transition_selection.identity].