-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
question about _likelihood #23
Comments
Upper and lower are the estimated CDF bounds for the current input, from there the densities can be derived. You can find more information in Ballé et al. papers: End-to-end Optimized Image Compression, Variational image compression with a scale hyperprior The |
Thanks for your reply! |
@torch.jit.unused
def _likelihood(self, inputs: Tensor) -> Tensor:
half = float(0.5)
v0 = inputs - half
v1 = inputs + half
lower = self._logits_cumulative(v0, stop_gradient=False)
upper = self._logits_cumulative(v1, stop_gradient=False)
sign = -torch.sign(lower + upper)
sign = sign.detach()
likelihood = torch.abs(
torch.sigmoid(sign * upper) - torch.sigmoid(sign * lower)
)
return likelihood Why not @torch.jit.unused
def _likelihood(self, inputs: Tensor) -> Tensor:
half = float(0.5)
v0 = inputs - half
v1 = inputs + half
lower = self._logits_cumulative(v0, stop_gradient=False)
upper = self._logits_cumulative(v1, stop_gradient=False)
likelihood = torch.sigmoid(upper) - torch.sigmoid(lower)
return likelihood I debug found > ll = torch.sigmoid(upper) - torch.sigmoid(lower)
> likelihood.isclose(ll).all()
True
> (likelihood == ll).all()
False Why?! |
I am a beginner in image compression. I don’t understand why lower, upper and sign are calculated for this step.
The text was updated successfully, but these errors were encountered: