GPLaSDI
GPLaSDI copied to clipboard
Incompatibility with up-to-date pytorch and numpy
This issue corresponds to the legacy code. The work-in-progress python package has already applied the fix for this issue.
The legacy code currently solves SINDY using the outdated torch/numpy routines at two routines in BurgersEqn1D/utils.py
:
-
find_sindy_coef
usestorch.pinverse
-
solve_sindy
usesnp.linalg.lstsq
Other examples are not examined, but expected to use the same routines.
For torch>=2.3.0
and numpy>=1.26.4
, the internal behaviors of torch.pinverse
and numpy.linalg.lstsq
have been changed, which make them unstable for our use of sindy loss training. Earlier versions of torch
or numpy
may have the same issue.
Currently the solution is:
- Use
torch.linalg.lstsq
insteady oftorch.pinverse
. This is also recommended from pytorch official documentation. - It is not clear
numpy.linalg.lstsq
is unstable. However, it often returns different results thantorch.linalg.lstsq
, given the same system. numpy official documentation says that if there are multiple solutions, the solution with minimal norm is chosen, which could be a reason for this inconsistency. For the best of our practice, it is recommended to use the sametorch.linalg.lstsq
.