tpe

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: MIT Imports: 7 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultGamma

func DefaultGamma(x int) int

DefaultGamma is a default gamma function.

func DefaultWeights

func DefaultWeights(x int) []float64

DefaultWeights is a default weights function.

func HyperoptDefaultGamma

func HyperoptDefaultGamma(x int) int

HyperoptDefaultGamma is a default gamma function of Hyperopt.

Types

type FuncGamma

type FuncGamma func(int) int

FuncGamma is a type of gamma function.

type FuncWeights

type FuncWeights func(int) []float64

FuncWeights is a type of weights function.

type ParzenEstimator

type ParzenEstimator struct {
	Weights []float64
	Mus     []float64
	Sigmas  []float64
}

ParzenEstimator is a surrogate model for TPE>

func NewParzenEstimator

func NewParzenEstimator(mus []float64, low, high float64, params ParzenEstimatorParams) *ParzenEstimator

NewParzenEstimator returns the parzen estimator object.

type ParzenEstimatorParams

type ParzenEstimatorParams struct {
	ConsiderPrior     bool
	ConsiderMagicClip bool
	ConsiderEndpoints bool
	Weights           FuncWeights
	PriorWeight       float64 // optional
}

ParzenEstimatorParams holds the parameters of ParzenEstimator

type Sampler

type Sampler struct {
	// contains filtered or unexported fields
}

Sampler returns the next search points by using TPE.

func NewSampler

func NewSampler(opts ...SamplerOption) *Sampler

NewSampler returns the TPE sampler.

func (*Sampler) Sample

func (s *Sampler) Sample(
	study *goptuna.Study,
	trial goptuna.FrozenTrial,
	paramName string,
	paramDistribution interface{},
) (float64, error)

Sample a parameter for a given distribution.

type SamplerOption

type SamplerOption func(sampler *Sampler)

SamplerOption is a type of the function to customizing TPE sampler.

func SamplerOptionConsiderEndpoints added in v0.6.0

func SamplerOptionConsiderEndpoints(considerEndpoints bool) SamplerOption

SamplerOptionConsiderEndpoints take endpoints of domains into account when calculating variances of Gaussians in Parzen estimator. See the original paper for details on the heuristics to calculate the variances.

func SamplerOptionConsiderMagicClip added in v0.6.0

func SamplerOptionConsiderMagicClip(considerMagicClip bool) SamplerOption

SamplerOptionPriorWeight enable a heuristic to limit the smallest variances of Gaussians used in the Parzen estimator.

func SamplerOptionConsiderPrior added in v0.6.0

func SamplerOptionConsiderPrior(considerPrior bool) SamplerOption

SamplerOptionConsiderPrior enhance the stability of Parzen estimator by imposing a Gaussian prior when True. The prior is only effective if the sampling distribution is either `UniformDistribution`, `DiscreteUniformDistribution`, `LogUniformDistribution`, or `IntUniformDistribution`.

func SamplerOptionGammaFunc

func SamplerOptionGammaFunc(gamma FuncGamma) SamplerOption

SamplerOptionGammaFunc sets the function that takes the number of finished trials and returns the number of trials to form a density function for samples with low grains.

func SamplerOptionNumberOfEICandidates

func SamplerOptionNumberOfEICandidates(n int) SamplerOption

SamplerOptionNumberOfEICandidates sets the number of EI candidates (default 24).

func SamplerOptionNumberOfStartupTrials

func SamplerOptionNumberOfStartupTrials(n int) SamplerOption

SamplerOptionNumberOfStartupTrials sets the number of start up trials (default 10).

func SamplerOptionParzenEstimatorParams

func SamplerOptionParzenEstimatorParams(params ParzenEstimatorParams) SamplerOption

SamplerOptionParzenEstimatorParams sets the parameter of ParzenEstimator.

func SamplerOptionPriorWeight added in v0.6.0

func SamplerOptionPriorWeight(priorWeight float64) SamplerOption

SamplerOptionPriorWeight sets the weight of the prior.

func SamplerOptionSeed

func SamplerOptionSeed(seed int64) SamplerOption

SamplerOptionSeed sets seed number.

func SamplerOptionWeights added in v0.6.0

func SamplerOptionWeights(weights func(x int) []float64) SamplerOption

SamplerOptionWeights sets the function that takes the number of finished trials and returns a weight for them. See `Making a Science of Model Search: Hyperparameter Optimization in Hundreds of Dimensions for Vision Architectures <http://proceedings.mlr.press/v28/bergstra13.pdf>` for more details.

Jump to

Keyboard shortcuts

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