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


Python Network.create_set方法代码示例

本文整理汇总了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
开发者ID:namlehai,项目名称:neural-network-genetic-algorithm,代码行数:35,代码来源:brute.py

示例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
开发者ID:namlehai,项目名称:neural-network-genetic-algorithm,代码行数:35,代码来源:optimizer.py

示例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
开发者ID:jsalatas,项目名称:HandsFreeWear,代码行数:37,代码来源:optimizer.py


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