當前位置: 首頁>>代碼示例>>Python>>正文


Python cnn.kaiming_init方法代碼示例

本文整理匯總了Python中mmcv.cnn.kaiming_init方法的典型用法代碼示例。如果您正苦於以下問題:Python cnn.kaiming_init方法的具體用法?Python cnn.kaiming_init怎麽用?Python cnn.kaiming_init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mmcv.cnn的用法示例。


在下文中一共展示了cnn.kaiming_init方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: init_weights

# 需要導入模塊: from mmcv import cnn [as 別名]
# 或者: from mmcv.cnn import kaiming_init [as 別名]
def init_weights(self, pretrained=None):
        print("init hrnet weights")
#         if isinstance(pretrained, str):
#             logger = logging.getLogger()
#             load_checkpoint(self, pretrained, strict=False, logger=logger)
#         elif pretrained is None:
#             for m in self.modules():
#                 if isinstance(m, nn.Conv2d):
#                     kaiming_init(m)
#                 elif isinstance(m, (_BatchNorm, nn.GroupNorm)):
#                     constant_init(m, 1)

#             if self.zero_init_residual:
#                 for m in self.modules():
#                     if isinstance(m, Bottleneck):
#                         constant_init(m.norm3, 0)
#                     elif isinstance(m, BasicBlock):
#                         constant_init(m.norm2, 0)
#         else:
#             raise TypeError('pretrained must be a str or None') 
開發者ID:lizhe960118,項目名稱:CenterNet,代碼行數:22,代碼來源:hrnet4.py

示例2: init_weights

# 需要導入模塊: from mmcv import cnn [as 別名]
# 或者: from mmcv.cnn import kaiming_init [as 別名]
def init_weights(self):
        for m in self.modules():
            if hasattr(m, 'kaiming_init') and m.kaiming_init:
                kaiming_init(
                    m,
                    mode='fan_in',
                    nonlinearity='leaky_relu',
                    bias=0,
                    distribution='uniform',
                    a=1) 
開發者ID:open-mmlab,項目名稱:mmdetection,代碼行數:12,代碼來源:generalized_attention.py

示例3: _make_stage

# 需要導入模塊: from mmcv import cnn [as 別名]
# 或者: from mmcv.cnn import kaiming_init [as 別名]
def _make_stage(self, layer_config, in_channels, multiscale_output=True):
        num_modules = layer_config['num_modules']
        num_branches = layer_config['num_branches']
        num_blocks = layer_config['num_blocks']
        num_channels = layer_config['num_channels']
        block = self.blocks_dict[layer_config['block']]

        hr_modules = []
        for i in range(num_modules):
            # multi_scale_output is only used for the last module
            if not multiscale_output and i == num_modules - 1:
                reset_multiscale_output = False
            else:
                reset_multiscale_output = True

            hr_modules.append(
                HRModule(
                    num_branches,
                    block,
                    num_blocks,
                    in_channels,
                    num_channels,
                    reset_multiscale_output,
                    with_cp=self.with_cp,
                    norm_cfg=self.norm_cfg,
                    conv_cfg=self.conv_cfg))

        return nn.Sequential(*hr_modules), in_channels

#     def init_weights(self, pretrained=None):
#         if isinstance(pretrained, str):
#             logger = logging.getLogger()
#             load_checkpoint(self, pretrained, strict=False, logger=logger)
#         elif pretrained is None:
#             for m in self.modules():
#                 if isinstance(m, nn.Conv2d):
#                     kaiming_init(m)
#                 elif isinstance(m, (_BatchNorm, nn.GroupNorm)):
#                     constant_init(m, 1)

#             if self.zero_init_residual:
#                 for m in self.modules():
#                     if isinstance(m, Bottleneck):
#                         constant_init(m.norm3, 0)
#                     elif isinstance(m, BasicBlock):
#                         constant_init(m.norm2, 0)
#         else:
#             raise TypeError('pretrained must be a str or None') 
開發者ID:lizhe960118,項目名稱:CenterNet,代碼行數:50,代碼來源:hrnet2.py


注:本文中的mmcv.cnn.kaiming_init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。