vindy.callbacks package

Submodules

vindy.callbacks.pdf_threshold_callback module

class PDFThresholdCallback(freq=1, threshold=1, on_train_end=False, **kwargs)[source]

Bases: Callback

cancel_coefficients()[source]

Cancel the coefficients of the SINDy layer if their corresponding probability density function at zero is above the threshold, i.e. if pdf(0) > self.threshold

Return type:

None

on_epoch_end(epoch, logs=None)[source]

Called at the end of an epoch.

Subclasses should override for any actions to run. This function should only be called during TRAIN mode.

Args:

epoch: Integer, index of epoch. logs: Dict, metric results for this training epoch, and for the

validation epoch if validation is performed. Validation result keys are prefixed with val_. For training epoch, the values of the Model’s metrics are returned. Example: {‘loss’: 0.2, ‘accuracy’: 0.7}.

on_train_end(logs=None)[source]

Called at the end of training.

Subclasses should override for any actions to run.

Args:
logs: Dict. Currently the output of the last call to

on_epoch_end() is passed to this argument for this method but that may change in the future.

vindy.callbacks.save_coefficients_callback module

class SaveCoefficientsCallback(freq=1, **kwargs)[source]

Bases: Callback

on_epoch_end(epoch, logs=None)[source]

Called at the end of an epoch during training.

Parameters:
  • epoch (int) – The current epoch number.

  • logs (dict, optional) – Dictionary of logs from the training process.

vindy.callbacks.sindy_callback module

class SindyCallback(x, dxdt, dxddt, mu, t, freq=100, train_end=False, ensemble=False, subset_size=0.5, n_subsets=100, threshold=0.1, thresholder: str = 'l0', z_names=None, mu_names=None, print_precision=3, **kwargs)[source]

Bases: Callback

Callback for the SINDy layer. This callback is used to update the identified coefficients of the SINDy layer.

call_pySINDy(z_feat, z_dot, times_train, fixed_coeffs, feat_ids, mask)[source]

Fit a separate SINDy model using the provided data and constraints.

Parameters:
  • z_feat (list of array-like) – Latent variables and their features.

  • z_dot (list of array-like) – Time derivatives of latent variables.

  • times_train (array-like) – Time.

  • fixed_coeffs (array-like) – Fixed coefficients for the SINDy model.

  • feat_ids (array-like) – IDs of the selected features.

  • mask (array-like) – Mask specifying which features are used in the SINDy model.

Returns:

Fitted SINDy model.

Return type:

pysindy.SINDy

on_epoch_end(epoch, logs=None)[source]

Perform SINDy update at the end of every specified number of epochs.

Parameters:
  • epoch (int) – Current epoch number.

  • logs (dict, optional) – Dictionary of logs (default is None).

on_train_end(logs=None)[source]

Perform SINDy update at the end of training if specified.

Parameters:

logs (dict, optional) – Dictionary of logs (default is None).

perform_update()[source]

Perform the SINDy update.

prepare_data_for_pysindy(t, z_feat, dzdt, dzddt=None)[source]

Prepare training data for the separate SINDy model.

Parameters:
  • t (array-like) – Time.

  • z_feat (array-like) – Latent variables and their features.

  • dzdt (array-like) – Time derivative of latent variables.

  • dzddt (array-like, optional) – Second time derivative of latent variables (default is None).

Returns:

Prepared latent variables, their time derivatives, and time.

Return type:

tuple

process_data_for_sindy()[source]

Process data for SINDy optimization.

Returns:

Processed latent variables, their time derivatives, time, fixed coefficients, feature IDs, and mask.

Return type:

tuple

update_weights(weights, variance=None)[source]

Update the weights of the SINDy layer.

Parameters:
  • weights (array-like) – Weights to update.

  • variance (array-like, optional) – Variance of the weights (default is None).

vindy.callbacks.spotify_callback module

class SpotifyCallback(song_link='https://open.spotify.com/track/3cHyrEgdyYRjgJKSOiOtcS?si=3281ab97ddde4286', n_epochs=20)[source]

Bases: Callback

on_epoch_end(epoch, logs=None)[source]

Called at the end of an epoch during training.

Parameters:
  • epoch (int) – The current epoch number.

  • logs (dict, optional) – Dictionary of logs from the training process.

vindy.callbacks.threshold_prune_callback module

class ThresholdPruneCallback(freq=1, threshold=0.01, on_train_end=False, start_epoch=0)[source]

Bases: Callback

on_epoch_end(epoch, logs=None)[source]

Called at the end of an epoch during training.

Parameters:
  • epoch (int) – The current epoch number.

  • logs (dict, optional) – Dictionary of logs from the training process.

on_train_end(logs=None)[source]

Called at the end of training.

Parameters:

logs (dict, optional) – Dictionary of logs from the training process.

prune_weights()[source]

Prune the weights of the SINDy layer if their value is below the threshold.

Return type:

None

Module contents