"\nTHIS FUNCTION IS EXPERIMENTAL. It may change or "
"be removed at any time, and without warning."
"\n"
- "\n"
"\nArgs:"
"\n arg0: Arg 0."
"\n arg1: Arg 1."
--- /dev/null
+EVERYTHING IN THIS DIRECTORY IS DEPRECATED.
+
+Using functions or classes will result in warnings.
+
+Instructions for converting to current alternatives are included in the
+warnings. A high-level overview is below.
+
+## Canned Estimators
+
+Many canned estimators (subclasses of `Estimator`) have equivalents in core:
+`DNNClassifier`, `DNNRegressor`, `DNNEstimator`, `LinearClassifier`,
+`LinearRegressor`, `DNNLinearCombinedClassifier` and
+`DNNLinearCombinedRegressor`. They are exposed under `tf.estimator`.
+`DNNEstimator`, `LinearEstimator` and `DNNLinearCombinedEstimator`
+are exposed under `tf.contrib.estimator`.
+
+To migrate to the new api, users need to take the following steps:
+
+* Replace `tf.contrib.learn` with `tf.estimator`.
+* If you subclass any of the estimators, stop doing that. You should be able to
+ write a factory method that returns a canned estimator instead. If this is not
+ possible (if you override methods from the canned estimator), consider writing
+ a custom estimator instead. See `tf.estimator.Estimator`.
+* Set `loss_reduction=tf.losses.Reduction.SUM_OVER_BATCH_SIZE` to preserve loss
+ reduction as the average over batch.
+* Some optimizer-related arguments are no longer passed in the estimator
+ constructor. Instead, we provide methods that perform the same job by wrapping
+ an optimizer. Specifically:
+ * `gradient_clip_norm`: Use `tf.contrib.estimator.clip_gradients_by_norm`
+ * `embedding_lr_multipliers`: Not supported.
+ Other arguments:
+ * `input_layer_min_slice_size`: Replaced by `input_layer_partitioner`
+ * `enable_centered_bias`: Not supported. Dropping this argument is unlikely to
+ harm your model.
+ * `feature_engineering_fn`: Not supported. You can call your
+ `feature_engineering_fn` inside your input_fn:
+ ```python
+ def new_input_fn():
+ features, labels = old_input_fn()
+ return feature_engineering_fn(features, labels)
+ ```
+* Use `tf.reshape` to reshape labels in your `input_fn`. `tf.estimator`
+ classifiers and regressors expect labels as a 2D Tensor of shape
+ `[batch_size, 1]`, or `[batch_size, n_labels]`. In contrast,
+ `tf.contrib.learn` classifiers and regressors supported labels with shape
+ `[batch_size]`.
+* If you pass custom metrics from the `evaluate()` method call, use
+ `tf.contrib.estimator.add_metrics`.
+* Replace your `serving_input_fn` with a `serving_input_receiver_fn`.
+ Note this should be entirely distinct from your training `input_fn`, so if you
+ previously had one `input_fn` with different "modes", you should now factor
+ that apart. Where the former returned either a simple `(features, labels)`
+ tuple or `InputFnOps`, you should now return a `ServingInputReceiver`.
+ If you were generating your `serving_input_fn` using the
+ `build_parsing_serving_input_fn` helper, you can simply drop in the
+ replacement `build_parsing_serving_input_receiver_fn`.
+
+Some remaining estimators/classes:
+
+* `DynamicRnnEstimator`: Consider a custom `model_fn`.
+* `KMeansClustering`: Use `tf.contrib.factorization.KMeansClustering`.
+* `LogisticRegressor`: Not supported. Instead, use `binary_classification_head`
+ with a custom `model_fn`, or with `DNNEstimator`.
+* `StateSavingRnnEstimator`: Consider a custom `model_fn`.
+* SVM: Consider a custom `model_fn`.
+* `LinearComposableModel` and `DNNComposableModel`: Not supported.
+ Consider `tf.contrib.estimator.DNNEstimator`, or write a custom model_fn.
+* `MetricSpec`: Deprecated. For adding custom metrics to canned Estimators, use
+ `tf.contrib.estimator.add_metrics`.
+
+## Estimator
+`tf.contrib.learn.Estimator` is migrated to `tf.estimator.Estimator`.
+
+To migrate, users need to take the following steps:
+
+* Replace `tf.contrib.learn.Estimator` with `tf.estimator.Estimator`.
+* If you pass a `config` argument to `Estimator`, this must be
+ `tf.estimator.RunConfig`. You may need to edit your code accordingly.
+* Edit your `model_fn` to return `tf.estimator.EstimatorSpec`. Refer to
+ `EstimatorSpec` for documentation of specific fields.
+* If your `model_fn` uses the `mode` argument, use `tf.estimator.ModeKeys`.
+
+Some related classes:
+* `Evaluable`, `Trainable`: Not supported, merged into `tf.estimator.Estimator`.
+* ExportStrategy: Replaced by `tf.estimator.Exporter`.
+
+## Head/MultiHead
+These classes are now supported under `tf.contrib.estimator`, e.g.
+`tf.contrib.estimator.multi_class_head` and `tf.contrib.estimator.multi_head`.
+
+Some differences:
+
+* `multi_class_head`: If you use `tf.contrib.learn.multi_class_head` with
+ `n_classes=2`, switch to `tf.contrib.estimator.binary_classification_head`.
+* `loss_only_head`: Not supported.
+* `poisson_regression_head`: Not supported (yet).
+* `binary_svm_head`: Not supported (yet).
+* `no_op_train_fn`: Replace it with `tf.no_op`.
+
+Some arguments are renamed, please refer to documentation. In addition:
+
+* `loss_fn`: Supported for `multi_label_head`. If you need it for other heads,
+ please open an issue.
+* `metric_class_ids`: Not supported (yet).
+* `enable_centered_bias`: Not supported. Dropping this argument is unlikely to
+ harm your model.
+* `label_name`: Not needed in `tf.estimator`. If you don’t use `multi_head`,
+ drop this argument. If you use `multi_head`, refer to
+ `tf.contrib.estimator.multi_head` documentation.
+
+## Experiment Class - Distributed Training Tooling
+
+Switch to `tf.estimator.train_and_evaluate`. Some differences:
+
+* Most of the constructor arguments, like `train_input_fn`, `eval_input_fn`,
+ should be wrapped into `tf.estimator.TrainSpec` and `tf.estimator.EvalSpec`.
+* Remove the `experiment_fn`. Instead, create the `Estimator`,
+ `train_spec` and `eval_spec`, then call `tf.estimator.train_and_evaluate`
+ directly.
+* Inside `tf.estimator.EvalSpec`, the `exporter` field is the replacement
+ for `export_strategy`. To be precise, `tf.estimator.LatestExporter` is the
+ replacement for `tf.contrib.learn.make_export_strategy`. If you want to export
+ only at the end of training use `tf.estimator.FinalExporter`.
+* If the `TF_CONFIG` environment variable is constructed manually, please read
+ the `train_and_evaluate` documentation for the new requirementds (in
+ particular, the chief node and evaluator node).
+
+## Others Classes and Functions
+
+* `tf.contrib.learn.datasets` is deprecated. We are adding ready to use datasets
+ to tensorflow/models. Many smaller datasets are available from other sources,
+ such as scikits.learn. Some Python processing may have to be written, but this
+ is straightforward to implement using the standard modules.
+* `tf.contrib.learn.preprocessing`: Deprecated. The python-only preprocessing
+ functions are not a good fit for TensorFlow. Please use `tf.data`, and
+ consider tensorflow/transform for more complex use cases.
+* `tf.contrib.learn.models`: Not supported, use canned estimators instead.
+* `tf.contrib.learn.monitors`: Implement `SessionRunHook` instead. Hook
+ implementations are in `tf.train`.
+* `tf.contrib.learn.learn_io`: Use the methods in `tf.estimator.inputs`, such as
+ `tf.estimator.inputs.numpy_input_fn`. Some utility functions have no
+ equivalent, we encourage the use of `tf.data`.
+
# limitations under the License.
# ==============================================================================
-# TODO(ptucker,ipolosukhin): Improve descriptions.
-"""High level API for learning.
+"""High level API for learning (DEPRECATED).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
See the @{$python/contrib.learn} guide.
# limitations under the License.
# ==============================================================================
-"""High level API for learning with TensorFlow."""
+"""High level API for learning with TensorFlow (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
# limitations under the License.
# ==============================================================================
-"""High level API for learning with TensorFlow."""
+"""High level API for learning with TensorFlow (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Some common SessionRunHook classes."""
+"""Some common SessionRunHook classes (deprected).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensorflow.python.training import basic_session_run_hooks
+from tensorflow.python.util.deprecation import deprecated_alias
# pylint: disable=invalid-name
-LoggingTensorHook = basic_session_run_hooks.LoggingTensorHook
-StopAtStepHook = basic_session_run_hooks.StopAtStepHook
-CheckpointSaverHook = basic_session_run_hooks.CheckpointSaverHook
-StepCounterHook = basic_session_run_hooks.StepCounterHook
-NanLossDuringTrainingError = basic_session_run_hooks.NanLossDuringTrainingError
-NanTensorHook = basic_session_run_hooks.NanTensorHook
-SummarySaverHook = basic_session_run_hooks.SummarySaverHook
+LoggingTensorHook = deprecated_alias(
+ 'tf.contrib.learn.basic_session_run_hooks.LoggingTensorHook',
+ 'tf.train.LoggingTensorHook',
+ basic_session_run_hooks.LoggingTensorHook)
+StopAtStepHook = deprecated_alias(
+ 'tf.contrib.learn.basic_session_run_hooks.StopAtStepHook',
+ 'tf.train.StopAtStepHook',
+ basic_session_run_hooks.StopAtStepHook)
+CheckpointSaverHook = deprecated_alias(
+ 'tf.contrib.learn.basic_session_run_hooks.CheckpointSaverHook',
+ 'tf.train.CheckpointSaverHook',
+ basic_session_run_hooks.CheckpointSaverHook)
+StepCounterHook = deprecated_alias(
+ 'tf.contrib.learn.basic_session_run_hooks.StepCounterHook',
+ 'tf.train.StepCounterHook',
+ basic_session_run_hooks.StepCounterHook)
+NanLossDuringTrainingError = deprecated_alias(
+ 'tf.contrib.learn.basic_session_run_hooks.NanLossDuringTrainingError',
+ 'tf.train.NanLossDuringTrainingError',
+ basic_session_run_hooks.NanLossDuringTrainingError)
+NanTensorHook = deprecated_alias(
+ 'tf.contrib.learn.basic_session_run_hooks.NanTensorHook',
+ 'tf.train.NanTensorHook',
+ basic_session_run_hooks.NanTensorHook)
+SummarySaverHook = deprecated_alias(
+ 'tf.contrib.learn.basic_session_run_hooks.SummarySaverHook',
+ 'tf.train.SummarySaverHook',
+ basic_session_run_hooks.SummarySaverHook)
# pylint: enable=invalid-name
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Dataset utilities and synthetic/reference datasets."""
+"""Dataset utilities and synthetic/reference datasets (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from tensorflow.contrib.learn.python.learn.datasets import mnist
from tensorflow.contrib.learn.python.learn.datasets import synthetic
from tensorflow.contrib.learn.python.learn.datasets import text_datasets
+from tensorflow.python.util.deprecation import deprecated
# Export load_iris and load_boston.
load_iris = base.load_iris
}
+@deprecated(None, 'Please use tf.data.')
def load_dataset(name, size='small', test_with_fake_data=False):
"""Loads dataset by name.
return DATASETS[name]()
+@deprecated(None, 'Please use tf.data.')
def make_dataset(name, n_samples=100, noise=None, seed=42, *args, **kwargs):
- """Creates binary synthetic datasets
+ """Creates binary synthetic datasets.
Args:
name: str, name of the dataset to generate
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Base utilities for loading datasets."""
+
+"""Base utilities for loading datasets (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from six.moves import urllib
from tensorflow.python.platform import gfile
+from tensorflow.python.util.deprecation import deprecated
+
Dataset = collections.namedtuple('Dataset', ['data', 'target'])
Datasets = collections.namedtuple('Datasets', ['train', 'validation', 'test'])
+@deprecated(None, 'Use tf.data instead.')
def load_csv_with_header(filename,
target_dtype,
features_dtype,
return Dataset(data=data, target=target)
+@deprecated(None, 'Use tf.data instead.')
def load_csv_without_header(filename,
target_dtype,
features_dtype,
return Dataset(data=data, target=target)
+@deprecated(None, 'Use tf.data instead.')
def shrink_csv(filename, ratio):
"""Create a smaller dataset of only 1/ratio of original data."""
filename_small = filename.replace('.', '_small.')
i += 1
+@deprecated(None, 'Use scikits.learn.datasets.')
def load_iris(data_path=None):
"""Load Iris dataset.
data_path, target_dtype=np.int, features_dtype=np.float)
+@deprecated(None, 'Use scikits.learn.datasets.')
def load_boston(data_path=None):
"""Load Boston housing dataset.
data_path, target_dtype=np.float, features_dtype=np.float)
-def retry(initial_delay, max_delay, factor=2.0, jitter=0.25, is_retriable=None):
+@deprecated(None, 'Use the retry module or similar alternatives.')
+def retry(initial_delay,
+ max_delay,
+ factor=2.0,
+ jitter=0.25,
+ is_retriable=None):
"""Simple decorator for wrapping retriable functions.
Args:
for delay in delays():
try:
return fn(*args, **kwargs)
- except Exception as e: # pylint: disable=broad-except)
+ except Exception as e: # pylint: disable=broad-except
if is_retriable is None:
continue
return isinstance(e, IOError) and e.errno in _RETRIABLE_ERRNOS
+@deprecated(None, 'Please use urllib or similar directly.')
@retry(initial_delay=1.0, max_delay=16.0, is_retriable=_is_retriable)
def urlretrieve_with_retry(url, filename=None):
return urllib.request.urlretrieve(url, filename)
+@deprecated(None, 'Please write your own downloading logic.')
def maybe_download(filename, work_directory, source_url):
"""Download the data from source url, unless it's already here.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Functions for downloading and reading MNIST data."""
+"""Functions for downloading and reading MNIST data (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import random_seed
from tensorflow.python.platform import gfile
+from tensorflow.python.util.deprecation import deprecated
# CVDF mirror of http://yann.lecun.com/exdb/mnist/
DEFAULT_SOURCE_URL = 'https://storage.googleapis.com/cvdf-datasets/mnist/'
return numpy.frombuffer(bytestream.read(4), dtype=dt)[0]
+@deprecated(None, 'Please use tf.data to implement this functionality.')
def extract_images(f):
"""Extract the images into a 4D uint8 numpy array [index, y, x, depth].
return data
+@deprecated(None, 'Please use tf.one_hot on tensors.')
def dense_to_one_hot(labels_dense, num_classes):
"""Convert class labels from scalars to one-hot vectors."""
num_labels = labels_dense.shape[0]
return labels_one_hot
+@deprecated(None, 'Please use tf.data to implement this functionality.')
def extract_labels(f, one_hot=False, num_classes=10):
"""Extract the labels into a 1D uint8 numpy array [index].
class DataSet(object):
+ """Container class for a dataset (deprecated).
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+ """
+ @deprecated(None, 'Please use alternatives such as official/mnist/dataset.py'
+ ' from tensorflow/models.')
def __init__(self,
images,
labels,
return self._images[start:end], self._labels[start:end]
+@deprecated(None, 'Please use alternatives such as official/mnist/dataset.py'
+ ' from tensorflow/models.')
def read_data_sets(train_dir,
fake_data=False,
one_hot=False,
return base.Datasets(train=train, validation=validation, test=test)
+@deprecated(None, 'Please use alternatives such as official/mnist/dataset.py'
+ ' from tensorflow/models.')
def load_mnist(train_dir='MNIST-data'):
return read_data_sets(train_dir)
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Produce DBpedia datasets of a smaller size."""
+"""Produce DBpedia datasets of a smaller size (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Synthetic dataset generators."""
+"""Synthetic dataset generators (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
import numpy as np
from tensorflow.contrib.learn.python.learn.datasets.base import Dataset
+from tensorflow.python.util.deprecation import deprecated
+@deprecated(None, 'Consider using synthetic datasets from scikits.learn.')
def circles(n_samples=100,
noise=None,
seed=None,
return Dataset(data=X[indices], target=y[indices])
+@deprecated(None, 'Consider using synthetic datasets from scikits.learn.')
def spirals(n_samples=100,
noise=None,
seed=None,
# limitations under the License.
# ==============================================================================
-"""Text datasets."""
+"""Text datasets (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from tensorflow.contrib.learn.python.learn.datasets import base
from tensorflow.python.platform import gfile
+from tensorflow.python.util.deprecation import deprecated
DBPEDIA_URL = 'https://github.com/le-scientifique/torchDatasets/raw/master/dbpedia_csv.tar.gz'
+@deprecated(None, 'See contrib/learn/README.md')
def maybe_download_dbpedia(data_dir):
"""Download if DBpedia data is not present."""
train_path = os.path.join(data_dir, 'dbpedia_csv/train.csv')
tfile.extractall(data_dir)
+@deprecated(None, 'See contrib/learn/README.md')
def load_dbpedia(size='small', test_with_fake_data=False):
"""Get DBpedia datasets from CSV files."""
if not test_with_fake_data:
# limitations under the License.
# ==============================================================================
-"""An estimator is a rule for calculating an estimate of a given quantity.
+"""An estimator is a rule for calculating an estimate of a given quantity (deprecated).
+
+These classes are deprecated and replaced with `tf.estimator`.
+
+See [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
# Estimators
# limitations under the License.
# ==============================================================================
-"""sklearn cross-support."""
+"""sklearn cross-support (deprecated)."""
from __future__ import absolute_import
from __future__ import division
class NotFittedError(ValueError, AttributeError):
"""Exception class to raise if estimator is used before fitting.
+ USE OF THIS EXCEPTION IS DEPRECATED.
+
This class inherits from both ValueError and AttributeError to help with
exception handling and backward compatibility.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""TensorFlow composable models used as building blocks for estimators."""
+"""TensorFlow composable models used as building blocks for estimators (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from tensorflow.python.ops import partitioned_variables
from tensorflow.python.ops import variable_scope
from tensorflow.python.summary import summary
+from tensorflow.python.util.deprecation import deprecated
class _ComposableModel(object):
_ComposableModel and its subclasses are not part of the public tf.learn API.
"""
+ @deprecated(None, "Please use model_fns in tf.estimator.")
def __init__(self,
num_label_columns,
optimizer,
class LinearComposableModel(_ComposableModel):
"""A _ComposableModel that implements linear regression.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Instances of this class can be used to build estimators through the use
of composition.
"""
class DNNComposableModel(_ComposableModel):
"""A _ComposableModel that implements a DNN.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Instances of this class can be used to build estimators through the use
of composition.
"""
# limitations under the License.
# ==============================================================================
-"""Constants regarding Estimators.
+"""Constants regarding Estimators (deprecated).
-This file is obsoleted in the move of Estimator to core.
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
"""
from __future__ import absolute_import
from __future__ import division
class ProblemType(object):
"""Enum-like values for the type of problem that the model solves.
+ THIS CLASS IS DEPRECATED.
+
These values are used when exporting the model to produce the appropriate
signature function for serving.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Debug estimators.
+"""Debug estimators (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
Debug estimators are bias-only estimators that can be used for debugging
and as simple baselines.
class DebugClassifier(estimator.Estimator):
"""A classifier for TensorFlow Debug models.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Example:
```python
class DebugRegressor(estimator.Estimator):
"""A regressor for TensorFlow Debug models.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Example:
```python
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Deep Neural Network estimators."""
+"""Deep Neural Network estimators (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
class DNNClassifier(estimator.Estimator):
"""A classifier for TensorFlow DNN models.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Example:
```python
class DNNRegressor(estimator.Estimator):
"""A regressor for TensorFlow DNN models.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Example:
```python
class DNNEstimator(estimator.Estimator):
"""A Estimator for TensorFlow DNN models with user specified _Head.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Example:
```python
# limitations under the License.
# ==============================================================================
-"""TensorFlow estimators for Linear and DNN joined training models."""
+"""TensorFlow estimators for Linear and DNN joined training models (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
class DNNLinearCombinedEstimator(estimator.Estimator):
"""An estimator for TensorFlow Linear and DNN joined training models.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Note: New users must set `fix_global_step_increment_bug=True` when creating an
estimator.
class DNNLinearCombinedClassifier(estimator.Estimator):
"""A classifier for TensorFlow Linear and DNN joined training models.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Note: New users must set `fix_global_step_increment_bug=True` when creating an
estimator.
class DNNLinearCombinedRegressor(estimator.Estimator):
"""A regressor for TensorFlow Linear and DNN joined training models.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Note: New users must set `fix_global_step_increment_bug=True` when creating an
estimator.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Estimator for Dynamic RNNs."""
+"""Estimator for Dynamic RNNs (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
class DynamicRnnEstimator(estimator.Estimator):
+ """Dynamically unrolled RNN (deprecated).
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+ """
def __init__(self,
problem_type,
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Base Estimator class."""
+"""Base Estimator class (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
return df.input_builder, df.get_feed_dict_fn()
+@deprecated(None, 'Please specify feature columns explicitly.')
def infer_real_valued_columns_from_input_fn(input_fn):
"""Creates `FeatureColumn` objects for inputs defined by `input_fn`.
return layers.infer_real_valued_columns(features)
+@deprecated(None, 'Please specify feature columns explicitly.')
def infer_real_valued_columns_from_input(x):
"""Creates `FeatureColumn` objects for inputs defined by input `x`.
trainable.Trainable):
"""Abstract BaseEstimator class to train and evaluate TensorFlow models.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Users should not instantiate or subclass this class. Instead, use an
`Estimator`.
"""
# TODO(wicke): Remove this once launcher takes over config functionality
_Config = run_config.RunConfig # pylint: disable=invalid-name
+ @deprecated(None, 'Please replace uses of any Estimator from tf.contrib.learn'
+ ' with an Estimator from tf.estimator.*')
def __init__(self, model_dir=None, config=None):
"""Initializes a BaseEstimator instance.
class Estimator(BaseEstimator):
"""Estimator class is the basic TensorFlow model trainer/evaluator.
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
"""
def __init__(self,
# For time of deprecation x,y from Estimator allow direct access.
# pylint: disable=protected-access
class SKCompat(sklearn.BaseEstimator):
- """Scikit learn wrapper for TensorFlow Learn Estimator."""
+ """Scikit learn wrapper for TensorFlow Learn Estimator.
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+ """
+ @deprecated(None, 'Please switch to the Estimator interface.')
def __init__(self, estimator):
self._estimator = estimator
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Utils for Estimator."""
+"""Utils for Estimator (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Abstractions for the head(s) of a model.
+"""Abstractions for the head(s) of a model (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
"""
+
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensorflow.python.training import training
from tensorflow.python.util import tf_decorator
from tensorflow.python.util import tf_inspect
+from tensorflow.python.util.deprecation import deprecated
class Head(object):
"""Interface for the head/top of a model.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Given logits (or output of a hidden layer), a Head knows how to compute
predictions, loss, default metric and export signature. It is meant to,
raise NotImplementedError("Calling an abstract method.")
+@deprecated(None, "Please switch to tf.contrib.estimator.*_head.")
def regression_head(label_name=None,
weight_column_name=None,
label_dimension=1,
link_fn=(link_fn if link_fn is not None else array_ops.identity))
+@deprecated(None, "Please switch to tf.contrib.estimator.*_head.")
def poisson_regression_head(label_name=None,
weight_column_name=None,
label_dimension=1,
# TODO(zakaria): Consider adding a _RegressionHead for logistic_regression
+@deprecated(None, "Please switch to tf.contrib.estimator.*_head.")
def multi_class_head(n_classes,
label_name=None,
weight_column_name=None,
label_keys=label_keys)
+@deprecated(None, "Please switch to tf.contrib.estimator.*_head.")
def binary_svm_head(
label_name=None,
weight_column_name=None,
thresholds=thresholds)
+@deprecated(None, "Please switch to tf.contrib.estimator.*_head.")
def multi_label_head(n_classes,
label_name=None,
weight_column_name=None,
loss_fn=_wrap_custom_loss_fn(loss_fn) if loss_fn else None)
+@deprecated(None, "Please switch to tf.contrib.estimator.*_head.")
def loss_only_head(loss_fn, head_name=None):
"""Creates a Head that contains only loss terms.
return _LossOnlyHead(loss_fn, head_name=head_name)
+@deprecated(None, "Please switch to tf.contrib.estimator.*_head.")
def multi_head(heads, loss_weights=None):
"""Creates a MultiHead stemming from same logits/hidden layer.
return _MultiHead(heads, loss_merger=_weighted_loss_merger)
+@deprecated(None, "Use 'lambda _: tf.no_op()'.")
def no_op_train_fn(loss):
del loss
return control_flow_ops.no_op()
# 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 (deprecated).
This module is deprecated. Please use
@{tf.contrib.factorization.KMeansClustering} instead of
# TODO(agarwal,ands): support sharded input.
class KMeansClustering(estimator.Estimator):
- """An Estimator for K-Means clustering."""
+ """An Estimator for K-Means clustering.
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+ """
SQUARED_EUCLIDEAN_DISTANCE = clustering_ops.SQUARED_EUCLIDEAN_DISTANCE
COSINE_DISTANCE = clustering_ops.COSINE_DISTANCE
RANDOM_INIT = clustering_ops.RANDOM_INIT
# limitations under the License.
# ==============================================================================
-"""Linear Estimators."""
+"""Linear Estimators (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
class LinearClassifier(estimator.Estimator):
"""Linear classifier model.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Train a linear model to classify instances into one of multiple possible
classes. When number of possible classes is 2, this is binary classification.
class LinearRegressor(estimator.Estimator):
"""Linear regressor model.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Train a linear regression model to predict label value given observation of
feature values.
class LinearEstimator(estimator.Estimator):
"""Linear model with user specified head.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Train a generalized linear model to predict label value given observation of
feature values.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Logistic regression (aka binary classifier) class.
+"""Logistic regression (aka binary classifier) class (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
This defines some useful basic metrics for using logistic regression to classify
a binary event (0 vs 1).
feature_engineering_fn=None):
"""Builds a logistic regression Estimator for binary classification.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
This method provides a basic Estimator with some additional metrics for custom
binary classification models, including AUC, precision/recall and accuracy.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Enum for metric keys."""
+"""Enum for metric keys (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
class MetricKey(object):
- """Metric key strings."""
+ """Metric key strings (deprecated)."""
+
LOSS = "loss"
AUC = "auc"
AUC_PR = "auc_precision_recall"
# limitations under the License.
# ==============================================================================
-"""Classes and methods related to model_fn."""
+"""Classes and methods related to model_fn (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.saved_model import signature_constants
from tensorflow.python.training import session_run_hook
+from tensorflow.python.util.deprecation import deprecated
class ModeKeys(object):
- """Standard names for model modes.
+ """Standard names for model modes (deprecated).
+
+ THIS CLASS IS DEPRECATED.
The following standard keys are defined:
'output_alternatives', 'training_chief_hooks', 'training_hooks',
'scaffold', 'mode'
])):
- """Ops returned from a model_fn."""
+ """Ops returned from a model_fn.
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+ """
+ @deprecated(None, 'When switching to tf.estimator.Estimator, use '
+ 'tf.estimator.EstimatorSpec. You can use the `estimator_spec`'
+ ' method to create an equivalent one.')
def __new__(cls,
mode,
predictions=None,
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Enum for model prediction keys.
+"""Enum for model prediction keys (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
This file is obsoleted in the move of Estimator to core.
"""
class PredictionKey(object):
+ """THIS CLASS IS DEPRECATED."""
+
CLASSES = "classes"
PROBABILITIES = "probabilities"
LOGITS = "logits"
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Common operations for RNN Estimators."""
+"""Common operations for RNN Estimators (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Run Config."""
+"""Run Config (deprecated, use tf.estimator.RunConfig instead).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from tensorflow.python.estimator import run_config as core_run_config
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.training import server_lib
+from tensorflow.python.util.deprecation import deprecated
# A list of the property names in RunConfig user allows to change. They will
# not affect the execution framework, so when execution framework checks the
-# `uid` of the RunConfig, it should be ingored.
+# `uid` of the RunConfig, it should be ignored.
_DEFAULT_UID_WHITE_LIST = [
'tf_random_seed',
'save_summary_steps',
class Environment(object):
+ """DEPRECATED CLASS."""
# For running general distributed training.
CLOUD = 'cloud'
# For running Google-internal distributed training.
class TaskType(object):
+ """DEPRECATED CLASS."""
MASTER = 'master'
PS = 'ps'
WORKER = 'worker'
class ClusterConfig(object):
"""This class specifies the configurations for a distributed run.
+ THIS CLASS IS DEPRECATED. Use tf.estimator.RunConfig instead.
+
If you're using an `Estimator`, you should probably use the subclass
RunConfig instead.
"""
class RunConfig(ClusterConfig, core_run_config.RunConfig):
"""This class specifies the configurations for an `Estimator` run.
- This class is the implementation of @{tf.estimator.RunConfig} interface.
+ This class is a deprecated implementation of @{tf.estimator.RunConfig}
+ interface.
"""
_USE_DEFAULT = 0
+ @deprecated(None, 'When switching to tf.estimator.Estimator, use'
+ ' tf.estimator.RunConfig instead.')
def __init__(self,
master=None,
num_cores=0,
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Estimator for State Saving RNNs."""
+"""Estimator for State Saving RNNs (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
class StateSavingRnnEstimator(estimator.Estimator):
+ """RNN with static unrolling and state saving (deprecated).
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+ """
def __init__(self,
problem_type,
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Support Vector Machine (SVM) Estimator."""
+"""Support Vector Machine (SVM) Estimator (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
class SVM(estimator.Estimator):
"""Support Vector Machine (SVM) model for binary classification.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Currently, only linear SVMs are supported. For the underlying optimization
problem, the `SDCAOptimizer` is used. For performance and convergence tuning,
the num_loss_partitions parameter passed to `SDCAOptimizer` (see `__init__()`
# limitations under the License.
# ==============================================================================
-"""TensorSignature class and utilities."""
+"""TensorSignature class and utilities (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
"TensorSignature", ["dtype", "shape", "is_sparse"])):
"""Signature of the `Tensor` object.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Useful to check compatibility of tensors.
Example:
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Test data utilities."""
+"""Test data utilities (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""`Evaluable` interface."""
+"""`Evaluable` interface (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
class Evaluable(object):
"""Interface for objects that are evaluatable by, e.g., `Experiment`.
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
"""
__metaclass__ = abc.ABCMeta
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Experiment class collecting information needed for a single training run."""
+"""Experiment class collecting information for a single training run (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
import time
from tensorflow.contrib.framework import deprecated
-from tensorflow.contrib.framework import deprecated_args
from tensorflow.contrib.framework.python.framework import experimental
from tensorflow.contrib.learn.python.learn import evaluable
from tensorflow.contrib.learn.python.learn import export_strategy
class Experiment(object):
"""Experiment is a class containing all information needed to train a model.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
After an experiment is created (by passing an Estimator and inputs for
training and evaluation), an Experiment instance knows how to invoke training
and eval loops in a sensible fashion for distributed training.
# TODO(ispir): remove delay_workers_by_global_step and make global step based
# waiting as only behavior.
- @deprecated_args(
- "2016-10-23",
- "local_eval_frequency is deprecated as local_run will be renamed to "
- "train_and_evaluate. Use min_eval_frequency and call train_and_evaluate "
- "instead. Note, however, that the default for min_eval_frequency is 1, "
- "meaning models will be evaluated every time a new checkpoint is "
- "available. In contrast, the default for local_eval_frequency is None, "
- "resulting in evaluation occurring only after training has completed. "
- "min_eval_frequency is ignored when calling the deprecated local_run.",
- "local_eval_frequency")
+ @deprecated(None, "Please switch to tf.estimator.train_and_evaluate. You will"
+ " also have to convert to a tf.estimator.Estimator.")
def __init__(self,
estimator,
train_input_fn,
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""ExportStrategy class represents different flavors of model export."""
+"""ExportStrategy class represents different flavors of model export (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
import collections
from tensorflow.python.util import tf_inspect
+from tensorflow.python.util.deprecation import deprecated
__all__ = ['ExportStrategy']
['name', 'export_fn', 'strip_default_attrs'])):
"""A class representing a type of model export.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Typically constructed by a utility function specific to the exporter, such as
`saved_model_export_utils.make_export_strategy()`.
forward compatibility of the resulting `SavedModel`.
"""
+ @deprecated(None, 'Please switch to tf.estimator.train_and_evaluate, and use '
+ 'tf.estimator.Exporter.')
def __new__(cls, name, export_fn, strip_default_attrs=None):
return super(ExportStrategy, cls).__new__(
cls, name, export_fn, strip_default_attrs)
# limitations under the License.
# ==============================================================================
-"""High level operations on graphs."""
+"""High level operations on graphs (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
return summary_io.SummaryWriterCache.clear()
+@deprecated(None, 'Use `SummaryWriterCache.get` directly.')
def get_summary_writer(logdir):
"""Returns single SummaryWriter per logdir in current run.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Tools to allow different io formats."""
+"""Tools to allow different io formats (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
# limitations under the License.
# ==============================================================================
-"""Methods to allow dask.DataFrame."""
+"""Methods to allow dask.DataFrame (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
import numpy as np
+from tensorflow.python.util.deprecation import deprecated
+
try:
# pylint: disable=g-import-not-at-top
import dask.dataframe as dd
return dd.Series(merge(dsk, df.dask), name, df.name, divisions)
+@deprecated(None, 'Please feed input to tf.data to support dask.')
def extract_dask_data(data):
"""Extract data from dask.Series or dask.DataFrame for predictors.
return data
+@deprecated(None, 'Please feed input to tf.data to support dask.')
def extract_dask_labels(labels):
"""Extract data from dask.Series or dask.DataFrame for labels.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Implementations of different data feeders to provide data for TF trainer."""
+"""Implementations of different data feeders to provide data for TF trainer (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
# TODO(ipolosukhin): Replace this module with feed-dict queue runners & queues.
from tensorflow.python.framework import tensor_util
from tensorflow.python.ops import array_ops
from tensorflow.python.platform import tf_logging as logging
+from tensorflow.python.util.deprecation import deprecated
# pylint: disable=g-multiple-import,g-bad-import-order
from .pandas_io import HAS_PANDAS, extract_pandas_data, extract_pandas_matrix, extract_pandas_labels
return hasattr(x, 'next') or hasattr(x, '__next__')
+@deprecated(None, 'Please use tensorflow/transform or tf.data.')
def setup_train_data_feeder(x,
y,
n_classes,
yield np.matrix(chunk)
+@deprecated(None, 'Please use tensorflow/transform or tf.data.')
def setup_predict_data_feeder(x, batch_size=None):
"""Returns an iterable for feeding into predict step.
return [x]
+@deprecated(None, 'Please use tensorflow/transform or tf.data.')
def setup_processor_data_feeder(x):
"""Sets up processor iterable.
return x
+@deprecated(None, 'Please convert numpy dtypes explicitly.')
def check_array(array, dtype):
"""Checks array on dtype and converts it if different.
class DataFeeder(object):
- """Data feeder is an example class to sample data for TF trainer."""
+ """Data feeder is an example class to sample data for TF trainer.
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+ """
+ @deprecated(None, 'Please use tensorflow/transform or tf.data.')
def __init__(self,
x,
y,
class StreamingDataFeeder(DataFeeder):
"""Data feeder for TF trainer that reads data from iterator.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Streaming data feeder allows to read data as it comes it from disk or
somewhere else. It's custom to have this iterators rotate infinetly over
the dataset, to allow control of how much to learn on the trainer side.
class DaskDataFeeder(object):
"""Data feeder for that reads data from dask.Series and dask.DataFrame.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Numpy arrays can be serialized to disk and it's possible to do random seeks
into them. DaskDataFeeder will remove requirement to have full dataset in the
memory and still do random seeks for sampling of batches.
"""
+ @deprecated(None, 'Please feed input to tf.data to support dask.')
def __init__(self,
x,
y,
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Methods to allow generator of dict with numpy arrays."""
+"""Methods to allow generator of dict with numpy arrays (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from types import GeneratorType
from tensorflow.python.estimator.inputs.queues.feeding_functions import _enqueue_data as enqueue_data
+from tensorflow.python.util.deprecation import deprecated
+@deprecated(None, 'Please use tf.data.')
def generator_input_fn(x,
target_key=None,
batch_size=128,
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Methods to read data in the graph."""
+"""Methods to read data in the graph (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from tensorflow.python.summary import summary
from tensorflow.python.training import input as input_ops
from tensorflow.python.training import queue_runner
+from tensorflow.python.util.deprecation import deprecated
# Default name for key in the feature dict.
KEY_FEATURE_NAME = '__key__'
+@deprecated(None, 'Use tf.data.')
def read_batch_examples(file_pattern,
batch_size,
reader,
return examples
+@deprecated(None, 'Use tf.data.')
def read_keyed_batch_examples(file_pattern,
batch_size,
reader,
seed=seed)
+@deprecated(None, 'Use tf.data.')
def read_keyed_batch_examples_shared_queue(file_pattern,
batch_size,
reader,
return queued_examples_with_keys
+@deprecated(None, 'Use tf.data.')
def read_keyed_batch_features(file_pattern,
batch_size,
features,
name=scope)
+@deprecated(None, 'Use tf.data.')
def read_keyed_batch_features_shared_queue(file_pattern,
batch_size,
features,
name=scope)
+@deprecated(None, 'Use tf.data.')
def queue_parsed_features(parsed_features,
keys=None,
feature_queue_capacity=100,
return dequeued_keys, dequeued_parsed_features
+@deprecated(None, 'Use tf.data.')
def read_batch_features(file_pattern,
batch_size,
features,
return features
+@deprecated(None, 'Use tf.data.')
def read_batch_record_features(file_pattern,
batch_size,
features,
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Methods to allow dict of numpy arrays."""
+"""Methods to allow dict of numpy arrays (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensorflow.python.estimator.inputs.numpy_io import numpy_input_fn as core_numpy_input_fn
+from tensorflow.python.util.deprecation import deprecated
+@deprecated(None, 'Use tf.estimator.inputs.numpy_input_fn.')
def numpy_input_fn(x,
y=None,
batch_size=128,
# limitations under the License.
# ==============================================================================
-"""Methods to allow pandas.DataFrame."""
+"""Methods to allow pandas.DataFrame (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensorflow.python.estimator.inputs.pandas_io import pandas_input_fn as core_pandas_input_fn
+from tensorflow.python.util.deprecation import deprecated
try:
# pylint: disable=g-import-not-at-top
}
+@deprecated(None, 'Please use tf.estimator.inputs.pandas_input_fn')
def pandas_input_fn(x,
y=None,
batch_size=128,
target_column=target_column)
+@deprecated(None, 'Please access pandas data directly.')
def extract_pandas_data(data):
"""Extract data from pandas.DataFrame for predictors.
'float, or bool. Found: ' + ', '.join(error_report))
+@deprecated(None, 'Please access pandas data directly.')
def extract_pandas_matrix(data):
"""Extracts numpy matrix from pandas DataFrame.
return data.as_matrix()
+@deprecated(None, 'Please access pandas data directly.')
def extract_pandas_labels(labels):
"""Extract data from pandas.DataFrame for labels.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Runs an Experiment."""
+"""Runs an Experiment (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from tensorflow.contrib.learn.python.learn.experiment import Experiment
from tensorflow.contrib.training.python.training import hparam as hparam_lib
from tensorflow.python.platform import tf_logging as logging
+from tensorflow.python.util.deprecation import deprecated
# TODO(xiejw): Refactor the learn_runner to make code reusable.
return wrapped_experiment_fn
+@deprecated(None, 'Use tf.estimator.train_and_evaluate.')
def run(experiment_fn, output_dir=None, schedule=None, run_config=None,
hparams=None):
"""Make and run an experiment.
return _execute_schedule(experiment, schedule)
+@deprecated(None, 'Use tf.estimator.train_and_evaluate.')
def tune(experiment_fn, tuner):
"""Tune an experiment with hyper-parameters.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Utilities to run and tune an Experiment.
+"""Utilities to run and tune an Experiment (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
@@run
@@tune
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""The metric spec class to flexibly connect models and metrics."""
+"""The metric spec class to flexibly connect models and metrics (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.util import tf_inspect
+from tensorflow.python.util.deprecation import deprecated
def _assert_named_args(sentinel):
class MetricSpec(object):
"""MetricSpec connects a model to metric functions.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
The MetricSpec class contains all information necessary to connect the
output of a `model_fn` to the metrics (usually, streaming metrics) that are
used in evaluation.
"""
+ @deprecated(None, 'Use tf.estimator.EstimatorSpec.eval_metric_ops.')
def __init__(self,
metric_fn,
prediction_key=None,
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Various high level TF models."""
+"""Various high level TF models (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from tensorflow.python.ops import init_ops
from tensorflow.python.ops import variable_scope as vs
from tensorflow.python.summary import summary
+from tensorflow.python.util.deprecation import deprecated
+@deprecated(None, 'Consider using a tf.estimator.LinearRegressor')
def linear_regression_zero_init(x, y):
"""Linear regression subgraph with zero-value initial weights and bias.
return linear_regression(x, y, init_mean=0.0, init_stddev=0.0)
+@deprecated(None, 'Consider using a class from tf.estimator.LinearClassifier')
def logistic_regression_zero_init(x, y):
"""Logistic regression subgraph with zero-value initial weights and bias.
return logistic_regression(x, y, init_mean=0.0, init_stddev=0.0)
+@deprecated(None, 'Consider using a class from tf.estimator.')
def linear_regression(x, y, init_mean=None, init_stddev=1.0):
"""Creates linear regression TensorFlow subgraph.
return losses_ops.mean_squared_error_regressor(x, y, weights, bias)
+@deprecated(None, 'Consider using a class from tf.estimator.')
def logistic_regression(x,
y,
class_weight=None,
return result
+@deprecated(None, 'Please consider `tf.nn.bidirectional_dynamic_rnn`.')
def bidirectional_rnn(cell_fw,
cell_bw,
inputs,
# End of TensorFlow 0.7
+@deprecated(None, 'Please consider tensorflow/tensor2tensor.')
def get_rnn_model(rnn_size, cell_type, num_layers, input_op_fn, bidirectional,
target_predictor_fn, sequence_length, initial_state,
attn_length, attn_size, attn_vec_size):
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""A wrapper of Session API which runs hooks."""
+"""A wrapper of Session API which runs hooks (deprecated).
+
+These are deprecated aliases for classes and functions in `tf.train`. Please use
+those directly.
+"""
from __future__ import absolute_import
from __future__ import division
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Monitors instrument the training process.
+"""Monitors instrument the training process (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
@@get_default_monitors
@@BaseMonitor
class BaseMonitor(object):
"""Base class for Monitors.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Defines basic interfaces of Monitors.
Monitors can either be run on all workers or, more commonly, restricted
to run exclusively on the elected chief worker.
class EveryN(BaseMonitor):
"""Base class for monitors that execute callbacks every N steps.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
This class adds three new callbacks:
- every_n_step_begin
- every_n_step_end
class PrintTensor(EveryN):
"""Prints given tensors every N steps.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
This is an `EveryN` monitor and has consistent semantic for `every_n`
and `first_n`.
class LoggingTrainable(EveryN):
"""Writes trainable variable values into log every N steps.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Write the tensors in trainable variables `every_n` steps,
starting with the `first_n`th step.
-
"""
def __init__(self, scope=None, every_n=100, first_n=1):
class SummarySaver(EveryN):
- """Saves summaries every N steps."""
+ """Saves summaries every N steps.
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+ """
def __init__(self,
summary_op,
class ValidationMonitor(EveryN):
"""Runs evaluation of a given estimator, at most every N steps.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Note that the evaluation is done based on the saved checkpoint, which will
usually be older than the current step.
class CaptureVariable(EveryN):
"""Captures a variable's values into a collection.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
This monitor is useful for unit testing. You should exercise caution when
using this monitor in production, since it never discards values.
self._var_values[step] = _extract_output(outputs, self._var_name)
+@deprecation.deprecated(None, "Use tf.train.MonitoredTrainingSession.")
def get_default_monitors(loss_op=None,
summary_op=None,
save_summary_steps=100,
class GraphDump(BaseMonitor):
"""Dumps almost all tensors in the graph at every step.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Note, this is very expensive, prefer `PrintTensor` in production.
"""
class ExportMonitor(EveryN):
- """Monitor that exports Estimator every N steps."""
+ """Monitor that exports Estimator every N steps.
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+ """
@deprecation.deprecated("2017-03-25",
"ExportMonitor is deprecated. Please pass an "
class CheckpointSaver(BaseMonitor):
- """Saves checkpoints every N steps or N seconds."""
+ """Saves checkpoints every N steps or N seconds.
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+ """
def __init__(self,
checkpoint_dir,
class StepCounter(EveryN):
- """Steps per second monitor."""
+ """Steps per second monitor.
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+ """
def __init__(self, every_n_steps=100, output_dir=None, summary_writer=None):
super(StepCounter, self).__init__(every_n_steps=every_n_steps)
class NanLoss(EveryN):
"""NaN Loss monitor.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Monitors loss and stops training if loss is NaN.
Can either fail with exception or just stop training.
"""
# limitations under the License.
# ==============================================================================
-"""Various TensorFlow Ops."""
+"""Various TensorFlow Ops (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
# limitations under the License.
# ==============================================================================
-"""TensorFlow Ops to work with embeddings.
+"""TensorFlow Ops to work with embeddings (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
Note: categorical variables are handled via embeddings in many cases.
For example, in case of words.
# limitations under the License.
# ==============================================================================
-"""TensorFlow Ops for loss computation."""
+"""TensorFlow Ops for loss computation (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
# limitations under the License.
# ==============================================================================
-"""TensorFlow Ops for Sequence to Sequence models."""
+"""TensorFlow Ops for Sequence to Sequence models (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from tensorflow.python.ops import math_ops
from tensorflow.python.ops import nn
from tensorflow.python.ops import variable_scope as vs
+from tensorflow.python.util.deprecation import deprecated
+@deprecated(None, 'Please use tf.nn/tf.layers directly.')
def sequence_classifier(decoding, labels, sampling_decoding=None, name=None):
"""Returns predictions and loss for sequence of predictions.
return array_ops.stack(predictions, axis=1), loss
+@deprecated(None, 'Please use tf.nn/tf.layers directly.')
def seq2seq_inputs(x, y, input_length, output_length, sentinel=None, name=None):
"""Processes inputs for Sequence to Sequence models.
return in_x, in_y, out_y
+@deprecated(None, 'Please use tf.nn/tf.layers directly.')
def rnn_decoder(decoder_inputs, initial_state, cell, scope=None):
"""RNN Decoder that creates training and sampling sub-graphs.
return outputs, states, sampling_outputs, sampling_states
+@deprecated(None, 'Please use tf.nn/tf.layers directly.')
def rnn_seq2seq(encoder_inputs,
decoder_inputs,
encoder_cell,
# limitations under the License.
# ==============================================================================
-"""Preprocessing tools useful for building models."""
+"""Preprocessing tools useful for building models (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
# limitations under the License.
# ==============================================================================
-"""Implements preprocessing transformers for categorical variables."""
+"""Implements preprocessing transformers for categorical variables (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
import math
import numpy as np
+from tensorflow.python.util.deprecation import deprecated
+
# pylint: disable=g-bad-import-order
from . import categorical_vocabulary
from ..learn_io.data_feeder import setup_processor_data_feeder
class CategoricalProcessor(object):
"""Maps documents to sequences of word ids.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
As a common convention, Nan values are handled as unknown tokens.
Both float('nan') and np.nan are accepted.
"""
+ @deprecated(None, 'Please use tensorflow/transform or tf.data for sequence '
+ 'processing.')
def __init__(self, min_frequency=0, share=False, vocabularies=None):
"""Initializes a CategoricalProcessor instance.
# limitations under the License.
# ==============================================================================
-"""Categorical vocabulary classes to map categories to indexes.
+"""Categorical vocabulary classes to map categories to indexes (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
Can be used for categorical variables, sparse variables and words.
"""
import collections
import six
+from tensorflow.python.util.deprecation import deprecated
+
class CategoricalVocabulary(object):
"""Categorical variables vocabulary class.
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+
Accumulates and provides mapping from classes to indexes.
Can be easily used for words.
"""
+ @deprecated(None, 'Please use tensorflow/transform or tf.data.')
def __init__(self, unknown_token="<UNK>", support_reverse=True):
self._unknown_token = unknown_token
self._mapping = {unknown_token: 0}
# limitations under the License.
# ==============================================================================
-"""Implements a number of text preprocessing utilities."""
+"""Implements a number of text preprocessing utilities (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
import six
from tensorflow.python.platform import gfile
+from tensorflow.python.util.deprecation import deprecated
from .categorical_vocabulary import CategoricalVocabulary # pylint: disable=g-bad-import-order
re.UNICODE)
+@deprecated(None, 'Please use tensorflow/transform or tf.data.')
def tokenizer(iterator):
"""Tokenizer generator.
yield TOKENIZER_RE.findall(value)
+@deprecated(None, 'Please use tensorflow/transform or tf.data.')
class ByteProcessor(object):
- """Maps documents into sequence of ids for bytes."""
+ """Maps documents into sequence of ids for bytes.
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+ """
+ @deprecated(None, 'Please use tensorflow/transform or tf.data.')
def __init__(self, max_document_length):
self.max_document_length = max_document_length
class VocabularyProcessor(object):
- """Maps documents to sequences of word ids."""
+ """Maps documents to sequences of word ids.
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+ """
+ @deprecated(None, 'Please use tensorflow/transform or tf.data.')
def __init__(self,
max_document_length,
min_frequency=0,
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""This file is deprecated. Use tensorflow.python.training.session_run_hook."""
+"""This file is deprecated. Use `tensorflow.python.training.session_run_hook`.
+
+See [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Wrapper for a Session-like object that handles threads and recovery.
+"""Wrapper for a Session-like object that handles threads and recovery (deprecated).
+
+These are deprecated aliases for classes and functions in `tf.train`. Please use
+those directly.
Based on an original design of Illia Polosukhin.
"""
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""`Trainable` interface."""
+"""`Trainable` interface (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
class Trainable(object):
"""Interface for objects that are trainable by, e.g., `Experiment`.
+
+ THIS CLASS IS DEPRECATED.
"""
__metaclass__ = abc.ABCMeta
# limitations under the License.
# ==============================================================================
-"""TensorFlow Learn Utils."""
+"""TensorFlow Learn Utils (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
# limitations under the License.
# ==============================================================================
-"""Export utilities."""
+"""Export utilities (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
+"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from tensorflow.contrib.framework import deprecated
-from tensorflow.python.training import training_util
from tensorflow.contrib.session_bundle import exporter
from tensorflow.contrib.session_bundle import gc
from tensorflow.python.client import session as tf_session
from tensorflow.python.ops import variables
from tensorflow.python.platform import tf_logging as logging
from tensorflow.python.training import saver as tf_saver
+from tensorflow.python.training import training_util
@deprecated('2017-03-25', 'Please use Estimator.export_savedmodel() instead.')
# limitations under the License.
# ==============================================================================
-r"""System for specifying garbage collection (GC) of path based data.
+r"""System for specifying garbage collection (GC) of path based data (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
This framework allows for GC of data specified by path names, for example files
on disk. gc.Path objects each represent a single item stored at a path and may
from tensorflow.python.platform import gfile
from tensorflow.python.util import compat
+from tensorflow.python.util.deprecation import deprecated
Path = collections.namedtuple('Path', 'path export_version')
+@deprecated(None, 'Please implement your own file management or use Saver.')
def largest_export_versions(n):
"""Creates a filter that keeps the largest n export versions.
return keep
+@deprecated(None, 'Please implement your own file management or use Saver.')
def one_of_every_n_export_versions(n):
"""Creates a filter that keeps one of every n export versions.
return keep
+@deprecated(None, 'Please implement your own file management or use Saver.')
def mod_export_version(n):
"""Creates a filter that keeps every export that is a multiple of n.
return keep
+@deprecated(None, 'Please implement your own file management or use Saver.')
def union(lf, rf):
"""Creates a filter that keeps the union of two filters.
return keep
+@deprecated(None, 'Please implement your own file management or use Saver.')
def negation(f):
"""Negate a filter.
return keep
+@deprecated(None, 'Please implement your own file name management.')
def get_paths(base_dir, parser):
"""Gets a list of Paths in a given directory.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Utilities for creating input_fns.
+"""Utilities for creating input_fns (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
Contents of this file are moved to tensorflow/python/estimator/export.py.
InputFnOps is renamed to ServingInputReceiver.
from tensorflow.python.framework import tensor_shape
from tensorflow.python.ops import array_ops
from tensorflow.python.ops import parsing_ops
+from tensorflow.python.util.deprecation import deprecated
class InputFnOps(collections.namedtuple('InputFnOps',
['features',
'labels',
'default_inputs'])):
- """A return type for an input_fn.
+ """A return type for an input_fn (deprecated).
+
+ THIS CLASS IS DEPRECATED. Please use tf.estimator.export.ServingInputReceiver
+ instead.
This return type is currently only supported for serving input_fn.
Training and eval input_fn should return a `(features, labels)` tuple.
"""
+@deprecated(None, 'Please use '
+ 'tf.estimator.export.build_parsing_serving_input_receiver_fn.')
def build_parsing_serving_input_fn(feature_spec, default_batch_size=None):
"""Build an input_fn appropriate for serving, expecting fed tf.Examples.
return input_fn
+@deprecated(None, 'Please use '
+ 'tf.estimator.export.build_raw_serving_input_receiver_fn.')
def build_default_serving_input_fn(features, default_batch_size=None):
"""Build an input_fn appropriate for serving, expecting feature Tensors.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""A simple script for inspect checkpoint files."""
+"""A simple script for inspect checkpoint files (deprecated)."""
from __future__ import absolute_import
from __future__ import division
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
-"""Utilities supporting export to SavedModel.
+"""Utilities supporting export to SavedModel (deprecated).
+
+This module and all its submodules are deprecated. See
+[contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+for migration instructions.
Some contents of this file are moved to tensorflow/python/estimator/export.py:
from tensorflow.python.saved_model import signature_def_utils
from tensorflow.python.summary import summary_iterator
from tensorflow.python.training import saver
-
from tensorflow.python.util import compat
+from tensorflow.python.util.deprecation import deprecated
+
# A key for use in the input_alternatives dict indicating the default input.
# This is the input that will be expected when a serving request does not
_FALLBACK_DEFAULT_OUTPUT_ALTERNATIVE_KEY = 'default_output_alternative'
+@deprecated(None, 'Switch to tf.estimator.Exporter and associated utilities.')
def build_standardized_signature_def(input_tensors, output_tensors,
problem_type):
"""Build a SignatureDef using problem type and input and output Tensors.
len(input_tensors) == 1 and len(output_tensors) == 1)
+@deprecated(None, 'Switch to tf.estimator.Exporter and associated utilities.')
def get_input_alternatives(input_ops):
"""Obtain all input alternatives using the input_fn output and heuristics."""
input_alternatives = {}
return input_alternatives, features
+@deprecated(None, 'Switch to tf.estimator.Exporter and associated utilities.')
def get_output_alternatives(model_fn_ops, default_output_alternative_key=None):
"""Obtain all output alternatives using the model_fn output and heuristics.
sorted(output_alternatives.keys())))
+@deprecated(None, 'Switch to tf.estimator.Exporter and associated utilities.')
def build_all_signature_defs(input_alternatives, output_alternatives,
actual_default_output_alternative_key):
"""Build `SignatureDef`s from all pairs of input and output alternatives."""
MAX_DIRECTORY_CREATION_ATTEMPTS = 10
+@deprecated(None, 'Switch to tf.estimator.Exporter and associated utilities.')
def get_timestamped_export_dir(export_dir_base):
"""Builds a path to a new subdirectory within the base directory.
'{} attempts.'.format(MAX_DIRECTORY_CREATION_ATTEMPTS))
+@deprecated(None, 'Switch to tf.estimator.Exporter and associated utilities.')
def get_temp_export_dir(timestamped_export_dir):
"""Builds a directory name based on the argument but starting with 'temp-'.
return path._replace(export_version=int(filename))
+@deprecated(None, 'Switch to tf.estimator.Exporter and associated utilities.')
def get_most_recent_export(export_dir_base):
"""Locate the most recent SavedModel export in a directory of many exports.
return next(iter(results or []), None)
+@deprecated(None, 'Switch to tf.estimator.Exporter and associated utilities.')
def garbage_collect_exports(export_dir_base, exports_to_keep):
"""Deletes older exports, retaining only a given number of the most recent.
logging.warn('Can not delete %s recursively: %s', p.path, e)
+@deprecated(None, 'Switch to tf.estimator.Exporter and associated utilities.')
def make_export_strategy(serving_input_fn,
default_output_alternative_key=None,
assets_extra=None,
return export_strategy.ExportStrategy('Servo', export_fn, strip_default_attrs)
+@deprecated(None,
+ 'Use tf.estimator.export.build_parsing_serving_input_receiver_fn')
def make_parsing_export_strategy(feature_columns,
default_output_alternative_key=None,
assets_extra=None,
class BestModelSelector(object):
- """A helper that keeps track of export selection candidates."""
+ """A helper that keeps track of export selection candidates.
+
+ THIS CLASS IS DEPRECATED. See
+ [contrib/learn/README.md](https://www.tensorflow.org/code/tensorflow/contrib/learn/README.md)
+ for general migration instructions.
+ """
+ @deprecated(None, 'Switch to tf.estimator.Exporter and associated utilities.')
def __init__(self, event_file_pattern=None, compare_fn=None):
"""Constructor of this class.
return best_eval_result
+@deprecated(None, 'Switch to tf.estimator.Exporter and associated utilities.')
def make_best_model_export_strategy(
serving_input_fn,
exports_to_keep=1,
# TODO(b/67013778): Revisit this approach when corresponding changes to
# TF Core are finalized.
+@deprecated(None, 'Switch to tf.estimator.Exporter and associated utilities.')
def extend_export_strategy(base_export_strategy,
post_export_fn,
post_export_name=None):
lines = _normalize_docstring(doc).splitlines()
lines[0] += ' ' + suffix_str
- notice = [''] + notice + [instructions]
+ notice = [''] + notice + ([instructions] if instructions else [])
if len(lines) > 1:
# Make sure that we keep our distance from the main body