torchsig.datasets.datasets.TorchsigIterableDataset

class torchsig.datasets.datasets.TorchsigIterableDataset(dataset_metadata: DatasetMetadata | str | dict, **kwargs)[source]

Bases: IterableDataset, Seedable

Creates a new TorchSig dataset that generates data infinitely unless num_samples inside dataset_metadata is defined.

This base class provides the functionality to generate signals and write them to disk if necessary. The dataset will continue to generate samples infinitely unless a num_samples value is defined in the dataset_metadata.

Methods

add_parent

Add parent Seedable object and set up RNGs accordingly

get_distribution

get_second_seed

Gets second seed, usually used to seed both torch and numpy generators with slightly different seeds

reset

Resets the dataset to its initial state.

seed

Seed number generators with given seed.

setup_rngs

Initialize torch and numpy number generators, and update its children.

update_from_parent

Update numpy and torch number generators with parent seed

Attributes

dataset_metadata

Returns the dataset metadata.

__init__(dataset_metadata: DatasetMetadata | str | dict, **kwargs)[source]

Initializes the dataset, creates signal builders, and prepares file handlers based on metadata.

Parameters:
  • dataset_metadata (DatasetMetadata | str | dict) – The dataset metadata.

  • **kwargs – Additional keyword arguments for initialization.

reset()[source]

Resets the dataset to its initial state.

__str__() str[source]

Returns a string representation of the dataset, including its metadata and the signal builders.

Returns:

String representation of the dataset.

Return type:

str

__repr__()[source]

Returns a string representation of the object with all its attributes.

Returns:

String representation of the object with its attributes.

Return type:

str

property dataset_metadata

Returns the dataset metadata.

Returns:

The dataset metadata.

Return type:

DatasetMetadata

add_parent(parent) None

Add parent Seedable object and set up RNGs accordingly

get_second_seed(seed: int) int

Gets second seed, usually used to seed both torch and numpy generators with slightly different seeds

Parameters:

seed (int) – Seed to use.

Returns:

New seed.

Return type:

int

seed(seed: int) None

Seed number generators with given seed.

Parameters:

seed (int) – Seed to use.

setup_rngs() None

Initialize torch and numpy number generators, and update its children.

update_from_parent() None

Update numpy and torch number generators with parent seed