Skip to main content

Standardize your ML projects

Project description

https://img.shields.io/badge/python-%3E%3D%203.5-blue

Introduction

XPipe is a library that I started developping in December 2020 for my personal use. As it might be useful for other people, I decided to publish the code as an open source project.

Configuration files are a big concern in data science field. XPipe facilitates your work by automatically loading python objects from a yaml configuration. You can also easily include other yaml files into another.

It is an interesting tool to improve your workflow, make it reproducible and make your configurations more readable.

Getting started

pip install xpipe

Documentation (work in progress): https://x-pipe.readthedocs.io/en/latest/#

Configuration files

Here is a simple example of how to use yaml configuration files to seamlessly load needed objects to run your experiments.

training:
  gpu: !env CUDA_VISIBLE_DEVICES # Get the value of env variable CUDA_VISIBLE_DEVICES
  epochs: 18
  batch_size: 100

  optimizer:
    !obj torch.optim.SGD : {lr : 0.001}

  scheduler:
    !obj torch.optim.lr_scheduler.MultiStepLR : {milestones: [2, 6, 10, 14]}

  loss:
    !obj torch.nn.BCELoss : {}

model: !include "./models/my_model.yaml"

transforms:
  - !obj transforms.Normalize : {}
  - !obj transforms.Noise : {}
  - !obj transforms.RandomFlip : {probability: 0.5}

In your models/my_model.yaml file, you can define your model and its parameters (assuming that you defined a module ‘models’ and a class ‘Model1’ in it).

definition:
  !obj models.Model1 :
    n_hidden: 100

Then you can load the configuration file:

from xpipe.config import load_config

conf = load_config("experiment.yaml")
epochs = conf.training.epochs() # 18

# Instantiate your model defined in models/my_model.yaml
my_model = conf.model.definition()

# Directly instantiate your optimizer and scheduler from configuration
# Note that you can add argument that are not in the configuration file
optimizer = conf.training.optimizer(params=my_model.parameters())
scheduler = conf.training.scheduler(optimizer=optimizer)

Try by yourself the exemples in the examples folder.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

XPipe-1.1.1-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file XPipe-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: XPipe-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/30.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.31.1 importlib-metadata/4.8.1 keyring/18.0.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.7.3

File hashes

Hashes for XPipe-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 53fb7f759633c27df7c5eec44d409f394238f456b1dbf2a65df2c8aecd51349c
MD5 5c46765969a26b6ac2c51037d71a1321
BLAKE2b-256 d95a8361d7917a5cb2b9ccedca368d6053594cb290a6a493581a14c3a0f06e0a

See more details on using hashes here.

Supported by

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