Shortcuts

mmengine.runner.base_loop 源代码

# Copyright (c) OpenMMLab. All rights reserved.
from abc import ABCMeta, abstractmethod
from typing import Any, Dict, Union

from torch.utils.data import DataLoader


[文档]class BaseLoop(metaclass=ABCMeta): """Base loop class. All subclasses inherited from ``BaseLoop`` should overwrite the :meth:`run` method. Args: runner (Runner): A reference of runner. dataloader (Dataloader or dict): An iterator to generate one batch of dataset each iteration. """ def __init__(self, runner, dataloader: Union[DataLoader, Dict]) -> None: self._runner = runner if isinstance(dataloader, dict): # Determine whether or not different ranks use different seed. diff_rank_seed = runner._randomness_cfg.get( 'diff_rank_seed', False) self.dataloader = runner.build_dataloader( dataloader, seed=runner.seed, diff_rank_seed=diff_rank_seed) else: self.dataloader = dataloader @property def runner(self): return self._runner
[文档] @abstractmethod def run(self) -> Any: """Execute loop."""

© Copyright 2022, mmengine contributors. Revision 13484aae.

Built with Sphinx using a theme provided by Read the Docs.
Read the Docs v: v0.2.0
Versions
latest
stable
v0.5.0
v0.4.0
v0.3.0
v0.2.0
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.