Skip to content

Commit 465a56d

Browse files
Add Distillation API to Keras (keras-team#21572)
* initial code dump * clean up the implementation of the distillation api * code reformat * final clean up * pre commit * address gemini review comments * address gemini review comments * add a way to save trained student model * disable tests in numpy and openvino backends * pre commit * address comments * address comments * run pre-commit * update distiller and strategies * code reformat * clean up * code reformat * remove multi output distiilation * clean up after merge * address comments * update file names * subclass logits distillation loss from feature distillation loss * update docstrings * add validation for feature extraction setup * Fix distiller API to accept single strategy or list of strategies * minor fixes * fix tests * address reveiw comments * oh * address review comments * address review comments * address review comments * code reformat * address gemini review comments * address gemini comments * address review comments
1 parent 47fcb39 commit 465a56d

File tree

9 files changed

+1744
-0
lines changed

9 files changed

+1744
-0
lines changed

keras/api/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from keras import config as config
1313
from keras import constraints as constraints
1414
from keras import datasets as datasets
15+
from keras import distillation as distillation
1516
from keras import distribution as distribution
1617
from keras import dtype_policies as dtype_policies
1718
from keras import export as export

keras/api/_tf_keras/keras/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from keras import config as config
1111
from keras import constraints as constraints
1212
from keras import datasets as datasets
13+
from keras import distillation as distillation
1314
from keras import distribution as distribution
1415
from keras import dtype_policies as dtype_policies
1516
from keras import export as export
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""DO NOT EDIT.
2+
3+
This file was autogenerated. Do not edit it by hand,
4+
since your modifications would be overwritten.
5+
"""
6+
7+
from keras.src.distillation.distillation_loss import (
8+
DistillationLoss as DistillationLoss,
9+
)
10+
from keras.src.distillation.distillation_loss import (
11+
FeatureDistillation as FeatureDistillation,
12+
)
13+
from keras.src.distillation.distillation_loss import (
14+
LogitsDistillation as LogitsDistillation,
15+
)
16+
from keras.src.distillation.distiller import Distiller as Distiller

keras/api/distillation/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""DO NOT EDIT.
2+
3+
This file was autogenerated. Do not edit it by hand,
4+
since your modifications would be overwritten.
5+
"""
6+
7+
from keras.src.distillation.distillation_loss import (
8+
DistillationLoss as DistillationLoss,
9+
)
10+
from keras.src.distillation.distillation_loss import (
11+
FeatureDistillation as FeatureDistillation,
12+
)
13+
from keras.src.distillation.distillation_loss import (
14+
LogitsDistillation as LogitsDistillation,
15+
)
16+
from keras.src.distillation.distiller import Distiller as Distiller

keras/src/distillation/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Distillation module for knowledge distillation in Keras."""

0 commit comments

Comments
 (0)