Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's missing
DeepXDE has no way to watch live a PINN train. The closest existing tools are:
MovieDumper— accumulates frames but only writes the GIF inon_train_end, after training has already finished.dde.saveplot()— plots the solution and loss history, but only once,after training completes.
Neither gives feedback while the model is still training. Other PINN
libraries (e.g. neurodiffeq's
Monitor1D/Monitor2D)support this: a periodically-refreshed plot of the current
prediction and loss history during training, which is very useful for
spotting divergence, bad loss weighting, or stalled optimization early instead of after a long run.
This feature can be helpful for issues (#2014, #1116).
What this PR adds
dde.callbacks.TrainingMonitor: a newCallbackthat, everyperiodepochs, redraws subplots — the current predicted solution
(optionally against a reference/analytical solution via
y_reference)and the train/test loss history on a log scale.
is no usable interactive Matplotlib backend/display and disables itself
gracefully.
examples/pinn_forward/ode_2nd_with_monitor.py, a dampedharmonic oscillator solved with a PINN, using
TrainingMonitoragainstthe closed-form analytical solution.
examples/pinn_forward/diffusion_1d_with_monitor.py, a monitor added to an already existing example.tests/test_callbacks.py, covering periodic triggering logicand headless-safety under the
Aggbackend.Usage
Test plan
pytest tests/test_callbacks.pypasses (4/4) underMPLBACKEND=Aggexamples/pinn_forward/ode_2nd_with_monitor.pyruns end-to-endimport deepxdeunaffected across the changepylint deepxde/callbacks.pyshows no new warnings beyond thefile's existing baseline
Still in progress
.rstfiles with documentation for ode example