aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/ops/clip_ops.py
diff options
context:
space:
mode:
authorGravatar Avijit <Avijit.Chakraborty@intel.com>2018-08-15 17:00:22 -0700
committerGravatar Avijit <Avijit.Chakraborty@intel.com>2018-08-15 17:00:22 -0700
commitbc6be507c71046dfc889a90e3949a903d5d1e6eb (patch)
tree84557e7bb7798e3d418a619c8452aa7baf78f255 /tensorflow/python/ops/clip_ops.py
parent9523a98466d16cf01fc76a67b489f1124cf626ac (diff)
parentd2875ea71373d05c645587a83dd870fa8a0ec070 (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'tensorflow/python/ops/clip_ops.py')
-rw-r--r--tensorflow/python/ops/clip_ops.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/tensorflow/python/ops/clip_ops.py b/tensorflow/python/ops/clip_ops.py
index e2580e8a2e..78b395a6c1 100644
--- a/tensorflow/python/ops/clip_ops.py
+++ b/tensorflow/python/ops/clip_ops.py
@@ -29,6 +29,7 @@ from tensorflow.python.ops import array_ops
from tensorflow.python.ops import gen_array_ops
from tensorflow.python.ops import gen_nn_ops
from tensorflow.python.ops import math_ops
+from tensorflow.python.ops import numerics
from tensorflow.python.util.tf_export import tf_export
@@ -57,7 +58,7 @@ def clip_by_value(t, clip_value_min, clip_value_max,
A clipped `Tensor`.
Raises:
- ValueError: if the clip tensors would trigger array broadcasting
+ ValueError: If the clip tensors would trigger array broadcasting
that would make the returned tensor larger than the input.
"""
with ops.name_scope(name, "clip_by_value",
@@ -246,6 +247,7 @@ def clip_by_global_norm(t_list, clip_norm, use_norm=None, name=None):
Raises:
TypeError: If `t_list` is not a sequence.
+ InvalidArgumentError: If global norm is not finite.
"""
if (not isinstance(t_list, collections.Sequence)
or isinstance(t_list, six.string_types)):
@@ -253,6 +255,8 @@ def clip_by_global_norm(t_list, clip_norm, use_norm=None, name=None):
t_list = list(t_list)
if use_norm is None:
use_norm = global_norm(t_list, name)
+ use_norm = numerics.verify_tensor_all_finite(use_norm,
+ "Found Inf or NaN global norm.")
with ops.name_scope(name, "clip_by_global_norm",
t_list + [clip_norm]) as name: