Package: torchlaplace
PyTorch Implementation of Differentiable Laplace ReconstructionsThis library provides Inverse Laplace Transform (ILT) algorithms implemented in PyTorch. Backpropagation through differential equation (DE) solutions in the Laplace domain is supported using the Riemann stereographic projection for better global representation of the complex Laplace domain. For usage for DE representations in the Laplace domain in deep learning applications, see reference[1].InstallationTo install latest stable version:pip install torchlaplaceTo install the latest on GitHub:pip install git+https://github.com/samholt/NeuralLaplace.gitTutorialsTutorial: Laplace ReconstructTutorial: Inverse Laplace Transform AlgorithmsExamplesExamples are placed in theexamplesdirectory.We encourage those who are interested in using this library to take a look atexamples/simple_demo.pyfor understanding how to usetorchlaplaceto fit a DE system.Basic usageThis library provides one main interfacelaplace_reconstructwhich uses a selected inverse Laplace transform algorithm to reconstruct trajectories from a provided parameterized Laplace representation functional $\mathbf{F}(\mathbf{p},\mathbf{s})$,$$\mathbf{x}(t) = \text{inverse laplace transform}(\mathbf{F}(\mathbf{p},\mathbf{s}), t)$$Where $\mathbf{p}$ is a Tensor encoding the initial system state as a latent variable, and $t$ is the time points to reconstruct trajectories for.This can be used byfrom torchlaplace import laplace_reconstruct

laplace_reconstruct(laplace_rep_func, p, t)wherelaplace_rep_funcis any callable implementing the parameterized Laplace representation functional $\mathbf{F}(\mathbf{p},\mathbf{s})$,pis a Tensor encoding the initial state of shape $(\text{MiniBatchSize},\text{K})$.
Where $\text{K}$ is a hyperparameter, and can be set by the user.
Finally,tis a Tensor of shape $(\text{MiniBatchSize},\text{SeqLen})$
or $(\text{SeqLen})$ containing the time points to reconstruct the trajectories for.Note that this is not numerically stable for all ILT methods, however should probably be fine with the defaultfourier(fourier series inverse) ILT algorithm.The parameterized Laplace representation functionallaplace_rep_func, $\mathbf{F}(\mathbf{p},\mathbf{s})$
also takes an input complex value $\mathbf{s}$.
This $\mathbf{s}$ is used internally when reconstructing a specified time point with the selected inverse Laplace transform algorithmilt_algorithm.The biggestgotchais thatlaplace_rep_funcmust be ann.Modulewhen using thelaplace_rep_funcfunction. This is due to internally needing to collect the parameters of the parameterized Laplace representation.To replicate the experiments in [1] see the in theexperimentsdirectory.Keyword arguments forlaplace_rep_funcKeyword arguments:recon_dim(int): trajectory dimension for a given time point. Corresponds to dim $d_{\text{obs}}$. If not explicitly specified, will use the same last dimension ofp, i.e. $\text{K}$.ilt_algorithm(str): inverse Laplace transform algorithm to use. Default:fourier. Available are {fourier,dehoog,cme,fixed_tablot,stehfest}. See api documentation on ILTs for further details.use_sphere_projection(bool): this uses thelaplace_rep_funcin the stereographic projection of the Riemann sphere. DefaultTrue.ilt_reconstruction_terms(int): number of ILT reconstruction terms, i.e. the number of complex $s$ points inlaplace_rep_functo reconstruct a single time point.List of ILT Algorithms:ILT algorithms implemented:fourierFourier Series Inverse[default].dehoogDeHoog (Accelerated version of Fourier) - Slower inference in comparison.cmeConcentrated Matrix Exponentials.fixed_tablotFixed Tablot.stehfestGaver-Stehfest.For most problems, good choices are the defaultfourier. However other ILT algorithms may be more appropriate when using higher ILT reconstruction terms, such as thecmealgorithm. Some allow trade-offs between speed and accuracy, for exampledehoogis very accurate if the representation is known or exact, however is slow and can be unstable to use when learning the correct representation.Detailed documentationFor detailed documentation see theofficial docs.Frequently Asked QuestionsTake a look at ourFAQfor frequently asked questions.ReferencesFor usage for DE representations in the Laplace domain and leveraging the stereographic projection and other applications see:[1] Samuel Holt, Zhaozhi Qian, and Mihaela van der Schaar. "Neural laplace: Learning diverse classes of
differential equations in the laplace domain."International Conference on Machine Learning.2022.[arxiv]If you found this library useful in your research, please consider citing.@inproceedings{holt2022neural,
  title={Neural Laplace: Learning diverse classes of differential equations in the Laplace domain},
  author={Holt, Samuel I and Qian, Zhaozhi and van der Schaar, Mihaela},
  booktitle={International Conference on Machine Learning},
  pages={8811--8832},
  year={2022},
  organization={PMLR}
}