diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2017-10-13 09:48:51 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2017-10-13 09:55:57 -0700 |
commit | aea2a316fc63a3bf922ed48b844c4f254a53449c (patch) | |
tree | 26189b1cc991fdc877c6784c8394113b72d8ed53 | |
parent | a0f70954f17756fd11c8032d14769353a253bb0d (diff) |
Direct users of the old KMeans estimator to use the new one that's built from the core Estimator API.
PiperOrigin-RevId: 172108321
-rw-r--r-- | tensorflow/contrib/learn/python/learn/estimators/kmeans.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tensorflow/contrib/learn/python/learn/estimators/kmeans.py b/tensorflow/contrib/learn/python/learn/estimators/kmeans.py index a92302420f..992b804f59 100644 --- a/tensorflow/contrib/learn/python/learn/estimators/kmeans.py +++ b/tensorflow/contrib/learn/python/learn/estimators/kmeans.py @@ -12,7 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================== -"""Implementation of k-means clustering on top of `Estimator` API.""" +"""Implementation of k-means clustering on top of `Estimator` API. + +This module is deprecated. Please use +@{tf.contrib.factorization.KMeansClustering} instead of +@{tf.contrib.learn.KMeansClustering}. It has a similar interface, but uses the +@{tf.estimator.Estimator} API instead of @{tf.contrib.learn.Estimator}. +""" from __future__ import absolute_import from __future__ import division @@ -29,12 +35,17 @@ from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import state_ops -from tensorflow.python.summary import summary from tensorflow.python.ops.control_flow_ops import with_dependencies from tensorflow.python.platform import tf_logging as logging from tensorflow.python.summary import summary from tensorflow.python.training import session_run_hook from tensorflow.python.training.session_run_hook import SessionRunArgs +from tensorflow.python.util.deprecation import deprecated + +_USE_TF_CONTRIB_FACTORIZATION = ( + 'Please use tf.contrib.factorization.KMeansClustering instead of' + ' tf.contrib.learn.KMeansClustering. It has a similar interface, but uses' + ' the tf.estimator.Estimator API instead of tf.contrib.learn.Estimator.') class _LossRelativeChangeHook(session_run_hook.SessionRunHook): @@ -153,6 +164,7 @@ class KMeansClustering(estimator.Estimator): ALL_SCORES = 'all_scores' LOSS_OP_NAME = 'kmeans_loss' + @deprecated(None, _USE_TF_CONTRIB_FACTORIZATION) def __init__(self, num_clusters, model_dir=None, @@ -204,6 +216,7 @@ class KMeansClustering(estimator.Estimator): model_dir=model_dir, config=config) + @deprecated(None, _USE_TF_CONTRIB_FACTORIZATION) def predict_cluster_idx(self, input_fn=None): """Yields predicted cluster indices.""" key = KMeansClustering.CLUSTER_IDX @@ -212,6 +225,7 @@ class KMeansClustering(estimator.Estimator): for result in results: yield result[key] + @deprecated(None, _USE_TF_CONTRIB_FACTORIZATION) def score(self, input_fn=None, steps=None): """Predict total sum of distances to nearest clusters. @@ -229,6 +243,7 @@ class KMeansClustering(estimator.Estimator): self.evaluate( input_fn=input_fn, steps=steps)[KMeansClustering.SCORES]) + @deprecated(None, _USE_TF_CONTRIB_FACTORIZATION) def transform(self, input_fn=None, as_iterable=False): """Transforms each element to distances to cluster centers. @@ -255,6 +270,7 @@ class KMeansClustering(estimator.Estimator): else: return results + @deprecated(None, _USE_TF_CONTRIB_FACTORIZATION) def clusters(self): """Returns cluster centers.""" return super(KMeansClustering, self).get_variable_value(self.CLUSTERS) |