Invert

พลิกกลับ คลาสสุดท้ายสาธารณะ

สลับ (พลิก) แต่ละบิตของประเภทที่รองรับ เช่น พิมพ์ค่า `uint8` 01010101 กลายเป็น 10101010

พลิกประเภทที่รองรับแต่ละบิต ตัวอย่างเช่น พิมพ์ `int8` (ทศนิยม 2) ไบนารี่ 00000010 กลายเป็น (ทศนิยม -3) ไบนารี่ 11111101 การดำเนินการนี้จะดำเนินการกับแต่ละองค์ประกอบของอาร์กิวเมนต์เทนเซอร์ `x`

ตัวอย่าง:

import tensorflow as tf
 from tensorflow.python.ops import bitwise_ops
 
 # flip 2 (00000010) to -3 (11111101)
 tf.assert_equal(-3, bitwise_ops.invert(2))
 
 dtype_list = [dtypes.int8, dtypes.int16, dtypes.int32, dtypes.int64,
               dtypes.uint8, dtypes.uint16, dtypes.uint32, dtypes.uint64]
 
 inputs = [0, 5, 3, 14]
 for dtype in dtype_list:
   # Because of issues with negative numbers, let's test this indirectly.
   # 1. invert(a) and a = 0
   # 2. invert(a) or a = invert(0)
   input_tensor = tf.constant([0, 5, 3, 14], dtype=dtype)
   not_a_and_a, not_a_or_a, not_0 = [bitwise_ops.bitwise_and(
                                       input_tensor, bitwise_ops.invert(input_tensor)),
                                     bitwise_ops.bitwise_or(
                                       input_tensor, bitwise_ops.invert(input_tensor)),
                                     bitwise_ops.invert(
                                       tf.constant(0, dtype=dtype))]
 
   expected = tf.constant([0, 0, 0, 0], dtype=tf.float32)
   tf.assert_equal(tf.cast(not_a_and_a, tf.float32), expected)
 
   expected = tf.cast([not_0] * 4, tf.float32)
   tf.assert_equal(tf.cast(not_a_or_a, tf.float32), expected)
 
   # For unsigned dtypes let's also check the result directly.
   if dtype.is_unsigned:
     inverted = bitwise_ops.invert(input_tensor)
     expected = tf.constant([dtype.max - x for x in inputs], dtype=tf.float32)
     tf.assert_equal(tf.cast(inverted, tf.float32), tf.cast(expected, tf.float32))
 

ค่าคงที่

สตริง OP_NAME ชื่อของ op นี้ ซึ่งรู้จักกันในชื่อของเอ็นจิ้นหลัก TensorFlow

วิธีการสาธารณะ

เอาท์พุต <T>
เป็นเอาท์พุต ()
ส่งกลับค่าแฮนเดิลสัญลักษณ์ของเทนเซอร์
คงที่ <T ขยาย TNumber > สลับ <T>
สร้าง (ขอบเขต ขอบเขต ตัวดำเนินการ <T> x)
วิธีการจากโรงงานเพื่อสร้างคลาสที่ห่อการดำเนินการ Invert ใหม่
เอาท์พุต <T>

วิธีการสืบทอด

ค่าคงที่

สตริงสุดท้ายแบบคงที่สาธารณะ OP_NAME

ชื่อของ op นี้ ซึ่งรู้จักกันในชื่อของเอ็นจิ้นหลัก TensorFlow

ค่าคงที่: "กลับด้าน"

วิธีการสาธารณะ

เอาท์ พุท สาธารณะ <T> asOutput ()

ส่งกลับค่าแฮนเดิลสัญลักษณ์ของเทนเซอร์

อินพุตสำหรับการดำเนินการ TensorFlow คือเอาต์พุตของการดำเนินการ TensorFlow อื่น วิธีการนี้ใช้เพื่อรับหมายเลขอ้างอิงสัญลักษณ์ที่แสดงถึงการคำนวณอินพุต

สาธารณะคง Invert <T> สร้าง (ขอบเขต ขอบเขต ตัวดำเนินการ <T> x)

วิธีการจากโรงงานเพื่อสร้างคลาสที่ห่อการดำเนินการ Invert ใหม่

พารามิเตอร์
ขอบเขต ขอบเขตปัจจุบัน
การส่งคืน
  • ตัวอย่างใหม่ของ Invert

เอาท์พุท สาธารณะ <T> y ()