Skip to main content

Deep learning library for research experiments

Project description

[!] This code is under development and mainly for my personal use. This project is for fast prototyping of deep learning and machine learning model with minimal code. Some parts of the code may not be well-commented or lack of citation.

Features

  • Writing minimal code to set up a new experiment
  • Pytorch or Tensorflow 2.0 or scikit-learn as backend with similar training flow
  • Efficiently log and analyze model results
  • Cross-platform GUI for monitoring experiments, either local or remote sever (Electron-based)

screenshot

See here for a list of implemented models

Installation

pip install dlex

Set up an experiment

Step 1: Folder structure

Experiment/
|-- model_configs
|-- model_outputs
|-- logs
|-- saved_models
|-- src
|   |-- datasets
|   |   |-- <dataset>.py
|   |-- models
|   |   |-- <model>.py
|-- README.md

Model parameters and outputs are saved to ./saved_models and ./model_outputs unless DLEX_SAVED_MODELS_PATH and DLEX_MODEL_OUTPUTS_PATH is specified

Step 2: Define dataset

  • Dataset Builder: handle downloading and preprocessing data. DatasetBuilder should be framework and config independent.
  • PytorchDataset, TensorflowDataset: handle loading dataset from the storage, shuffle, sort, batchify, etc. using concepts from each framework
from dlex.configs import AttrDict
from dlex.datasets.torch import PytorchDataset
from dlex.datasets.builder import DatasetBuilder

class SampleDatasetBuilder(DatasetBuilder):
    def __init__(self, params: AttrDict):
        super().__init__(params)
        
    def maybe_download_and_extract(self, force=False):
        super().maybe_download_and_extract(force)
        # Download dataset...
        # self.download_and_extract([some url], self.get_raw_data_dir())
            
    def maybe_preprocess(self, force=False):
        super().maybe_preprocess(force)
        # Preprocess data...
        
    def get_pytorch_wrapper(self, mode: str):
        return PytorchSampleDataset(self, mode)

class PytorchSampleDataset(PytorchDataset):
    def __init__(self, builder, mode):
        super().__init__(builder, mode)
        # Load data from preprocessed files...

Step 3: Construct model

Model supports loss calculation, training, predicting and outputting prediction to specified format.

from dlex.torch.models.base import BaseModel

class Model(BaseModel):
     def __init__(self, params, dataset):
        super().__init__(params, dataset)

    def infer(self, batch):
        ...

    def forward(self, batch):
        ...

    def loss(self, batch):
        ...

Step 4: Configuration

Model

Dataset

Train

  • batch_size: int or dict of { [progress]: [batch_size] } (0 as key must always be included)

  • num_epochs

  • optimizer: dict of name and optimizer's arguments. Support sgd, adam, adadelta.

Test

  • batch_size: int. Training batch size value is used if not specified.
model:
  name: {model import path}
  ...{model configs}
dataset:
  name: {dataset import path}
  ...{dataset configs}
train:
  batch_size: 256
  num_epochs: 30
  optimizer:
    name: adam
    learning_rate: 0.01
    weight_decay: 1e-5

Step 5: Train & evaluate

dlex train <config_path>
dlex evaluate <config_path>
dlex infer <config_path>

Environment Variables

  • DLEX_TMP_PATH (default: ~/tmp)
  • DLEX_DATASETS_PATH (default: ~/tmp/dlex/datasets)
  • DLEX_SAVED_MODELS_PATH (default: ./saved_models)

Using dlex

https://github.com/trungd/ml-graph: Implementations of machine learning algorithms for graph

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

dlex-0.0.2.tar.gz (52.8 kB view details)

Uploaded Source

Built Distribution

dlex-0.0.2-py3-none-any.whl (75.8 kB view details)

Uploaded Python 3

File details

Details for the file dlex-0.0.2.tar.gz.

File metadata

  • Download URL: dlex-0.0.2.tar.gz
  • Upload date:
  • Size: 52.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

File hashes

Hashes for dlex-0.0.2.tar.gz
Algorithm Hash digest
SHA256 839bc4e63a15f3a0bf2c8b25ed067c744ddd56087d0c28d0278794e1ae9e03fb
MD5 5bc5883c8aacff949db70199043624c2
BLAKE2b-256 1f32881bdbfce2612d808bdeebee03b175e63ae743aded419dac63c9e003ce62

See more details on using hashes here.

File details

Details for the file dlex-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: dlex-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 75.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.8.0

File hashes

Hashes for dlex-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 48e6a68c7f1b52f6edbae856bea6f561b7405dcdf875c022fa4311f7e2e4d9dc
MD5 466be0c1457e2c18ea442561634bf96b
BLAKE2b-256 46d0c035a0b7d4609d74f78785380dc718e4a9367d069deb9cc2b3641ea5566b

See more details on using hashes here.

Supported by

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