AdamCobb / hamiltorch

PyTorch-based library for Riemannian Manifold Hamiltonian Monte Carlo (RMHMC) and inference in Bayesian neural networks
BSD 2-Clause "Simplified" License
426 stars 63 forks source link

Custom model_loss for Bayesian PINN #15

Open izzatum opened 3 years ago

izzatum commented 3 years ago

Hi! Is there any way to use Hamiltorch for Bayesian PINN, especially in calling fmodel in each iteration to evaluate the PDE loss?

AdamCobb commented 3 years ago

Hi!

You might be able to use the callable custom loss by setting model_loss = foo(output, y).

This is written here:

https://github.com/AdamCobb/hamiltorch/blob/bfa6ece60e71c0b08fcb03fadeb0f1f1c3e53d10/hamiltorch/samplers.py#L1150

All the best,

Adam

zzhang222 commented 2 years ago

Hi,

I don't think it's possible to use the current custom loss to incorporate PDE loss, since the PDE loss includes the term grad(output, x) However, you can write a Bayesian PINN by writing an nn.Module that outputs grad(output, x) as well as the boundary condition in its forward function and set model_loss = "regression". I tried that and it works. Hope that helps.

zzhang222 commented 2 years ago

Hi! Is there any way to use Hamiltorch for Bayesian PINN, especially in calling fmodel in each iteration to evaluate the PDE loss?

I just created a repository, check it out if you are interested: https://github.com/zzhang222/Bayesian-PINN-Pytorch

izzatum commented 2 years ago

Hi! Great thanks! It is really awesome!

On Wed, Mar 9, 2022 at 6:26 PM zzhang222 @.***> wrote:

Hi! Is there any way to use Hamiltorch for Bayesian PINN, especially in calling fmodel in each iteration to evaluate the PDE loss?

I just created a repository, check it out if you are interested: https://github.com/zzhang222/Bayesian-PINN-Pytorch https://urldefense.com/v3/__https://github.com/zzhang222/Bayesian-PINN-Pytorch__;!!Nmw4Hv0!jqsX1GqvLSVw7_jaEQx8E4sdhF-qXgjprcBUaOZ0OTDF-qpgVzPIdfidSumiLsO1_vulmLh_sfuV$

— Reply to this email directly, view it on GitHub https://urldefense.com/v3/__https://github.com/AdamCobb/hamiltorch/issues/15*issuecomment-1063039103__;Iw!!Nmw4Hv0!jqsX1GqvLSVw7_jaEQx8E4sdhF-qXgjprcBUaOZ0OTDF-qpgVzPIdfidSumiLsO1_vulmInVgw-p$, or unsubscribe https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/ALH7GBDAAHGRQUH6DEFKMI3U7C7K5ANCNFSM5AIYT4YQ__;!!Nmw4Hv0!jqsX1GqvLSVw7_jaEQx8E4sdhF-qXgjprcBUaOZ0OTDF-qpgVzPIdfidSumiLsO1_vulmHjrTxgf$ . Triage notifications on the go with GitHub Mobile for iOS https://urldefense.com/v3/__https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675__;!!Nmw4Hv0!jqsX1GqvLSVw7_jaEQx8E4sdhF-qXgjprcBUaOZ0OTDF-qpgVzPIdfidSumiLsO1_vulmMGbASVm$ or Android https://urldefense.com/v3/__https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign*3Dnotification-email*26utm_medium*3Demail*26utm_source*3Dgithub__;JSUlJSU!!Nmw4Hv0!jqsX1GqvLSVw7_jaEQx8E4sdhF-qXgjprcBUaOZ0OTDF-qpgVzPIdfidSumiLsO1_vulmJVKP6ZG$.

You are receiving this because you authored the thread.Message ID: @.***>

-- Muhammad Izzatullah King Abdullah University of Science and Technology (KAUST) Division of Physical Sciences and Engineering Bldg. 1, #0202-WS023 Thuwal 23955-6900, Kingdom of Saudi Arabia

Tel.: +966 (56) 569 7388 Email: @.***

--

This message and its contents, including attachments are intended solely for the original recipient. If you are not the intended recipient or have received this message in error, please notify me immediately and delete this message from your computer system. Any unauthorized use or distribution is prohibited. Please consider the environment before printing this email.