NVIDIA / modulus-sym

Framework providing pythonic APIs, algorithms and utilities to be used with Modulus core to physics inform model training as well as higher level abstraction for domain experts
https://developer.nvidia.com/modulus
Apache License 2.0
165 stars 68 forks source link

🐛[BUG]: Validator L2 Relative Error Loss #96

Open BoomChawit opened 9 months ago

BoomChawit commented 9 months ago

Version

v1.3.0

On which installation method(s) does this occur?

No response

Describe the issue

I would like to report an issue in modulus/sym/domain/validator/validator.py.

As in lines 39 - 42, the L2 relative error is written as

$$ e{L^2} = \sqrt{\frac{ \frac{1}{N} \sum{i} \left( u_{truei} - u{pred_i} \right)^2} {\frac{1}{N-\delta N} \sumi \left(u{truei} - \overline{u}{true}\right)^2}} $$

new_var["l2_relative_error_" + str(key)] = torch.sqrt(
                torch.mean(torch.square(true_var[key] - pred_var[key]))
                / torch.var(true_var[key])
            )

However, I understand that the L2 relative error is defined as

$$ e{L^2} = \sqrt{ \frac{ \sum{i} \left( u_{truei}-u{pred_i} \right)^2} {\sumi \left(u{true_i}\right)^2} } $$

new_var["l2_relative_error_" + str(key)] = torch.sqrt(
                torch.sum(torch.square(true_var[key] - pred_var[key]))
                /  torch.sum(torch.square(true_var[key]))
            )

Regarding the validation loss, I would like to bring up this concern. If I misunderstand the concept of the function, please correct my understanding. Thank you very much for your consideration.

Minimum reproducible example

No response

Relevant log output

No response

Environment details

No response

Other/Misc.

No response