Example #1
0
def split_test_training(positions_w_context, est_num_positions):
    print("Estimated number of chunks: %s" % (est_num_positions // CHUNK_SIZE))
    desired_test_size = 10**5
    if est_num_positions < 2 * desired_test_size:
        positions_w_context = list(positions_w_context)
        test_size = len(positions_w_context) // 3
        return positions_w_context[:test_size], [
            positions_w_context[test_size:]
        ]
    else:
        shuffled_positions = utils.shuffler(positions_w_context)
        test_chunk = utils.take_n(desired_test_size, shuffled_positions)
        training_chunks = utils.iter_chunks(CHUNK_SIZE, shuffled_positions)
        return test_chunk, training_chunks
Example #2
0
def extract_moves(final_positions):
    winning_moves = []
    losing_moves = []
    for final_position in final_positions:
        positions_w_context = utils.take_n(
            strategies.POLICY_CUTOFF_DEPTH,
            sgf_wrapper.replay_position(final_position,extract_move_probs=True))
        winner = utils.parse_game_result(final_position.result())
        for pwc in positions_w_context:
            if pwc.position.to_play == winner:
                winning_moves.append(pwc)
            else:
                losing_moves.append(pwc)
    return load_data_sets.DataSet.from_positions_w_context(winning_moves,extract_move_prob=True),\
           load_data_sets.DataSet.from_positions_w_context(losing_moves,extract_move_prob=True)
def extract_moves(final_positions):
    winning_moves = []
    losing_moves = []
    #logger.debug(f'Game final positions{final_positions}')
    for final_position in final_positions:
        positions_w_context = utils.take_n(
            POLICY_CUTOFF_DEPTH,
            sgf_wrapper.replay_position(final_position,
                                        extract_move_probs=True))
        winner = utils.parse_game_result(final_position.result())
        #logger.debug(f'positions_w_context length: {len(positions_w_context)}')
        for pwc in positions_w_context:
            if pwc.position.to_play == winner:
                winning_moves.append(pwc)
            else:
                losing_moves.append(pwc)
    return load_data_sets.DataSet.from_positions_w_context(winning_moves, extract_move_prob=True),\
        load_data_sets.DataSet.from_positions_w_context(losing_moves, extract_move_prob=True)