コード例 #1
0
    def mutate(self,
               min_swap_probability=0.1,
               max_swap_probability=0.2,
               inverse_probability=0.01,
               random_probability=0.01,
               shift_probability=0.01):
        swap_probability = random.uniform(min_swap_probability,
                                          max_swap_probability)
        for inhabitant in self.generation:
            if decision(random_probability):
                inhabitant.gene = self._random_word()
            else:
                if decision(shift_probability):
                    shift_range = random.randint(1, 3)
                    inhabitant.gene = [inhabitant.gene[-shift_range]
                                       ] + inhabitant.gene[:-shift_range]

                for i in range(len(inhabitant.gene) // 2):
                    if decision(swap_probability):
                        random_id = random.randint(0, len(inhabitant) - 1)
                        inhabitant.gene[i], inhabitant.gene[random_id] = (
                            inhabitant.gene[random_id],
                            inhabitant.gene[i],
                        )

                if decision(inverse_probability):
                    inhabitant.gene = inhabitant.gene[::-1]
コード例 #2
0
    def mutate(self, min_swap_probability=0.1, max_swap_probability=0.2, inverse_probability=0.01, random_probability=0.005, shift_probability=0.01, insert_probability=0.01):
        swap_probability = random.uniform(min_swap_probability, max_swap_probability)
        for inhabitant in self.generation:
            if decision(insert_probability):
                possible_chars = self._random_word()
                for char in inhabitant.gene:
                    if char in possible_chars:
                        possible_chars.remove(char)
                inhabitant.gene += possible_chars[0]
            elif decision(random_probability):
                inhabitant.gene = self._random_word()
            else:
                if decision(shift_probability):
                    shift_range = random.randint(1, 3)
                    for _ in range(shift_range+1):
                        inhabitant.gene = [inhabitant.gene[-1]] + inhabitant.gene[:-1]

                for i in range(len(inhabitant.gene)//2):
                    if decision(swap_probability):
                        random_id = random.randint(0, len(inhabitant) - 1)
                        inhabitant.gene[i], inhabitant.gene[random_id] = (
                            inhabitant.gene[random_id],
                            inhabitant.gene[i],
                        )

                if decision(inverse_probability):
                    inhabitant.gene = inhabitant.gene[::-1]
コード例 #3
0
    def mutate(
        self,
        min_swap_probability=0.2,
        max_swap_probability=1,
        inverse_probability=0.001,
        shift_probability=0.01,
        min_insert_probability=0.3,
        max_insert_probability=1,
        random_probability=0.2,
    ):
        swap_probability = random.uniform(min_swap_probability,
                                          max_swap_probability)
        insert_probability = random.uniform(min_insert_probability,
                                            max_insert_probability)
        for inhabitant in self.generation[1:]:
            if len(inhabitant.gene) == 0:
                inhabitant.gene = self._random_moves()
                continue
            if decision(random_probability):
                inhabitant.gene = self._random_moves()
            elif decision(insert_probability):
                insert_amount = random.randint(1, 3)
                if decision(0.5):  # remove decision
                    possible_chars = self._random_word(insert_amount)
                    if decision(0.33):
                        inhabitant.gene += possible_chars
                    elif decision(0.5):
                        inhabitant.gene = possible_chars + inhabitant.gene
                    else:
                        insert_index = random.randint(1, len(inhabitant.gene))
                        inhabitant.gene = (inhabitant.gene[:insert_index] +
                                           possible_chars +
                                           inhabitant.gene[insert_index:])
                else:
                    if len(inhabitant) - insert_amount > 0:
                        if decision(0.33):
                            inhabitant.gene = inhabitant.gene[insert_amount:]
                        elif decision(0.5):
                            inhabitant.gene = inhabitant.gene[:-insert_amount]
                        else:
                            remove_index = random.randint(
                                1,
                                len(inhabitant.gene) - insert_amount)
                            inhabitant.gene = (
                                inhabitant.gene[:remove_index] +
                                inhabitant.gene[remove_index + insert_amount:])

            if decision(shift_probability):
                shift_range = random.randint(1, 3)
                for _ in range(shift_range + 1):
                    inhabitant.gene = [inhabitant.gene[-1]
                                       ] + inhabitant.gene[:-1]

            if decision(swap_probability):
                inhabitant.gene = gen_neighbour(inhabitant.gene)

            if decision(inverse_probability):
                inhabitant.gene = inhabitant.gene[::-1]

            inhabitant.gene = self._cancel_backtrack(inhabitant.gene)
コード例 #4
0
    def mutate(
        self,
        min_swap_probability=0.2,
        max_swap_probability=0.7,
        inverse_probability=0.001,
        random_probability=0.05,
        shift_probability=0.001,
        insert_probability=0.9,
        replace_probability=0.5,
    ):
        swap_probability = random.uniform(min_swap_probability, max_swap_probability)
        for inhabitant in self.generation[1:]:
            if decision(insert_probability):
                insert_amount = random.randint(1, 2)
                if decision(0.5): # remove decision
                    if(len(inhabitant)+insert_amount < len(self.all_puzzle_keys)):
                        possible_chars = self._random_word()
                        for char in inhabitant.gene:
                            if char in possible_chars:
                                possible_chars.remove(char)
                        if decision(0.33):  
                            inhabitant.gene += possible_chars[:insert_amount]
                        elif decision(0.5):
                            inhabitant.gene = possible_chars[:insert_amount] + inhabitant.gene
                        else:
                            insert_index = random.randint(1, len(inhabitant.gene)) 
                            inhabitant.gene = inhabitant.gene[:insert_index] + possible_chars[:insert_amount] + inhabitant.gene[insert_index:]
                else:
                    if(len(inhabitant)-insert_amount > 0):
                        if len(inhabitant) - insert_amount > 0:
                            if decision(0.33):
                                inhabitant.gene = inhabitant.gene[insert_amount:]
                            elif decision(0.5):
                                inhabitant.gene = inhabitant.gene[:-insert_amount]
                            else:
                                remove_index = random.randint(1, len(inhabitant.gene)-insert_amount)
                                inhabitant.gene = (
                                inhabitant.gene[:remove_index]
                                + inhabitant.gene[remove_index+insert_amount:]
                            )
                            
            elif decision(random_probability):
                inhabitant.gene = self._random_word()
            else:
                if decision(shift_probability):
                    shift_range = random.randint(1, 3)
                    for _ in range(shift_range + 1):
                        inhabitant.gene = [inhabitant.gene[-1]] + inhabitant.gene[:-1]

                for i in range(len(inhabitant.gene) // 2):
                    if decision(swap_probability):
                            random_id = random.randint(0, len(inhabitant) - 1)
                            inhabitant.gene[i], inhabitant.gene[random_id] = (
                                inhabitant.gene[random_id],
                                inhabitant.gene[i],
                            )

                if decision(inverse_probability):
                    inhabitant.gene = inhabitant.gene[::-1]
コード例 #5
0
 def mutate(self, swap_probability=0.5, inverse_probability=0.01):
     for inhabitant in self.generation:
         for i in range(len(inhabitant.gene) // 2):
             if decision(swap_probability):
                 random_id = random.randint(0, len(inhabitant) - 1)
                 inhabitant.gene[i], inhabitant.gene[random_id] = (
                     inhabitant.gene[random_id],
                     inhabitant.gene[i],
                 )
         if decision(inverse_probability):
             inhabitant.gene = inhabitant.gene[::-1]
コード例 #6
0
    def mutate(
        self,
        min_swap_probability=0.2,
        max_swap_probability=0.7,
        inverse_probability=0.001,
        shift_probability=0.001,
        insert_probability=0.9,
    ):
        swap_probability = random.uniform(min_swap_probability,
                                          max_swap_probability)
        for inhabitant in self.generation[1:]:
            if decision(insert_probability):
                insert_amount = random.randint(1, 2)
                if decision(0.5):  # remove decision
                    possible_chars = self._random_word(insert_amount)
                    if decision(0.33):
                        inhabitant.gene += possible_chars
                    elif decision(0.5):
                        inhabitant.gene = possible_chars + inhabitant.gene
                    else:
                        insert_index = random.randint(1, len(inhabitant.gene))
                        inhabitant.gene = (inhabitant.gene[:insert_index] +
                                           possible_chars +
                                           inhabitant.gene[insert_index:])
                else:
                    if len(inhabitant) - insert_amount > 0:
                        if decision(0.33):
                            inhabitant.gene = inhabitant.gene[insert_amount:]
                        elif decision(0.5):
                            inhabitant.gene = inhabitant.gene[:-insert_amount]
                        else:
                            remove_index = random.randint(
                                1, len(inhabitant.gene))
                            inhabitant.gene = (
                                inhabitant.gene[:insert_index - remove_index] +
                                possible_chars +
                                inhabitant.gene[insert_index:])
            else:
                if decision(shift_probability):
                    shift_range = random.randint(1, 3)
                    for _ in range(shift_range + 1):
                        inhabitant.gene = [inhabitant.gene[-1]
                                           ] + inhabitant.gene[:-1]

                for i in range(len(inhabitant.gene) // 2):
                    if decision(swap_probability):
                        random_id = random.randint(0, len(inhabitant) - 1)
                        inhabitant.gene[i], inhabitant.gene[random_id] = (
                            inhabitant.gene[random_id],
                            inhabitant.gene[i],
                        )

                if decision(inverse_probability):
                    inhabitant.gene = inhabitant.gene[::-1]
コード例 #7
0
 def mutate(self, probability=0.05):
     for inhabitant in self.generation:
         for i in range(len(inhabitant.gene)):
             if decision(probability):
                 inhabitant.gene[i], inhabitant.gene[random.randint(
                     0, len(inhabitant))] = inhabitant.gene[random.randint(
                         0, len(inhabitant))], inhabitant.gene[i]
コード例 #8
0
 def mutate(self, probability=0.05):
     for inhabitant in self.generation:
         for i in range(len(inhabitant.gene)):
             if decision(probability):
                 random_id = random.randint(0,len(inhabitant)-1)
                 inhabitant.gene[i], inhabitant.gene[random_id] = inhabitant.gene[random_id], inhabitant.gene[i]
                 print("boom")
コード例 #9
0
    def mutate(self, min_swap_probability=0.2, max_swap_probability=0.8, inverse_probability=0.05, random_probability=0.05, shift_probability=0.1):
        swap_probability = random.uniform(min_swap_probability, max_swap_probability)
        for inhabitant in self.generation:
            if decision(random_probability):
                inhabitant.gene = self._random_word()[:self.word_size]
            elif decision(shift_probability):
                inhabitant.gene = [inhabitant.gene[-1]] + inhabitant.gene[:-1]
            else:
                for i in range(len(inhabitant.gene)//2):
                    if decision(swap_probability):
                        random_id = random.randint(0, len(inhabitant) - 1)
                        inhabitant.gene[i], inhabitant.gene[random_id] = (
                            inhabitant.gene[random_id],
                            inhabitant.gene[i],
                        )

                if decision(inverse_probability):
                    inhabitant.gene = inhabitant.gene[::-1]
コード例 #10
0
    def mutate(self,
               swap_probability=0.8,
               inverse_probability=0.1,
               random_probability=0.1):
        swap_probability = random.uniform(0.05, swap_probability)
        for inhabitant in self.generation:
            if decision(random_probability):
                inhabitant.gene = self._random_word()
            else:
                for i in range(len(inhabitant.gene) // 2):
                    if decision(swap_probability):
                        random_id = random.randint(0, len(inhabitant) - 1)
                        inhabitant.gene[i], inhabitant.gene[random_id] = (
                            inhabitant.gene[random_id],
                            inhabitant.gene[i],
                        )

                if decision(inverse_probability):
                    inhabitant.gene = inhabitant.gene[::-1]
コード例 #11
0
    def mutate(
        self,
        min_swap_probability=0.2,
        max_swap_probability=0.7,
        inverse_probability=0.001,
        random_probability=0.05,
        shift_probability=0.001,
        insert_probability=0.9,
    ):
        swap_probability = random.uniform(min_swap_probability, max_swap_probability)
        for inhabitant in self.generation[1:]:
            if decision(insert_probability):
                insert_amount = random.randint(1, 2)
                if decision(0.5): # remove decision
                    char = random.choice(self.all_puzzles)
                    if decision(0.33):  
                        inhabitant.gene += [char]
                    elif decision(0.5):
                        inhabitant.gene = [char] + inhabitant.gene
                    else:
                        insert_index = random.randint(1, len(inhabitant.gene)) 
                        inhabitant.gene = inhabitant.gene[:insert_index] + [char] + inhabitant.gene[insert_index:]
                else:
                    if(len(inhabitant)-insert_amount > 0):
                        if decision(0.5):  
                            inhabitant.gene = inhabitant.gene[insert_amount:]
                        else:
                            inhabitant.gene = inhabitant.gene[:-insert_amount]
                            
            elif decision(random_probability):
                inhabitant.gene = self._random_word()
            else:
                if decision(shift_probability):
                    shift_range = random.randint(1, 3)
                    for _ in range(shift_range + 1):
                        inhabitant.gene = [inhabitant.gene[-1]] + inhabitant.gene[:-1]

                for i in range(len(inhabitant.gene) // 2):
                    if decision(swap_probability):
                        random_id = random.randint(0, len(inhabitant) - 1)
                        inhabitant.gene[i], inhabitant.gene[random_id] = (
                            inhabitant.gene[random_id],
                            inhabitant.gene[i],
                        )

                if decision(inverse_probability):
                    inhabitant.gene = inhabitant.gene[::-1]
コード例 #12
0
def sa(t, n, m, k, matrix, start_T, multiplier=2):
    start = time.time()
    T = start_T
    puzzle_shuffler = PuzzleShuffler()

    puzzles = puzzle_shuffler.random_puzzles(n, m, k, matrix)
    matrixp = calculate_matrixp(puzzles, matrix, n, m)
    best_matrixp = matrixp
    best_puzzles = puzzles.copy()
    shuffle_puzzles = puzzles.copy()

    square_number = calc_square_number(puzzles)

    best_min = calculate_mse(n, m, matrix, matrixp)
    fail_counter = 0

    while check_time(start, t) and T > 0:
        puzzles = puzzle_shuffler.random_puzzles(n, m, k, matrix)
        matrixp = calculate_matrixp(puzzles, matrix, n, m)
        cur_min = calculate_mse(n, m, matrix, matrixp)
        if cur_min < best_min:
            best_matrixp = matrixp.copy()
            best_puzzles = puzzles.copy()
            fail_counter = 0
            best_min = cur_min
        else:
            fail_counter += 1

        probability = calculate_probability(T, n, m, matrix, best_matrixp,
                                            matrixp)
        if decision(probability) and cur_min != best_min:
            T = decrease_temperature(T)
            shuffle_puzzles = puzzles.copy()

        if fail_counter == square_number * multiplier:
            fail_counter = 0
            puzzle_shuffler.set_T(best_puzzles,
                                  int(random.uniform(0, square_number // 2)))
            puzzle_shuffler.set_starters(
                best_puzzles, int(random.uniform(0, square_number // 2)))
            shuffle_puzzles = puzzle_shuffler.random_puzzles(n, m, k, matrix)
        elif fail_counter >= square_number * multiplier // 2:
            if fail_counter == square_number * multiplier // 2:
                puzzle_shuffler.set_T(best_puzzles, 0)
                puzzle_shuffler.set_starters(best_puzzles, 8)
            else:
                puzzle_shuffler.set_starters(
                    best_puzzles,
                    square_number - int(random.uniform(2, square_number // 2)))
        else:
            puzzle_shuffler.set_starters(
                shuffle_puzzles, int(random.uniform(0, square_number // 2)))

    return best_min, best_matrixp
コード例 #13
0
    def mutate(
        self,
        swap_probability=0.2,
        min_transpose_probability=0.2,
        max_transpose_probability=0.5,
        inverse_probability=0.01,
        random_probability=0.01,
        shift_probability=0.01,
        insert_probability=0.5,
    ):
        transpose_probability = random.uniform(min_transpose_probability, max_transpose_probability)
        for inhabitant in self.generation:
            if decision(insert_probability):
                insert_amount = random.randint(1, 2)
                if(len(inhabitant)+insert_amount < len(self.all_puzzle_keys)):
                    possible_chars = self._random_word()
                    for char in inhabitant.gene:
                        if char in possible_chars:
                            possible_chars.remove(char)
                    if decision(0.5):  
                        inhabitant.gene += possible_chars[:insert_amount]
                    else:
                        inhabitant.gene = possible_chars[:insert_amount] + inhabitant.gene
            if decision(random_probability):
                inhabitant.gene = self._random_word()

            if decision(shift_probability):
                shift_range = random.randint(1, 3)
                for _ in range(shift_range + 1):
                    inhabitant.gene = [inhabitant.gene[-1]] + inhabitant.gene[:-1]

            for i in range(len(inhabitant.gene) // 2):
                if decisitranspose):
                    random_id = random.randint(0, len(inhabitant) - 1)
                    inhabitant.gene[i], inhabitant.gene[random_id] = (
                        inhabitant.gene[random_id],
                        inhabitant.gene[i],
                    )

            if decision(inverse_probability):
                inhabitant.gene = inhabitant.gene[::-1]
コード例 #14
0
    def recombinate(self, elite_percentage=0.6):
        selection = self.make_selection(elite_percentage)
        permutation = np.random.permutation(len(selection))
        new_generation = []
        new_generation.append(Inhabitant(selection[0].gene.copy()))
        new_generation.append(Inhabitant(selection[1].gene.copy()))
        for i in range(1, len(permutation)):
            pivot = random.randint(
                0,
                min(
                    len(selection[permutation[i % len(permutation)]]),
                    len(selection[permutation[(i + 1) % len(permutation)]]),
                )
                // 2,
            )
            if len(selection[permutation[i % len(permutation)]]) > 1:
                pivot2 = random.randint(len(selection[permutation[i % len(permutation)]])//2, len(selection[permutation[i % len(permutation)]])-1)
            else:
                pivot2 = 1
            new_word = selection[permutation[i % len(permutation)]][:pivot2]

            if self._check_if_correct(new_word):
                new_generation.append(Inhabitant(new_word))
            else:
                new_generation.append(
                    Inhabitant(selection[permutation[i % len(permutation)]].gene)
                )

            if len(selection[permutation[(i+1) % len(permutation)]]) > 2:
                pivot2 = random.randint(len(selection[0, len(selection[permutation[(i+1) % len(permutation)]])-2))
            else:
                pivot2 = 1
            new_word = selection[permutation[(i+1) % len(permutation)]][pivot2:]
            if self._check_if_correct(new_word):
                new_generation.append(Inhabitant(new_word))
            else:
                new_generation.append(
                    Inhabitant(selection[permutation[(i + 1) % len(permutation)]].gene)
                )

        self.generation = new_generation

    def mutate(
        self,
        min_swap_probability=0.2,
        max_swap_probability=0.5,
        inverse_probability=0.001,
        random_probability=0.05,
        shift_probability=0.001,
        insert_probability=0.9,
        replace_probability=0.5,
    ):
        swap_probability = random.uniform(min_swap_probability, max_swap_probability)
        for inhabitant in self.generation[1:]:
            if decision(insert_probability):
                insert_amount = random.randint(1, 3)
                if decision(0.5): # remove decision
                    if(len(inhabitant)+insert_amount < len(self.all_puzzle_keys)):
                        possible_chars = self._random_word()
                        for char in inhabitant.gene:
                            if char in possible_chars:
                                possible_chars.remove(char)
                        if decision(0.33):  
                            inhabitant.gene += possible_chars[:insert_amount]
                        elif decision(0.5):
                            inhabitant.gene = possible_chars[:insert_amount] + inhabitant.gene
                        else:
                            insert_index = random.randint(1, len(inhabitant.gene)) 
                            inhabitant.gene = inhabitant.gene[:insert_index] + possible_chars[:insert_amount] + inhabitant.gene[insert_index:]
                else:
                    if(len(inhabitant)-insert_amount > 0):
                        if len(inhabitant) - insert_amount > 0:
                            if decision(0.33):
                                inhabitant.gene = inhabitant.gene[insert_amount:]
                            elif decision(0.5):
                                inhabitant.gene = inhabitant.gene[:-insert_amount]
                            else:
                                remove_index = random.randint(1, len(inhabitant.gene)-insert_amount)
                                inhabitant.gene = (
                                inhabitant.gene[:remove_index]
                                + inhabitant.gene[remove_index+insert_amount:]
                            )
                            
            elif decision(random_probability):
                inhabitant.gene = self._random_word()
            else:
                if decision(shift_probability):
                    shift_range = random.randint(1, 3)
                    for _ in range(shift_range + 1):
                        inhabitant.gene = [inhabitant.gene[-1]] + inhabitant.gene[:-1]
                
                if decision(replace_probability):
                    replace_index = random.randint(0, len(inhabitant.gene)-1) 
                    possible_chars = self._random_word()
                    for char in inhabitant.gene:
                        if char in possible_chars:
                            possible_chars.remove(char)
                    if possible_chars:
                        inhabitant.gene[replace_index] = possible_chars[0]
                else:
                    for i in range(len(inhabitant.gene) // 2):
                        if decision(swap_probability):
                                random_id = random.randint(0, len(inhabitant) - 1)
                                inhabitant.gene[i], inhabitant.gene[random_id] = (
                                    inhabitant.gene[random_id],
                                    inhabitant.gene[i],
                                )

                if decision(inverse_probability):
                    inhabitant.gene = inhabitant.gene[::-1]
コード例 #15
0
        self.generation = new_generation

    def mutate(
        self,
        min_swap_probability=0.2,
        max_swap_probability=0.5,
        inverse_probability=0.001,
        random_probability=0.05,
        shift_probability=0.001,
        insert_probability=0.9,
        replace_probability=0.5,
    ):
        swap_probability = random.uniform(min_swap_probability, max_swap_probability)
        for inhabitant in self.generation[1:]:
            if decision(insert_probability):
                insert_amount = random.randint(1, 3)
                if decision(0.5): # remove decision
                    if(len(inhabitant)+insert_amount < len(self.all_puzzle_keys)):
                        possible_chars = self._random_word()
                        for char in inhabitant.gene:
                            if char in possible_chars:
                                possible_chars.remove(char)
                        if decision(0.33):  
                            inhabitant.gene += possible_chars[:insert_amount]
                        elif decision(0.5):
                            inhabitant.gene = possible_chars[:insert_amount] + inhabitant.gene
                        else:
                            insert_index = random.randint(1, len(inhabitant.gene)) 
                            inhabitant.gene = inhabitant.gene[:insert_index] + possible_chars[:insert_amount] + inhabitant.gene[insert_index:]
                else:
コード例 #16
0
 def mutate(self, probability=0.05):
     for inhabitant in self.generation:
         for i in range(len(inhabitant.gene)):
             if decision(probability):
                 inhabitant.gene[i] = self._random_char()
コード例 #17
0
        self.generation = new_generation

    def mutate(
        self,
        swap_probability=0.2
        min_transpose_probability=0.2,
        max_transpose_probability=0.5,
        inverse_probability=0.01,
        random_probability=0.01,
        shift_probability=0.01,
        insert_probability=0.5,
    ):
        transpose_probability = random.uniform(min_transpose_probability, max_transpose_probability)
        for inhabitant in self.generation:
            if decision(insert_probability):
                insert_amount = random.randint(1, 2)
                if(len(inhabitant)+insert_amount < len(self.all_puzzle_keys)):
                    possible_chars = self._random_word()
                    for char in inhabitant.gene:
                        if char in possible_chars:
                            possible_chars.remove(char)
                    if decision(0.5):  
                        inhabitant.gene += possible_chars[:insert_amount]
                    else:
                        inhabitant.gene = possible_chars[:insert_amount] + inhabitant.gene
            if decision(random_probability):
                inhabitant.gene = self._random_word()

            if decision(shift_probability):
                shift_range = random.randint(1, 3)
コード例 #18
0
async def yarek(msg: types.Message):
    if decision(0.5):
        await msg.answer(
            'Вы всё ещё готовите на огне @yaroslav_y? Тогда мы идём к вам.')
コード例 #19
0
ファイル: network.py プロジェクト: zhaoxiaomian/Deep-BCI
                                  st.batch_size_val]
        val_pred_lbl_2 = sess.run([pred_l2],
                                  feed_dict={
                                      dat: batch_x_val_2,
                                      lbl: batch_y_val_2,
                                      keep: 1.0
                                  })

        val_batch_lbl_all_1.append(batch_y_val_1)
        val_batch_lbl_all_2.append(batch_y_val_2)

        val_pred_lbl_all_1.append(val_pred_lbl_1)
        val_pred_lbl_all_2.append(val_pred_lbl_2)

    ori_lbl_all_1, ori_pred_all_1 = ut.decision(val_batch_lbl_all_1,
                                                val_pred_lbl_all_1,
                                                class_number=4)
    ori_lbl_all_2, ori_pred_all_2 = ut.decision(val_batch_lbl_all_2,
                                                val_pred_lbl_all_2,
                                                class_number=4)

    val_acc_lbl_1 = accuracy_score(ori_lbl_all_1, ori_pred_all_1)
    val_acc_lbl_2 = accuracy_score(ori_lbl_all_2, ori_pred_all_2)

    print("%dth Epoch over." % (epoch + 1))
    if (epoch + 1) % st.eval_epoch == 0:
        print(
            "All variables are saved in path",
            saver_tr.save(
                sess, (st.model_path +
                       "CNN2path_tgt%d_src%d_bs%d_te%d_%02dth_epoch.ckpt") %
コード例 #20
0
async def toopa(msg: types.Message):
    if decision(0.05):
        await msg.reply('ТУПА АЛЕГАНТОР))))))')