Base Refinement#
- class BaseRefinement(sample_every, condition_to_update=None)[source]#
Bases:
Callback,RefinementInterfaceBase class for all refinement strategies, implementing common functionality.
A refinement strategy is responsible for dynamically updating the training dataset during optimization, typically by resampling points in the domain based on model behavior (e.g., error-driven refinement).
All specific refinement strategies should inherit from this class and implement its abstract methods.
This class is not meant to be instantiated directly.
Initialization of the
BaseRefinementclass.- Parameters:
- Raises:
AssertionError – If
sample_everyis not a positive integer.ValueError – If
condition_to_update, when provided, is not a string or an iterable of strings.
- on_train_start(trainer, solver)[source]#
This method is called once before training begins and is typically used to initialize datasets, sampling conditions, or internal state.
- Parameters:
trainer (Trainer) – The trainer managing the training loop.
solver (BaseSolver) – The solver associated with the trainer.
- Raises:
RuntimeError – If the solver is not physics-informed (i.e., does not implement PINNInterface).
RuntimeError – If any of the specified conditions do not exist in the problem.
RuntimeError – If any of the specified conditions do not have a ‘domain’ attribute for sampling.
- on_train_epoch_end(trainer, solver)[source]#
Apply refinement at the end of a training epoch.
This method is invoked after each epoch and can update the dataset based on the current state of the model.
- Parameters:
trainer (Trainer) – The trainer managing the training loop.
solver (BaseSolver) – The solver associated with the trainer.
- property dataset#
The training datasets managed by the refinement strategy.
The dataset is stored as a dictionary whose keys are condition names and whose values are the corresponding dataset subsets. The content of this dictionary can be updated dynamically during refinement.
- Returns:
The mapping between condition names and dataset subsets.
- Return type: