示例#1
0
                                ),
                                daemon=True) for i in range(NUM_ENVIRONMENTS)
    ]
    for p in processes:
        p.start()

    steps_statistics = Statistics()
    total_reward_statistics = Statistics()
    collision_statistics = Statistics()
    num_nodes_statistics = Statistics()
    depth_statistics = Statistics()
    stats_statistics = [Statistics() for _ in range(5)]
    planner_value_statistics = defaultdict(lambda: Statistics())
    value_statistics = defaultdict(lambda: Statistics())

    while len(total_reward_statistics) < 100 or total_reward_statistics.stderr(
    ) > TARGET_SE:
        # Read request and process.
        (steps, total_reward, collision, num_nodes, depth,
         stats) = socket.recv_pyobj()
        socket.send_pyobj(0)

        if args.task not in ['DriveHard']:
            if not collision:
                steps_statistics.append(steps)
        else:
            steps_statistics.append(steps)
        total_reward_statistics.append(total_reward)
        collision_statistics.append(collision)
        if num_nodes is not None:
            num_nodes_statistics.append(num_nodes)
        if depth is not None:
示例#2
0
        gen_model.load_state_dict(torch.load(model_path))

        steps_statistics = Statistics()
        total_reward_statistics = Statistics()
        collision_statistics = Statistics()
        macro_length_statistics = Statistics()
        num_nodes_statistics = Statistics()
        depth_statistics = Statistics()
        stats_statistics = [Statistics() for _ in range(5)]
        planner_value_statistics = defaultdict(lambda: Statistics())
        value_statistics = defaultdict(lambda: Statistics())

        completed_iterations = 0
        while completed_iterations < ITERATIONS or (
                TARGET_SE is not None
                and total_reward_statistics.stderr() > TARGET_SE):

            # Read request and process.
            request = socket.recv_pyobj()
            instruction = request[0]
            instruction_data = request[1:]

            if instruction == 'CALL_GENERATOR':

                context = instruction_data[0]
                state = instruction_data[1]
                with torch.no_grad():
                    (macro_actions) = gen_model.mode(
                        torch.tensor(instruction_data[0],
                                     dtype=torch.float,
                                     device=device).unsqueeze(0),