代码之家  ›  专栏  ›  技术社区  ›  DomJack

云引擎scaleType实现

  •  0
  • DomJack  · 技术社区  · 6 年前

    我正在尝试使用SciKit优化(skopt)实现GoogleCloudML引擎的超参数调优功能。我不确定如何始终转换ML引擎 scaleType skopt.space.Real prior S.

    制服足够直,圆木也一样 每种方法都有一个等价物,但我不完全确定实现是否一致。我也不确定如何实现ML引擎 UNIT_REVERSE_LOG_SCALE 如果 LOG_SCALE skopt log-uniform 优先。这个 原木均匀 对于远离的参数,分布的行为似乎不像人们希望的那样。 0 -例如,如果你想在 0.9 0.999 分布接近均匀(见下面的第一张图)。

    代码和可视化使用 斯科普 S 原木均匀 以及下面的一些自定义转换。

    #!/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()
    

    distributions

    我的问题是:

    • ml engine 实施 对数刻度 作为 原木均匀 custom-log-uniform 从上面还是别的什么?
    • ML引擎 实施 REVERSE_LOG_SCALE 作为 custom-reverse-log-uniform 在上面,还是其他什么?
    2 回复  |  直到 6 年前
        1
  •  1
  •   lwz1992    6 年前

    对于具有可行区域[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-x)/a)/log(b/a)。

        2
  •  0
  •   rhaertel80    6 年前

    CloudML引擎不使用Scikit Learn进行超参数优化,而是使用自定义实现来提供最先进的结果。