检查张量的 NaN 和 Inf 值。
用法
tf.raw_ops.CheckNumerics(
tensor, message, name=None
)参数
-
tensor一个Tensor。必须是以下类型之一:bfloat16,half,float32,float64。 -
message一个string。错误消息的前缀。 -
name操作的名称(可选)。
返回
-
一个
Tensor。具有与tensor相同的类型。
运行时,如果 tensor 具有任何不是数字 (NaN) 或无穷大 (Inf) 的值,则报告 InvalidArgument 错误。否则,返回输入张量。
示例用法:
a = tf.Variable(1.0)
tf.debugging.check_numerics(a, message='')
b = tf.Variable(np.nan)
try:
tf.debugging.check_numerics(b, message='Checking b')
except Exception as e:
assert "Checking b:Tensor had NaN values" in e.message
c = tf.Variable(np.inf)
try:
tf.debugging.check_numerics(c, message='Checking c')
except Exception as e:
assert "Checking c:Tensor had Inf values" in e.message
相关用法
- Python tf.raw_ops.ComplexAbs用法及代码示例
- Python tf.raw_ops.Conv2D用法及代码示例
- Python tf.raw_ops.Cos用法及代码示例
- Python tf.raw_ops.Case用法及代码示例
- Python tf.raw_ops.Cumsum用法及代码示例
- Python tf.raw_ops.Conj用法及代码示例
- Python tf.raw_ops.Cosh用法及代码示例
- Python tf.raw_ops.Complex用法及代码示例
- Python tf.raw_ops.Cumprod用法及代码示例
- Python tf.raw_ops.CumulativeLogsumexp用法及代码示例
- Python tf.raw_ops.ConcatOffset用法及代码示例
- Python tf.raw_ops.TPUReplicatedInput用法及代码示例
- Python tf.raw_ops.Bitcast用法及代码示例
- Python tf.raw_ops.SelfAdjointEigV2用法及代码示例
- Python tf.raw_ops.BatchMatMul用法及代码示例
- Python tf.raw_ops.OneHot用法及代码示例
- Python tf.raw_ops.ResourceScatterNdSub用法及代码示例
- Python tf.raw_ops.ReadVariableXlaSplitND用法及代码示例
- Python tf.raw_ops.GatherV2用法及代码示例
- Python tf.raw_ops.Expm1用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.raw_ops.CheckNumerics。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
