Shortcuts

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.

参数:
  • runner (Runner) – The runner of the training, validation or testing process.

  • checkpoint (dict) – Model’s checkpoint.

返回类型:

None

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.

参数:
  • runner (Runner) – The runner of the testing process.

  • metrics (Dict[str, float], optional) – Evaluation results of all metrics on test dataset. The keys are the names of the metrics, and the values are corresponding results.

返回类型:

None

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.

参数:
  • runner (Runner) – The runner of the training process.

  • batch_idx (int) – The index of the current batch in the test loop.

  • data_batch (dict or tuple or list, optional) – Data from dataloader.

  • outputs (Sequence, optional) – Outputs from model.

返回类型:

None

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.

参数:
  • runner (Runner) – The runner of the training process.

  • batch_idx (int) – The index of the current batch in the train loop.

  • data_batch (dict tuple or list, optional) – Data from dataloader.

  • outputs (dict, optional) – Outputs from model.

返回类型:

None

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.

参数:
  • runner (Runner) – The runner of the validation process.

  • metrics (Dict[str, float], optional) – Evaluation results of all metrics on validation dataset. The keys are the names of the metrics, and the values are corresponding results.

返回类型:

None

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.

参数:
  • runner (Runner) – The runner of the validation process.

  • batch_idx (int) – The index of the current batch in the val loop.

  • data_batch (dict or tuple or list, optional) – Data from dataloader.

  • outputs (Sequence, optional) – Outputs from model.

返回类型:

None

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.

参数:
  • runner (Runner) – The runner of the training, validation or testing process.

  • checkpoint (dict) – Model’s checkpoint.

返回类型:

None

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.

参数:
  • runner (Runner) – The runner of the testing process.

  • batch_idx (int) – The index of the current batch in the test loop.

  • data_batch (dict or tuple or list, optional) – Data from dataloader. Defaults to None.

返回类型:

None

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.

参数:
  • runner (Runner) – The runner of the training process.

  • batch_idx (int) – The index of the current batch in the train loop.

  • data_batch (dict or tuple or list, optional) – Data from dataloader.

返回类型:

None

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.

参数:
  • runner (Runner) – The runner of the validation process.

  • batch_idx (int) – The index of the current batch in the val loop.

  • data_batch (dict, optional) – Data from dataloader. Defaults to None.

返回类型:

None

end_of_epoch(dataloader, batch_idx)[源代码]

Check whether the current iteration reaches the last iteration of the dataloader.

参数:
  • dataloader (Dataloader) – The dataloader of the training, validation or testing process.

  • batch_idx (int) – The index of the current batch in the loop.

返回:

Whether reaches the end of current epoch or not.

返回类型:

bool

every_n_epochs(runner, n, start=0)[源代码]

Test whether current epoch can be evenly divided by n.

参数:
  • runner (Runner) – The runner of the training, validation or testing process.

  • n (int) – Whether current epoch can be evenly divided by n.

  • start (int) – Starting from start to check the logic for every n epochs. Defaults to 0.

返回:

Whether current epoch can be evenly divided by n.

返回类型:

bool

every_n_inner_iters(batch_idx, n)[源代码]

Test whether current inner iteration can be evenly divided by n.

参数:
  • batch_idx (int) – Current batch index of the training, validation or testing loop.

  • n (int) – Whether current inner iteration can be evenly divided by n.

返回:

Whether current inner iteration can be evenly divided by n.

返回类型:

bool

every_n_train_iters(runner, n, start=0)[源代码]

Test whether current training iteration can be evenly divided by n.

参数:
  • runner (Runner) – The runner of the training, validation or testing process.

  • n (int) – Whether current iteration can be evenly divided by n.

  • start (int) – Starting from start to check the logic for every n iterations. Defaults to 0.

返回:

Return True if the current iteration can be evenly divided by n, otherwise False.

返回类型:

bool

get_triggered_stages()[源代码]

Get all triggered stages with method name of the hook.

返回:

List of triggered stages.

返回类型:

list

is_last_train_epoch(runner)[源代码]

Test whether current epoch is the last train epoch.

参数:

runner (Runner) – The runner of the training process.

返回:

Whether reaches the end of training epoch.

返回类型:

bool

is_last_train_iter(runner)[源代码]

Test whether current iteration is the last train iteration.

参数:

runner (Runner) – The runner of the training process.

返回:

Whether current iteration is the last train iteration.

返回类型:

bool

Read the Docs v: latest
Versions
latest
stable
v0.10.3
v0.10.2
v0.10.1
v0.10.0
v0.9.1
v0.9.0
v0.8.5
v0.8.4
v0.8.3
v0.8.2
v0.8.1
v0.8.0
v0.7.4
v0.7.3
v0.7.2
v0.7.1
v0.7.0
v0.6.0
v0.5.0
v0.4.0
v0.3.0
v0.2.0
Downloads
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.