当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python tf.raw_ops.BitwiseOr用法及代码示例


Elementwise 计算 xy 的按位或。

用法

tf.raw_ops.BitwiseOr(
    x, y, name=None
)

参数

  • x 一个Tensor。必须是以下类型之一:int8 , int16 , int32 , int64 , uint8 , uint16 , uint32 , uint64
  • y 一个Tensor。必须与 x 具有相同的类型。
  • name 操作的名称(可选)。

返回

  • 一个Tensor。具有与 x 相同的类型。

结果将设置那些在x , y 中设置的位或两者。计算是在 xy 的基础表示上执行的。

例如:

import tensorflow as tf
from tensorflow.python.ops import bitwise_ops
dtype_list = [tf.int8, tf.int16, tf.int32, tf.int64,
              tf.uint8, tf.uint16, tf.uint32, tf.uint64]

for dtype in dtype_list:
  lhs = tf.constant([0, 5, 3, 14], dtype=dtype)
  rhs = tf.constant([5, 0, 7, 11], dtype=dtype)
  exp = tf.constant([5, 5, 7, 15], dtype=tf.float32)

  res = bitwise_ops.bitwise_or(lhs, rhs)
  tf.assert_equal(tf.cast(res,  tf.float32), exp)  # TRUE

相关用法


注:本文由纯净天空筛选整理自tensorflow.org大神的英文原创作品 tf.raw_ops.BitwiseOr。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。