Importance Sampling Based on PDE Loss

I’m interested in using importance sampling based on the local PDE error, however there is no existing computable variable in the computational graph representing PDE error. Is there a better way to implement this than rewriting the PDE loss calculation within the importance model graph? It seems inefficient to have to calculate PDE loss at each collocation point twice (one for importance sampling and a second time for loss formulation)

Hi @rohan.patel

The PDE error is typically the residual produced from the PDE nodes. If the residual isn’t the right quantity you’re interested in consider adding another Node (for example the Node.from_sympy() is quite useful) that calculates this quantity for you.

For importance sampling, the calculation of the measure will always occur at the defined resample frequency. If performance is an issue, consider creating this dataset manually and then constructing a pointwise constraint.

The challenge here is that the importance function needs to be recalculated for the entire dataset of points (not just 1 mini-batch). Additionally there is no guarantee that all points will be used before a resampling, thus the most straight forward solution is to periodically have repeat work.