A PyTorch implementation of SPILSNet (Spatiotemporal Physics-derived Internal Latent Space Network)
Project description
SPILSNet-Torch
A high-performance PyTorch implementation of SPILSNet (Spatiotemporal Physics-derived Internal Latent Space Network).
SPILSNet is designed for modeling complex dynamical systems where preserving physical structure (like spatial relationships and temporal consistency) is critical. It combines convolutional encoders for spatial feature extraction with a Gated Recurrent Unit (GRU) core to capture temporal evolution, while maintaining a learned skip-connection architecture to preserve high-frequency details.
Features
- Unified Non-Pickle Serialization: Industry-standard
safetensorsformat for weights and metadata (config, scalers), ensuring cross-platform safety and performance. - Physics-derived Temporal Dynamics: GRU-based core for robust state-space modeling.
- Flexible Scaling: Built-in support for Scikit-learn scalers and custom transformers (e.g., CubeRoot).
- Professional Engineering: Full type hinting, Google-style docstrings, and robust serialization.
- Extensible Loss: Custom
spils_lossincluding Laplacian smoothness terms for spatial consistency.
Installation
Install via pip:
pip install spilsnet-torch
For development:
git clone https://github.com/andinoboerst/spilsnet-torch.git
cd spilsnet-torch
pip install -e ".[dev]"
Quick Start
import numpy as np
import torch
from spilsnet import SPILSNet
from sklearn.preprocessing import StandardScaler
# 1. Configure the architecture
model_config = {
"dimension": 2, # 2D coordinates (x, y)
"input_size": 102, # 51 nodes * 2 dimensions
"internal_state_size": 16, # Size of physical internal states
"encoder_structure": [
{"out": 32, "k": 3, "s": 1, "p": 1},
{"out": 16, "k": 3, "s": 1, "p": 1},
],
"bottleneck_pool_size": 4,
"latent_dim": 32,
"gru_hidden_size": 64,
"latent_encoder_mlp": [64, 64],
"internal_input_mlp": [32],
"internal_output_mlp": [32],
"dropout_rate": 0.1,
}
# 2. Initialize the wrapper
model = SPILSNet(
model_config=model_config,
input_scaler_class=StandardScaler(),
internal_in_scaler_class=StandardScaler(),
internal_out_scaler_class=StandardScaler(),
output_scaler_class=StandardScaler()
)
# 3. Fit the model
# X: [Sims, Steps, Input_Size], Y: [Sims, Steps, Output_Size], I: [Sims, Steps, Internal_Size]
X, Y, I = np.random.randn(10, 50, 102), np.random.randn(10, 50, 102), np.random.randn(10, 50, 16)
model.fit(X, Y, I)
# 4. Sequential Inference
model.initialize_memory_variables()
current_x = np.random.randn(102)
next_y = model.predict(current_x)
print(f"Predicted next state shape: {next_y.shape}")
Testing
Run the test suite using pytest:
pytest
To run with coverage:
pytest --cov=spilsnet
License
This project is licensed under the AGPL 3.0 License - see the LICENSE file for details.
Citation
If you use this code in your research, please cite the associated paper and this repository.
Paper Citation
@article{boerst2026spilsnet,
title={Accelerating Transient Structural Dynamics via SPILS-Net, a Physics-Derived Latent Space Subdomain Surrogate},
author={Börst, Andino and Díez, Pedro and Zlotnik, Sergio and Cavaliere, Fabiola and Curtosi, Gabriel and Larráyoz, Xabier},
journal={Computer Methods in Applied Mechanics and Engineering},
year={2026},
doi={[DOI — to be added upon publication]}
}
Software Citation
(this repository, spilsnet-torch, available on PyPI):
@software{boerst_spilsnet_torch_2026,
author={Börst, Andino},
title={spilsnet-torch: PyTorch Implementation of SPILS-Net},
year={2026},
publisher={GitHub},
url={https://github.com/andinoboerst/spilsnet-torch},
doi={10.5281/zenodo.21236781},
version={1.0.1}
}
For machine-readable citation metadata, see CITATION.cff.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spilsnet_torch-1.0.2.tar.gz.
File metadata
- Download URL: spilsnet_torch-1.0.2.tar.gz
- Upload date:
- Size: 56.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b288e4da21de63b123da6edfa0efb8dcb3525f82facbe0e50cc8ef6f6d0f86c
|
|
| MD5 |
1c397a560b75a356e2948509739653c4
|
|
| BLAKE2b-256 |
ff56b08ea862ec4be184fbebb0d3dddfb9588af4a1af1e07ad106b9d6ae35560
|
Provenance
The following attestation bundles were made for spilsnet_torch-1.0.2.tar.gz:
Publisher:
publish.yml on andinoboerst/spilsnet-torch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spilsnet_torch-1.0.2.tar.gz -
Subject digest:
9b288e4da21de63b123da6edfa0efb8dcb3525f82facbe0e50cc8ef6f6d0f86c - Sigstore transparency entry: 2099839049
- Sigstore integration time:
-
Permalink:
andinoboerst/spilsnet-torch@3786f1e0712937c4595e7dc2c10cc531be963635 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/andinoboerst
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3786f1e0712937c4595e7dc2c10cc531be963635 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file spilsnet_torch-1.0.2-py3-none-any.whl.
File metadata
- Download URL: spilsnet_torch-1.0.2-py3-none-any.whl
- Upload date:
- Size: 41.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4199221354feba651f83cc06b37f463b1ab2360f3eaee225a3d561f4fdd87e77
|
|
| MD5 |
931cf2675d599cb78a295a5459ae45e1
|
|
| BLAKE2b-256 |
3b9c3e98deefd1829388fa5774a4d556acc336427ab87a145b078f21f197c24d
|
Provenance
The following attestation bundles were made for spilsnet_torch-1.0.2-py3-none-any.whl:
Publisher:
publish.yml on andinoboerst/spilsnet-torch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
spilsnet_torch-1.0.2-py3-none-any.whl -
Subject digest:
4199221354feba651f83cc06b37f463b1ab2360f3eaee225a3d561f4fdd87e77 - Sigstore transparency entry: 2099839489
- Sigstore integration time:
-
Permalink:
andinoboerst/spilsnet-torch@3786f1e0712937c4595e7dc2c10cc531be963635 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/andinoboerst
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3786f1e0712937c4595e7dc2c10cc531be963635 -
Trigger Event:
workflow_dispatch
-
Statement type: