Skip to content
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

Loss simple and loss vlb #349

Open
TuanDTr opened this issue Feb 16, 2024 · 2 comments
Open

Loss simple and loss vlb #349

TuanDTr opened this issue Feb 16, 2024 · 2 comments

Comments

@TuanDTr
Copy link

TuanDTr commented Feb 16, 2024

I don't fully understand how final loss is computed based on loss simple and loss vlb. It seems like both loss terms are measured with L1/L2 and are combined by different weighting terms. For loss vlb, I found the formula in the original DDPM that seems to match the implementation. But I am not clear about the weighting term for loss simple and why it is combined with loss vlb. Apologize if this question is too trivial ...

        loss_simple = self.get_loss(model_output, target, mean=False).mean([1, 2, 3])
        loss_dict.update({f"{prefix}/loss_simple": loss_simple.mean()})

        logvar_t = self.logvar[t.to("cpu")].to(self.device)
        loss = loss_simple / torch.exp(logvar_t) + logvar_t
        if self.learn_logvar:
            loss_dict.update({f"{prefix}/loss_gamma": loss.mean()})
            loss_dict.update({"logvar": self.logvar.data.mean()})

        loss = self.l_simple_weight * loss.mean()

        loss_vlb = self.get_loss(model_output, target, mean=False).mean(dim=(1, 2, 3))
        loss_vlb = (self.lvlb_weights[t] * loss_vlb).mean()
        loss_dict.update({f"{prefix}/loss_vlb": loss_vlb})
        loss += self.original_elbo_weight * loss_vlb
        loss_dict.update({f"{prefix}/loss": loss})
@kaka45inablink
Copy link

just find that original_elbo_weight is set to zero by default

@sivannavis
Copy link

Same question here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants