torchsig.transforms.target_transforms.TargetTransform¶
- class torchsig.transforms.target_transforms.TargetTransform(**kwargs)[source]¶
Bases:
TransformTarget Transform base class
This class defines the basic structure of a target transform, which includes: - The ability to validate metadata before applying the transform. - A method for applying the transform on signal metadata. - A callable interface to apply the transform to a list of signal metadata.
- required_metadata¶
List of metadata fields required for applying the target transform.
- Type:
List[str]
- targets_metadata¶
List of target metadata fields to be added to output of target transform.
- Type:
List[str]
- __validate(metadata
Dict[str, Any]) -> Dict[str, Any]: Validates the signal metadata before applying the transform.
- __apply(metadata
Dict[str, Any]) -> Dict[str, Any]: Applies the target transform to the metadata. Should be overridden by subclasses.
- __call__(metadatas
List[Dict[str, Any]], enable_verify: bool = True) -> List[Dict[str, Any]]: Applies the transform to a list of signal metadata dictionaries.
Methods
Add parent Seedable object and set up RNGs accordingly
get_distributionGets second seed, usually used to seed both torch and numpy generators with slightly different seeds
Seed number generators with given seed.
Initialize torch and numpy number generators, and update its children.
Update bookeeping for signals
Update numpy and torch number generators with parent seed
- __call__(metadatas: List[Dict[str, Any]], enable_verify=True) List[Any] | Dict[str, Any][source]¶
Applies the target transform to a list of signal metadata.
- __repr__() str[source]¶
Transform string representation. Should be able to recreate class from this string.
- Returns:
Transform representation.
- Return type:
- get_second_seed(seed: int) int¶
Gets second seed, usually used to seed both torch and numpy generators with slightly different seeds
- update(signal: Signal | DatasetSignal) None¶
Update bookeeping for signals
- Parameters:
signal (Signal | DatasetSignal) – signal to update metadata.
- Raises:
NotImplementedError – Inherited classes must override this method.