Unverified Commit bcd32914 authored by WINDSKY45's avatar WINDSKY45 Committed by GitHub
Browse files

Add type hints for mmcv/runner (#2008)



* [Enhance] Add type hint in 'utils.py'.

* [Enhance] Add type hint in 'default_constructor.py'.

* Fixed undefined name.

* minor refinement
Co-authored-by: default avatarZaida Zhou <58739961+zhouzaida@users.noreply.github.com>
parent d499abf2
......@@ -143,7 +143,7 @@ class DefaultOptimizerConstructor:
params: List[Dict],
module: nn.Module,
prefix: str = '',
is_dcn_module: Optional[Union[int, float]] = None) -> None:
is_dcn_module: Union[int, float, None] = None) -> None:
"""Add all parameters of module to the params list.
The parameters of the given module will be added to the list of param
......
......@@ -6,6 +6,8 @@ import time
import warnings
from getpass import getuser
from socket import gethostname
from types import ModuleType
from typing import Optional
import numpy as np
import torch
......@@ -32,7 +34,9 @@ def get_time_str():
return time.strftime('%Y%m%d_%H%M%S', time.localtime())
def obj_from_dict(info, parent=None, default_args=None):
def obj_from_dict(info: dict,
parent: Optional[ModuleType] = None,
default_args: Optional[dict] = None):
"""Initialize an object from dict.
The dict must contain the key "type", which indicates the object type, it
......@@ -67,7 +71,9 @@ def obj_from_dict(info, parent=None, default_args=None):
return obj_type(**args)
def set_random_seed(seed, deterministic=False, use_rank_shift=False):
def set_random_seed(seed: int,
deterministic: bool = False,
use_rank_shift: bool = False) -> None:
"""Set random seed.
Args:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment