Aalto-QuML / ClimODE

ClimODE: Climate and Weather Forecasting With Physics-informed Neural ODEs
https://yogeshverma1998.github.io/ClimODE/
MIT License
63 stars 5 forks source link

Mismatch between code and equation given in the paper #2

Closed Yumenomae closed 1 month ago

Yumenomae commented 5 months ago

Hello. I am training ClimODE to other tasks for comparison, and have found some mismatch of the code.

  1. Code to generate the initial velocity in optimize_vel

    vel_loss = nn.MSELoss()(delta_u,out.squeeze(dim=1)) + 0.0000001*(final_x + final_y)

    The code wants to generate the initial velocity according to the continuity function described in the paper, but it minizes the $||du/dt - \text{advection}(\text{velocity})||_2^2$, which is different from the equation (10) $\text{argmin} ||du/dt + \text{advection}(\text{velocity})||_2^2$.

    However, as a result, the wrong loss function vel_loss will generate a velocity fits the numerical differentiation of any variable at current time, which is also useful for predicting the future state.

  2. Code to update the state of variable in Climate_encoder_free_uncertain The function self.pde will generate the tuple $(d \ \text{velocity}/dt, \text{advection}=\text{adv}1+\text{adv}2 )$, which is used to numerical integration in pde_rhs = lambda t,vs: self.pde(t,vs) final_result = odeint(pde_rhs,final_data,t,method=self.method,atol=atol,rtol=rtol)

    It indicates that $du/dt = \text{advection}$, which is contradictory to the equation (2) $du/dt = -\text{advection}$ in the paper.

Yumenomae commented 5 months ago

The two mismatch mentioned above would still generate the true result, but the true velocity should be the negative of the velocity trained in the model. However, I don't know whether it would produce new problems in other parts of the code.

yogeshverma1998 commented 5 months ago

Hi,

In the code, we are fitting and learning -v instead of v, which modifies the advection equation as $du/dt = advection$. This equation defines the dynamics for the initial velocity, as you showed, also in the pde function in the model class to evolve the state variables u.

The advection equation is used only in these two model components, and the emission model is independent of the advection equation (only taking the evolved states). Hence, the learning of -v will not affect any other part of the model, and since we use the same equation everywhere throughout the model, the dynamics learned are still advection. We have empirically verified that learning -v does not affect via validating the mass preserving nature of advection (See Appendix H).

If you plot the velocity field, kindly use -v as it will show the true velocity, as learning -v is just a negative direction of v and is consistent with the advection equation used in the model. The advection equation in the paper and used in the code is conceptually the same; it's just a matter of implementation choice that we learn -v instead of v, but the state still follows advection.

I will also add a note in the repo mentioning that to clarify it.

yogeshverma1998 commented 1 month ago

Hi,

Due to inactivity, I assume the issue has been resolved and am closing it. If you have any other questions, feel free to open another issue.

Yumenomae commented 1 month ago

Hi,

It was an oversight on my part that I forgot to close the issue. Thank you very much for your answer.     ------------------ Original ------------------ From: @.>; Date:  Wed, Aug 28, 2024 10:22 PM To: @.>; Cc: @.>; @.>; Subject:  Re: [Aalto-QuML/ClimODE] Mismatch between code and equation given in the paper (Issue #2)

 

Hi,

Due to inactivity, I assume the issue has been resolved and am closing it. If you have any other questions, feel free to open another issue.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>