deepxde icon indicating copy to clipboard operation
deepxde copied to clipboard

Manual loss weights adaptation in TF2.0

Open haison19952013 opened this issue 1 year ago • 3 comments

What?

  • Supported and tested backend: tensorflow
  • Details:
    • Provide a way to change the loss weights dynamically via callbacks without the need to recompile the model
    • Currently works for non-gradient-based adaptive loss weight scheme

Why?

  • Motivation
  • Help deepxde users can formulate their non-gradient-based adaptive loss weights scheme

How?

  • In model.py:
    • Add loss_weights as instances for functions that work for tensorflow backend
  • In callbacks.py, give some examples on how to define a calback to change the loss_weights
    • Add ManualDynamicLossWeight: to change the loss weights based on the specified index
    • Add PrintLossWeight: to display the loss weights based on the specified period

Testing?

  • A working example is given in deepxde\examples\pinn_inverse\elliptic_inverse_field_manual_dynamic_loss_weights.py

Future work

  • Work on gradient-based adaptive loss weight scheme

haison19952013 avatar Feb 18 '24 04:02 haison19952013

Format the code via black https://github.com/psf/black

lululxvi avatar Feb 18 '24 17:02 lululxvi

Format the code via black https://github.com/psf/black

Updated

haison19952013 avatar Feb 24 '24 05:02 haison19952013

@haison19952013, do you plan to keep working on this PR? If not, I will continue the work.

pescap avatar Jun 05 '24 13:06 pescap