断言条件 x 和 y 在元素层面是接近的。
用法
tf.compat.v1.assert_near(
x, y, rtol=None, atol=None, data=None, summarize=None, message=None, name=None
)参数
-
x浮点数或复数Tensor。 -
y浮点数或复数Tensor,与dtype相同,可广播到x。 -
rtolTensor。dtype与x相同,并且可广播到x。相对容差。默认为10 * eps。 -
atolTensor。dtype与x相同,并且可广播到x。绝对的容忍度。默认为10 * eps。 -
data如果条件为 False,则打印出的张量。默认为错误消息和x,y的前几个条目。 -
summarize打印每个张量的这么多条目。 -
message默认消息的前缀字符串。 -
name此操作的名称(可选)。默认为"assert_near"。
返回
-
如果
x和y不够接近,则会引发InvalidArgumentError的操作。
将依赖项添加到操作的示例:
with tf.control_dependencies([tf.compat.v1.assert_near(x, y)]):
output = tf.reduce_sum(x)
如果对于每对(可能是广播)元素 x[i] , y[i] ,我们有
tf.abs(x[i] - y[i]) <= atol + rtol * tf.abs(y[i]) 。
如果x 和y 都是空的,这很容易满足。
默认的 atol 和 rtol 是 10 * eps ,其中 eps 是最小的可表示正数,例如 1 + eps != 1 。这是关于 1.2e-6 in 32bit , 2.22e-15 in 64bit 和 0.00977 in 16bit 。请参阅numpy.finfo。
numpy 兼容性
类似于 numpy.testing.assert_allclose ,除了容差取决于数据类型。这是因为 TensorFlow 经常与 32bit , 64bit 甚至 16bit 数据一起使用。
相关用法
- Python tf.compat.v1.assert_negative用法及代码示例
- Python tf.compat.v1.assert_none_equal用法及代码示例
- Python tf.compat.v1.assert_non_positive用法及代码示例
- Python tf.compat.v1.assert_non_negative用法及代码示例
- Python tf.compat.v1.assert_less_equal用法及代码示例
- Python tf.compat.v1.assert_integer用法及代码示例
- Python tf.compat.v1.assert_greater用法及代码示例
- Python tf.compat.v1.assert_rank_at_least用法及代码示例
- Python tf.compat.v1.assert_less用法及代码示例
- Python tf.compat.v1.assert_rank_in用法及代码示例
- Python tf.compat.v1.assert_greater_equal用法及代码示例
- Python tf.compat.v1.assert_rank用法及代码示例
- Python tf.compat.v1.assert_positive用法及代码示例
- Python tf.compat.v1.assert_equal用法及代码示例
- Python tf.compat.v1.assign_add用法及代码示例
- Python tf.compat.v1.assign用法及代码示例
- Python tf.compat.v1.assign_sub用法及代码示例
- Python tf.compat.v1.autograph.to_graph用法及代码示例
- Python tf.compat.v1.arg_max用法及代码示例
- Python tf.compat.v1.arg_min用法及代码示例
注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.compat.v1.assert_near。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
