Skip to content

Commit 60b3587

Browse files
LukeWoodtensorflower-gardener
authored andcommitted
Explicitly import estimator from tensorflow as a separate import instead of accessing it via tf.estimator and depend on the tensorflow estimator target.
PiperOrigin-RevId: 437237782
1 parent a20982e commit 60b3587

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

tensorflow_model_optimization/python/core/sparsity/keras/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ py_strict_library(
175175
deps = [
176176
":pruning_wrapper",
177177
# tensorflow dep1,
178+
# tensorflow:tensorflow_compat_v1_estimator dep1,
178179
# python/framework:for_generated_wrappers tensorflow dep2,
179180
],
180181
)

tensorflow_model_optimization/python/core/sparsity/keras/estimator_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
"""Utility functions for making pruning wrapper work with estimators."""
1616

1717
import tensorflow.compat.v1 as tf
18+
from tensorflow.compat.v1 import estimator as tf_estimator
1819

1920
from tensorflow.python.framework import ops
2021
from tensorflow_model_optimization.python.core.sparsity.keras.pruning_wrapper import PruneLowMagnitude
2122

2223

23-
class PruningEstimatorSpec(tf.estimator.EstimatorSpec):
24+
class PruningEstimatorSpec(tf_estimator.EstimatorSpec):
2425
"""Returns an EstimatorSpec modified to prune the model while training."""
2526

2627
def __new__(cls, model, step=None, train_op=None, **kwargs):

tensorflow_model_optimization/python/examples/sparsity/keras/mnist/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ py_strict_binary(
2323
# numpy dep1,
2424
# six dep1,
2525
# tensorflow dep1,
26+
# tensorflow:tensorflow_compat_v1_estimator dep1,
2627
"//tensorflow_model_optimization/python/core/sparsity/keras:estimator_utils",
2728
"//tensorflow_model_optimization/python/core/sparsity/keras:prune",
2829
"//tensorflow_model_optimization/python/core/sparsity/keras:pruning_schedule",

0 commit comments

Comments
 (0)