tensoreflusso:: ops:: Dequantizzare

#include <array_ops.h>

Dequantizza il tensore 'input' in un float o bfloat16 Tensor .

Riepilogo

[min_range, max_range] sono float scalari che specificano l'intervallo per l'output. L'attributo 'mode' controlla esattamente quali calcoli vengono utilizzati per convertire i valori float nei loro equivalenti quantizzati.

Nella modalità 'MIN_COMBINED', ciascun valore del tensore subirà quanto segue:

if T == qint8: in[i] += (range(T) + 1)/ 2.0
out[i] = min_range + (in[i]* (max_range - min_range) / range(T))
qui range(T) = numeric_limits ::max() - numeric_limits ::min() range(T) = numeric_limits ::max() - numeric_limits ::min() range(T) = numeric_limits ::max() - numeric_limits ::min()

Esempio di modalità MIN_COMBINED

Se l'input proviene da un QuantizedRelu6 , il tipo di output è quint8 (intervallo 0-255) ma il possibile intervallo di QuantizedRelu6 è 0-6. I valori min_range e max_range sono quindi 0,0 e 6,0. Dequantizza su quint8 prenderà ogni valore, lo convertirà in float e lo moltiplicherà per 6/255. Tieni presente che se quantizedtype è qint8, l'operazione aggiungerà inoltre ogni valore per 128 prima dell'esecuzione del cast.

Se la modalità è "MIN_FIRST", viene utilizzato questo approccio:

num_discrete_values = 1 << (# of bits in T)
range_adjust = num_discrete_values / (num_discrete_values - 1)
range = (range_max - range_min) * range_adjust
range_scale = range / num_discrete_values
const double offset_input = static_cast(input) - lowest_quantized;
result = range_min + ((input - numeric_limits::min()) * range_scale)

Se la modalità è SCALED , la dequantizzazione viene eseguita moltiplicando ciascun valore di input per uno scaling_factor. (Pertanto un input pari a 0 corrisponde sempre a 0,0).

Lo scaling_factor è determinato da min_range , max_range e narrow_range in modo compatibile con QuantizeAndDequantize{V2|V3} e QuantizeV2 , utilizzando il seguente algoritmo:

  

  const int min_expected_T = std::numeric_limits::min() +
    (narrow_range ? 1 : 0);
  const int max_expected_T = std::numeric_limits::max();
  const float max_expected_T = std::numeric_limits::max();

  const float scale_factor =
    (std::numeric_limits::min() == 0) ? (max_range / max_expected_T)
                                         : std::max(min_range / min_expected_T,
                                                    max_range / max_expected_T);

Argomenti:

  • scope: un oggetto Scope
  • min_range: il valore scalare minimo eventualmente prodotto per l'input.
  • max_range: il valore scalare massimo possibilmente prodotto per l'input.

Attributi facoltativi (vedi Attrs ):

  • dtype: tipo del tensore di uscita. Attualmente Dequantize supporta float e bfloat16. Se 'dtype' è 'bfloat16', supporta solo la modalità 'MIN_COMBINED'.

Ritorna:

  • Output : il tensore di uscita.

Costruttori e distruttori

Dequantize (const :: tensorflow::Scope & scope, :: tensorflow::Input input, :: tensorflow::Input min_range, :: tensorflow::Input max_range)
Dequantize (const :: tensorflow::Scope & scope, :: tensorflow::Input input, :: tensorflow::Input min_range, :: tensorflow::Input max_range, const Dequantize::Attrs & attrs)

Attributi pubblici

operation
output

Funzioni pubbliche

node () const
::tensorflow::Node *
operator::tensorflow::Input () const
operator::tensorflow::Output () const

Funzioni pubbliche statiche

Axis (int64 x)
Dtype (DataType x)
Mode (StringPiece x)
NarrowRange (bool x)

Strutture

tensorflow:: ops:: Dequantize:: Attrs

Setter di attributi facoltativi per Dequantize .

Attributi pubblici

operazione

Operation operation

produzione

::tensorflow::Output output

Funzioni pubbliche

Dequantizzare

 Dequantize(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  ::tensorflow::Input min_range,
  ::tensorflow::Input max_range
)

Dequantizzare

 Dequantize(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  ::tensorflow::Input min_range,
  ::tensorflow::Input max_range,
  const Dequantize::Attrs & attrs
)

nodo

::tensorflow::Node * node() const 

operatore::tensorflow::Input

 operator::tensorflow::Input() const 

operatore::tensorflow::Output

 operator::tensorflow::Output() const 

Funzioni pubbliche statiche

Asse

Attrs Axis(
  int64 x
)

Tipo D

Attrs Dtype(
  DataType x
)

Modalità

Attrs Mode(
  StringPiece x
)

Gamma ristretta

Attrs NarrowRange(
  bool x
)