pub fn tournament_select<B: Backend>(
population: &Tensor<B, 2>,
fitness: &[f32],
tournament_size: usize,
n_winners: usize,
rng: &mut dyn Rng,
device: &<B as BackendTypes>::Device,
) -> Tensor<B, 2>Expand description
Gathers n_winners rows out of a population tensor by tournament.
Convenience wrapper that runs tournament_indices_host on the
host and then performs a single Tensor::select gather on the
device. The returned tensor has shape (n_winners, genome_dim).
population must have shape (N, D) where N matches
fitness.len(). tournament_size and n_winners are forwarded
directly to tournament_indices_host.
§Panics
Inherits the panic conditions of tournament_indices_host:
fitness.is_empty() or tournament_size < 2.