我试图实现google引擎的超参数调优功能,使用的是scikit优化(skopt)。我不知道如何始终如一地将ml engine的scaleType转换为skopt.space.Real的prior。
制服是足够直接的,日志制服看起来每个都有一个等价的--但我不完全确定实现是一致的。我也不确定如何实现ml engine的UNIT_REVERSE_LOG_SCALE (如果LOG_SCALE与skopt的log-uniform优先一致)。对于远离0的参数,log-uniform分布的行为似乎并不像人们所希望的那样--例如,如果您想在0.9和0.999之间扩展,则分布接近统一(见下面的第一幅图)。
使用skopt的log-uniform和下面的几个自定义转换进行代码和可视化。
#!/usr/bin/python
import numpy as np
import matplotlib.pyplot as plt
import skopt
def sample_custom_log_uniform(min_val, max_val, n_samples):
sample = skopt.space.uniform(0, 1).rvs(n_samples)
return min_val + (10 ** sample - 1) / 9 *(max_val - min_val)
def sample_custom_reverse_log_uniform(min_val, max_val, n_samples):
sample = skopt.space.uniform(0, 1).rvs(n_samples)
return max_val - (10 ** sample - 1) / 9 *(max_val - min_val)
def sample(min_val, max_val, prior='log-uniform', n_samples=100000):
if prior == 'custom-log-uniform':
return sample_custom_log_uniform(min_val, max_val, n_samples)
elif prior == 'custom-reverse-log-uniform':
return sample_custom_reverse_log_uniform(min_val, max_val, n_samples)
else:
return skopt.space.Real(min_val, max_val, prior=prior).rvs(n_samples)
priors = (
'log-uniform', 'custom-log-uniform', 'custom-reverse-log-uniform')
fig, axes = plt.subplots(1, len(priors))
for (prior, ax) in zip(priors, axes):
ax.hist(sample(0.9, 0.999, prior))
ax.set_title(prior)
ax.set_yticklabels([])
plt.show()

我的问题是:
ml engine是否从上面将LOG_SCALE实现为log-uniform或custom-log-uniform,或者其他什么?ml engine是否将REVERSE_LOG_SCALE实现为上面的custom-reverse-log-uniform或其他什么东西?发布于 2019-01-25 23:52:38
对于具有可行区域a的参数,b:UNIT_LOG_SCALE将可行空间的对数缩放为0,1。这将值x映射为log(x / a) / log(b / a)。UNIT_REVERSE_LOG_SCALE将可行空间“反向”缩放为0,1。这将一个值x映射到1.0 - log((b + a) / a) / log(b /a)。
发布于 2019-01-22 10:58:50
云ML引擎并不是使用scikit学习来进行其超参数优化,而是使用自定义实现来提供最先进的结果。
https://stackoverflow.com/questions/54282342
复制相似问题