MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / Evaluator

Class Evaluator

examples/DeepQNetwork/common.py:117–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115
116
117class Evaluator(Callback):
118 def __init__(self, nr_eval, input_names, output_names, get_player_fn):
119 self.eval_episode = nr_eval
120 self.input_names = input_names
121 self.output_names = output_names
122 self.get_player_fn = get_player_fn
123
124 def _setup_graph(self):
125 NR_PROC = min(multiprocessing.cpu_count() // 2, 20)
126 self.pred_funcs = [self.trainer.get_predictor(
127 self.input_names, self.output_names)] * NR_PROC
128
129 def _trigger(self):
130 t = time.time()
131 mean, max = eval_with_funcs(
132 self.pred_funcs, self.eval_episode, self.get_player_fn)
133 t = time.time() - t
134 if t > 10 * 60: # eval takes too long
135 self.eval_episode = int(self.eval_episode * 0.94)
136 self.trainer.monitors.put_scalar('mean_score', mean)
137 self.trainer.monitors.put_scalar('max_score', max)

Callers 1

get_configFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected