distill_configs(list(dict) | path): the list of distill config.
student_models(list(nn.Layer)): the list of student model, the state of student model must be training mode.
teacher_models(list(nn.Layer)): the list of teacher model, the state of student model must be evaluate mode.
return_model_outputs(bool): whether to return model output. Default: True.
configs(list(dict) | string): the list of distill config or the path of yaml file which contain the distill config.
students(list(nn.Layer)): the list of student model, the state of student model must be training mode.
teachers(list(nn.Layer)): the list of teacher model.
convert_fn(bool): convert the functional in paddlepaddle to nn.Layer. The detail of this convert operation please
reference to ```paddleslim.common.functional2layer```. Default: True.
return_model_outputs(bool): whether to return the origin outputs of the model. If set to True, will return distill loss, the output of students and the output of teachers, the output of each part will be returned as a list. Default: True.
"""
def__init__(self,
distill_configs,
student_models,
teacher_models,
configs,
students,
teachers,
convert_fn=True,
return_model_outputs=True):
super(Distill,self).__init__()
ifisinstance(student_models,nn.Layer):
student_models=[student_models]
ifisinstance(teacher_models,nn.Layer):
teacher_models=[teacher_models]
forstudent_modelinstudent_models:
assertstudent_model.training,"The student model should not be eval mode."
forteacher_modelinteacher_models:
assertteacher_model.trainingisFalse,"The teacher model should be eval mode."