-
Notifications
You must be signed in to change notification settings - Fork 104
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
Feature/Multi-fidelity PINNs #144
base: master
Are you sure you want to change the base?
Conversation
I think this is ready for review! Please let me know what y'all think, especially regarding the changes in the trainer (I'm open to create one in PyTorchLightning as well). |
updating README with new notebooks
lets make this PR to develop branch first before we integrate it into master. |
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 PR looks good to me we can integrate
I like your idea of merging it to develop instead of master, Jan. We can definitely do that. |
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.
Can we clean these training scripts up, e.g.
# Number of epochs
epochs_mf = 50000
# Neuromancer trainer
trainer_mf = Trainer(
problem_mf.to(device),
torch.utils.data.DataLoader(train_data, batch_size=t_train.shape[0],
collate_fn=train_data.collate_fn, shuffle=False),
optimizer=optimizer_mf,
epochs=epochs_mf,
epoch_verbose=5000,
train_metric='train_loss',
dev_metric='train_loss',
eval_metric="train_loss",
warmup=epochs_mf,
device=device,
multi_fidelity=True
)
# Train PINN
best_model_mf = trainer_mf.train()
# Load best trained model
problem_mf.load_state_dict(best_model_mf)
Also for this section, I'd like to leave the dynamics simulators in-house as much as possible, so use ODE or PSL's pendulum class and our integrator examples to generate forward data (instead of solveIVP)
# Compare with numerical solution of ODE solver
# Define the ODE system for numerical solution
def pendulum_ode(t, y):
s1, s2 = y
ds1_dt = s2
ds2_dt = -b/m * s2 - g/L * np.sin(s1)
return [ds1_dt, ds2_dt]
# Initial conditions for numerical solution
y0 = [s1_0, s2_0]
# Time points for numerical solution
t_span = (0, T)
t_eval = np.linspace(0, T, N_cp)
# Solve the ODE numerically
sol = solve_ivp(pendulum_ode, t_span, y0, t_eval=t_eval)
Really good job here. Code-wise only couple minor revisions in the pendulum notebook (see my comment there)
Hopefully this isn't too much of a lift to add the educational and "so what" contexts. Once those are done will be approved. Not trying to be overly picky. It's awesome we are incorporating state-of-the-art methods but as a result, require additional context. Thanks |
Implementation of multi-fidelity PINNs via stacking, as proposed in Howard et al., 2023.
Modifications are based on the creation of a
MultiFidelityMLP
class that inherits fromBlock
, as well as modifications to the loss that require the creation of a custom loss for these types of networks (MultiFidelityLoss
).p.s.: this is still a draft. It will have companion tutorials, unit test updates and TLC on the docstrings.