evox.algorithms.so.pso_variants.utils
¶
Module Contents¶
Functions¶
Find the value with the minimum key. |
|
Randomly select |
API¶
- evox.algorithms.so.pso_variants.utils.min_by(values: List[torch.Tensor], keys: List[torch.Tensor]) Tuple[torch.Tensor, torch.Tensor] [source]¶
Find the value with the minimum key.
- Parameters:
values – A tensor or list of tensors.
keys – A tensor or list of tensors corresponding to the values.
- Returns:
The value with the minimum key and the corresponding key.
- evox.algorithms.so.pso_variants.utils.random_select_from_mask(mask: torch.Tensor, count: int, dim: int = -1) torch.Tensor [source]¶
Randomly select
s
elements from a 1D mask using uniform noise.- Parameters:
key – A tensor used as the random seed.
mask – A tensor of shape (N,) containing {0, 1}.
s – The number of elements to select.
- Returns:
A new mask tensor with exactly
s
elements set to 1.