Sapsan project
Project description
Sapsan
Intro
Sapsan is a pipeline for easy Machine Learning implementation in scientific projects. That being said, its primary goal and featured models are geared towards dynamic MHD turbulence subgrid modeling. Sapsan will soon feature Physics-Informed Machine Learning models in its set of tools to accurately capture the turbulent nature applicable to Core-Collapse Supernovae.
Feel free to check out a website version at sapsan.app. The interface is indentical to the GUI of the local version of Sapsan, except lacking the ability to edit the model code on the fly.
Note: currently Sapsan is in alpha, but we are actively working on it and introduce new feature on a daily basis.
Getting Started
To get started, clone this repo and install the requirements
git clone https://github.com/pikarpov-LANL/Sapsan.git
cd Sapsan/
pip install -r requirements.txt
If you want to use the GPU enabled version then change the last line to
pip install -r requirements_gpu.txt
or you can install sapsan via pip
pip install sapsan
Graphical Interface
We've built a Sapsan configuration and running interface with Streamlit. In order to run it type in the following and follow the instrucitons - the interface will be opened in your browser.
streamlit run examples/GUI/st_intro.py
Command Line Interface
Please run an example to make sure everything has been installed correctly. It is a jupyter notebook which can be found here:
Sapsan/examples/cnn_example.ipynb
In order to get started on your own project, you can use the command-line-interface interface:
sapsan create --name awesome
Structure
Structure of project is build around few concepts making this project easier to extend to more cases. Core abstractions are: estimator, dataset, experiment, tracking backend Core abstraction are defined in models.py file.
Estimator
General abstraction for models/algorithms.
Available estimators
How to implement new estimator:
Extend Estimator
class and implement train
, predict
and metrics
methods.
from sapsan.core.models import Estimator, EstimatorConfiguration
class AwesomeEstimator(Estimator):
def __init__(self, config: EstimatorConfiguration):
super().__init__(config)
self.model = ... # your awesome model
def train(self, inputs, labels):
# fit model to labels
return self.model
def predict(self, inputs):
prediction = ... # derive prediction from inputs
return prediction
def metrics(self):
return {"training_time": 146, "training_avg_loss": 42}
Dataset
General abstraction for dataset/dataframes.
Available datasets
How to implement new dataset:
Extend Dataset
class and impement load
method.
import numpy as np
from sapsan.core.models import Dataset
class RandomDataset(Dataset):
def __init__(self, n_entries: int, n_features: int):
self.n_entries = n_entries
self.n_features = n_features
def load(self):
return np.random.random((self.n_entries, self.n_features))
Experiment
General abstraction for experiments.
Available experiments
- general training experiment
- evaluation 1d experiment
- evaluation 3d encoder experiment
- evaluation 3d autoencoder experiment
How to implement new experiment:
Extend Experiment
class and impement run
method.
from sapsan.core.models import Experiment, ExperimentBackend
class AwesomeExperiment(Experiment):
def __init__(self, name: str, backend: ExperimentBackend):
super().__init__(name, backend)
def run(self):
# do whatever you need to execute during experiment
return {}
Tracking backend
General abstraction for experiment tracker.
Available tracking backends
How to implement new experiment:
Extend ExperimentBackend
class and impement log_metric
, log_parameter
, log_artifact
methods.
from sapsan.core.models import ExperimentBackend
class InMemoryTrackingBackend(ExperimentBackend):
def __init__(self, name: str):
super().__init__(name)
self.metrics = []
self.parameters = []
self.artifacts = []
def log_metric(self, name, value):
self.metrics.append((name, value))
def log_parameter(self, name, value):
self.metrics.append((name, value))
def log_argifact(self, path):
self.artifacts.append(path)
Examples
Examples of implemented experiments.
- 3d convolution encoder example
- 3d audoencoder example (coming soon!)
- KRR 1d estimator (coming soon!)
CLI
To use structure of Sapsan and CI/CD capabilities run
sapsan create <NAME>
cd <NAME>
git init
git remote add origin <YOUR_REPOSITORY_ORIGIN>
git add .
git commit -m "Initial commit"
git push origin master
<NAME>
can be research
for example.
Examples
Local via docker compose
docker-compose build
docker-compose up --force-recreate
Then open browser at localhost:8888
© (or copyright) 2019. Triad National Security, LLC. All rights reserved. This program was produced under U.S. Government contract 89233218CNA000001 for Los Alamos National Laboratory (LANL), which is operated by Triad National Security, LLC for the U.S. Department of Energy/National Nuclear Security Administration. All rights in the program are reserved by Triad National Security, LLC, and the U.S. Department of Energy/National Nuclear Security Administration. The Government is granted for itself and others acting on its behalf a nonexclusive, paid-up, irrevocable worldwide license in this material to reproduce, prepare derivative works, distribute copies to the public, perform publicly and display publicly, and to permit others to do so.
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
File details
Details for the file sapsan-0.1.5.tar.gz
.
File metadata
- Download URL: sapsan-0.1.5.tar.gz
- Upload date:
- Size: 36.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c382fb82bbac5602745336d037fe6628efbd61b4548136e2c3d9bf6ef0fba5c7 |
|
MD5 | 6b131e459c459a584a02552eb5e09013 |
|
BLAKE2b-256 | f7105ba924db5ee97501bad4959ec390e8804ff37d335cf8fa4b99926dcbec68 |
Provenance
File details
Details for the file sapsan-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: sapsan-0.1.5-py3-none-any.whl
- Upload date:
- Size: 52.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 063b141de7a371b8a0793c4d0b2162c9f06728f3846ab7e15e73dadc010477ab |
|
MD5 | 89ea3de0e38bdf5648ef9c6633111d8c |
|
BLAKE2b-256 | 4cd3592d3a4cf0ad337fb5307ab374ce6a08dbfd023616ce54ad650fe5dd7ee0 |