本文整理汇总了Python中tensorflow.python.ops.gen_math_ops.logical_not方法的典型用法代码示例。如果您正苦于以下问题:Python gen_math_ops.logical_not方法的具体用法?Python gen_math_ops.logical_not怎么用?Python gen_math_ops.logical_not使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.python.ops.gen_math_ops
的用法示例。
在下文中一共展示了gen_math_ops.logical_not方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: logical_xor
# 需要导入模块: from tensorflow.python.ops import gen_math_ops [as 别名]
# 或者: from tensorflow.python.ops.gen_math_ops import logical_not [as 别名]
def logical_xor(x, y, name="LogicalXor"):
"""x ^ y = (x | y) & ~(x & y)."""
# TODO(alemi) Make this a cwise op if people end up relying on it.
return gen_math_ops.logical_and(
gen_math_ops.logical_or(x, y),
gen_math_ops.logical_not(gen_math_ops.logical_and(x, y)),
name=name)
示例2: __while_loop
# 需要导入模块: from tensorflow.python.ops import gen_math_ops [as 别名]
# 或者: from tensorflow.python.ops.gen_math_ops import logical_not [as 别名]
def __while_loop(self, b, a, d, n, seed):
def __cond(w, e, bool_mask, b, a, d):
return math_ops.reduce_any(bool_mask)
def __body(w_, e_, bool_mask, b, a, d):
e = math_ops.cast(Beta((self.__mf - 1) / 2, (self.__mf - 1) / 2).sample(
shape, seed=seed), dtype=self.dtype)
u = random_ops.random_uniform(shape, dtype=self.dtype, seed=seed)
w = (1 - (1 + b) * e) / (1 - (1 - b) * e)
t = (2 * a * b) / (1 - (1 - b) * e)
accept = gen_math_ops.greater(((self.__mf - 1) * math_ops.log(t) - t + d), math_ops.log(u))
reject = gen_math_ops.logical_not(accept)
w_ = array_ops.where(gen_math_ops.logical_and(bool_mask, accept), w, w_)
e_ = array_ops.where(gen_math_ops.logical_and(bool_mask, accept), e, e_)
bool_mask = array_ops.where(gen_math_ops.logical_and(bool_mask, accept), reject, bool_mask)
return w_, e_, bool_mask, b, a, d
shape = array_ops.concat([[n], self.batch_shape_tensor()[:-1], [1]], 0)
b, a, d = [gen_array_ops.tile(array_ops.expand_dims(e, axis=0), [n] + [1] * len(e.shape)) for e in (b, a, d)]
w, e, bool_mask, b, a, d = control_flow_ops.while_loop(__cond, __body,
[array_ops.zeros_like(b, dtype=self.dtype),
array_ops.zeros_like(b, dtype=self.dtype),
array_ops.ones_like(b, dtypes.bool),
b, a, d])
return e, w