probly.representation.sampling.torch_sample¶
Torch sample implementation.
Classes
|
A sample implementation for torch tensors. |
- class probly.representation.sampling.torch_sample.TorchTensorSample(tensor, sample_dim)[source]¶
-
A sample implementation for torch tensors.
- classmethod from_iterable(samples, sample_dim=None, sample_axis='auto', dtype=None)[source]¶
Create an TorchTensorSample from a sequence of samples.
- Parameters:
samples (Iterable[torch.Tensor]) – The predictions to create the sample from.
sample_dim (SampleAxis | None) – The dimension along which samples are organized.
sample_axis (SampleAxis | None) – Alias for sample_dim for compatibility.
dtype (torch.dtype | None) – Desired data type of the array.
- Returns:
The created TorchTensorSample.
- Return type:
Self
- classmethod from_sample(sample, **kwargs)¶
Create a new Sample from an existing Sample.
- Parameters:
sample (Sample[T]) – The sample to create the new sample from.
kwargs (Unpack[SampleParams]) – Parameters for sample creation.
- Returns:
The created Sample.
- Return type:
Self
- move_sample_axis(new_sample_axis)[source]¶
Alias for
TorchTensorSample.move_sample_dim().- Parameters:
new_sample_axis (int)
- Return type:
- move_sample_dim(new_sample_dim)[source]¶
Return a new TorchTensorSample with the sample dimension moved to new_sample_dim.
- Parameters:
new_sample_dim (int) – The new sample dimension.
- Returns:
A new TorchTensorSample with the sample dimension moved.
- Return type:
- size(dim: int) int[source]¶
- size(dim: None = None) Size
The total number of elements in the underlying array.