Skip to content

Normalize the pred of the network but not for the ground truth of score. Why? #2

Description

@Guanbin-Huang

Hi! Animadversio

Firstly, I'd like to commend you on your work; it's truly impressive! I've been closely examining the sample_X_and_score experiment in the ReverseSDE_Diffusion.ipynb notebook and have a few clarifications to seek.

In your approach to approximate the analytical score with a Neural Network, I noticed that while constructing the data-ground-truth pair, there doesn't seem to be any normalization applied to the ground truth of the score. However, in the code snippet, there appears to be a form of normalization in the fourth line. This has left me a bit puzzled. Specifically, while y_pred is normalized, y_train (which serves as the ground truth) isn't normalized by the timestep. This gives an impression that they might be on different scales.

-------- code ----------
for ep in pbar:
y_pred = score_model_analy(X_train, T_train)
loss = torch.mean(torch.sum((y_pred - y_train)**2 * std_vec[:, None], dim=(1))) # <======= here
-------- code ----------
Moreover, in the forward method, the output is normalized:

-------- code ----------
def forward(self, x, t):
t_embed = self.embed(t)
pred = self.net(torch.cat((x,t_embed),dim=1))
pred = pred / self.marginal_prob_std_f(t)[:, None,]. # <======= here
return pred
-------- code ----------

Given this, I'm curious about how arithmetic operations can be applied on y_pred and y_train if they're potentially on different scales.

I've also taken a look at the Colab notebook you provided (link) and attached an image for reference:
image
I'd greatly appreciate your insights on this matter. Thank you for your time and patience.

Warm regards,

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions