Skip to content

declearn.model.api.VectorSpec

Metadata container to specify a Vector for its (un)flattening.

Fields

names: List of names of the coefficient tensors. shapes: Dict associating shapes (as tuples of int) to coefficient names. dtypes: Dict associating dtypes (as string values) to coefficient names. v_type: Optional (name, group) tuple of strings containing registration information enabling to recover the Vector subclass. kwargs: Dict containing any subclass-specific metadata useful in building back a Vector from its specifications and flattened values.

Source code in declearn/model/api/_vector.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
@dataclasses.dataclass
class VectorSpec:
    """Metadata container to specify a Vector for its (un)flattening.

    Fields
    ------
    names:
        List of names of the coefficient tensors.
    shapes:
        Dict associating shapes (as tuples of int) to coefficient names.
    dtypes:
        Dict associating dtypes (as string values) to coefficient names.
    v_type:
        Optional (name, group) tuple of strings containing registration
        information enabling to recover the `Vector` subclass.
    kwargs:
        Dict containing any subclass-specific metadata useful in building
        back a Vector from its specifications and flattened values.
    """

    names: List[str]
    shapes: Dict[str, Tuple[int, ...]]
    dtypes: Dict[str, str]
    v_type: Optional[Tuple[str, str]] = None
    kwargs: Dict[str, Any] = dataclasses.field(default_factory=dict)