neural_compressor.experimental.common.criterion
Initialize critetion classes.
- Classes includes:
TensorFlowCrossEntropyLoss, PyTorchCrossEntropyLoss, TensorflowKnowledgeDistillationLoss, PyTorchKnowledgeDistillationLoss, PyTorchIntermediateLayersKnowledgeDistillationLoss.
Module Contents
Classes
Record criterions in TensorflowCriterions class. |
|
Record criterions in PyTorchCriterions class. |
|
Integrate criterions of different framework. |
|
Knowledge Distillation Framework. |
|
Initialize the KnowledgeDistillationLoss class. |
|
The PyTorchKnowledgeDistillationLoss class inherits from KnowledgeDistillationLoss. |
|
PyTorchKnowledgeDistillationLossWrapper wraps PyTorchKnowledgeDistillationLoss. |
|
TensorflowKnowledgeDistillationLossExternal inherits from KnowledgeDistillationLoss. |
|
The IntermediateLayersKnowledgeDistillationLoss class inherits from KnowledgeDistillationLoss. |
|
PyTorch Intermediate Layers Knowledge Distillation Loss. |
|
PyTorch Intermediate Layers Knowledge Distillation Loss Wrapper. |
|
SelfKnowledge Distillation Loss. |
Functions
|
Use to register criterion classes in registry_criterions. |
- class neural_compressor.experimental.common.criterion.TensorflowCriterions[source]
Record criterions in TensorflowCriterions class.
- class neural_compressor.experimental.common.criterion.PyTorchCriterions[source]
Record criterions in PyTorchCriterions class.
- class neural_compressor.experimental.common.criterion.Criterions(framework)[source]
Integrate criterions of different framework.
- neural_compressor.experimental.common.criterion.criterion_registry(criterion_type, framework)[source]
Use to register criterion classes in registry_criterions.
- Parameters:
criterion_type (str) – The string of supported criterion.
framework (str) – The string of supported framework.
- Returns:
The class of register.
- Return type:
cls
- class neural_compressor.experimental.common.criterion.KnowledgeDistillationFramework(student_model=None, teacher_model=None)[source]
Knowledge Distillation Framework.
- class neural_compressor.experimental.common.criterion.KnowledgeDistillationLoss(temperature=1.0, loss_types=['CE', 'CE'], loss_weights=[0.5, 0.5], student_model=None, teacher_model=None)[source]
Initialize the KnowledgeDistillationLoss class.
- class neural_compressor.experimental.common.criterion.PyTorchKnowledgeDistillationLoss(temperature=1.0, loss_types=['CE', 'CE'], loss_weights=[0.5, 0.5], student_model=None, teacher_model=None)[source]
The PyTorchKnowledgeDistillationLoss class inherits from KnowledgeDistillationLoss.
- class neural_compressor.experimental.common.criterion.PyTorchKnowledgeDistillationLossWrapper(param_dict)[source]
PyTorchKnowledgeDistillationLossWrapper wraps PyTorchKnowledgeDistillationLoss.
- class neural_compressor.experimental.common.criterion.TensorflowKnowledgeDistillationLossExternal(temperature=1.0, loss_types=['CE', 'CE'], loss_weights=[0.5, 0.5], student_model=None, teacher_model=None)[source]
TensorflowKnowledgeDistillationLossExternal inherits from KnowledgeDistillationLoss.
- class neural_compressor.experimental.common.criterion.IntermediateLayersKnowledgeDistillationLoss(layer_mappings=[], loss_types=None, loss_weights=None, add_origin_loss=False, student_model=None, teacher_model=None)[source]
The IntermediateLayersKnowledgeDistillationLoss class inherits from KnowledgeDistillationLoss.
- class neural_compressor.experimental.common.criterion.PyTorchIntermediateLayersKnowledgeDistillationLoss(layer_mappings=[], loss_types=None, loss_weights=None, add_origin_loss=False, student_model=None, teacher_model=None)[source]
PyTorch Intermediate Layers Knowledge Distillation Loss.