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

Why is forward method for ANP maximizing LogLikelihood for Context labels? #1

Open
yair-schiff opened this issue Sep 11, 2022 · 0 comments

Comments

@yair-schiff
Copy link

In the ANP implementation, during training mode, the full set (i.e. context + target) is being passed to predict meaning that log likelihood is being maximized for both target and context labels.

        if self.training:
            pz = self.lenc(batch.xc, batch.yc)
            qz = self.lenc(batch.x, batch.y)
            z = qz.rsample() if num_samples is None else \
                    qz.rsample([num_samples])
            py = self.predict(batch.xc, batch.yc, batch.x,
                    z=z, num_samples=num_samples)


            if num_samples > 1:
                # K * B * N
                recon = py.log_prob(stack(batch.y, num_samples)).sum(-1)
                # K * B
                log_qz = qz.log_prob(z).sum(-1)
                log_pz = pz.log_prob(z).sum(-1)


                # K * B
                log_w = recon.sum(-1) + log_pz - log_qz


                outs.loss = -logmeanexp(log_w).mean() / batch.x.shape[-2]

Shouldn't this line:

            py = self.predict(batch.xc, batch.yc, batch.x,

be changed to this

            py = self.predict(batch.xc, batch.yc, batch.xt,

i.e. batch.x --> batch.xt in 3rd argument of predict?

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

1 participant