mix
Dataset wrapper that mixes each sample with a random partner via a pairwise transform.
Classes:
-
MixDatasetβDraws a second random sample and applies a pairwise mix transform.
MixDataset [source] ΒΆ
MixDataset(
dataset: Dataset,
mix: Callable[
[Dict[str, Any], Dict[str, Any]], Dict[str, Any]
],
transform: Optional[
Callable[[Dict[str, Any]], Dict[str, Any]]
] = None,
seed: Optional[int] = None,
)
Bases: Dataset, Randomizable
Draws a second random sample and applies a pairwise mix transform.
Each source sample is produced by the wrapped dataset (its own transform runs first), then a partner sample is drawn at a random index and merged via mix(data, other). Pairwise mixes such as Mix3D, LaserMix, and PolarMix fit this contract; the mix's own p decides how often the merge actually happens.
Parameters:
-
dataset(Dataset) βThe wrapped dataset; its own
transformruns per source sample before mixing. -
mix(Callable[[Dict[str, Any], Dict[str, Any]], Dict[str, Any]]) βPairwise transform called as
mix(data, other). -
transform(Optional[Callable[[Dict[str, Any]], Dict[str, Any]]], default:None) βOptional per-sample transform applied after mixing.
-
seed(Optional[int], default:None) βSeed for the partner index;
Nonedraws from the global generator (seeRandomizable).
Methods:
-
set_random_stateβGive the object its own random stream, or return it to the global generator.
set_random_state [source] ΒΆ
Give the object its own random stream, or return it to the global generator.
Parameters:
-
seed(Optional[int], default:None) βSeed of a new generator.
-
state(Optional[Generator], default:None) βGenerator to draw from, shared with the caller.
Returns:
-
SelfβThe object itself, for chaining.
Raises:
-
ValueErrorβIf both
seedandstateare given.