Skip to main content

Sapsan project

Project description

Sapsan Sapsan logo


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 appicable to Core-Collapse Supernovae.

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, simply pull sapsan via pip (or you could clone this repo)

pip install sapsan

Next, 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
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.


Kubeflow

Docs for experiments in kubeflow

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sapsan-0.0.2a0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

sapsan-0.0.2a0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file sapsan-0.0.2a0.tar.gz.

File metadata

  • Download URL: sapsan-0.0.2a0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for sapsan-0.0.2a0.tar.gz
Algorithm Hash digest
SHA256 1ffdfeda2f7e66ec54ef8e2f2a714b10eab989d4d925cc673747340cc789a85b
MD5 cab9cdab7fbbf519261d294223a0f547
BLAKE2b-256 f187a64ed34185c9f8abd38d66627814852e6e5c83d93d3c19c0834c13be5e80

See more details on using hashes here.

Provenance

File details

Details for the file sapsan-0.0.2a0-py3-none-any.whl.

File metadata

  • Download URL: sapsan-0.0.2a0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for sapsan-0.0.2a0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c0a23f3a8bc76fe033161f68c6f9fdc5996babeaf248e5a785919bb38b7adf0
MD5 6594f23c43d345298f018a245e18d97a
BLAKE2b-256 62d637f364b086f4e3745fb33975e8e88901bda83a108212b8def869afc342fa

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page