Invert

classe finale pubblica Invert

Inverti (capovolgi) ogni bit dei tipi supportati; ad esempio, digita "uint8" il valore 01010101 diventa 10101010.

Capovolgi ogni bit dei tipi supportati. Ad esempio, digita "int8" (decimale 2) binario 00000010 diventa (decimale -3) binario 11111101. Questa operazione viene eseguita su ciascun elemento dell'argomento tensore "x".

Esempio:

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))
 

Costanti

Corda OP_NAME Il nome di questa operazione, come noto al motore principale di TensorFlow

Metodi pubblici

Uscita <T>
comeuscita ()
Restituisce l'handle simbolico del tensore.
statico <T estende TNumero > Inverti <T>
create ( ambito ambito , operando <T> x)
Metodo factory per creare una classe che racchiude una nuova operazione Invert.
Uscita <T>
()

Metodi ereditati

Costanti

Stringa finale statica pubblica OP_NAME

Il nome di questa operazione, come noto al motore principale di TensorFlow

Valore costante: "Inverti"

Metodi pubblici

Uscita pubblica <T> asOutput ()

Restituisce l'handle simbolico del tensore.

Gli input per le operazioni TensorFlow sono output di un'altra operazione TensorFlow. Questo metodo viene utilizzato per ottenere un handle simbolico che rappresenta il calcolo dell'input.

public static Invert <T> create ( Scope scope, Operando <T> x)

Metodo factory per creare una classe che racchiude una nuova operazione Invert.

Parametri
scopo ambito attuale
ritorna
  • una nuova istanza di Invert

Uscita pubblica <T> y ()