dequantize#

class diffsptk.InverseUniformQuantization(abs_max=1, n_bit=8, quantizer='mid-rise')[source]#

See this page for details.

Parameters:
abs_maxfloat > 0 [scalar]

Absolute maximum value of input.

n_bitint >= 1 [scalar]

Number of quantization bits.

quantizer[‘mid-rise’, ‘mid-tread’]

Quantizer.

forward(y)[source]#

Dequantize input.

Parameters:
yTensor [shape=(…,)]

Quantized input.

Returns:
xTensor [shape=(…,)]

Dequantized input.

Examples

>>> x = diffsptk.ramp(-4, 4)
>>> x
tensor([-4., -3., -2., -1.,  0.,  1.,  2.,  3.,  4.])
>>> quantize = diffsptk.UniformQuantization(4, 2)
>>> dequantize = diffsptk.InverseUniformQuantization(4, 2)
>>> x2 = dequantize(quantize(x))
>>> x2
tensor([-3., -3., -1., -1.,  1.,  1.,  3.,  3.,  3.])

See also

iulaw quantize