(1)tf.assert_positive
tf..debugging.assert_positive
tf.debugging.assert_positive(
x,
data=None,
summarize=None,
message=None,
name=None
)
判断输入张量 x 的元素都大于 0,否则抛出错误 InvalidArgumentError
通常可以用于给某个操作添加依赖条件,如:
with tf.control_dependencies([tf.assert_positive(x)]):
output = tf.reduce_sum(x)
(2)tf.assert_non_positive
tf.debugging.assert_non_positive
同理,判断输入张量 x 的元素都非正数,否则抛出错误 InvalidArgumentError
(3)tf.assert_negative
tf.debugging.assert_negative
同理,判断输入张量 x 的元素都小于 0,否则抛出错误 InvalidArgumentError
(4)tf.assert_non_negative
tf.debugging.assert_non_negative
同理,判断输入张量 x 的元素都非负数,否则抛出错误 InvalidArgumentError
这些断言操作都在命名空间 tf.debugging 下
https://tensorflow.google.cn/api_docs/python/tf/debugging
Assert(...): Asserts that the given condition is true.
assert_all_finite(...): Assert that the tensor does not contain any NaN's or Inf's.
assert_equal(...): Assert the condition x == y holds element-wise.
assert_greater(...): Assert the condition x > y holds element-wise.
assert_greater_equal(...): Assert the condition x >= y holds element-wise.
assert_integer(...): Assert that x is of integer dtype.
assert_less(...): Assert the condition x < y holds element-wise.
assert_less_equal(...): Assert the condition x <= y holds element-wise.
assert_near(...): Assert the condition x and y are close element-wise.
assert_negative(...): Assert the condition x < 0 holds element-wise.
assert_non_negative(...): Assert the condition x >= 0 holds element-wise. assert_non_positive(...):
Assert the condition x <= 0 holds element-wise. assert_none_equal(...):
Assert the condition x != y holds for all elements. assert_positive(...):
Assert the condition x > 0 holds element-wise.
assert_proper_iterable(...): Static assert that values is a "proper" iterable.
assert_rank(...): Assert x has rank equal to rank.
assert_rank_at_least(...): Assert x has rank equal to rank or higher.
assert_rank_in(...): Assert x has rank in ranks.
assert_same_float_dtype(...): Validate and return float type based on tensors and dtype.
assert_scalar(...) assert_type(...): Statically asserts that the given Tensor is of the specified type.
check_numerics(...): Checks a tensor for NaN and Inf values.
is_finite(...): Returns which elements of x are finite. is_inf(...): Returns which elements of x are Inf.
is_nan(...): Returns which elements of x are NaN.
is_non_decreasing(...): Returns True if x is non-decreasing.
is_numeric_tensor(...) is_strictly_increasing(...): Returns True if x is strictly increasing.