Note
You are reading the documentation for MMClassification 0.x, which will soon be deprecated at the end of 2022. We recommend you upgrade to MMClassification 1.0 to enjoy fruitful new features and better performance brought by OpenMMLab 2.0. Check the installation tutorial, migration tutorial and changelog for more details.
mmcls.apis.train_model¶
- mmcls.apis.train_model(model, dataset, cfg, distributed=False, validate=False, timestamp=None, device=None, meta=None)[source]¶
Train a model.
This method will build dataloaders, wrap the model and build a runner according to the provided config.
- Parameters
model (
torch.nn.Module
) – The model to be run.dataset (
mmcls.datasets.BaseDataset
| List[BaseDataset]) – The dataset used to train the model. It can be a single dataset, or a list of dataset with the same length as workflow.cfg (
mmcv.utils.Config
) – The configs of the experiment.distributed (bool) – Whether to train the model in a distributed environment. Defaults to False.
validate (bool) – Whether to do validation with
mmcv.runner.EvalHook
. Defaults to False.timestamp (str, optional) – The timestamp string to auto generate the name of log files. Defaults to None.
device (str, optional) – TODO
meta (dict, optional) – A dict records some import information such as environment info and seed, which will be logged in logger hook. Defaults to None.