本文整理汇总了Python中network.Network.create_set方法的典型用法代码示例。如果您正苦于以下问题:Python Network.create_set方法的具体用法?Python Network.create_set怎么用?Python Network.create_set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network.Network
的用法示例。
在下文中一共展示了Network.create_set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_network_list
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import create_set [as 别名]
def generate_network_list(nn_param_choices):
"""Generate a list of all possible networks.
Args:
nn_param_choices (dict): The parameter choices
Returns:
networks (list): A list of network objects
"""
networks = []
# This is silly.
for nbn in nn_param_choices['nb_neurons']:
for nbl in nn_param_choices['nb_layers']:
for a in nn_param_choices['activation']:
for o in nn_param_choices['optimizer']:
# Set the parameters.
network = {
'nb_neurons': nbn,
'nb_layers': nbl,
'activation': a,
'optimizer': o,
}
# Instantiate a network object with set parameters.
network_obj = Network()
network_obj.create_set(network)
networks.append(network_obj)
return networks
示例2: breed
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import create_set [as 别名]
def breed(self, mother, father):
"""Make two children as parts of their parents.
Args:
mother (dict): Network parameters
father (dict): Network parameters
Returns:
(list): Two network objects
"""
children = []
for _ in range(2):
child = {}
# Loop through the parameters and pick params for the kid.
for param in self.nn_param_choices:
child[param] = random.choice(
[mother.network[param], father.network[param]]
)
# Now create a network object.
network = Network(self.nn_param_choices)
network.create_set(child)
# Randomly mutate some of the children.
if self.mutate_chance > random.random():
network = self.mutate(network)
children.append(network)
return children
示例3: breed
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import create_set [as 别名]
def breed(self, mother, father):
"""Make two children as parts of their parents.
Args:
mother (dict): Network parameters
father (dict): Network parameters
Returns:
(list): Two network objects
"""
children = []
for _ in range(2):
child = {}
child['activation'] = random.choice([mother.network['activation'], father.network['activation']])
child['optimizer'] = random.choice([mother.network['optimizer'], father.network['optimizer']])
child['epochs'] = random.choice([mother.network['epochs'], father.network['epochs']])
layer_parent = random.choice([mother, father])
child['nb_layers'] = layer_parent.network['nb_layers']
child['nb_neurons'] = []
child['nb_neurons'].extend(layer_parent.network['nb_neurons'])
# Now create a network object.
network = Network(self.nn_param_choices)
network.create_set(child)
if self.mutate_chance > random.random():
network = self.mutate(network)
children.append(self.mutate(network))
return children