19e56dc21044bd9fa05cced1fb64670cd664e169,ch16/02_breakout_es.py,,,#,179

Before Change


    net.eval()

    params_queues = [mp.Queue(maxsize=1) for _ in range(PROCESSES_COUNT)]
    rewards_queues = [mp.Queue(maxsize=ITERS_PER_UPDATE) for _ in range(PROCESSES_COUNT)]
    workers = []

    for idx, (params_queue, rewards_queue) in enumerate(zip(params_queues, rewards_queues)):
        proc = mp.Process(target=worker_func, args=(idx, params_queue, rewards_queue, args.cuda))
        proc.start()
        workers.append(proc)

    print("All started!")

    for step_idx in range(100000):
        // broadcasting network params
        params = net.state_dict()
        for q in params_queues:
            q.put(params)

        // waiting for results
        t_start = time.time()
        batch_noise = []
        batch_reward = []
        results = 0
        batch_steps = 0
        batch_steps_data = []
        while True:
            for idx, q in enumerate(rewards_queues):
                if not q.empty():
                    reward = q.get_nowait()
                    np.random.seed(reward.seed)
                    noise, neg_noise = sample_noise(net)
                    batch_noise.append(noise)
                    batch_reward.append(reward.pos_reward)
                    batch_noise.append(neg_noise)
                    batch_reward.append(reward.neg_reward)
                    results += 1
                    batch_steps += reward.steps
                    batch_steps_data.append(reward.steps)
                    // print("Result from %d: %s, noise: %s" % (
                    //     idx, reward, noise[0][0, 0, 0:1]))

            if results == PROCESSES_COUNT * ITERS_PER_UPDATE:
                break
            time.sleep(0.1)

After Change


    net.eval()

    params_queues = [mp.Queue(maxsize=1) for _ in range(PROCESSES_COUNT)]
    rewards_queue = mp.Queue(maxsize=ITERS_PER_UPDATE)
    workers = []

    for idx, params_queue in enumerate(params_queues):
        proc = mp.Process(target=worker_func, args=(idx, params_queue, rewards_queue, args.cuda))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: PacktPublishing/Deep-Reinforcement-Learning-Hands-On
Commit Name: 19e56dc21044bd9fa05cced1fb64670cd664e169
Time: 2018-02-20
Author: max.lapan@gmail.com
File Name: ch16/02_breakout_es.py
Class Name:
Method Name:


Project Name: ray-project/ray
Commit Name: d9124e932954f9c497c49548c588f2b9f918c676
Time: 2021-02-16
Author: architkulkarni@users.noreply.github.com
File Name: python/ray/tests/test_queue.py
Class Name:
Method Name: test_custom_resources


Project Name: ray-project/ray
Commit Name: f51c26bae62b00a78bc6f3eb1c7979bce9f15a84
Time: 2021-02-09
Author: simon.mo@hey.com
File Name: python/ray/tests/test_queue.py
Class Name:
Method Name: test_custom_resources