- flamo.optimize.utils.generate_partitions(tensor: Tensor, n_samples: int, n_sets: int, seed: int | None = None)
Create
n_sets
sets oflength(tensor) // n_samples
partitions of a tensor, and the items are shuffled randomly for each set.- Arguments:
tensor (torch.Tensor): The input tensor to partition.
n_samples (int): The number of samples in each partition.
n_sets (int): The number of different sets of partitions.
seed (int, optional): A seed for reproducibility. Default is None.
- Returns:
list of lists of torch.Tensor: list of
n_sets
sets, where each set containslength(tensor) // n_samples
partitions.