MCPcopy Create free account
hub / github.com/YeWR/EfficientZero / _test

Function _test

core/test.py:17–49  ·  view source on GitHub ↗
(config, shared_storage)

Source from the content-addressed store, hash-verified

15
16@ray.remote(num_gpus=0.25)
17def _test(config, shared_storage):
18 test_model = config.get_uniform_network()
19 best_test_score = float('-inf')
20 episodes = 0
21 while True:
22 counter = ray.get(shared_storage.get_counter.remote())
23 if counter >= config.training_steps + config.last_steps:
24 time.sleep(30)
25 break
26 if counter >= config.test_interval * episodes:
27 episodes += 1
28 test_model.set_weights(ray.get(shared_storage.get_weights.remote()))
29 test_model.eval()
30
31 test_score, eval_steps, _ = test(config, test_model, counter, config.test_episodes, config.device, False, save_video=False)
32 mean_score = test_score.mean()
33 std_score = test_score.std()
34 print('Start evaluation at step {}.'.format(counter))
35 if mean_score >= best_test_score:
36 best_test_score = mean_score
37 torch.save(test_model.state_dict(), config.model_path)
38
39 test_log = {
40 'mean_score': mean_score,
41 'std_score': std_score,
42 'max_score': test_score.max(),
43 'min_score': test_score.min(),
44 }
45
46 shared_storage.add_test_log.remote(counter, test_log)
47 print('Training step {}, test scores: \n{} of {} eval steps.'.format(counter, test_score, eval_steps))
48
49 time.sleep(30)
50
51
52def test(config, model, counter, test_episodes, device, render, save_video=False, final_test=False, use_pb=False):

Callers

nothing calls this directly

Calls 3

testFunction · 0.85
get_uniform_networkMethod · 0.45
set_weightsMethod · 0.45

Tested by

no test coverage detected