Hook¶
- class mmengine.hooks.Hook[源代码]¶
Base hook class.
All hooks should inherit from this class.
- after_load_checkpoint(runner, checkpoint)[源代码]¶
All subclasses should override this method, if they need any operations after loading the checkpoint.
- after_run(runner)[源代码]¶
All subclasses should override this method, if they need any operations before the training validation or testing process.
- 参数:
runner (Runner) – The runner of the training, validation or testing process.
- 返回类型:
None
- after_test(runner)[源代码]¶
All subclasses should override this method, if they need any operations after testing.
- 参数:
runner (Runner) – The runner of the testing process.
- 返回类型:
None
- after_test_epoch(runner, metrics=None)[源代码]¶
All subclasses should override this method, if they need any operations after each test epoch.
- after_test_iter(runner, batch_idx, data_batch=None, outputs=None)[源代码]¶
All subclasses should override this method, if they need any operations after each test iteration.
- after_train(runner)[源代码]¶
All subclasses should override this method, if they need any operations after train.
- 参数:
runner (Runner) – The runner of the training process.
- 返回类型:
None
- after_train_epoch(runner)[源代码]¶
All subclasses should override this method, if they need any operations after each training epoch.
- 参数:
runner (Runner) – The runner of the training process.
- 返回类型:
None
- after_train_iter(runner, batch_idx, data_batch=None, outputs=None)[源代码]¶
All subclasses should override this method, if they need any operations after each training iteration.
- after_val(runner)[源代码]¶
All subclasses should override this method, if they need any operations after validation.
- 参数:
runner (Runner) – The runner of the validation process.
- 返回类型:
None
- after_val_epoch(runner, metrics=None)[源代码]¶
All subclasses should override this method, if they need any operations after each validation epoch.
- after_val_iter(runner, batch_idx, data_batch=None, outputs=None)[源代码]¶
All subclasses should override this method, if they need any operations after each validation iteration.
- before_run(runner)[源代码]¶
All subclasses should override this method, if they need any operations before the training validation or testing process.
- 参数:
runner (Runner) – The runner of the training, validation or testing process.
- 返回类型:
None
- before_save_checkpoint(runner, checkpoint)[源代码]¶
All subclasses should override this method, if they need any operations before saving the checkpoint.
- before_test(runner)[源代码]¶
All subclasses should override this method, if they need any operations before testing.
- 参数:
runner (Runner) – The runner of the testing process.
- 返回类型:
None
- before_test_epoch(runner)[源代码]¶
All subclasses should override this method, if they need any operations before each test epoch.
- 参数:
runner (Runner) – The runner of the testing process.
- 返回类型:
None
- before_test_iter(runner, batch_idx, data_batch=None)[源代码]¶
All subclasses should override this method, if they need any operations before each test iteration.
- before_train(runner)[源代码]¶
All subclasses should override this method, if they need any operations before train.
- 参数:
runner (Runner) – The runner of the training process.
- 返回类型:
None
- before_train_epoch(runner)[源代码]¶
All subclasses should override this method, if they need any operations before each training epoch.
- 参数:
runner (Runner) – The runner of the training process.
- 返回类型:
None
- before_train_iter(runner, batch_idx, data_batch=None)[源代码]¶
All subclasses should override this method, if they need any operations before each training iteration.
- before_val(runner)[源代码]¶
All subclasses should override this method, if they need any operations before validation.
- 参数:
runner (Runner) – The runner of the validation process.
- 返回类型:
None
- before_val_epoch(runner)[源代码]¶
All subclasses should override this method, if they need any operations before each validation epoch.
- 参数:
runner (Runner) – The runner of the validation process.
- 返回类型:
None
- before_val_iter(runner, batch_idx, data_batch=None)[源代码]¶
All subclasses should override this method, if they need any operations before each validation iteration.
- end_of_epoch(dataloader, batch_idx)[源代码]¶
Check whether the current iteration reaches the last iteration of the dataloader.
- every_n_inner_iters(batch_idx, n)[源代码]¶
Test whether current inner iteration can be evenly divided by n.
- every_n_train_iters(runner, n, start=0)[源代码]¶
Test whether current training iteration can be evenly divided by n.
- 参数:
- 返回:
Return True if the current iteration can be evenly divided by n, otherwise False.
- 返回类型:
- get_triggered_stages()[源代码]¶
Get all triggered stages with method name of the hook.
- 返回:
List of triggered stages.
- 返回类型: