{"id":19932125,"url":"https://github.com/amazon-science/probconserv","last_synced_at":"2025-08-20T07:31:00.847Z","repository":{"id":139012725,"uuid":"599172445","full_name":"amazon-science/probconserv","owner":"amazon-science","description":"Datasets and code for results presented in the ProbConserv paper","archived":false,"fork":false,"pushed_at":"2024-06-14T20:47:45.000Z","size":36354,"stargazers_count":51,"open_issues_count":0,"forks_count":9,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-12-05T16:22:21.218Z","etag":null,"topics":["conservation-laws","downstream-tasks","partial-differential-equations","porous-media-flow","shock-capturing","uncertainty-quantification"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amazon-science.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-08T15:49:48.000Z","updated_at":"2024-09-04T16:03:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"0f203c6d-d21c-42dc-9690-6e4431c356c7","html_url":"https://github.com/amazon-science/probconserv","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amazon-science%2Fprobconserv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amazon-science%2Fprobconserv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amazon-science%2Fprobconserv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amazon-science%2Fprobconserv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amazon-science","download_url":"https://codeload.github.com/amazon-science/probconserv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230400616,"owners_count":18219831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conservation-laws","downstream-tasks","partial-differential-equations","porous-media-flow","shock-capturing","uncertainty-quantification"],"created_at":"2024-11-12T23:09:10.673Z","updated_at":"2024-12-19T08:09:22.328Z","avatar_url":"https://github.com/amazon-science.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ProbConserv: Probabilistic Framework to Enforce Conservation Laws\n[![wemake-python-styleguide](https://img.shields.io/badge/style-wemake-000000.svg)](https://github.com/wemake-services/wemake-python-styleguide)\n\n![Image](resources/schematic.png)\n\n[Derek Hansen](http://www-personal.umich.edu/~dereklh/), [Danielle C. Maddix](https://dcmaddix.github.io/), [Shima Alizadeh](https://scholar.google.com/citations?user=r3qS03kAAAAJ\u0026hl=en), [Gaurav Gupta](http://guptagaurav.me/index.html), [Michael W. Mahoney](https://www.stat.berkeley.edu/~mmahoney/) \\\n**Learning Physical Models that Can Respect Conservation Laws** \\\n[Proceedings of the 40th International Conference on Machine Learning (ICML)](https://proceedings.mlr.press/v202/hansen23b/hansen23b.pdf), PMLR. 202:12469-12510, 2023.\n\n## Installation\nThis project uses [poetry](https://python-poetry.org/) to manage dependencies.\n\nFrom the root directory:\n```\npoetry install\n```\n\nSome of the plots require certain LaTeX packages are present. On Ubuntu, these are\n```\nsudo apt install cm-super dvipng texlive-latex-extra texlive-fonts-recommended\n```\n\nYou can then use `poetry run` followed by a command, or `poetry shell` to open a shell with the correct virtual environment.\n\nTo run the tests:\n```\npoetry run pytest\n```\nThe code for this project is located in the `deep_pdes` folder. It consists of two libraries, `attentive_neural_process` and  `datasets`, that comprise the models and datasets respectively.\nThese libraries are imported by the scripts in `experiments` that configure and run the specific case studies explored in the ProbConserv paper.\n## Running experiments\nThe experiment code in `deep_pdes/experiment` uses [Hydra](https://hydra.cc/) to manage configuration and run experiments. The different stages of the experiments are broken into distinct commands for easier reproduceability\n- `generate.py`: Generate synthetic datasets for training\n- `train.py`: Train ProbConserv-ANP, ANP, and other baseline methods such as Physics-Informed Neural Networks (PINNs)\n- `analyze.py`: Evaluate the trained models on test datasets and create tables/plots from the results.\n- `plots.py`: Generate all plots used in the submission. Does not use the Hydra CLI but uses the compose API internally.\n\nEach script is run by passing an `+experiments=*` flag. The available experiments can be found in `deep_pdes/experiments/conf/experiments`. For example, to recreate the results on the Stefan GPME setting:\n```\nEXPERIMENT=2b_stefan_var_p\n\npython generate.py +experiments=$EXPERIMENT\npython train.py +experiments=$EXPERIMENT +train=${EXPERIMENT}_anp\npython train.py +experiments=$EXPERIMENT +train=${EXPERIMENT}_pinp\npython analyze.py +experiments=$EXPERIMENT\n```\nThese commands are also available in convenience scripts; for example, the above is in `deep_pdes/experiments/2b_stefan_var_p.sh`.\n\n![Image](resources/stefan_solution_profile_UQ) \\\n**Solution Profiles and UQ for the Stefan Equation** \\\n![Image](resources/stefan_shock_position_downstream_task) \\\n**Downstream Task: Shock location detection**\n\nFor the diffusion equation with constant diffusivity, see  `deep_pdes/experiments/3b_heat_var_c.sh`.\n![Image](resources//diffusion_eqtn_conserv_mass.png) \\\n**Conservation of mass** can be violated by the black-box deep learning models, even with applying the PDE as a soft-constraint to the loss function a la Physics informed Neural Networks (PINNs). The true mass for this diffusion equation is zero over time since there is zero net flux from the domain boundaries and mass cannot be created or destroyed on the interior.\n\n## Sources\nThis repo contains modified versions of the code found in the following repos:\n- `https://github.com/a1k12/characterizing-pinns-failure-modes`: For diffusion/heat equation analytical solution (MIT license)\n- `https://github.com/soobinseo/Attentive-Neural-Process`: For implementation of the Attentive Neural Process (Apache 2.0 license)\n\n## Citation\nIf you use this code, or our work, please cite:\n```\n@inproceedings{hansen2023learning,\n  title={Learning Physical Models that Can Respect Conservation Laws},\n  author={Hansen, Derek and Maddix, Danielle C. and Alizadeh, Shima and Gupta, Gaurav and Mahoney, Michael W},\n  booktitle={International Conference on Machine Learning},\n  year={2023},\n  volume = {202},\n  pages={12469-12510},\n  organization={PMLR}      \n}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famazon-science%2Fprobconserv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famazon-science%2Fprobconserv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famazon-science%2Fprobconserv/lists"}