nami.core.specs#
Functions
|
normaliser to take flexible input and return always a tuple for convenience. |
|
returns the total number of elements in the event shape |
|
collapse all event dimensions into a single flat dimension |
|
given a tensor, return shape split into leading shape and event shape |
|
inverse of flatten_event |
|
Runtime assertion helper to enforce explicit shapes and prevent silent broadcasting |
Classes
|
Minimal tensor specification for models, samplers, and distributions. |
- class nami.core.specs.TensorSpec(event_shape, dtype=None)[source]#
Bases:
objectMinimal tensor specification for models, samplers, and distributions.
Attributes:#
event_shape (tuple[int, …]): The shape of a single event (sample, vector, matrix, etc). dtype (torch.dtype | None): The expected data type of the tensor.
- nami.core.specs.as_tuple(x)[source]#
normaliser to take flexible input and return always a tuple for convenience.
- nami.core.specs.event_numel(event_shape)[source]#
returns the total number of elements in the event shape
- nami.core.specs.flatten_event(x, event_ndim)[source]#
collapse all event dimensions into a single flat dimension
- nami.core.specs.split_event(x, event_ndim)[source]#
given a tensor, return shape split into leading shape and event shape