Add warning in the deprecated Keras support API

PiperOrigin-RevId: 235986495
This commit is contained in:
Sourabh Bajaj 2019-02-27 13:58:08 -08:00 committed by TensorFlower Gardener
parent 76814f7654
commit 0968bafb5d

View File

@ -63,6 +63,7 @@ from tensorflow.contrib.tpu.python.tpu import tpu_optimizer
from tensorflow.contrib.tpu.python.tpu import tpu_system_metadata as tpu_system_metadata_lib
from tensorflow.core.protobuf import config_pb2
from tensorflow.core.protobuf.tpu import compilation_result_pb2 as tpu_compilation_result
from tensorflow.python import tf2
from tensorflow.python.client import session as tf_session
from tensorflow.python.data.ops import dataset_ops
from tensorflow.python.data.ops import iterator_ops
@ -206,7 +207,16 @@ class TPUDistributionStrategy(object):
Raises:
Exception: No TPU Found on the given worker.
"""
if tf2.enabled():
raise RuntimeError(
'Keras support is now deprecated in support of TPU Strategy. '
'Please follow the distribution strategy guide on tensorflow.org '
'to migrate to the 2.0 supported version.')
else:
logging.warning(
'Keras support is now deprecated in support of TPU Strategy. '
'Please follow the distribution strategy guide on tensorflow.org '
'to migrate to the 2.0 supported version.')
if tpu_cluster_resolver is None:
tpu_cluster_resolver = tpu_cluster_resolver_lib.TPUClusterResolver('')
@ -1373,7 +1383,16 @@ class KerasTPUModel(models.Model):
outputs=cpu_model.outputs,
name=cpu_model.name,
)
if tf2.enabled():
raise RuntimeError(
'Keras support is now deprecated in support of TPU Strategy. '
'Please follow the distribution strategy guide on tensorflow.org '
'to migrate to the 2.0 supported version.')
else:
logging.warning(
'Keras support is now deprecated in support of TPU Strategy. '
'Please follow the distribution strategy guide on tensorflow.org '
'to migrate to the 2.0 supported version.')
# Create a mapping from numpy arrays to infeed managers.
# Note: uses a list of tuples instead of a map because numpy arrays are
# not hashable.