Skip to content

Core

Core Building blocks for AutoML Tasks

BaseAutoModel (ABC)

The main class for AutoML which consists everything required for tranining a model - data, model and trainer.

build_model(self, search_space)

Build model from dictionary _search_space

BaseTracker dataclass

BaseTracker()

TrackingValues dataclass

TrackingValues()


AutoBackend

optimization_objective(self, config, trainer_config, gpu=0.0)

Defines lightning_objective function which is used by tuner to minimize/maximize the metric.

Parameters:

Name Type Description Default
config dict

key value pair of hyperparameters.

required
trainer_config dict

configurations passed directly to Lightning Trainer.

required
gpu Optional[float]

GPU per trial

0.0

Backend (Enum)

An enumeration.


AutoModel (BaseAutoModel, ABC)

Base model that defines hyperparameter search methods and initializes Ray. All other tasks are implementation of AutoModel.

Parameters:

Name Type Description Default
datamodule flash.DataModule

DataModule from Flash or PyTorch Lightning

required
max_epochs [int]

Maximum number of epochs for which model will train

required
max_steps Optional[int]

Maximum number of steps for each epoch. Defaults None.

required
optimization_metric str

Value on which hyperparameter search will run.

required
n_trials int

Number of trials for HPO

required
suggested_conf Dict

Any extra suggested configuration

required
timeout int

HPO will stop after timeout

required
prune bool

Whether to stop unpromising training.

required
backend Optional[str]

Training backend - PL / torch / fastai. Default is PL

required

hp_tune(self, name=None, ray_config=None, trainer_config=None, mode=None, gpu=0, cpu=None, resume=False)

Search Hyperparameter and builds model with the best params

    automodel = AutoClassifier(data)  # implements `AutoModel`
    automodel.hp_tune(name="gflow-example", gpu=1)

Parameters:

Name Type Description Default
name Optional[str]

name of the experiment.

None
ray_config dict

configuration passed to ray.tune.run(...)

None
trainer_config dict

configuration passed to pl.trainer.fit(...)

None
mode Optional[str]

Whether to maximize or minimize the optimization_metric.

None
gpu Optional[float]

Amount of GPU resource per trial.

0
cpu float

CPU cores per trial

None
resume bool

Whether to resume the training or not.

False

AutoClassifier (AutoModel)

Implements AutoModel for classification tasks.

build_model(self, config)

Every Task implementing AutoClassifier has to implement a build model method that can build torch.nn.Module from dictionary config and return the model.


Last update: September 29, 2021