pg.tuning.Backend

Accessible via pg.tuning.Backend.

class Backend[source]

Bases: object

Interface for the tuning backend.

Methods:

create(name, group, dna_spec, algorithm, ...)

Create an instance of Backend based on pg.sample arguments.

next()

Get the feedback object for the next sample.

poll_result(name, **kwargs)

Gets tuning result by a unique tuning identifier.

classmethod create(name, group, dna_spec, algorithm, metrics_to_optimize, early_stopping_policy=None, num_examples=None, **kwargs)[source]

Create an instance of Backend based on pg.sample arguments.

The default implementation is to pass through all the arguments to __init__ for creating an instance of the backend. Users can override.

Return type:

pg.tuning.Backend

Parameters:
  • name – A string as a unique identifier for current sampling. Two separate calls to pg.sample with the same name (also the same algorithm) will share the same sampling queue, whose examples are proposed by the same search algorithm.

  • group – An string or integer as the group ID of current process in distributed sampling, which will be used to group different workers into co-worker groups. Workers with the same group id will work on the same trial. On the contrary, workers in different groups will always be working with different trials. If not specified, each worker in current sampling will be in different groups. group is usually used in the outer loops of nested search, in order to allow workers to work on the same higher-order item.

  • dna_spec – An pg.DNASpec object representing the search space.

  • algorithm – The search algorithm that samples the search space.

  • metrics_to_optimize – A sequence of string as the names of the metrics to be optimized by the algorithm, which is [‘reward’] by default. When specified, it should have only 1 item for single-objective algorithm and can have multiple items for algorithms that support multi-objective optimization.

  • early_stopping_policy – An optional early stopping policy for user to tell if incremental evaluation (which reports multiple measurements) on each example can be early short circuited. After each call to feedback.add_measurement, users can use method feedback.should_stop_early to check whether current example worth further evaluation or not.

  • num_examples – An optional integer as the max number of examples to sample. If None, sample will return an iterator of infinite examples.

  • **kwargs – Arguments passed to the BackendFactory subclass registered with the requested backend.

Returns:

A pg.tuning.Backend object.

abstract next()[source]

Get the feedback object for the next sample.

Return type:

pg.tuning.Feedback

abstract classmethod poll_result(name, **kwargs)[source]

Gets tuning result by a unique tuning identifier.

Return type:

pg.tuning.Result