SMAC源码分析

这次依然用官方的Example:examples/SMAC4HPO_svm.py

初始化与DOE

DOE: Design of Experiment

初始采样次数的确定

self.init_budget = 12

        self.init_budget = int(max(1, min(n_configs_x_params * n_params,
                          (max_config_fracs * scenario.ta_run_limit))))

n_configs_x_params
Out[2]: 10
n_params
Out[3]: 7
max_config_fracs
Out[4]: 0.25
scenario.ta_run_limit
Out[5]: 50.0
scenario.ta_run_limit*0.25
Out[6]: 12.5
        n_configs_x_params: int
            how many configurations will be used at most in the initial design (X*D)
        max_config_fracs: float
            use at most X*budget in the initial design. Not active if a time limit is given.

DOE

smac.initial_design.sobol_design.SobolDesign#_select_configurations

sobol = sobol_seq.i4_sobol_generate(len(params) - constants, self.init_budget)

看看算出来这个东西是什么

sobol
Out[6]: 
array([[0.5   , 0.5   , 0.5   , 0.5   , 0.5   , 0.5   , 0.5   ],
       [0.75  , 0.25  , 0.75  , 0.25  , 0.75  , 0.25  , 0.75  ],
       [0.25  , 0.75  , 0.25  , 0.75  , 0.25  , 0.75  , 0.25  ],
       [0.375 , 0.375 , 0.625 , 0.125 , 0.875 , 0.875 , 0.125 ],
       [0.875 , 0.875 , 0.125 , 0.625 , 0.375 , 0.375 , 0.625 ],
       [0.625 , 0.125 , 0.375 , 0.375 , 0.125 , 0.625 , 0.875 ],
       [0.125 , 0.625 , 0.875 , 0.875 , 0.625 , 0.125 , 0.375 ],
       [0.1875, 0.3125, 0.3125, 0.6875, 0.5625, 0.1875, 0.0625],
       [0.6875, 0.8125, 0.8125, 0.1875, 0.0625, 0.6875, 0.5625],
       [0.9375, 0.0625, 0.5625, 0.9375, 0.3125, 0.4375, 0.8125],
       [0.4375, 0.5625, 0.0625, 0.4375, 0.8125, 0.9375, 0.3125],
       [0.3125, 0.1875, 0.9375, 0.5625, 0.4375, 0.8125, 0.1875]])

第一个参数是维数,第二个参数是样本数。
不过需要注意的是,sobol_seq规定,维数不能大于40 。

self.init_budget = 12


将design向量封装为Configuration

sobol_seq.sobol_seq.i4_sobol_generate

cs
Out[11]: 
Configuration space object:
  Hyperparameters:
    C, Type: UniformFloat, Range: [0.001, 1000.0], Default: 1.0
    coef0, Type: UniformFloat, Range: [0.0, 10.0], Default: 0.0
    degree, Type: UniformInteger, Range: [1, 5], Default:
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值