Trainer

class classy_vision.trainer.ClassyTrainer(use_gpu: Optional[bool] = None, num_dataloader_workers: int = 0, dataloader_mp_context: Optional[str] = None)

Base class for shared training code.

A trainer is responsible for setting up the environment for training, for instance: configuring rendezvous for distributed training, deciding what GPU to use and so on. Trainers also control the outer portion of the training loop, but delegate to the task to decide how exactly to perform inference, compute loss etc. That allows combining tasks with different trainers depending on whether you want to train on your current machine, AWS cluster etc.

__init__(use_gpu: Optional[bool] = None, num_dataloader_workers: int = 0, dataloader_mp_context: Optional[str] = None)

Constructor for ClassyTrainer.

Parameters
  • use_gpu – If true, then use GPUs for training. If None, then check if we have GPUs available, if we do then use GPU for training.

  • num_dataloader_workers – Number of CPU processes doing dataloading per GPU. If 0, then dataloading is done on main thread.

  • dataloader_mp_context – Determines how to launch new processes for dataloading. Must be one of “fork”, “forkserver”, “spawn”. If None, process launching is inherited from parent.

train(task: classy_vision.tasks.classy_task.ClassyTask)

Runs training phases, phases are generated from the config.

Parameters

task – Task to be used in training. It should contain everything that is needed for training

class classy_vision.trainer.DistributedTrainer(use_gpu: Optional[bool] = None, num_dataloader_workers: int = 0, dataloader_mp_context: Optional[str] = None)

Distributed trainer for using multiple training processes

__init__(use_gpu: Optional[bool] = None, num_dataloader_workers: int = 0, dataloader_mp_context: Optional[str] = None)

Constructor for DistributedTrainer.

Parameters
  • use_gpu – If true, then use GPU 0 for training. If None, then check if we have GPUs available, if we do then use GPU for training.

  • num_dataloader_workers – Number of CPU processes doing dataloading per GPU. If 0, then dataloading is done on main thread.

  • dataloader_mp_context – Determines how to launch new processes for dataloading. Must be one of “fork”, “forkserver”, “spawn”. If None, process launching is inherited from parent.

class classy_vision.trainer.LocalTrainer(use_gpu: Optional[bool] = None, num_dataloader_workers: int = 0, dataloader_mp_context: Optional[str] = None)

Trainer to be used if you want want use only a single training process.

__init__(use_gpu: Optional[bool] = None, num_dataloader_workers: int = 0, dataloader_mp_context: Optional[str] = None)

Constructor for LocalTrainer.

Parameters
  • use_gpu – If true, then use GPU 0 for training. If None, then check if we have GPUs available, if we do then use GPU for training.

  • num_dataloader_workers – Number of CPU processes doing dataloading per GPU. If 0, then dataloading is done on main thread.

  • dataloader_mp_context – Determines how to launch new processes for dataloading. Must be one of “fork”, “forkserver”, “spawn”. If None, process launching is inherited from parent.