tensorflow::ops::Dequantize
#include <array_ops.h>Dequantizza il tensore 'input' in un tensore float o bfloat16.
Riepilogo
[min_range, max_range] sono valori scalari in virgola mobile che specificano l'intervallo per l'output. L'attributo 'mode' controlla esattamente quali calcoli vengono utilizzati per convertire i valori in virgola mobile nei loro equivalenti quantizzati.
Nella modalità 'MIN_COMBINED', ogni valore del tensore verrà sottoposto alle seguenti operazioni:
if T == qint8: in[i] += (range(T) + 1)/ 2.0 out[i] = min_range + (in[i]* (max_range - min_range) / range(T))
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 da 0 a 255), ma l'intervallo possibile di QuantizedRelu6 è da 0 a 6. I valori di min_range e max_range sono quindi 0.0 e 6.0. La dequantizzazione su quint8 prenderà ciascun valore, lo convertirà in float e lo moltiplicherà per 6 / 255. Si noti che se quantizedtype è qint8, l'operazione aggiungerà inoltre 128 a ciascun valore prima della conversione.
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 un fattore di scala. (Pertanto, un input pari a 0 viene sempre mappato a 0,0).
Il fattore di scala viene 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);
Argomentazioni:
- ambito: un oggetto Scope
- min_range: Il valore scalare minimo che può essere prodotto per l'input.
- max_range: Il valore scalare massimo che può essere prodotto per l'input.
Attributi opzionali (vedere Attrs ):
- dtype: Tipo del tensore di output. Attualmente Dequantize supporta float e bfloat16. Se 'dtype' è 'bfloat16', supporta solo la modalità 'MIN_COMBINED'.
Resi:
-
Output: Il tensore di output.
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 statiche pubbliche | |
|---|---|
Axis (int64 x) | |
Dtype (DataType x) | |
Mode (StringPiece x) | |
NarrowRange (bool x) | |
Strutture | |
|---|---|
| tensorflow::ops::Dequantize::Attrs | Impostatori di attributi opzionali 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::tensoreflusso::output
operator::tensorflow::Output() const
Funzioni statiche pubbliche
Asse
Attrs Axis( int64 x )
Tipo D
Attrs Dtype( DataType x )
Modalità
Attrs Mode( StringPiece x )
Gamma ristretta
Attrs NarrowRange( bool x )