pymor.algorithms.ml.nn.utils

Module Contents

class pymor.algorithms.ml.nn.utils.CustomDataset(training_data)[source]

Bases: torch.utils.data.Dataset

Class that represents the dataset to use in PyTorch.

Parameters:

training_data – Set of training parameters and the respective coefficients of the solution in the reduced basis.

class pymor.algorithms.ml.nn.utils.EarlyStoppingScheduler(size_training_validation_parameters, patience=10, delta=0.0)[source]

Bases: pymor.core.base.BasicObject

Class for performing early stopping in training of neural networks.

If the validation loss does not decrease over a certain amount of epochs, the training should be aborted to avoid overfitting the training data. This class implements an early stopping scheduler that recommends to stop the training process if the validation loss did not decrease by at least delta over patience epochs.

Parameters:
  • size_training_validation_parameters – Size of both, training and validation parameters together.

  • patience – Number of epochs of non-decreasing validation loss allowed, before early stopping the training process.

  • delta – Minimal amount of decrease in the validation loss that is required to reset the counter of non-decreasing epochs.

class pymor.algorithms.ml.nn.utils.LRSchedulerWrapper(scheduler, interval='epoch')[source]

Bases: pymor.core.base.BasicObject

Wrapper to handle different LR scheduler interfaces uniformly.

Parameters:
  • scheduler – A PyTorch learning rate scheduler.

  • interval – When to step: 'epoch' or 'batch'.

Methods

step

Step the scheduler, passing metrics if required.

step(metrics=None)[source]

Step the scheduler, passing metrics if required.