Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.dequantize function

PyTorch torch.dequantize function


PyTorch torch reference manual PyTorch torch reference manual

torch.dequantize is a PyTorch function for dequantizing a quantized tensor into a floating-point tensor.

Function definition

torch.dequantize(input)


Usage examples

Example

import

torch

Create an input tensor

input

=

torch.

tensor

(

[

[

1.0

,

0.0

]

,

[

1.0

,

2.0

]

]

)

Quantize the tensor

quantized

=

torch.

quantize_per_tensor

(

input

,

scale

=

0.1

,

zero_point

=

10

,

dtype

=

torch.

quint8

)

print

(

"Quantized tensor:"

)

print

(

quantized

)

Dequantize

x

=

torch.

dequantize

(

quantized

)

print

(

"Dequantized floating-point tensor:"

)

print

(

x

)


PyTorch torch reference manual PyTorch torch reference manual