예제 #1
0
if __name__ == '__main__':

    param = argparse.ArgumentParser(usage='param', description='for main')
    param.add_argument('--model',
                       type=str,
                       default='Single',
                       help='choose one model')
    param.add_argument('--lr', type=float, default=0.001, help='learning rate')
    param.add_argument('--optimizer',
                       type=str,
                       default='adam',
                       help='you can also choose sgd, adagrad, rmsprop')
    param.add_argument('--shell',
                       type=bool,
                       default=False,
                       help='learning rate')
    temparam = param.parse_args()

    config = configure()
    config.lr = temparam.lr
    config.lr_method = temparam.optimizer

    model_ = getattr(models, temparam.model)

    model = model_(config)
    print 'Present used model %s\n' % model
    model.train()

    if temparam.shell:
        print('\n######################\n open ipython for eval')
        _start_shell(locals())
예제 #2
0
# end_point = Point(x2, y2, z2, 1)

## experiment for group 2: 5*20*20 grid scale
# 高度
x1 = 0
x2 = 0
# 长度
y1 = 0
y2 = 18
# 宽度
z1 = 9
z2 = 9
starting_point = Point(x1, y1, z1, 1)
end_point = Point(x2, y2, z2, 1)

config = configure(grid_x, grid_y, grid_z, safety_threshold, privacy_threshold,
                   privacy_radius, starting_point, end_point, delay)
T_budget = config.T_budget
T_optimal = config.T_optimal

# print(occ_grid)
occ_grid_known = copy.deepcopy(occ_grid)
for i in range(occ_grid.shape[0]):
    for j in range(occ_grid.shape[1]):
        for k in range(occ_grid.shape[2]):
            if occ_grid_known[i][j][k] > 1:
                occ_grid_known[i][j][k] = 1

## ref == 1 to show the initial results without self-adaptive motion planning
ref = 0
if ref == 1:
    reference_path = np.load('../data_raw/reference_path.npy')
            end_point = Point(x2, y2, z2, 1)

            # alpha ,beta 固定
            # alpha_list = [4/2, 5/3, 6/4, 7/5, 8/6, 9/7, 10/8, 11/9, 12/10, 13/11]
            # alpha = alpha_list[i % 10]
            # beta_list = [3/2, 4/3, 5/4, 6/5, 7/6, 8/7, 9/8, 10/9, 11/10, 12/11]
            # beta = beta_list[i % 10]
            alpha = 5 / 3
            beta = 4 / 3
            # alpha = 10
            # beta = 10

            Kca = 10

            config = configure(grid_x, grid_y, grid_z, safety_threshold,
                               privacy_threshold, privacy_radius,
                               starting_point, end_point, viewradius, alpha,
                               beta, exploration_rate, preference)
            T_budget = alpha * (abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2))
            T_optimal = beta * (abs(x1 - x2) + abs(y1 - y2) + abs(z1 - z2))
            log.info(
                "Iteration: %d; Configuration: grid: %d, safety_threshold: %f, privacy_threshold: %f, the starting point: [%d, %d, %d]; the end point: [%d, %d, %d]; T_budget(alpha): "
                "%f (%f); "
                "T_optimal(beta): %f (%f); Exploration_rate: %f; Preference: %f; View_radius: %f"
                % (iteration, grid_x, safety_threshold, privacy_threshold, x1,
                   y1, z1, x2, y2, z2, T_budget, alpha, T_optimal, beta,
                   exploration_rate, preference, viewradius))
            SaveMap(config, iteration, exploration_rate, num)

            reinitial_flag = 1
            refpath = []
            planpath = []
예제 #4
0
        unk_id = self.vocab.word2id('<unk>')
        with open(self.config.eval_data, "rb") as analogy_f:
            for line in analogy_f:
                if line.startswith(b":"):  # Skip comments.
                    continue
                words = line.strip().lower().split(b" ")
                ids = self.vocab.word2id(words)
                if unk_id in ids or len(ids) != 4:
                    questions_skipped += 1
                else:
                    questions.append(np.array(ids))
        print("Eval analogy file: ", self.config.eval_data)
        print("Questions: ", len(questions))
        print("Skipped: ", questions_skipped)
        self._analogy_questions = np.array(questions, dtype=np.int32)


def _start_shell(local_ns=None):
    ''''''
    import IPython
    user_ns = {}
    if local_ns:
        user_ns.update(local_ns)
    user_ns.update(globals())
    IPython.start_ipython(argv=[], user_ns=user_ns)


if __name__ == '__main__':
    param = configure()
    train = emTrainer(param)