Skip to content

logo

An AutoML Library made with Optuna and PyTorch Lightning

Maintainability Rating Reliability Rating Security Rating Coverage Documentation Status DOI Slack

PyPI - Python Version PyPI version Downloads Downloads license

Installation

pip install -U gradsflow

From source

pip install git+https://github.com/gradsflow/gradsflow@main

Examples

Auto Image Classification

from gradsflow.autoclassifier import AutoImageClassifier

from flash.core.data.utils import download_data
from flash.image import ImageClassificationData

# 1. Create the DataModule
download_data("https://pl-flash-data.s3.amazonaws.com/hymenoptera_data.zip", "./data")

datamodule = ImageClassificationData.from_folders(
    train_folder="data/hymenoptera_data/train/",
    val_folder="data/hymenoptera_data/val/",
)

suggested_conf = dict(
    optimizers=["adam"],
    lr=(5e-4, 1e-3),
)

model = AutoImageClassifier(datamodule,
                            suggested_backbones=['ssl_resnet18'],
                            suggested_conf=suggested_conf,
                            max_epochs=1,
                            optimization_metric="val_accuracy",
                            timeout=30)

print("AutoImageClassifier initialised!")
model.hp_tune()

Auto Text Classification

from gradsflow.autoclassifier import AutoTextClassifier

from flash.core.data.utils import download_data
from flash.text import TextClassificationData

# 1. Create the DataModule
download_data("https://pl-flash-data.s3.amazonaws.com/imdb.zip", "./data/")

datamodule = TextClassificationData.from_csv(
    "review",
    "sentiment",
    train_file="data/imdb/train.csv",
    val_file="data/imdb/valid.csv",
    backbone="prajjwal1/bert-medium",
)

suggested_conf = dict(
    optimizers=["adam"],
    lr=(5e-4, 1e-3),
)

model = AutoTextClassifier(datamodule,
                           suggested_backbones=['sgugger/tiny-distilbert-classification'],
                           suggested_conf=suggested_conf,
                           max_epochs=1,
                           optimization_metric="val_accuracy",
                           timeout=30)

print("AutoTextClassifier initialised!")
model.hp_tune()

📑 For detailed usage examples please visit our documentation page.

💬 Join the Slack group to chat with us.

🤗 Contribute

Contributions of any kind are welcome. Please check the Contributing Guidelines before contributing.

Code Of Conduct

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

Read full Contributor Covenant Code of Conduct

Acknowledgement

Gradsflow is built with help of Optuna and PyTorch Lightning 💜

Citing

@software{aniket_maurya_2021_5245151,
  author       = {Aniket Maurya},
  title        = {{gradsflow/gradsflow: An AutoML Library made with
                   Optuna and PyTorch Lightning}},
  month        = aug,
  year         = 2021,
  publisher    = {Zenodo},
  version      = {v0.0.1b1},
  doi          = {10.5281/zenodo.5245151},
  url          = {https://doi.org/10.5281/zenodo.5245151}
}

Last update: August 24, 2021