hyperopt - TPE
在hyperopt/tpe.py:935
处打一断点
5:超参的取值
3:loss的取值
{
'GMM1', 'GMM1_lpdf', 'len', 'dict', 'literal', 'broadcast_best', 'getitem', 'sub', 'array_union', 'mul', 'add',
'ap_split_trials', 'adaptive_parzen_normal', 'pos_args'}
重点看一下hyperopt.tpe.build_posterior
obs_memo 的 keys
采样函数: hyperopt/tpe.py:476
@adaptive_parzen_sampler("uniform")
def ap_uniform_sampler(obs, prior_weight, low, high, size=(), rng=None):
prior_mu = 0.5 * (high + low)
prior_sigma = 1.0 * (high - low)
weights, mus, sigmas = scope.adaptive_parzen_normal(
obs, prior_weight, prior_mu, prior_sigma
)
return scope.GMM1(
weights, mus, sigmas, low=low, high=high, q=None, size=size, rng=rng
)
@implicit_stochastic
@scope.define
def GMM1(weights, mus, sigmas, low=None, high=None, q=None, rng=None, size=()):
"""Sample from truncated 1-D Gaussian Mixture Model"""
weights, mus, sigmas = list(map(np.asarray, (weights, mus, sigmas)))
assert len(weights) == len(mus) == len(sigmas)
n_samples = int(np.prod(size))
# n_components = len(weights)
if low is None and high is None:
# -- draw from a standard GMM
active = np.argmax(rng.multinomial(1, weights, (n_samples,)), axis=1)
samples = rng.normal(loc=mus[active], scale=sigmas[active])
else