当前位置: 首页>>代码示例>>Python>>正文


Python ConfigSpace.UniformFloatHyperparameter方法代码示例

本文整理汇总了Python中ConfigSpace.UniformFloatHyperparameter方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigSpace.UniformFloatHyperparameter方法的具体用法?Python ConfigSpace.UniformFloatHyperparameter怎么用?Python ConfigSpace.UniformFloatHyperparameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigSpace的用法示例。


在下文中一共展示了ConfigSpace.UniformFloatHyperparameter方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: import ConfigSpace [as 别名]
# 或者: from ConfigSpace import UniformFloatHyperparameter [as 别名]
def setUp(self):
		self.configspace = CS.ConfigurationSpace()

		self.HPs = []
		
		self.HPs.append( CS.CategoricalHyperparameter('parent', [1,2,3]))
		
		self.HPs.append( CS.CategoricalHyperparameter('child1_x1', ['foo','bar']))
		self.HPs.append( CS.UniformFloatHyperparameter('child2_x1', lower=-1, upper=1))
		self.HPs.append( CS.UniformIntegerHyperparameter('child3_x1', lower=-2, upper=5))

		self.configspace.add_hyperparameters(self.HPs)
		
		self.conditions = []
		
		self.conditions += [CS.EqualsCondition(self.HPs[1], self.HPs[0], 1)]
		self.conditions += [CS.EqualsCondition(self.HPs[2], self.HPs[0], 2)] 
		self.conditions += [CS.EqualsCondition(self.HPs[3], self.HPs[0], 3)]
		[self.configspace.add_condition(cond) for cond in self.conditions] 
开发者ID:automl,项目名称:HpBandSter,代码行数:21,代码来源:test_config_generators.py

示例2: create_configspace

# 需要导入模块: import ConfigSpace [as 别名]
# 或者: from ConfigSpace import UniformFloatHyperparameter [as 别名]
def create_configspace(parameter_config):
        """
        Wrap the Worker's get_configspace() function for HpBandSter interface
        """
        cs = CS.ConfigurationSpace()
        params = []
        for config in parameter_config:
            p = AbstractProposer.parse_param_config(config)
            if p['type'] == 'choice':
                param = CS.CategoricalHyperparameter(p['name'], choices=p['range'])
            else:  # for int or float
                param = dict(name=p['name'])
                param['lower'], param['upper'] = min(p['range']), max(p['range'])
                if p['type'] == 'int':
                    param = CS.UniformIntegerHyperparameter(**param)
                else:
                    param = CS.UniformFloatHyperparameter(**param)
            params.append(param)
        cs.add_hyperparameters(params)
        return cs 
开发者ID:LGE-ARC-AdvancedAI,项目名称:auptimizer,代码行数:22,代码来源:BOHBProposer.py

示例3: get_configspace

# 需要导入模块: import ConfigSpace [as 别名]
# 或者: from ConfigSpace import UniformFloatHyperparameter [as 别名]
def get_configspace():
    """ Returns the configuration space for the network to be configured in the example. """
    config_space = CS.ConfigurationSpace()
    config_space.add_hyperparameters([
        CSH.CategoricalHyperparameter('activation', ['tanh', 'relu']),
        CS.UniformFloatHyperparameter(
            'learning_rate_init', lower=1e-6, upper=1e-2, log=True)])
    
    solver = CSH.CategoricalHyperparameter('solver', ['sgd', 'adam'])
    config_space.add_hyperparameter(solver)
    
    beta_1 = CS.UniformFloatHyperparameter('beta_1', lower=0, upper=1)
    config_space.add_hyperparameter(beta_1)
    
    condition = CS.EqualsCondition(beta_1, solver, 'adam')
    config_space.add_condition(condition)
    
    beta_2 = CS.UniformFloatHyperparameter('beta_2', lower=0, upper=1)
    config_space.add_hyperparameter(beta_2)
    
    condition = CS.EqualsCondition(beta_2, solver, 'adam')
    config_space.add_condition(condition)
    
    return config_space 
