Remove the usages of TF private API deprecation.deprecated
.
PiperOrigin-RevId: 331570018 Change-Id: I66f398fdfc61eb414e4683897fe350fbbdd4ea0e
This commit is contained in:
parent
835f274efb
commit
499d35942a
@ -27,6 +27,7 @@ import json
|
||||
import os
|
||||
import sys
|
||||
import threading
|
||||
import warnings
|
||||
import weakref
|
||||
|
||||
import numpy as np
|
||||
@ -425,10 +426,10 @@ def set_learning_phase(value):
|
||||
Raises:
|
||||
ValueError: if `value` is neither `0` nor `1`.
|
||||
"""
|
||||
logging.warning('`tf.keras.backend.set_learning_phase` is deprecated and '
|
||||
'will be removed after 2020-10-11. To update it, simply '
|
||||
'pass a True/False value to the `training` argument of the '
|
||||
'`__call__` method of your layer or model.')
|
||||
warnings.warn('`tf.keras.backend.set_learning_phase` is deprecated and '
|
||||
'will be removed after 2020-10-11. To update it, simply '
|
||||
'pass a True/False value to the `training` argument of the '
|
||||
'`__call__` method of your layer or model.')
|
||||
deprecated_internal_set_learning_phase(value)
|
||||
|
||||
|
||||
@ -483,10 +484,10 @@ def learning_phase_scope(value):
|
||||
Raises:
|
||||
ValueError: if `value` is neither `0` nor `1`.
|
||||
"""
|
||||
logging.warning('`tf.keras.backend.learning_phase_scope` is deprecated and '
|
||||
'will be removed after 2020-10-11. To update it, simply '
|
||||
'pass a True/False value to the `training` argument of the '
|
||||
'`__call__` method of your layer or model.')
|
||||
warnings.warn('`tf.keras.backend.learning_phase_scope` is deprecated and '
|
||||
'will be removed after 2020-10-11. To update it, simply '
|
||||
'pass a True/False value to the `training` argument of the '
|
||||
'`__call__` method of your layer or model.')
|
||||
with deprecated_internal_learning_phase_scope(value):
|
||||
try:
|
||||
yield
|
||||
@ -6018,8 +6019,9 @@ def random_binomial(shape, p=0.0, dtype=None, seed=None):
|
||||
<tf.Tensor: shape=(2, 3), dtype=float32, numpy=...,
|
||||
dtype=float32)>
|
||||
"""
|
||||
logging.warning('`tf.keras.backend.random_binomial` is deprecated. '
|
||||
'Please use `tf.keras.backend.random_bernoulli` instead.')
|
||||
warnings.warn('`tf.keras.backend.random_binomial` is deprecated, '
|
||||
'and will be removed in a future version.'
|
||||
'Please use `tf.keras.backend.random_bernoulli` instead.')
|
||||
return random_bernoulli(shape, p, dtype, seed)
|
||||
|
||||
|
||||
|
@ -23,6 +23,7 @@ import copy
|
||||
import functools
|
||||
import itertools
|
||||
import threading
|
||||
import warnings
|
||||
import weakref
|
||||
|
||||
import numpy as np
|
||||
@ -79,7 +80,6 @@ from tensorflow.python.training.tracking import data_structures
|
||||
from tensorflow.python.training.tracking import layer_utils as trackable_layer_utils
|
||||
from tensorflow.python.training.tracking import tracking
|
||||
from tensorflow.python.util import compat
|
||||
from tensorflow.python.util import deprecation
|
||||
from tensorflow.python.util import nest
|
||||
from tensorflow.python.util import object_identity
|
||||
from tensorflow.python.util import tf_inspect
|
||||
@ -1370,12 +1370,11 @@ class Layer(module.Module, version_utils.LayerVersionSelector):
|
||||
return self.trainable_weights + self.non_trainable_weights
|
||||
|
||||
@property
|
||||
@deprecation.deprecated(
|
||||
date=None,
|
||||
instructions='This property should not be used in TensorFlow 2.0, '
|
||||
'as updates are applied automatically.')
|
||||
@doc_controls.do_not_generate_docs
|
||||
def updates(self):
|
||||
warnings.warn('`layer.updates` will be removed in a future version. '
|
||||
'This property should not be used in TensorFlow 2.0, '
|
||||
'as `updates` are applied automatically.')
|
||||
if keras_tensor.keras_tensors_enabled():
|
||||
return []
|
||||
|
||||
@ -1895,8 +1894,6 @@ class Layer(module.Module, version_utils.LayerVersionSelector):
|
||||
output_weights.append(weight)
|
||||
return backend.batch_get_value(output_weights)
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None, instructions='Please use `layer.updates` instead.')
|
||||
@doc_controls.do_not_generate_docs
|
||||
def get_updates_for(self, inputs):
|
||||
"""Deprecated, do NOT use!
|
||||
@ -1909,10 +1906,11 @@ class Layer(module.Module, version_utils.LayerVersionSelector):
|
||||
Returns:
|
||||
List of update ops of the layer that depend on `inputs`.
|
||||
"""
|
||||
warnings.warn('`layer.get_updates_for` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `layer.updates` method instead.')
|
||||
return self.updates
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None, instructions='Please use `layer.losses` instead.')
|
||||
@doc_controls.do_not_generate_docs
|
||||
def get_losses_for(self, inputs):
|
||||
"""Deprecated, do NOT use!
|
||||
@ -1925,6 +1923,9 @@ class Layer(module.Module, version_utils.LayerVersionSelector):
|
||||
Returns:
|
||||
List of loss tensors of the layer that depend on `inputs`.
|
||||
"""
|
||||
warnings.warn('`layer.get_losses_for` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `layer.losses` instead.')
|
||||
return self.losses
|
||||
|
||||
@doc_controls.do_not_doc_inheritable
|
||||
@ -2229,8 +2230,6 @@ class Layer(module.Module, version_utils.LayerVersionSelector):
|
||||
# Methods & attributes below are public aliases of other methods. #
|
||||
##############################################################################
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None, instructions='Please use `layer.__call__` method instead.')
|
||||
@doc_controls.do_not_doc_inheritable
|
||||
def apply(self, inputs, *args, **kwargs):
|
||||
"""Deprecated, do NOT use!
|
||||
@ -2245,13 +2244,17 @@ class Layer(module.Module, version_utils.LayerVersionSelector):
|
||||
Returns:
|
||||
Output tensor(s).
|
||||
"""
|
||||
warnings.warn('`layer.apply` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `layer.__call__` method instead.')
|
||||
return self.__call__(inputs, *args, **kwargs)
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None, instructions='Please use `layer.add_weight` method instead.')
|
||||
@doc_controls.do_not_doc_inheritable
|
||||
def add_variable(self, *args, **kwargs):
|
||||
"""Deprecated, do NOT use! Alias for `add_weight`."""
|
||||
warnings.warn('`layer.add_variable` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `layer.add_weight` method instead.')
|
||||
return self.add_weight(*args, **kwargs)
|
||||
|
||||
@property
|
||||
|
@ -22,6 +22,7 @@ import collections
|
||||
import functools
|
||||
import itertools
|
||||
import threading
|
||||
import warnings
|
||||
|
||||
import numpy as np
|
||||
import six
|
||||
@ -66,7 +67,6 @@ from tensorflow.python.training.tracking import base as trackable
|
||||
from tensorflow.python.training.tracking import data_structures
|
||||
from tensorflow.python.training.tracking import layer_utils as trackable_layer_utils
|
||||
from tensorflow.python.training.tracking import tracking
|
||||
from tensorflow.python.util import deprecation
|
||||
from tensorflow.python.util import nest
|
||||
from tensorflow.python.util import object_identity
|
||||
from tensorflow.python.util import tf_inspect
|
||||
@ -1694,8 +1694,6 @@ class Layer(base_layer.Layer):
|
||||
# Methods & attributes below are public aliases of other methods. #
|
||||
##############################################################################
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None, instructions='Please use `layer.__call__` method instead.')
|
||||
@doc_controls.do_not_doc_inheritable
|
||||
def apply(self, inputs, *args, **kwargs):
|
||||
"""Deprecated, do NOT use!
|
||||
@ -1710,13 +1708,17 @@ class Layer(base_layer.Layer):
|
||||
Returns:
|
||||
Output tensor(s).
|
||||
"""
|
||||
warnings.warn('`layer.apply` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `layer.__call__` method instead.')
|
||||
return self.__call__(inputs, *args, **kwargs)
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None, instructions='Please use `layer.add_weight` method instead.')
|
||||
@doc_controls.do_not_doc_inheritable
|
||||
def add_variable(self, *args, **kwargs):
|
||||
"""Deprecated, do NOT use! Alias for `add_weight`."""
|
||||
warnings.warn('`layer.add_variable` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `layer.add_weight` method instead.')
|
||||
return self.add_weight(*args, **kwargs)
|
||||
|
||||
@property
|
||||
|
@ -20,6 +20,7 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import copy
|
||||
import warnings
|
||||
|
||||
from tensorflow.python import tf2
|
||||
from tensorflow.python.framework import ops
|
||||
@ -421,9 +422,9 @@ class Sequential(functional.Functional):
|
||||
Returns:
|
||||
A Numpy array of probability predictions.
|
||||
"""
|
||||
logging.warning('`model.predict_proba()` is deprecated and '
|
||||
'will be removed after 2021-01-01. '
|
||||
'Please use `model.predict()` instead.')
|
||||
warnings.warn('`model.predict_proba()` is deprecated and '
|
||||
'will be removed after 2021-01-01. '
|
||||
'Please use `model.predict()` instead.')
|
||||
preds = self.predict(x, batch_size, verbose)
|
||||
if preds.min() < 0. or preds.max() > 1.:
|
||||
logging.warning('Network returning invalid probability values. '
|
||||
@ -446,15 +447,15 @@ class Sequential(functional.Functional):
|
||||
Returns:
|
||||
A numpy array of class predictions.
|
||||
"""
|
||||
logging.warning('`model.predict_classes()` is deprecated and '
|
||||
'will be removed after 2021-01-01. '
|
||||
'Please use instead:'
|
||||
'* `np.argmax(model.predict(x), axis=-1)`, '
|
||||
' if your model does multi-class classification '
|
||||
' (e.g. if it uses a `softmax` last-layer activation).'
|
||||
'* `(model.predict(x) > 0.5).astype("int32")`, '
|
||||
' if your model does binary classification '
|
||||
' (e.g. if it uses a `sigmoid` last-layer activation).')
|
||||
warnings.warn('`model.predict_classes()` is deprecated and '
|
||||
'will be removed after 2021-01-01. '
|
||||
'Please use instead:'
|
||||
'* `np.argmax(model.predict(x), axis=-1)`, '
|
||||
' if your model does multi-class classification '
|
||||
' (e.g. if it uses a `softmax` last-layer activation).'
|
||||
'* `(model.predict(x) > 0.5).astype("int32")`, '
|
||||
' if your model does binary classification '
|
||||
' (e.g. if it uses a `sigmoid` last-layer activation).')
|
||||
proba = self.predict(x, batch_size=batch_size, verbose=verbose)
|
||||
if proba.shape[-1] > 1:
|
||||
return proba.argmax(axis=-1)
|
||||
|
@ -22,6 +22,7 @@ import copy
|
||||
import itertools
|
||||
import json
|
||||
import os
|
||||
import warnings
|
||||
import six
|
||||
|
||||
from tensorflow.python.autograph.lang import directives
|
||||
@ -72,7 +73,6 @@ from tensorflow.python.training.tracking import base as trackable
|
||||
from tensorflow.python.training.tracking import data_structures
|
||||
from tensorflow.python.training.tracking import layer_utils as trackable_layer_utils
|
||||
from tensorflow.python.training.tracking import util as trackable_utils
|
||||
from tensorflow.python.util import deprecation
|
||||
from tensorflow.python.util import nest
|
||||
from tensorflow.python.util import tf_decorator
|
||||
from tensorflow.python.util.tf_export import keras_export
|
||||
@ -1775,8 +1775,6 @@ class Model(base_layer.Layer, version_utils.ModelVersionSelector):
|
||||
outputs = self.predict_function(iterator)
|
||||
return tf_utils.to_numpy_or_python_type(outputs)
|
||||
|
||||
@deprecation.deprecated(
|
||||
None, 'Please use Model.fit, which supports generators.')
|
||||
def fit_generator(self,
|
||||
generator,
|
||||
steps_per_epoch=None,
|
||||
@ -1798,6 +1796,9 @@ class Model(base_layer.Layer, version_utils.ModelVersionSelector):
|
||||
`Model.fit` now supports generators, so there is no longer any need to use
|
||||
this endpoint.
|
||||
"""
|
||||
warnings.warn('`Model.fit_generator` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `Model.fit`, which supports generators.')
|
||||
return self.fit(
|
||||
generator,
|
||||
steps_per_epoch=steps_per_epoch,
|
||||
@ -1814,8 +1815,6 @@ class Model(base_layer.Layer, version_utils.ModelVersionSelector):
|
||||
shuffle=shuffle,
|
||||
initial_epoch=initial_epoch)
|
||||
|
||||
@deprecation.deprecated(
|
||||
None, 'Please use Model.evaluate, which supports generators.')
|
||||
def evaluate_generator(self,
|
||||
generator,
|
||||
steps=None,
|
||||
@ -1830,6 +1829,9 @@ class Model(base_layer.Layer, version_utils.ModelVersionSelector):
|
||||
`Model.evaluate` now supports generators, so there is no longer any need
|
||||
to use this endpoint.
|
||||
"""
|
||||
warnings.warn('`Model.evaluate_generator` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `Model.evaluate`, which supports generators.')
|
||||
self._check_call_args('evaluate_generator')
|
||||
|
||||
return self.evaluate(
|
||||
@ -1841,8 +1843,6 @@ class Model(base_layer.Layer, version_utils.ModelVersionSelector):
|
||||
verbose=verbose,
|
||||
callbacks=callbacks)
|
||||
|
||||
@deprecation.deprecated(
|
||||
None, 'Please use Model.predict, which supports generators.')
|
||||
def predict_generator(self,
|
||||
generator,
|
||||
steps=None,
|
||||
@ -1857,6 +1857,9 @@ class Model(base_layer.Layer, version_utils.ModelVersionSelector):
|
||||
`Model.predict` now supports generators, so there is no longer any need
|
||||
to use this endpoint.
|
||||
"""
|
||||
warnings.warn('`Model.predict_generator` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `Model.predict`, which supports generators.')
|
||||
return self.predict(
|
||||
generator,
|
||||
steps=steps,
|
||||
@ -2270,10 +2273,6 @@ class Model(base_layer.Layer, version_utils.ModelVersionSelector):
|
||||
layer.reset_states()
|
||||
|
||||
@property
|
||||
@deprecation.deprecated(
|
||||
date=None,
|
||||
instructions='This property should not be used in TensorFlow 2.0, '
|
||||
'as updates are applied automatically.')
|
||||
@doc_controls.do_not_generate_docs
|
||||
def state_updates(self):
|
||||
"""Deprecated, do NOT use!
|
||||
@ -2287,6 +2286,9 @@ class Model(base_layer.Layer, version_utils.ModelVersionSelector):
|
||||
Returns:
|
||||
A list of update ops.
|
||||
"""
|
||||
warnings.warn('`Model.state_updates` will be removed in a future version. '
|
||||
'This property should not be used in TensorFlow 2.0, '
|
||||
'as `updates` are applied automatically.')
|
||||
state_updates = []
|
||||
for layer in self.layers:
|
||||
if getattr(layer, 'stateful', False):
|
||||
|
@ -18,6 +18,7 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import collections
|
||||
import warnings
|
||||
|
||||
import numpy as np
|
||||
|
||||
@ -61,7 +62,6 @@ from tensorflow.python.platform import tf_logging as logging
|
||||
from tensorflow.python.training.tracking import base as trackable
|
||||
from tensorflow.python.training.tracking import layer_utils as trackable_layer_utils
|
||||
from tensorflow.python.types import core
|
||||
from tensorflow.python.util import deprecation
|
||||
from tensorflow.python.util import nest
|
||||
from tensorflow.python.util import tf_inspect
|
||||
from tensorflow.python.util.compat import collections_abc
|
||||
@ -1211,8 +1211,6 @@ class Model(training_lib.Model):
|
||||
return outputs[0]
|
||||
return outputs
|
||||
|
||||
@deprecation.deprecated(
|
||||
None, 'Please use Model.fit, which supports generators.')
|
||||
def fit_generator(self,
|
||||
generator,
|
||||
steps_per_epoch=None,
|
||||
@ -1234,6 +1232,9 @@ class Model(training_lib.Model):
|
||||
`Model.fit` now supports generators, so there is no longer any need to use
|
||||
this endpoint.
|
||||
"""
|
||||
warnings.warn('`model.fit_generator` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `Model.fit`, which supports generators.')
|
||||
return self.fit(
|
||||
generator,
|
||||
steps_per_epoch=steps_per_epoch,
|
||||
@ -1250,8 +1251,6 @@ class Model(training_lib.Model):
|
||||
shuffle=shuffle,
|
||||
initial_epoch=initial_epoch)
|
||||
|
||||
@deprecation.deprecated(
|
||||
None, 'Please use Model.evaluate, which supports generators.')
|
||||
def evaluate_generator(self,
|
||||
generator,
|
||||
steps=None,
|
||||
@ -1266,6 +1265,9 @@ class Model(training_lib.Model):
|
||||
`Model.evaluate` now supports generators, so there is no longer any need
|
||||
to use this endpoint.
|
||||
"""
|
||||
warnings.warn('`Model.evaluate_generator` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `Model.evaluate`, which supports generators.')
|
||||
self._check_call_args('evaluate_generator')
|
||||
|
||||
return self.evaluate(
|
||||
@ -1277,8 +1279,6 @@ class Model(training_lib.Model):
|
||||
verbose=verbose,
|
||||
callbacks=callbacks)
|
||||
|
||||
@deprecation.deprecated(
|
||||
None, 'Please use Model.predict, which supports generators.')
|
||||
def predict_generator(self,
|
||||
generator,
|
||||
steps=None,
|
||||
@ -1293,6 +1293,9 @@ class Model(training_lib.Model):
|
||||
`Model.predict` now supports generators, so there is no longer any need
|
||||
to use this endpoint.
|
||||
"""
|
||||
warnings.warn('`Model.predict_generator` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `Model.predict`, which supports generators.')
|
||||
return self.predict(
|
||||
generator,
|
||||
steps=steps,
|
||||
|
@ -25,6 +25,7 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import collections
|
||||
import warnings
|
||||
|
||||
from tensorflow.python.eager import context
|
||||
from tensorflow.python.framework import constant_op
|
||||
@ -416,9 +417,10 @@ class BasicRNNCell(LayerRNNCell):
|
||||
name=None,
|
||||
dtype=None,
|
||||
**kwargs):
|
||||
logging.warning("`tf.nn.rnn_cell.BasicRNNCell` is deprecated. This class "
|
||||
"is equivalent as `tf.keras.layers.SimpleRNNCell`, "
|
||||
"and will be replaced by that in Tensorflow 2.0.")
|
||||
warnings.warn("`tf.nn.rnn_cell.BasicRNNCell` is deprecated and will be "
|
||||
"removed in a future version. This class "
|
||||
"is equivalent as `tf.keras.layers.SimpleRNNCell`, "
|
||||
"and will be replaced by that in Tensorflow 2.0.")
|
||||
super(BasicRNNCell, self).__init__(
|
||||
_reuse=reuse, name=name, dtype=dtype, **kwargs)
|
||||
_check_supported_dtypes(self.dtype)
|
||||
@ -523,9 +525,10 @@ class GRUCell(LayerRNNCell):
|
||||
name=None,
|
||||
dtype=None,
|
||||
**kwargs):
|
||||
logging.warning("`tf.nn.rnn_cell.GRUCell` is deprecated. This class "
|
||||
"is equivalent as `tf.keras.layers.GRUCell`, "
|
||||
"and will be replaced by that in Tensorflow 2.0.")
|
||||
warnings.warn("`tf.nn.rnn_cell.GRUCell` is deprecated and will be removed "
|
||||
"in a future version. This class "
|
||||
"is equivalent as `tf.keras.layers.GRUCell`, "
|
||||
"and will be replaced by that in Tensorflow 2.0.")
|
||||
super(GRUCell, self).__init__(
|
||||
_reuse=reuse, name=name, dtype=dtype, **kwargs)
|
||||
_check_supported_dtypes(self.dtype)
|
||||
@ -695,9 +698,10 @@ class BasicLSTMCell(LayerRNNCell):
|
||||
When restoring from CudnnLSTM-trained checkpoints, must use
|
||||
`CudnnCompatibleLSTMCell` instead.
|
||||
"""
|
||||
logging.warning("`tf.nn.rnn_cell.BasicLSTMCell` is deprecated. This class "
|
||||
"is equivalent as `tf.keras.layers.LSTMCell`, "
|
||||
"and will be replaced by that in Tensorflow 2.0.")
|
||||
warnings.warn("`tf.nn.rnn_cell.BasicLSTMCell` is deprecated and will be "
|
||||
"removed in a future version. This class "
|
||||
"is equivalent as `tf.keras.layers.LSTMCell`, "
|
||||
"and will be replaced by that in Tensorflow 2.0.")
|
||||
super(BasicLSTMCell, self).__init__(
|
||||
_reuse=reuse, name=name, dtype=dtype, **kwargs)
|
||||
_check_supported_dtypes(self.dtype)
|
||||
@ -895,9 +899,10 @@ class LSTMCell(LayerRNNCell):
|
||||
When restoring from CudnnLSTM-trained checkpoints, use
|
||||
`CudnnCompatibleLSTMCell` instead.
|
||||
"""
|
||||
logging.warning("`tf.nn.rnn_cell.LSTMCell` is deprecated. This class "
|
||||
"is equivalent as `tf.keras.layers.LSTMCell`, "
|
||||
"and will be replaced by that in Tensorflow 2.0.")
|
||||
warnings.warn("`tf.nn.rnn_cell.LSTMCell` is deprecated and will be "
|
||||
"removed in a future version. This class "
|
||||
"is equivalent as `tf.keras.layers.LSTMCell`, "
|
||||
"and will be replaced by that in Tensorflow 2.0.")
|
||||
super(LSTMCell, self).__init__(
|
||||
_reuse=reuse, name=name, dtype=dtype, **kwargs)
|
||||
_check_supported_dtypes(self.dtype)
|
||||
|
@ -19,6 +19,8 @@ from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import warnings
|
||||
|
||||
import numpy as np
|
||||
|
||||
from tensorflow.python.distribute import distribution_strategy_context as ds_context
|
||||
@ -43,7 +45,6 @@ from tensorflow.python.ops import state_ops
|
||||
from tensorflow.python.platform import tf_logging as logging
|
||||
from tensorflow.python.training.tracking import base as trackable
|
||||
from tensorflow.python.training.tracking import data_structures
|
||||
from tensorflow.python.util import deprecation
|
||||
from tensorflow.python.util import nest
|
||||
from tensorflow.python.util.compat import collections_abc
|
||||
from tensorflow.python.util.tf_export import keras_export
|
||||
@ -2545,8 +2546,6 @@ class PeepholeLSTMCell(LSTMCell):
|
||||
```
|
||||
"""
|
||||
|
||||
@deprecation.deprecated(
|
||||
None, 'Please use tensorflow_addons.rnn.PeepholeLSTMCell instead')
|
||||
def __init__(self,
|
||||
units,
|
||||
activation='tanh',
|
||||
@ -2565,6 +2564,10 @@ class PeepholeLSTMCell(LSTMCell):
|
||||
dropout=0.,
|
||||
recurrent_dropout=0.,
|
||||
**kwargs):
|
||||
warnings.warn('`tf.keras.experimental.PeepholeLSTMCell` is deprecated '
|
||||
'and will be removed in a future version. '
|
||||
'Please use tensorflow_addons.rnn.PeepholeLSTMCell '
|
||||
'instead.')
|
||||
super(PeepholeLSTMCell, self).__init__(
|
||||
units=units,
|
||||
activation=activation,
|
||||
|
@ -18,6 +18,7 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import copy
|
||||
import warnings
|
||||
|
||||
from tensorflow.python.eager import context
|
||||
from tensorflow.python.framework import dtypes
|
||||
@ -29,7 +30,6 @@ from tensorflow.python.keras.mixed_precision.experimental import policy
|
||||
from tensorflow.python.ops import variable_scope as vs
|
||||
from tensorflow.python.ops import variables as tf_variables
|
||||
from tensorflow.python.training.tracking import base as trackable
|
||||
from tensorflow.python.util import deprecation
|
||||
from tensorflow.python.util import function_utils
|
||||
from tensorflow.python.util import nest
|
||||
from tensorflow.python.util import tf_contextlib
|
||||
@ -237,11 +237,11 @@ class Layer(base_layer.Layer):
|
||||
# We no longer track graph in tf.layers layers. This property is only kept to
|
||||
# maintain API backward compatibility.
|
||||
@property
|
||||
@deprecation.deprecated(
|
||||
date=None,
|
||||
instructions='Stop using this property because tf.layers layers no '
|
||||
'longer track their graph.')
|
||||
def graph(self):
|
||||
warnings.warn('`Layer.graph` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please stop using this property because tf.layers layers no '
|
||||
'longer track their graph.')
|
||||
if context.executing_eagerly():
|
||||
raise RuntimeError('Layer.graph not supported when executing eagerly.')
|
||||
return None
|
||||
|
@ -19,10 +19,11 @@ from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import warnings
|
||||
|
||||
from tensorflow.python.keras import layers as keras_layers
|
||||
from tensorflow.python.keras.legacy_tf_layers import base
|
||||
from tensorflow.python.ops import init_ops
|
||||
from tensorflow.python.util import deprecation
|
||||
from tensorflow.python.util.tf_export import tf_export
|
||||
|
||||
|
||||
@ -118,9 +119,6 @@ class Conv1D(keras_layers.Conv1D, base.Layer):
|
||||
name=name, **kwargs)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None,
|
||||
instructions='Use `tf.keras.layers.Conv1D` instead.')
|
||||
@tf_export(v1=['layers.conv1d'])
|
||||
def conv1d(inputs,
|
||||
filters,
|
||||
@ -201,6 +199,9 @@ def conv1d(inputs,
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.conv1d` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please Use `tf.keras.layers.Conv1D` instead.')
|
||||
layer = Conv1D(
|
||||
filters=filters,
|
||||
kernel_size=kernel_size,
|
||||
@ -323,9 +324,6 @@ class Conv2D(keras_layers.Conv2D, base.Layer):
|
||||
name=name, **kwargs)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None,
|
||||
instructions='Use `tf.keras.layers.Conv2D` instead.')
|
||||
@tf_export(v1=['layers.conv2d'])
|
||||
def conv2d(inputs,
|
||||
filters,
|
||||
@ -413,6 +411,9 @@ def conv2d(inputs,
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.conv2d` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please Use `tf.keras.layers.Conv2D` instead.')
|
||||
layer = Conv2D(
|
||||
filters=filters,
|
||||
kernel_size=kernel_size,
|
||||
@ -536,9 +537,6 @@ class Conv3D(keras_layers.Conv3D, base.Layer):
|
||||
name=name, **kwargs)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None,
|
||||
instructions='Use `tf.keras.layers.Conv3D` instead.')
|
||||
@tf_export(v1=['layers.conv3d'])
|
||||
def conv3d(inputs,
|
||||
filters,
|
||||
@ -627,6 +625,9 @@ def conv3d(inputs,
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.conv3d` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please Use `tf.keras.layers.Conv3D` instead.')
|
||||
layer = Conv3D(
|
||||
filters=filters,
|
||||
kernel_size=kernel_size,
|
||||
@ -875,9 +876,6 @@ class SeparableConv2D(keras_layers.SeparableConv2D, base.Layer):
|
||||
**kwargs)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None,
|
||||
instructions='Use `tf.keras.layers.SeparableConv1D` instead.')
|
||||
@tf_export(v1=['layers.separable_conv1d'])
|
||||
def separable_conv1d(inputs,
|
||||
filters,
|
||||
@ -971,6 +969,9 @@ def separable_conv1d(inputs,
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.separable_conv1d` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please Use `tf.keras.layers.SeparableConv1D` instead.')
|
||||
layer = SeparableConv1D(
|
||||
filters=filters,
|
||||
kernel_size=kernel_size,
|
||||
@ -998,9 +999,6 @@ def separable_conv1d(inputs,
|
||||
return layer.apply(inputs)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None,
|
||||
instructions='Use `tf.keras.layers.SeparableConv2D` instead.')
|
||||
@tf_export(v1=['layers.separable_conv2d'])
|
||||
def separable_conv2d(inputs,
|
||||
filters,
|
||||
@ -1099,6 +1097,9 @@ def separable_conv2d(inputs,
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.separable_conv2d` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please Use `tf.keras.layers.SeparableConv2D` instead.')
|
||||
layer = SeparableConv2D(
|
||||
filters=filters,
|
||||
kernel_size=kernel_size,
|
||||
@ -1214,9 +1215,6 @@ class Conv2DTranspose(keras_layers.Conv2DTranspose, base.Layer):
|
||||
**kwargs)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None,
|
||||
instructions='Use `tf.keras.layers.Conv2DTranspose` instead.')
|
||||
@tf_export(v1=['layers.conv2d_transpose'])
|
||||
def conv2d_transpose(inputs,
|
||||
filters,
|
||||
@ -1293,6 +1291,9 @@ def conv2d_transpose(inputs,
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.conv2d_transpose` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please Use `tf.keras.layers.Conv2DTranspose` instead.')
|
||||
layer = Conv2DTranspose(
|
||||
filters=filters,
|
||||
kernel_size=kernel_size,
|
||||
@ -1400,9 +1401,6 @@ class Conv3DTranspose(keras_layers.Conv3DTranspose, base.Layer):
|
||||
**kwargs)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None,
|
||||
instructions='Use `tf.keras.layers.Conv3DTranspose` instead.')
|
||||
@tf_export(v1=['layers.conv3d_transpose'])
|
||||
def conv3d_transpose(inputs,
|
||||
filters,
|
||||
@ -1473,6 +1471,9 @@ def conv3d_transpose(inputs,
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.conv3d_transpose` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please Use `tf.keras.layers.Conv3DTranspose` instead.')
|
||||
layer = Conv3DTranspose(
|
||||
filters=filters,
|
||||
kernel_size=kernel_size,
|
||||
|
@ -21,11 +21,11 @@ from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import warnings
|
||||
|
||||
from tensorflow.python.keras import layers as keras_layers
|
||||
from tensorflow.python.keras.legacy_tf_layers import base
|
||||
from tensorflow.python.ops import init_ops
|
||||
from tensorflow.python.util import deprecation
|
||||
from tensorflow.python.util.tf_export import tf_export
|
||||
|
||||
|
||||
@ -110,8 +110,6 @@ class Dense(keras_layers.Dense, base.Layer):
|
||||
**kwargs)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None, instructions='Use keras.layers.Dense instead.')
|
||||
@tf_export(v1=['layers.dense'])
|
||||
def dense(
|
||||
inputs, units,
|
||||
@ -170,6 +168,9 @@ def dense(
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.dense` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `tf.keras.layers.Dense` instead.')
|
||||
layer = Dense(units,
|
||||
activation=activation,
|
||||
use_bias=use_bias,
|
||||
@ -226,9 +227,6 @@ class Dropout(keras_layers.Dropout, base.Layer):
|
||||
return super(Dropout, self).call(inputs, training=training)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None,
|
||||
instructions='Use keras.layers.dropout instead.')
|
||||
@tf_export(v1=['layers.dropout'])
|
||||
def dropout(inputs,
|
||||
rate=0.5,
|
||||
@ -267,6 +265,9 @@ def dropout(inputs,
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.dropout` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `tf.keras.layers.Dropout` instead.')
|
||||
layer = Dropout(rate, noise_shape=noise_shape, seed=seed, name=name)
|
||||
return layer.apply(inputs, training=training)
|
||||
|
||||
@ -297,9 +298,6 @@ class Flatten(keras_layers.Flatten, base.Layer):
|
||||
pass
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None,
|
||||
instructions='Use keras.layers.Flatten instead.')
|
||||
@tf_export(v1=['layers.flatten'])
|
||||
def flatten(inputs, name=None, data_format='channels_last'):
|
||||
"""Flattens an input tensor while preserving the batch axis (axis 0).
|
||||
@ -328,6 +326,9 @@ def flatten(inputs, name=None, data_format='channels_last'):
|
||||
# now `y` has shape `(None, None)`
|
||||
```
|
||||
"""
|
||||
warnings.warn('`tf.layers.flatten` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `tf.keras.layers.Flatten` instead.')
|
||||
layer = Flatten(name=name, data_format=data_format)
|
||||
return layer.apply(inputs)
|
||||
|
||||
|
@ -19,11 +19,11 @@ from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import warnings
|
||||
|
||||
from tensorflow.python.keras.layers import normalization as keras_normalization
|
||||
from tensorflow.python.keras.legacy_tf_layers import base
|
||||
from tensorflow.python.ops import init_ops
|
||||
from tensorflow.python.util import deprecation
|
||||
from tensorflow.python.util.tf_export import tf_export
|
||||
|
||||
|
||||
@ -172,11 +172,6 @@ class BatchNormalization(keras_normalization.BatchNormalization, base.Layer):
|
||||
return super(BatchNormalization, self).call(inputs, training=training)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None, instructions='Use keras.layers.BatchNormalization instead. In '
|
||||
'particular, `tf.control_dependencies(tf.GraphKeys.UPDATE_OPS)` should not '
|
||||
'be used (consult the `tf.keras.layers.BatchNormalization` '
|
||||
'documentation).')
|
||||
@tf_export(v1=['layers.batch_normalization'])
|
||||
def batch_normalization(inputs,
|
||||
axis=-1,
|
||||
@ -309,6 +304,13 @@ def batch_normalization(inputs,
|
||||
2017](http://papers.nips.cc/paper/6790-batch-renormalization-towards-reducing-minibatch-dependence-in-batch-normalized-models)
|
||||
([pdf](http://papers.nips.cc/paper/6790-batch-renormalization-towards-reducing-minibatch-dependence-in-batch-normalized-models.pdf))
|
||||
"""
|
||||
warnings.warn(
|
||||
'`tf.layers.batch_normalization` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `tf.keras.layers.BatchNormalization` instead. '
|
||||
'In particular, `tf.control_dependencies(tf.GraphKeys.UPDATE_OPS)` '
|
||||
'should not be used (consult the `tf.keras.layers.BatchNormalization` '
|
||||
'documentation).')
|
||||
layer = BatchNormalization(
|
||||
axis=axis,
|
||||
momentum=momentum,
|
||||
|
@ -19,9 +19,10 @@ from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import warnings
|
||||
|
||||
from tensorflow.python.keras import layers as keras_layers
|
||||
from tensorflow.python.keras.legacy_tf_layers import base
|
||||
from tensorflow.python.util import deprecation
|
||||
from tensorflow.python.util.tf_export import tf_export
|
||||
|
||||
|
||||
@ -58,8 +59,6 @@ class AveragePooling1D(keras_layers.AveragePooling1D, base.Layer):
|
||||
**kwargs)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None, instructions='Use keras.layers.AveragePooling1D instead.')
|
||||
@tf_export(v1=['layers.average_pooling1d'])
|
||||
def average_pooling1d(inputs, pool_size, strides,
|
||||
padding='valid', data_format='channels_last',
|
||||
@ -87,6 +86,9 @@ def average_pooling1d(inputs, pool_size, strides,
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.average_pooling1d` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `tf.keras.layers.AveragePooling1D` instead.')
|
||||
layer = AveragePooling1D(pool_size=pool_size,
|
||||
strides=strides,
|
||||
padding=padding,
|
||||
@ -128,8 +130,6 @@ class MaxPooling1D(keras_layers.MaxPooling1D, base.Layer):
|
||||
**kwargs)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None, instructions='Use keras.layers.MaxPooling1D instead.')
|
||||
@tf_export(v1=['layers.max_pooling1d'])
|
||||
def max_pooling1d(inputs, pool_size, strides,
|
||||
padding='valid', data_format='channels_last',
|
||||
@ -157,6 +157,9 @@ def max_pooling1d(inputs, pool_size, strides,
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.max_pooling1d` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `tf.keras.layers.MaxPooling1D` instead.')
|
||||
layer = MaxPooling1D(pool_size=pool_size,
|
||||
strides=strides,
|
||||
padding=padding,
|
||||
@ -198,8 +201,6 @@ class AveragePooling2D(keras_layers.AveragePooling2D, base.Layer):
|
||||
padding=padding, data_format=data_format, name=name, **kwargs)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None, instructions='Use keras.layers.AveragePooling2D instead.')
|
||||
@tf_export(v1=['layers.average_pooling2d'])
|
||||
def average_pooling2d(inputs,
|
||||
pool_size, strides,
|
||||
@ -232,6 +233,9 @@ def average_pooling2d(inputs,
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.average_pooling2d` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `tf.keras.layers.AveragePooling2D` instead.')
|
||||
layer = AveragePooling2D(pool_size=pool_size, strides=strides,
|
||||
padding=padding, data_format=data_format,
|
||||
name=name)
|
||||
@ -271,8 +275,6 @@ class MaxPooling2D(keras_layers.MaxPooling2D, base.Layer):
|
||||
padding=padding, data_format=data_format, name=name, **kwargs)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None, instructions='Use keras.layers.MaxPooling2D instead.')
|
||||
@tf_export(v1=['layers.max_pooling2d'])
|
||||
def max_pooling2d(inputs,
|
||||
pool_size, strides,
|
||||
@ -305,6 +307,9 @@ def max_pooling2d(inputs,
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.max_pooling2d` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `tf.keras.layers.MaxPooling2D` instead.')
|
||||
layer = MaxPooling2D(pool_size=pool_size, strides=strides,
|
||||
padding=padding, data_format=data_format,
|
||||
name=name)
|
||||
@ -346,8 +351,6 @@ class AveragePooling3D(keras_layers.AveragePooling3D, base.Layer):
|
||||
padding=padding, data_format=data_format, name=name, **kwargs)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None, instructions='Use keras.layers.AveragePooling3D instead.')
|
||||
@tf_export(v1=['layers.average_pooling3d'])
|
||||
def average_pooling3d(inputs,
|
||||
pool_size, strides,
|
||||
@ -382,6 +385,9 @@ def average_pooling3d(inputs,
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.average_pooling3d` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `tf.keras.layers.AveragePooling3D` instead.')
|
||||
layer = AveragePooling3D(pool_size=pool_size, strides=strides,
|
||||
padding=padding, data_format=data_format,
|
||||
name=name)
|
||||
@ -423,8 +429,6 @@ class MaxPooling3D(keras_layers.MaxPooling3D, base.Layer):
|
||||
padding=padding, data_format=data_format, name=name, **kwargs)
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None, instructions='Use keras.layers.MaxPooling3D instead.')
|
||||
@tf_export(v1=['layers.max_pooling3d'])
|
||||
def max_pooling3d(inputs,
|
||||
pool_size, strides,
|
||||
@ -457,6 +461,9 @@ def max_pooling3d(inputs,
|
||||
Raises:
|
||||
ValueError: if eager execution is enabled.
|
||||
"""
|
||||
warnings.warn('`tf.layers.max_pooling3d` is deprecated and '
|
||||
'will be removed in a future version. '
|
||||
'Please use `tf.keras.layers.MaxPooling3D` instead.')
|
||||
layer = MaxPooling3D(pool_size=pool_size, strides=strides,
|
||||
padding=padding, data_format=data_format,
|
||||
name=name)
|
||||
|
@ -18,6 +18,7 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import warnings
|
||||
|
||||
import six
|
||||
|
||||
@ -41,7 +42,6 @@ from tensorflow.python.saved_model import utils_impl as saved_model_utils
|
||||
from tensorflow.python.training import saver as saver_lib
|
||||
from tensorflow.python.training.tracking import graph_view
|
||||
from tensorflow.python.util import compat
|
||||
from tensorflow.python.util import deprecation
|
||||
from tensorflow.python.util import nest
|
||||
from tensorflow.python.util.tf_export import keras_export
|
||||
|
||||
@ -61,10 +61,6 @@ sequential = LazyLoader(
|
||||
# pylint:enable=g-inconsistent-quotes
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None,
|
||||
instructions=('Please use `model.save(..., save_format="tf")` or '
|
||||
'`tf.keras.models.save_model(..., save_format="tf")`.'))
|
||||
@keras_export(v1=['keras.experimental.export_saved_model'])
|
||||
def export_saved_model(model,
|
||||
saved_model_path,
|
||||
@ -130,6 +126,10 @@ def export_saved_model(model,
|
||||
ValueError: If the input signature cannot be inferred from the model.
|
||||
AssertionError: If the SavedModel directory already exists and isn't empty.
|
||||
"""
|
||||
warnings.warn('`tf.keras.experimental.export_saved_model` is deprecated'
|
||||
'and will be removed in a future version. '
|
||||
'Please use `model.save(..., save_format="tf")` or '
|
||||
'`tf.keras.models.save_model(..., save_format="tf")`.')
|
||||
if serving_only:
|
||||
save_lib.save(
|
||||
model,
|
||||
@ -372,10 +372,6 @@ def _assert_same_non_optimizer_objects(model, model_graph, clone, clone_graph):
|
||||
return True
|
||||
|
||||
|
||||
@deprecation.deprecated(
|
||||
date=None,
|
||||
instructions=('The experimental save and load functions have been '
|
||||
'deprecated. Please switch to `tf.keras.models.load_model`.'))
|
||||
@keras_export(v1=['keras.experimental.load_from_saved_model'])
|
||||
def load_from_saved_model(saved_model_path, custom_objects=None):
|
||||
"""Loads a keras Model from a SavedModel created by `export_saved_model()`.
|
||||
@ -413,6 +409,9 @@ def load_from_saved_model(saved_model_path, custom_objects=None):
|
||||
Returns:
|
||||
a keras.Model instance.
|
||||
"""
|
||||
warnings.warn('`tf.keras.experimental.load_from_saved_model` is deprecated'
|
||||
'and will be removed in a future version. '
|
||||
'Please switch to `tf.keras.models.load_model`.')
|
||||
# restore model topology from json string
|
||||
model_json_filepath = os.path.join(
|
||||
compat.as_bytes(saved_model_path),
|
||||
|
Loading…
Reference in New Issue
Block a user