-
Notifications
You must be signed in to change notification settings - Fork 166
Adding notebooks for Fourier Neural Operator #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…, loss defintions etc
drgona
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this syntax will work for custom loss functions
h1_obj = Loss( ["y_fno", "y_grid"], lambda yhat, y: h1_loss_fn(yhat.squeeze(1), y.squeeze(1)), name="h1_loss_fn", )
but it is uncecessarily verbose, any pytorch callable works on neuromancer variables.
You could define yhat and y to be neuromancer variables and then simply call:
h1_var = h1_loss_fn(yhat, y)
to instantiate new variable h1_var, then you can either use h1_var.minimize() or h1_var ==0 to instantiate objective or constraint term
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this syntax will work for custom loss functions
h1_obj = Loss( ["y_fno", "y_grid"], lambda yhat, y: h1_loss_fn(yhat.squeeze(1), y.squeeze(1)), name="h1_loss_fn", )but it is uncecessarily verbose, any pytorch callable works on neuromancer variables.
You could define yhat and y to be neuromancer variables and then simply call:
h1_var = h1_loss_fn(yhat, y)
to instantiate new variable h1_var, then you can either use h1_var.minimize() or h1_var ==0 to instantiate objective or constraint term
Not sure if this will work, as h1_loss_fn is an H1Loss instance that expects real tensors and not Neuromancer variables.
I tried this
y_true = variable("y_grid") # ground-truth field in your datadict
y_hat_fno = variable("y_fno") # output from the FNO node
h1_var = h1_loss_fn(y_hat_fno, y_true)
h1_constraint = (h1_var).minimize()
This snippet might just work for h1loss, witohut needing the H1loss module. It follows from the https://github.com/pnnl/neuromancer/blob/master/examples/ODEs/Part_2_param_estim_ODE.ipynb example |
this would work for more didactical exposure of the loss construction. |
|
I've added 3 different ways to formulate this loss, for your review |
approach 1 and approach 2 are both good, we can discuss on Wednesday which one to pick |
Implemented FNO notebooks
Darcy Flow (Darcy Flow example from the
neuraloplibrary):examples/NOs/Part_1_FNO_DarcyFlow.ipynbInspiration: https://neuraloperator.github.io/dev/auto_examples/models/plot_FNO_darcy.html
Diffusion Equation (original PINN example adapted to grid-based data):
examples/NOs/Part_1_FNO_DiffusionEquation.ipynbInspiration:
examples/PDEs/Part_1_PINN_DiffusionEquation.ipynbFeatures
FNO Wrapper (
src/neuromancer/modules/operators.py)Provides a thin interface that enables direct use of
neuralopmodules while attaching the required_metadatafor checkpoint compatibility across PyTorch versions. This approach generalizes to any Neural Operator from theneuraloplibrary.Custom Losses
Implementation of
LpLossandH1Lossinsrc/neuromancer/modules/operators.py.Future Task (Non-blocking)
Pseudocode