pyshred.objects package#
Submodules#
pyshred.objects.dataset module#
- class pyshred.objects.dataset.TimeSeriesDataset(X, Y)[source]#
Bases:
DatasetPyTorch Dataset for time series sensor data and corresponding full-state measurements.
- Parameters:
X (torch.Tensor) – Input sensor sequences of shape (batch_size, lags, num_sensors).
Y (torch.Tensor) – Target full-state measurements of shape (batch_size, state_dim).
- Variables:
X (torch.Tensor) – Sensor measurement sequences.
Y (torch.Tensor) – Full-state target measurements.
len (int) – Number of samples in the dataset.
pyshred.objects.sindy module#
- class pyshred.objects.sindy.E_SINDy(num_replicates, latent_dim, library_dim, poly_order, include_sine)[source]#
Bases:
ModuleEnsemble Sparse Identification of Nonlinear Dynamics (E-SINDy) module.
An ensemble version of SINDy that uses multiple replicate models to improve robustness and handle noise in the data.
- Parameters:
num_replicates (int) – Number of SINDy models in the ensemble.
latent_dim (int) – Dimension of the latent space.
library_dim (int) – Dimension of the feature library.
poly_order (int) – Order of polynomial terms in the library.
include_sine (bool) – Whether to include sine functions in the library.
- Variables:
coefficients (torch.nn.Parameter) – Learnable coefficients for all ensemble members.
coefficient_mask (torch.Tensor) – Binary masks for enforcing sparsity in each ensemble member.
- add_noise(noise=0.1)[source]#
Add noise to coefficients and reset masks.
- Parameters:
noise (float, optional) – Standard deviation of noise to add. Defaults to 0.1.
- forward(h_replicates, dt)[source]#
Forward pass through the E-SINDy ensemble dynamics.
- Parameters:
h_replicates (torch.Tensor) – Current latent states for all replicates, shape (num_data, num_replicates, latent_dim).
dt (float) – Time step size.
- Returns:
Updated latent states for all replicates after one time step.
- Return type:
torch.Tensor
- class pyshred.objects.sindy.SINDy(latent_dim, library_dim, poly_order, include_sine)[source]#
Bases:
ModuleSparse Identification of Nonlinear Dynamics (SINDy) module.
A PyTorch implementation of SINDy for discovering sparse dynamical systems from data. Uses polynomial and optional sine libraries to represent the dynamics with sparse coefficients.
- Parameters:
latent_dim (int) – Dimension of the latent space.
library_dim (int) – Dimension of the feature library.
poly_order (int) – Order of polynomial terms in the library.
include_sine (bool) – Whether to include sine functions in the library.
- Variables:
coefficients (torch.nn.Parameter) – Learnable coefficients of the SINDy model.
coefficient_mask (torch.Tensor) – Binary mask for enforcing sparsity.
- add_noise(noise=0.1)[source]#
Add noise to coefficients and reset mask.
- Parameters:
noise (float, optional) – Standard deviation of noise to add. Defaults to 0.1.