"vscode:/vscode.git/clone" did not exist on "ff0dfb74d76872bcbcbadb6e1e52c0dcb00bb4ce"
Unverified Commit 00870b9c authored by Miao Zheng's avatar Miao Zheng Committed by GitHub
Browse files

[Refactoring] Revise function of is_init flag in BaseModule (#898)

parent 967d9d58
...@@ -40,14 +40,12 @@ class BaseModule(nn.Module, metaclass=ABCMeta): ...@@ -40,14 +40,12 @@ class BaseModule(nn.Module, metaclass=ABCMeta):
from ..cnn import initialize from ..cnn import initialize
if not self._is_init: if not self._is_init:
if hasattr(self, 'init_cfg'): if hasattr(self, 'init_cfg'):
initialize(self, self.init_cfg) initialize(self, self.init_cfg)
self._is_init = True
for module in self.children(): for module in self.children():
if 'init_weight' in dir(module): if 'init_weight' in dir(module):
module.init_weight() module.init_weight()
self._is_init = True
else: else:
warnings.warn('This module has bee initialized, \ warnings.warn('This module has bee initialized, \
please call initialize(module, init_cfg) to reinitialize it') please call initialize(module, init_cfg) to reinitialize it')
......
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