test deepcopy for distillation best model
@@ -66,6 +66,9 @@ class Distillation(Component):
logger.info("initial model score is {}.".format(str(score)))
if self.eval_frequency > 0:
self.best_score = score
+ if self.framework == "pytorch":
+ self.best_model = copy.deepcopy(self._model)
+ else:
self.best_model = self._model
def on_post_forward(self, input, teacher_output=None):
@@ -87,6 +90,9 @@ class Distillation(Component):
logger.info("model score of epoch {} is {}.".format(self._epoch_runned, str(score)))
if score > self.best_score:
self.best_score = score
+ if self.framework == "pytorch":
+ self.best_model = copy.deepcopy(self._model)
+ else:
self.best_model = self._model
def pre_process(self):
