Unverified Commit da071146 authored by Shilong Zhang's avatar Shilong Zhang Committed by GitHub
Browse files

[Fix]: fix basemodule (#1018)

* fix basemodule

* add commnet
parent 4c2b05f9
......@@ -4,6 +4,8 @@ from abc import ABCMeta
import torch.nn as nn
from mmcv import ConfigDict
class BaseModule(nn.Module, metaclass=ABCMeta):
"""Base module for all modules in openmmlab."""
......@@ -41,6 +43,13 @@ class BaseModule(nn.Module, metaclass=ABCMeta):
if not self._is_init:
if self.init_cfg:
initialize(self, self.init_cfg)
if isinstance(self.init_cfg, (dict, ConfigDict)):
# Avoid the parameters of the pre-training model
# being overwritten by the init_weights
# of the children.
if self.init_cfg['type'] == 'Pretrained':
return
for m in self.children():
if hasattr(m, 'init_weights'):
m.init_weights()
......
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