tlc.client.utils#

Module Contents#

Classes#

Class

Description

SubsetSequentialSampler

Samples elements sequentially from a given list of indices.

RangeSampler

Samples elements sequentially from a range

Functions#

Function

Description

bytes2str

str2bytes

take

batched_iterator

without_transforms

Ensures that, if the dataset is a Torchvision dataset, its transforms are temporarily removed.

standardized_transforms

Create a new transforms function which takes the whole sample as its only argument, rather than destructuring it.

API#

tlc.client.utils.bytes2str(obj: bytes) str#
tlc.client.utils.str2bytes(s: str) bytes#
tlc.client.utils.take(iterator: collections.abc.Iterator, batch_size: int) list#
tlc.client.utils.batched_iterator(iterator: collections.abc.Iterable, batch_size: int) collections.abc.Iterator[list]#
class tlc.client.utils.SubsetSequentialSampler(indices: list[int])#

Bases: torch.utils.data.sampler.Sampler[int]

Samples elements sequentially from a given list of indices.

class tlc.client.utils.RangeSampler(end: int, start: int = 0, step: int = 1)#

Bases: torch.utils.data.sampler.Sampler[int]

Samples elements sequentially from a range

tlc.client.utils.without_transforms(dataset: torch.utils.data.Dataset) Generator[Callable | None, None, None]#

Ensures that, if the dataset is a Torchvision dataset, its transforms are temporarily removed.

Parameters:

dataset – The dataset to temporarily remove transforms from.

tlc.client.utils.standardized_transforms(transforms: Callable[..., Any]) Callable[[Any], Any]#

Create a new transforms function which takes the whole sample as its only argument, rather than destructuring it.

Parameters:

transforms – The transforms function to standardize.

Returns:

The standardized transforms function.