deepxde
deepxde copied to clipboard
Manual loss weights adaptation in TF2.0
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
- Provide a way to change the loss weights dynamically via
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 fortensorflow
backend
- Add
- In callbacks.py, give some examples on how to define a
calback
to change theloss_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
- Add
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
Format the code via black https://github.com/psf/black
Format the code via black https://github.com/psf/black
Updated
@haison19952013, do you plan to keep working on this PR? If not, I will continue the work.