espnet.lm.chainer_backend.lm.LMEvaluator
espnet.lm.chainer_backend.lm.LMEvaluator
class espnet.lm.chainer_backend.lm.LMEvaluator(val_iter, eval_model, device)
Bases: BaseEvaluator
A custom evaluator for a chainer LM
:param chainer.dataset.Iterator val_iter : The validation iterator :param eval_model : The model to evaluate :param int device : The device id to use
evaluate()
Evaluates the model and returns a result dictionary.
This method runs the evaluation loop over the validation dataset. It accumulates the reported values to DictSummary
and returns a dictionary whose values are means computed by the summary.
Note that this function assumes that the main iterator raises StopIteration
or code in the evaluation loop raises an exception. So, if this assumption is not held, the function could be caught in an infinite loop.
Users can override this method to customize the evaluation routine.
NOTE
This method encloses eval_func
calls with function.no_backprop_mode()
context, so all calculations using FunctionNode
s inside eval_func
do not make computational graphs. It is for reducing the memory consumption.
- Returns: Result dictionary. This dictionary is further reported via
report()
without specifying any observer. - Return type: dict