Closed danishnazir closed 10 months ago
The latent y
is quantized uniformly to bins of width 1.
This is done in one of the following ways:
ste(y) = round(y) during forward
ste(y) = y during backward
i.e., $\frac{d}{dy} \mathrm{STE}(y) = 1$
Thanks for your response. is it possible/reccomended to somehow change the bin width to influence the amount of quantization?
Sure. Just replace round
with your own quantize
:
@torch.no_grad()
def quantize(x):
return (torch.sign(x) * x.abs().sqrt()).round()
And then:
def quantize_ste(x):
return x + (quantize(x) - x).detach()
Or for noise-based quantization, just modify each symbol's noise gain accordingly:
noise_gain = function_depending_on_bin_widths_and_y(y)
y_hat = y + noise_gain * 2 * (torch.rand(y.shape) - 0.5)
Hello,
Is it possible to somehow defined the level of quantization during training? For instance one can use the following code for hard quantization during training,
then if we look inside quantize_ste function, we have
return (torch.round(x) - x).detach() + x
This is basically dependant on the inputx
, however, I am not really sure what level of quanitzation will be applied to latent variabley
. Is this possible to know during training?