示例#1
0
    def randomInit(self):
        self.conv_layers = []
        num_conv_layers = random.randint(1, Config.MAX_CONV_LAYERS)
        for l in range(num_conv_layers):
            layer = createRandomLayer().randomInit()
            self.conv_layers.append(layer)

        self.dense_layers = []
        num_dense_layers = random.randint(1, Config.MAX_DENSE_LAYERS)
        for l in range(num_dense_layers):
            layer = Layer().randomInit()
            self.dense_layers.append(layer)
    def addLayer(self, individual):
        conv_part = random.randint(0, 1)
        if (conv_part):
            l = random.randint(0, len(individual.conv_layers) - 1)
            if random.randint(0, 1):
                individual.conv_layers.insert(l, ConvLayer().randomInit())
            else:
                individual.conv_layers.insert(l, MaxPoolLayer().randomInit())
        else:
            l = random.randint(0, len(individual.dense_layers) - 1)
            individual.dense_layers.insert(l, Layer().randomInit())

        return individual,
示例#3
0
    def randomInit(self):
        self.conv_layers = []
        num_conv_layers = random.randint(
            1, config.global_config["network"]["max_conv_layers"])
        for l in range(num_conv_layers):
            layer = createRandomLayer().randomInit()
            self.conv_layers.append(layer)

        self.dense_layers = []
        num_dense_layers = random.randint(
            1, config.global_config["network"]["max_dense_layers"])
        for l in range(num_dense_layers):
            layer = Layer().randomInit()
            self.dense_layers.append(layer)
示例#4
0
 def addLayer(self, individual):
     l = random.randint(0, len(individual.layers) - 1)
     individual.layers.insert(l, Layer().randomInit())
     individual.strategy.blocks.insert(l, Block().randomInit())
     return individual,
示例#5
0
 def addLayer(self, individual):
     """ Inserts one random layer into individual."""
     l = random.randint(0, len(individual.layers) - 1)
     individual.layers.insert(l, Layer().randomInit())
     return individual,