Skip to main content

tournament_select

Function tournament_select 

Source
pub fn tournament_select<B: Backend>(
    population: &Tensor<B, 2>,
    fitness: &[f32],
    tournament_size: usize,
    n_winners: usize,
    rng: &mut dyn Rng,
    device: &B::Device,
) -> Tensor<B, 2>
Expand description

Gather n_winners rows out of the population by tournament.

Convenience wrapper that lifts tournament_indices_host into a device gather on the population tensor.

§Panics

Inherits the panic conditions of tournament_indices_host: fitness.is_empty() or tournament_size < 2.