oracle

package
v0.0.0-...-4c91ef0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2019 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package oracle includes pre-defined oracles for picking parameter values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Func

type Func func(previous []diviner.Trial, params diviner.Params, objective diviner.Objective, howmany int) ([]diviner.Values, error)

Func is an adapter type so that ordinary functions may be used as oracles.

func (Func) Next

func (f Func) Next(previous []diviner.Trial, params diviner.Params, objective diviner.Objective, howmany int) ([]diviner.Values, error)

Next implements diviner.Oracle.

type GridSearch

type GridSearch struct{}

func (*GridSearch) Next

func (_ *GridSearch) Next(previous []diviner.Trial,
	params diviner.Params, objective diviner.Objective,
	howmany int) ([]diviner.Values, error)

GridSearch is an oracle that performs grid searching [1]. It currently supports only discrete parameters, and returns errors if continuous parameters are encountered. GridSearch is deterministic, always returning parameters in the same order.

[1] https://en.wikipedia.org/wiki/Hyperparameter_optimization

type Random

type Random struct {
	// Seed records the random seed that will be used to initialize random number generation for
	// the next point. It is exported so it can be serialized to preserve the oracle's state.
	Seed int64
	// contains filtered or unexported fields
}

Random is an oracle that returns random points in the search space. This is typically much more effective than grid search for most hyperparameter optimization problems. Currently, this oracle supports only integer and real parameter types.

func NewRandom

func NewRandom(seed int64) *Random

NewRandom returns a new Random oracle with the given random seed.

func (*Random) Next

func (r *Random) Next(previous []diviner.Trial, params diviner.Params, objective diviner.Objective,
	howmany int) ([]diviner.Values, error)

Next implements Oracle.Next.

type Skopt

type Skopt struct {
	// BaseEstimator is the estimator used in by the oracle. It is one
	// of "GP" (default), "RF", "ET", "GBRT"; documented at
	// https://scikit-optimize.github.io/optimizer/index.html#skopt.optimizer.Optimizer
	BaseEstimator string
	// NumInitialPoints specifies the number of initialization
	// evaluations to perform before approximating the function using
	// the above estimator.
	NumInitialPoints int
	// AcquisitionFunc is the acquisition function that is used. One of
	// "gp_hedge" (default), "LCB", "EI", or "PI". See
	// https://scikit-optimize.github.io/optimizer/index.html#skopt.optimizer.Optimizer
	// for more details.
	AcquisitionFunc string
	// AcquisitionOptimizer is the method by which the acquisition
	// function is minimized. It is one of "sampling" or "lgbfs". By
	// default, the optimizer is selected automatically based on the
	// estimator and parameter space.
	AcquisitionOptimizer string
}

Skopt is an oracle that uses scikit-optimize [1] to perform bayesian optimization. It works by calling into Python, and expects the environment to have a Python installation with scikit-optimize available. (It may be installed with "pip install scikit-optimize"). The parameters in the class are passed to skopt.Optimizer, which is documented at [2]. Default values are used for parameter's zero values, also defined at [2].

[1] https://scikit-optimize.github.io/ [2] https://scikit-optimize.github.io/optimizer/index.html#skopt.optimizer.Optimizer

TODO(marius): support passing in scikit-optimize's "random state" for determinism.

TODO(marius): figure out a better distribution mechanism, perhaps by bundling a PEX package or the like.

func (*Skopt) Next

func (s *Skopt) Next(inputTrials []diviner.Trial, params diviner.Params, objective diviner.Objective, n int) ([]diviner.Values, error)

Next performs a single round of optimizations, yielding n trials. It fits a model based on the datapoints provided by the trials using the provided objective. This model is then used to select the next set of points by optimizing the configured acquisition function.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL