def _forward(self, *args, calc_score=False):
"""Forward computation without backward.
Predicts by the model's output by returning `predictor`'s output
"""
with chainer.using_config('train', False), chainer.no_backprop_mode():
if calc_score:
self(*args)
return self.y
else:
if self.predictor is None:
print("[ERROR] predictor is not set or not build yet.")
return
# TODO: it passes all the args, sometimes (x, y) which is too many arguments.
# Consider how to deal with the number of input
if hasattr(self.predictor, '_forward'):
fn = self.predictor._forward
else:
fn = self.predictor
return fn(*filter_args(fn, args))
评论列表
文章目录