当前位置: 首页>>代码示例>>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;未经允许,请勿转载。