pulsatrix
Loading...
Searching...
No Matches
pbt.hpp File Reference

Population Based Training (Jaderberg et al. 2017, "Population Based Training of Neural Networks"): a population of live, incrementally-trained trials periodically truncation-selected – the bottom fraction exploits (copies weights and hyperparameters from a uniformly-randomly-chosen top performer) then explores (perturbs the copied hyperparameters) – producing a hyperparameter schedule (different effective hyperparameters at different points in training) rather than a single fixed configuration. More...

#include <algorithm>
#include <cmath>
#include <map>
#include <memory>
#include <numeric>
#include <random>
#include <stdexcept>
#include <variant>
#include <vector>
#include "pulsatrix/pbt_trial.hpp"
#include "pulsatrix/search_space.hpp"
Include dependency graph for pbt.hpp:

Go to the source code of this file.

Classes

struct  pulsatrix::PBTTruncationGroups
 Indices of the population's current worst- and best-performing members. More...
 
struct  pulsatrix::PBTResult
 The best-performing trial's index, its metric, and how many generations ran. More...
 

Namespaces

namespace  pulsatrix
 

Functions

PBTTruncationGroups pulsatrix::ComputeTruncationGroups (const std::vector< double > &metrics, double truncation_fraction)
 Pure core: identifies the bottom and top truncation_fraction of the population by metric (higher is better). Ties are broken by a stable sort on descending metric, so the earlier index among equal values sorts toward "top." At least one individual is always selected on each end, even if floor(size*fraction) would be 0.
 
Configuration pulsatrix::ExploreConfigurationGivenFactors (const Configuration &config, const SearchSpace &space, const std::map< std::string, double > &factors)
 Pure core: applies an explicit per-parameter multiplicative factor to every Continuous/LogUniform/Integer parameter in config, clamped to that parameter's own bounds – PBT's own "explore" step (Jaderberg et al.'s own simple perturbation: multiply by 0.8 or 1.2). Categorical parameters are left unchanged (explore, in its original form, perturbs numeric hyperparameters only – a deliberate, logged scope decision, not an oversight). Integer results are rounded to the nearest integer.
 
template<typename RNG >
Configuration pulsatrix::ExploreConfiguration (const Configuration &config, const SearchSpace &space, RNG &rng)
 RNG-driven wrapper: draws each non-categorical parameter's factor uniformly from {0.8, 1.2} (Jaderberg et al.'s own standard explore perturbation), then applies ExploreConfigurationGivenFactors.
 
template<typename RNG >
std::vector< double > pulsatrix::RunPBTGeneration (std::vector< std::unique_ptr< PBTResumableTrial > > &trials, const SearchSpace &space, int num_epochs, double truncation_fraction, RNG &rng)
 Runs one PBT generation: trains every live trial for num_epochs, then exploits+explores the bottom truncation_fraction of the population from a uniformly-randomly-chosen member of the top truncation_fraction. Individuals outside both groups are left running untouched. Returns each trial's metric as of this generation (post exploit/explore for any trial that was replaced) – the value to feed into the next generation's own truncation.
 
template<typename RNG >
PBTResult pulsatrix::RunPBT (std::vector< std::unique_ptr< PBTResumableTrial > > &trials, const SearchSpace &space, int num_generations, int epochs_per_generation, double truncation_fraction, RNG &rng)
 Runs num_generations of RunPBTGeneration in sequence.
 

Detailed Description

Population Based Training (Jaderberg et al. 2017, "Population Based Training of Neural Networks"): a population of live, incrementally-trained trials periodically truncation-selected – the bottom fraction exploits (copies weights and hyperparameters from a uniformly-randomly-chosen top performer) then explores (perturbs the copied hyperparameters) – producing a hyperparameter schedule (different effective hyperparameters at different points in training) rather than a single fixed configuration.