Refinments callbacks#
- class R3Refinement(sample_every, residual_loss=<class 'torch.nn.modules.loss.L1Loss'>, condition_to_update=None)[source]#
Bases:
BaseRefinementRefinement strategy based on the R3 (Retain-Resample-Release) algorithm.
This method adaptively updates collocation points by retaining points with high residuals, resampling new points in the domain, releasing points with low residuals.
The objective is to concentrate sampling in regions where the PDE residual is large, improving training efficiency and solution accuracy.
See also
Original Reference: Daw, Arka, et al. (2023). Mitigating Propagation Failures in Physics-informed Neural Networks using Retain-Resample-Release (R3) Sampling. DOI: 10.48550/arXiv.2207.02338
- Example:
>>> r3 = R3Refinement(sample_every=5)
Initialization of the
R3Refinementclass.- Parameters:
sample_every (int) – The number of epochs between successive refinement steps.
residual_loss (DualLossInterface | torch.nn.modules.loss._Loss) – The loss used to evaluate residual magnitude. Must be a subclass of
torch.nn.Moduleorpina.loss.DualLossInterface. Default istorch.nn.L1Loss.condition_to_update (str | list[str] | tuple[str]) – The condition(s) to be updated during refinement. If
None, all conditions associated with a domain are updated. Default isNone.
- Raises:
ValueError – If the condition_to_update is neither a string nor an iterable of strings.
ValueError – If the residual_loss is not a valid loss class.
- sample(current_points, condition_name, solver)[source]#
Generate new sample points for a given condition.
- Parameters:
current_points (LabelTensor) – The existing points in the domain.
condition_name (str) – The identifier of the condition to refine.
solver (BaseSolver) – The solver used for sampling decisions.
- Returns:
Newly sampled points.
- Return type: