Invert

공개 최종 클래스 반전

지원되는 유형의 각 비트를 반전(플립)합니다. 예를 들어 'uint8'을 입력하면 값 01010101은 10101010이 됩니다.

지원되는 유형의 각 비트를 뒤집습니다. 예를 들어 'int8'(10진수 2) 유형의 이진수 00000010은 (10진수 -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 TensorFlow 코어 엔진에서 알려진 이 작업의 이름

공개 방법

출력 <T>
출력 ()
텐서의 기호 핸들을 반환합니다.
static <T는 Tnumber를 확장합니다. > 반전 <T>
생성 ( 범위 범위, 피연산자 <T> x)
새로운 반전 작업을 래핑하는 클래스를 생성하는 팩토리 메서드입니다.
출력 <T>
와이 ()

상속된 메서드

상수

공개 정적 최종 문자열 OP_NAME

TensorFlow 코어 엔진에서 알려진 이 작업의 이름

상수 값: "반전"

공개 방법

공개 출력 <T> asOutput ()

텐서의 기호 핸들을 반환합니다.

TensorFlow 작업에 대한 입력은 다른 TensorFlow 작업의 출력입니다. 이 메서드는 입력 계산을 나타내는 기호 핸들을 얻는 데 사용됩니다.

public static Invert <T> create ( 범위 범위, 피연산자 <T> x)

새로운 반전 작업을 래핑하는 클래스를 생성하는 팩토리 메서드입니다.

매개변수
범위 현재 범위
보고
  • Invert의 새로운 인스턴스

공개 출력 <T> y ()