src.auto_trainer
Entry point for running AutoMAX hyperparameter search with a standard
LibAUC Trainer (image classification and similar tasks).
CLI usage
python -m src.auto_trainer --config_file config.yaml
Functions
- main()
Parse CLI arguments, load the megaconf, build an
autopartialtrainer, and runoptimize().Steps performed:
Load YAML config and apply CLI overrides via
apply_cli_overrides().Set global random seeds via
set_seed().Load train / eval datasets with
libauc.trainer.load_dataset.Resolve default optimizer and loss configs from
parse_defaultconfig.Build an
autopartialTrainingArgumentsthat carries the search distributions.Construct an
AutoMAXConfigrationfrom theautomax:config section.Build an
autopartialTrainerand runoptimize().
- apply_cli_overrides(cfg, args)
Merge CLI-supplied values into the megaconf in-place.
- Parameters:
cfg (OmegaConf DictConfig) – Merged megaconf produced by
_build_megaconf.args (argparse.Namespace) – Parsed CLI arguments from
argparse.
- Returns:
The mutated config (same object).
- Return type:
OmegaConf DictConfig
The following CLI flags are supported:
CLI flag
Config key overridden
--epochstraining.epochs--batch_sizetraining.batch_size--eval_batch_sizetraining.eval_batch_size--sampling_ratetraining.sampling_rate--num_workerstraining.num_workers--output_pathtraining.output_path--seedtraining.SEED--resume_from_checkpoint/--no-resume_from_checkpointtraining.resume_from_checkpoint--save_checkpoint_everytraining.save_checkpoint_every
- set_seed(seed)
Set all relevant random seeds for reproducibility.
- Parameters:
seed (int) – Seed value to apply.
Sets
numpy,torchCPU,torchCUDA seeds, and enablestorch.backends.cudnn.deterministic.
Megaconf defaults
auto_trainer ships with the following built-in defaults, which are merged
under any user-supplied YAML:
training:
optimizer: PESG
optimizer_kwargs: {}
loss: AUCMLoss
loss_kwargs: {}
SEED: 42
batch_size: 128
eval_batch_size: 128
sampling_rate: 0.5
epochs: 50
decay_epochs: []
num_workers: 2
output_path: ./output
resume_from_checkpoint: true
save_checkpoint_every: 5
project_name: libauc
experiment_name: run_auto
verbose: 1
automax:
deterministic: true
n_trials: 5
n_configs: 1
SEED: 42
name: automax_search
output_directory: ./automax_output
overwrite: true
dataset:
name: ""
kwargs: {}
eval_splits: [val]
model:
name: resnet18
pretrained: false
num_classes: 1
in_channels: 3
metrics: [AUROC]
metric_kwargs: []