self.scorer = SequenceScorer([self.model], self.dict)
// set up the grader and the trainer
self.criterion = criterions.build_criterion(self.args, self.task)
// TODO: we might choose to add a --no-fp16 opt in the future to
// explicitly disable fp16 instead
if not self.args.fp16 and torch.cuda.get_device_capability(0)[0] >= 7:
print("Heads up: using --fp16 could be a lot faster!")
if self.use_cuda:
self.trainer = trainer.Trainer(
self.args, self.task, self.model, self.criterion, None
)
self.trainer._build_optimizer()
After Change
self.meters = defaultdict(AverageMeter)
// actually construct the criterion, model and generator
self.build_criterion()
self.build_model()
// Construct the generator and scorer
self.generator = SequenceGenerator(