开发者ID:automl,项目名称:BOAH,代码行数:26,代码来源:helper_functions.py

示例4: get_configuration_space

# 需要导入模块: import ConfigSpace [as 别名]
# 或者: from ConfigSpace import UniformFloatHyperparameter [as 别名]
def get_configuration_space():
        cs = ConfigSpace.ConfigurationSpace()

        ops_choices = ['conv1x1-bn-relu', 'conv3x3-bn-relu', 'maxpool3x3']
        cs.add_hyperparameter(ConfigSpace.CategoricalHyperparameter("op_node_0", ops_choices))
        cs.add_hyperparameter(ConfigSpace.CategoricalHyperparameter("op_node_1", ops_choices))
        cs.add_hyperparameter(ConfigSpace.CategoricalHyperparameter("op_node_2", ops_choices))
        cs.add_hyperparameter(ConfigSpace.CategoricalHyperparameter("op_node_3", ops_choices))
        cs.add_hyperparameter(ConfigSpace.CategoricalHyperparameter("op_node_4", ops_choices))

        cs.add_hyperparameter(ConfigSpace.UniformIntegerHyperparameter("num_edges", 0, MAX_EDGES))

        for i in range(VERTICES * (VERTICES - 1) // 2):
            cs.add_hyperparameter(ConfigSpace.UniformFloatHyperparameter("edge_%d" % i, 0, 1))
        return cs 
开发者ID:automl,项目名称:nas_benchmarks,代码行数:17,代码来源:nas_cifar10.py

示例5: get_configspace

# 需要导入模块: import ConfigSpace [as 别名]
# 或者: from ConfigSpace import UniformFloatHyperparameter [as 别名]
def get_configspace():
        config_space = CS.ConfigurationSpace()
        config_space.add_hyperparameter(CS.UniformFloatHyperparameter('x', lower=0, upper=1))
        return(config_space) 
开发者ID:automl,项目名称:HpBandSter,代码行数:6,代码来源:commons.py

示例6: setUp

# 需要导入模块: import ConfigSpace [as 别名]
# 或者: from ConfigSpace import UniformFloatHyperparameter [as 别名]
def setUp(self):
        self.configspace = CS.ConfigurationSpace(42)
        self.configspace.add_hyperparameters([CS.UniformFloatHyperparameter('cont1', lower=0, upper=1)])

        self.run_id = 'hpbandsterUnittestWorker' 
开发者ID:automl,项目名称:HpBandSter,代码行数:7,代码来源:test_worker.py

示例7: add_hyperparameters

# 需要导入模块: import ConfigSpace [as 别名]
# 或者: from ConfigSpace import UniformFloatHyperparameter [as 别名]
def add_hyperparameters(self):
		HPs=[]
		HPs.append( CS.UniformFloatHyperparameter('cont1', lower=0, upper=1))
		self.configspace.add_hyperparameters(HPs) 
开发者ID:automl,项目名称:HpBandSter,代码行数:6,代码来源:test_kde.py

示例8: _get_types

# 需要导入模块: import ConfigSpace [as 别名]
# 或者: from ConfigSpace import UniformFloatHyperparameter [as 别名]
def _get_types(self):
		""" extracts the needed types from the configspace for faster retrival later
		
			type = 0 - numerical (continuous or integer) parameter
			type >=1 - categorical parameter
			
			TODO: figure out a way to properly handle ordinal parameters
		
		"""
		types = []
		num_values = []
		for hp in self.configspace.get_hyperparameters():
			#print(hp)
			if isinstance(hp, CS.CategoricalHyperparameter):
				types.append('U')
				num_values.append(len(hp.choices))
			elif isinstance(hp, CS.UniformIntegerHyperparameter):
				types.append('I')
				num_values.append((hp.upper - hp.lower + 1))
			elif isinstance(hp, CS.UniformFloatHyperparameter):
				types.append('C')
				num_values.append(np.inf)
			elif isinstance(hp, CS.OrdinalHyperparameter):
				types.append('O')
				num_values.append(len(hp.sequence))
			else:
				raise ValueError('Unsupported Parametertype %s'%type(hp))
		return(types, num_values) 
开发者ID:automl,项目名称:HpBandSter,代码行数:30,代码来源:mvkde.py

示例9: get_fANOVA_data

# 需要导入模块: import ConfigSpace [as 别名]
# 或者: from ConfigSpace import UniformFloatHyperparameter [as 别名]
def get_fANOVA_data(self, config_space, budgets=None):

		import numpy as np
		import ConfigSpace as CS

		id2conf = self.get_id2config_mapping()

		if budgets is None:
			budgets = self.HB_config['budgets']

		if len(budgets)>1:
			config_space.add_hyperparameter(CS.UniformFloatHyperparameter('budget', min(budgets), max(budgets), log=True))
		
		hp_names = list(map( lambda hp: hp.name, config_space.get_hyperparameters()))

		all_runs = self.get_all_runs(only_largest_budget=False)


		all_runs=list(filter( lambda r: r.budget in budgets, all_runs))

		X = []
		y = []

		for r in all_runs:
			if r.loss is None: continue
			config = id2conf[r.config_id]['config']
			if len(budgets)>1:
				config['budget'] = r.budget

			config = CS.Configuration(config_space, config)

			X.append([config[n] for n in hp_names])
			y.append(r.loss)

		return(np.array(X), np.array(y), config_space) 
开发者ID:automl,项目名称:nasbench-1shot1,代码行数:37,代码来源:result.py

示例10: get_config_space

# 需要导入模块: import ConfigSpace [as 别名]
# 或者: from ConfigSpace import UniformFloatHyperparameter [as 别名]
def get_config_space(
        num_groups=(1, 9),
        blocks_per_group=(1, 4),
        max_units=((10, 1024), True),
        activation=('sigmoid', 'tanh', 'relu'),
        max_shake_drop_probability=(0, 1),
        max_dropout=(0, 1.0),
        resnet_shape=('funnel', 'long_funnel', 'diamond', 'hexagon', 'brick', 'triangle', 'stairs'),
        use_dropout=(True, False),
        use_shake_shake=(True, False),
        use_shake_drop=(True, False)
    ):
        cs = CS.ConfigurationSpace()
        
        num_groups_hp = get_hyperparameter(CS.UniformIntegerHyperparameter, "num_groups", num_groups)
        cs.add_hyperparameter(num_groups_hp)
        blocks_per_group_hp = get_hyperparameter(CS.UniformIntegerHyperparameter, "blocks_per_group", blocks_per_group)
        cs.add_hyperparameter(blocks_per_group_hp)
        add_hyperparameter(cs, CS.CategoricalHyperparameter, "activation", activation)
        use_dropout_hp = add_hyperparameter(cs, CS.CategoricalHyperparameter, "use_dropout", use_dropout)
        add_hyperparameter(cs, CS.CategoricalHyperparameter, "use_shake_shake", use_shake_shake)
        
        shake_drop_hp = add_hyperparameter(cs, CS.CategoricalHyperparameter, "use_shake_drop", use_shake_drop)
        if True in use_shake_drop:
            shake_drop_prob_hp = add_hyperparameter(cs, CS.UniformFloatHyperparameter, "max_shake_drop_probability",
                max_shake_drop_probability)
            cs.add_condition(CS.EqualsCondition(shake_drop_prob_hp, shake_drop_hp, True))
        
        add_hyperparameter(cs, CSH.CategoricalHyperparameter, 'resnet_shape', resnet_shape)
        add_hyperparameter(cs, CSH.UniformIntegerHyperparameter, "max_units", max_units)

        if True in use_dropout:
            max_dropout_hp = add_hyperparameter(cs, CSH.UniformFloatHyperparameter, "max_dropout", max_dropout)
            cs.add_condition(CS.EqualsCondition(max_dropout_hp, use_dropout_hp, True))

        return cs 
开发者ID:automl,项目名称:Auto-PyTorch,代码行数:38,代码来源:shapedresnet.py

示例11: get_config_space

# 需要导入模块: import ConfigSpace [as 别名]
# 或者: from ConfigSpace import UniformFloatHyperparameter [as 别名]
def get_config_space(   nr_main_blocks=[1, 8], nr_residual_blocks=([1, 16], True), initial_filters=([8, 32], True), widen_factor=([0.5, 4], True), 
                            res_branches=([1, 5], False), filters_size=[3, 3], **kwargs):
                            
        import ConfigSpace as CS
        import ConfigSpace.hyperparameters as CSH

        cs = CS.ConfigurationSpace()

        nr_main_blocks_hp = get_hyperparameter(ConfigSpace.UniformIntegerHyperparameter, "nr_main_blocks", nr_main_blocks)
        cs.add_hyperparameter(nr_main_blocks_hp)
        initial_filters_hp = get_hyperparameter(ConfigSpace.UniformIntegerHyperparameter, "initial_filters", initial_filters)
        cs.add_hyperparameter(initial_filters_hp)
        # add_hyperparameter(cs, CSH.UniformIntegerHyperparameter, 'nr_convs', nr_convs, log=True)
        death_rate_hp = get_hyperparameter(ConfigSpace.UniformFloatHyperparameter, "death_rate", ([0,1], False))
        cs.add_hyperparameter(death_rate_hp)

        if type(nr_main_blocks[0]) is int:
            main_blocks_min = nr_main_blocks[0]
            main_blocks_max = nr_main_blocks[1]
        else:
            main_blocks_min = nr_main_blocks[0][0]
            main_blocks_max = nr_main_blocks[0][1]
	    
        for i in range(1, main_blocks_max + 1):
            blocks_hp = get_hyperparameter(ConfigSpace.UniformIntegerHyperparameter, 'nr_residual_blocks_%d' % i, nr_residual_blocks)
            blocks = cs.add_hyperparameter(blocks_hp)
            widen_hp = get_hyperparameter(ConfigSpace.UniformFloatHyperparameter, 'widen_factor_%d' % i, widen_factor)
            widen = cs.add_hyperparameter(widen_hp)
            branches_hp = get_hyperparameter(ConfigSpace.UniformIntegerHyperparameter, 'res_branches_%d' % i, res_branches)
            branches = cs.add_hyperparameter(branches_hp)
            # filters = add_hyperparameter(cs, CSH.UniformIntegerHyperparameter, 'filters_size_%d' % i, filters_size, log=False)

            if i > main_blocks_min:
                cs.add_condition(CS.GreaterThanCondition(blocks_hp, nr_main_blocks_hp, i-1))
                cs.add_condition(CS.GreaterThanCondition(widen_hp, nr_main_blocks_hp, i-1))
                cs.add_condition(CS.GreaterThanCondition(branches_hp, nr_main_blocks_hp, i-1))
                # cs.add_condition(CS.GreaterThanCondition(filters, main_blocks, i-1))

        return cs 
开发者ID:automl,项目名称:Auto-PyTorch,代码行数:41,代码来源:resnet.py

示例12: get_fANOVA_data

# 需要导入模块: import ConfigSpace [as 别名]
# 或者: from ConfigSpace import UniformFloatHyperparameter [as 别名]
def get_fANOVA_data(self, config_space, budgets=None, loss_fn=lambda r: r.loss, failed_loss=None):

		import numpy as np
		import ConfigSpace as CS

		id2conf = self.get_id2config_mapping()

		if budgets is None:
			budgets = self.HB_config['budgets']

		if len(budgets)>1:
			config_space.add_hyperparameter(CS.UniformFloatHyperparameter('budget', min(budgets), max(budgets), log=True))
		
		hp_names = config_space.get_hyperparameter_names()
		hps = config_space.get_hyperparameters()
		needs_transform = list(map(lambda h: isinstance(h, CS.CategoricalHyperparameter), hps))

		all_runs = self.get_all_runs(only_largest_budget=False)


		all_runs=list(filter( lambda r: r.budget in budgets, all_runs))

		X = []
		y = []

		for r in all_runs:
			if r.loss is None:
				if failed_loss is None: continue
				else: y.append(failed_loss)
			else:
				y.append(loss_fn(r))
				
			config = id2conf[r.config_id]['config']
			if len(budgets)>1:
				config['budget'] = r.budget

			config = CS.Configuration(config_space, config)
			
			x = []
			for (name, hp, transform) in zip(hp_names, hps, needs_transform):
				if transform:
					x.append(hp._inverse_transform(config[name]))
				else:
					x.append(config[name])
			
			X.append(x)

		return(np.array(X), np.array(y), config_space) 
开发者ID:automl,项目名称:HpBandSter,代码行数:50,代码来源:result.py

示例13: get_config_space

# 需要导入模块: import ConfigSpace [as 别名]
# 或者: from ConfigSpace import UniformFloatHyperparameter [as 别名]
def get_config_space(
        num_groups=((1, 9), False),
        blocks_per_group=((1, 4), False),
        num_units=((10, 1024), True),
        activation=('sigmoid', 'tanh', 'relu'),
        max_shake_drop_probability=(0, 1),
        dropout=(0, 1.0),
        use_shake_drop=(True, False),
        use_shake_shake=(True, False),
        use_dropout=(True, False),
        **kwargs
    ):
        cs = ConfigSpace.ConfigurationSpace()

        num_groups_hp = get_hyperparameter(ConfigSpace.UniformIntegerHyperparameter, "num_groups", num_groups)
        cs.add_hyperparameter(num_groups_hp)
        blocks_per_group_hp = get_hyperparameter(ConfigSpace.UniformIntegerHyperparameter, "blocks_per_group", blocks_per_group)
        cs.add_hyperparameter(blocks_per_group_hp)
        add_hyperparameter(cs, ConfigSpace.CategoricalHyperparameter, "activation", activation)
        
        use_dropout_hp = get_hyperparameter(ConfigSpace.CategoricalHyperparameter, "use_dropout", use_dropout)
        cs.add_hyperparameter(use_dropout_hp)
        add_hyperparameter(cs, ConfigSpace.CategoricalHyperparameter, "use_shake_shake", use_shake_shake)
        
        use_shake_drop_hp = add_hyperparameter(cs, ConfigSpace.CategoricalHyperparameter, "use_shake_drop", use_shake_drop)
        if True in use_shake_drop:
            shake_drop_prob_hp = add_hyperparameter(cs, ConfigSpace.UniformFloatHyperparameter, "max_shake_drop_probability",
                max_shake_drop_probability)
            cs.add_condition(ConfigSpace.EqualsCondition(shake_drop_prob_hp, use_shake_drop_hp, True))
        

        # it is the upper bound of the nr of groups, since the configuration will actually be sampled.
        for i in range(0, num_groups[0][1] + 1):

            n_units_hp = add_hyperparameter(cs, ConfigSpace.UniformIntegerHyperparameter,
                "num_units_%d" % i, kwargs.pop("num_units_%d" % i, num_units))

            if i > 1:
                cs.add_condition(ConfigSpace.GreaterThanCondition(n_units_hp, num_groups_hp, i - 1))

            if True in use_dropout:
                dropout_hp = add_hyperparameter(cs, ConfigSpace.UniformFloatHyperparameter,
                    "dropout_%d" % i, kwargs.pop("dropout_%d" % i, dropout))
                dropout_condition_1 = ConfigSpace.EqualsCondition(dropout_hp, use_dropout_hp, True)

                if i > 1:
                
                    dropout_condition_2 = ConfigSpace.GreaterThanCondition(dropout_hp, num_groups_hp, i - 1)

                    cs.add_condition(ConfigSpace.AndConjunction(dropout_condition_1, dropout_condition_2))
                else:
                    cs.add_condition(dropout_condition_1)
        assert len(kwargs) == 0, "Invalid hyperparameter updates for resnet: %s" % str(kwargs)
        return cs 
开发者ID:automl,项目名称:Auto-PyTorch,代码行数:56,代码来源:resnet.py


注:本文中的ConfigSpace.UniformFloatHyperparameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。