A fully-comprehensive library for Physics-Informed Deep Learning under uncertainty
π Requirements
βοΈ Installation
Windows
- Go into the directory of your project with
cd project_folder_path
- Create an empty virtual environment with
py -m venv .\my_env_name
- Enter into the virtual environment with
my_env_name\scripts\activate
- Check that the environment is empty with
pip freeze
; normally, it should print nothing - Install the required packages from the
.txt
filerequirements.txt
withpip install -r requirements.txt
- Run again
pip freeze
and check that the environment is no longer empty - Add the environment folder to your
.gitignore
(in order to avoid pushing the packages on git!)
To exit from the virtual environment, use deactivate
Mac and Linux
- Go into the directory of your project with
cd project_folder_path
- Create an empty virtual environment with
virtualenv .\my_env_name
- Enter into the virtual environment with
source my_env_name\bin\activate
- Check that the environment is empty with
pip freeze
; normally, it should print nothing - Install the required packages from the
.txt
filerequirements.txt
withpip install -r requirements.txt
- Run again
pip freeze
and check that the environment is no longer empty - Add the environment folder to your
.gitignore
(in order to avoid pushing the packages on git!)
To exit from the virtual environment, use deactivate
π Repository Structure
- π
config
contains.json
files which encode the options and parameter choices for the test cases proposed. - π
data
contains the dataset for each test case. In each subfolder, you can find.npy
files storing inputs, solution and parametric field values. They are stored separately, according to the category of data they belong to (such as fitting data, collocation data...).
In particular, we have:- Boundary data:
dom_bnd.npy
,sol_bnd.npy
for the coordinates and solution values of boundaries; - Collocation data:
dom_pde.npy
for the coordinates of collocation points; - Fitting data:
dom_sol.npy
,sol_train.npy
anddom_par.npy
,par_train.npy
for coordinate and values couples for solution and/or parametric field; - Test data:
dom_test.npy
,sol_test.npy
,par_test.npy
for coordinate and function values of test points.
- Boundary data:
- π
outs
contains the results for each test case. In each subfolder, you can find the folders:log
with loss history and summary of the experiment options and errors in.txt
filesplot
with the plotsthetas
with network parametersvalues
with the solution computed by the network
- π
src
contains the source code, described in detail in the section below.
π» Source Code
main.py
is the executable script, relying on all the below modules.main_data.py
is a script that can be run independently from the main and it generates a new data subfolder for each new test case.main_loader.py
is a script that can be run independently from the main and it reloads a test case already present inouts
.- π
setup
is a module containing:- the class to parse command line arguments (in
args.py
) - the class to set parameters (in
param.py
), reading them both from the configuration files and from command line data_creation.py
contains the class for dataset creation starting from raw data stored in the folderdata
data_generator.py
contains the class to generate raw datadata_loader.py
defines the data loader class (now not in use)
- the class to parse command line arguments (in
- π
utility
contains technical auxiliary tasks, in particular:switcher.py
switches to the test case under analysis among the files contained in the three folders belowdirectories.py
generates directories for data generation and results storagemiscellaneous.py
contains utility functions for all other purposes
- π
algorithms
is a module containing classes representing the training algorithms proposed in this project:ADAM
: Adaptive Moment EstimationHMC
: Hamiltionian Monte CarloSVGD
: Stein Variational Gradient DescentVI
: Variational Inference
The folder includes as well the classTrainer
, used to manage the pre-training and training algorithm.
- π
datasets
contains:- π
config
contains definitions of functions and domains for generating datasets - π
template
contains names and definitions of input and output for generating datasets
- π
- π
equations
contains the differential operators library (Operators.py
) and, in separate files, the definition of physical loss and dataset pre/post processing criteria for each problem studied - π
networks
contains classes for each part of the Bayesian Neural Network. The network built is an instance of the classBayesNN
, which inherits methods and attributes fromLossNN
andPredNN
, having the loss computation and the prediction/post-processing functionalities, respectively. In turn, the above classes inherit fromCoreNN
, representing a basic fully connected network).
Network weights and biases are instances of the classTheta
, which contains the overloading of some operators for an easier managements of lists of tensors. - π
postprocessing
is a module with:- the class
Plotter
to generate the plots and save them in the folderouts
- the class
Storage
to store and load results, uncertainty quantification study, loss history and network parameters
- the class
π Main References
- B-PINNs: Bayesian Physics-Informed Neural Networks for Forward and Inverse PDE Problems with Noisy Data, Liu Yang, Xuhui Meng, George Em Karniadakis, Mar 2020.
- Bayesian Physics Informed Neural Networks for real-world nonlinear dynamical systems, Kevin Linka, Amelie SchΓ€fer, Xuhui Meng, Zongren Zou, George Em Karniadakis, and Ellen Kuhl., May 2022.
- Bayesian Physics-Informed Neural Networks for Inverse Uncertainty Quantification problems in Cardiac Electrophysiology, Master Thesis at Politecnico di Milano by Daniele Ceccarelli.
π¬ Authors
- Giulia Mescolini (@giuliamesc)
- Luca Sosta (@sostaluca)
π Tutors
- Stefano Pagani (@StefanoPagani)
- Andrea Manzoni