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

What exactly does the loss function compute? #26

Closed
DanBigioi opened this issue Jun 23, 2022 · 1 comment
Closed

What exactly does the loss function compute? #26

DanBigioi opened this issue Jun 23, 2022 · 1 comment

Comments

@DanBigioi
Copy link

Hi,

I'm just a bit confused on how the loss is computed. From my understanding, for a given training loop we have a ground truth image denoted as GT. GT is passed through a series of 1000 timesteps t, and at each timestep a small amount of random gaussian noise is added.

Lets say the network takes in as input the noisy GT image from timestep 50. The network should predict the small amount of noise that was generated at timestep 50 right? So when we compute the loss, it should be the noise the network predicted that was generated at timestep 50 vs the actual noise that was generated at timestep 50? Or am I understanding it wrong.

In that case, why when the loss is calculated, the value for the actual noise is computed as being torch.randn_like(y_0) and not the noise at t=50?

noise = default(noise, lambda: torch.randn_like(y_0))
        y_noisy = self.q_sample(
            y_0=y_0, sample_gammas=sample_gammas.view(-1, 1, 1, 1), noise=noise)

        if mask is not None:
            noise_hat = self.denoise_fn(torch.cat([y_cond, y_noisy*mask+(1.-mask)*y_0], dim=1), sample_gammas)
            loss = self.loss_fn(mask*noise, mask*noise_hat)
@Janspiry
Copy link
Owner

Thanks for your attention.
Here just the noise added from y_0 is predicted.
At inference, y_0 is obtained by predict noise, and then y_{t-1} is obtained by the posterior distribution of y_0 with y_t

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

2 participants