File tree 1 file changed +9
-5
lines changed
tensorflow_model_optimization/python/core/sparsity/keras
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 19
19
from tensorflow_model_optimization .python .core .sparsity .keras import prunable_layer
20
20
21
21
try :
22
- from keras .engine import base_layer # pylint: disable=g-import-not-at-top
22
+ # OSS case.
23
+ import keras # pylint: disable=g-import-not-at-top
24
+ if hasattr (keras , 'src' ):
25
+ # Path as seen in pip packages as of TF/Keras 2.13.
26
+ from keras .src .engine import base_layer # pylint: disable=g-import-not-at-top,g-importing-member
27
+ else :
28
+ from keras .engine import base_layer # pylint: disable=g-import-not-at-top,g-importing-member
23
29
except ImportError :
24
- # Path as seen in pip packages as of TF/Keras 2.13.
25
- from keras .src .engine import base_layer # pylint: disable=g-import-not-at-top
26
-
27
- # TODO(b/139939526): move to public API.
30
+ # Internal case.
31
+ base_layer = tf ._keras_internal .engine .base_layer # pylint: disable=protected-access
28
32
29
33
layers = tf .keras .layers
30
34
layers_compat_v1 = tf .compat .v1 .keras .layers
You can’t perform that action at this time.
0 commit comments