Skip to content

Commit

Permalink
fix init cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangshilong committed Apr 16, 2021
1 parent ae41150 commit 92c3c59
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions mmcv/runner/base_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ def __init__(self, init_cfg=None):
# define default value of init_cfg instead of hard code
# in init_weigt() function
self._is_init = False
if init_cfg is not None:
self.init_cfg = init_cfg
self.init_cfg = init_cfg

# Backward compatibility in derived classes
# if pretrained is not None:
Expand All @@ -40,7 +39,7 @@ def init_weight(self):
from ..cnn import initialize

if not self._is_init:
if hasattr(self, 'init_cfg'):
if self.init_cfg:
initialize(self, self.init_cfg)
for m in self.children():
if hasattr(m, 'init_weight'):
Expand All @@ -52,7 +51,7 @@ def init_weight(self):

def __repr__(self):
s = super().__repr__()
if hasattr(self, 'init_cfg'):
if self.init_cfg:
s += f'\ninit_cfg={self.init_cfg}'
return s

Expand Down

0 comments on commit 92c3c59

Please sign in to comment.