Change API for debugging.assert_all_finite and debugging.check_numerics in TF 2.0.

PiperOrigin-RevId: 222096573
This commit is contained in:
Mihai Maruseac 2018-11-19 10:18:20 -08:00 committed by TensorFlower Gardener
parent eba747c55d
commit 5c60fb7e9b
4 changed files with 28 additions and 9 deletions
tensorflow
core/api_def/python_api
python/ops
tools

View File

@ -1,5 +1,7 @@
op {
graph_op_name: "CheckNumerics"
deprecation_version: 2
deprecation_message: "Use debugging.assert_all_finite instead"
endpoint {
name: "debugging.check_numerics"
}

View File

@ -28,9 +28,7 @@ from tensorflow.python.util import deprecation
from tensorflow.python.util.tf_export import tf_export
@tf_export(
"debugging.assert_all_finite",
v1=["debugging.assert_all_finite", "verify_tensor_all_finite"])
@tf_export(v1=["debugging.assert_all_finite", "verify_tensor_all_finite"])
@deprecation.deprecated_endpoints("verify_tensor_all_finite")
def verify_tensor_all_finite(t, msg, name=None):
"""Assert that the tensor does not contain any NaN's or Inf's.
@ -43,11 +41,26 @@ def verify_tensor_all_finite(t, msg, name=None):
Returns:
Same tensor as `t`.
"""
with ops.name_scope(name, "VerifyFinite", [t]) as name:
t = ops.convert_to_tensor(t, name="t")
with ops.colocate_with(t):
verify_input = array_ops.check_numerics(t, message=msg)
out = control_flow_ops.with_dependencies([verify_input], t)
return verify_tensor_all_finite_v2(t, msg, name)
@tf_export("debugging.assert_all_finite", v1=[])
def verify_tensor_all_finite_v2(x, message, name=None):
"""Assert that the tensor does not contain any NaN's or Inf's.
Args:
x: Tensor to check.
message: Message to log on failure.
name: A name for this operation (optional).
Returns:
Same tensor as `x`.
"""
with ops.name_scope(name, "VerifyFinite", [x]) as name:
x = ops.convert_to_tensor(x, name="x")
with ops.colocate_with(x):
verify_input = array_ops.check_numerics(x, message=message)
out = control_flow_ops.with_dependencies([verify_input], x)
return out

View File

@ -6,7 +6,7 @@ tf_module {
}
member_method {
name: "assert_all_finite"
argspec: "args=[\'t\', \'msg\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
argspec: "args=[\'x\', \'message\', \'name\'], varargs=None, keywords=None, defaults=[\'None\'], "
}
member_method {
name: "assert_equal"

View File

@ -51,6 +51,10 @@ class TFAPIChangeSpec(ast_edits.APIChangeSpec):
"tf.nn.sufficient_statistics": {
"keep_dims": "keepdims"
},
"tf.debugging.assert_all_finite": {
"t": "x",
"msg": "message",
},
"tf.sparse.split": {
"split_dim": "axis",
},