当前位置: 首页>>代码示例>>Python>>正文


Python initializer.Uniform方法代码示例

本文整理汇总了Python中mxnet.initializer.Uniform方法的典型用法代码示例。如果您正苦于以下问题:Python initializer.Uniform方法的具体用法?Python initializer.Uniform怎么用?Python initializer.Uniform使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mxnet.initializer的用法示例。


在下文中一共展示了initializer.Uniform方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_params

# 需要导入模块: from mxnet import initializer [as 别名]
# 或者: from mxnet.initializer import Uniform [as 别名]
def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None,
                    allow_missing=False, force_init=False, allow_extra=False):
        if self.params_initialized and not force_init:
            return
        assert self.binded, 'call bind before initializing the parameters'
        #TODO init the same weights with all work nodes
        self._curr_module.init_params(initializer=initializer, arg_params=None,
                                      aux_params=None, allow_missing=allow_missing,
                                      force_init=force_init, allow_extra=allow_extra)
        for _module in self._arcface_modules:
          #_initializer = initializer
          _initializer = mx.init.Normal(0.01)
          _module.init_params(initializer=_initializer, arg_params=None,
                                        aux_params=None, allow_missing=allow_missing,
                                        force_init=force_init, allow_extra=allow_extra)
        self.params_initialized = True 
开发者ID:deepinsight,项目名称:insightface,代码行数:18,代码来源:parall_module_local_v1.py

示例2: make_layer

# 需要导入模块: from mxnet import initializer [as 别名]
# 或者: from mxnet.initializer import Uniform [as 别名]
def make_layer(self, block, planes, blocks, stride=1, **kwargs):
        """ Make ResNet stage """
        downsample = None
        if stride != 1 or self.inplanes != planes * block.expansion:
            downsample = nn.HybridSequential()
            downsample.add(nn.Conv2D(planes * block.expansion, in_channels=self.inplanes,
                                     kernel_size=1, strides=stride, use_bias=False,
                                     weight_initializer=initializer.Uniform(
                                         scale=math.sqrt(1 / (self.inplanes * 1 * 1))),
                                     bias_initializer=initializer.Uniform(
                                         scale=math.sqrt(1 / (self.inplanes * 1 * 1)))))
            downsample.add(self.norm_layer(gamma_initializer=ZeroUniform(), **kwargs))

        layers = nn.HybridSequential()
        if downsample is not None:
            layers.add(block(self.inplanes, planes, stride, downsample,
                             reduction=True, norm_layer=self.norm_layer, **kwargs))
        else:
            layers.add(block(self.inplanes, planes, stride, downsample,
                             norm_layer=self.norm_layer, **kwargs))
        self.inplanes = planes * block.expansion
        for _ in range(1, blocks):
            layers.add(block(self.inplanes, planes, norm_layer=self.norm_layer, **kwargs))

        return layers 
开发者ID:dmlc,项目名称:gluon-cv,代码行数:27,代码来源:fast_pose.py

示例3: __init__

# 需要导入模块: from mxnet import initializer [as 别名]
# 或者: from mxnet.initializer import Uniform [as 别名]
def __init__(self, preact, num_joints,
                 norm_layer=nn.BatchNorm, norm_kwargs=None, **kwargs):
        super(AlphaPose, self).__init__(**kwargs)
        self.preact = preact
        self.num_joints = num_joints

        self.shuffle1 = PixelShuffle(2)
        if norm_kwargs is None:
            norm_kwargs = {}
        self.duc1 = DUC(1024, inplanes=512,
                        upscale_factor=2, norm_layer=norm_layer, **norm_kwargs)
        self.duc2 = DUC(512, inplanes=256,
                        upscale_factor=2, norm_layer=norm_layer, **norm_kwargs)

        self.conv_out = nn.Conv2D(
            channels=num_joints,
            in_channels=128,
            kernel_size=3,
            strides=1,
            padding=1,
            weight_initializer=initializer.Uniform(scale=math.sqrt(1 / (128 * 3 * 3))),
            bias_initializer=initializer.Uniform(scale=math.sqrt(1 / (128 * 3 * 3)))
        ) 
开发者ID:dmlc,项目名称:gluon-cv,代码行数:25,代码来源:fast_pose.py

示例4: fit

# 需要导入模块: from mxnet import initializer [as 别名]
# 或者: from mxnet.initializer import Uniform [as 别名]
def fit(self, train_data, eval_data=None, eval_metric='acc',
            epoch_end_callback=None, batch_end_callback=None, kvstore='local',
            optimizer='sgd', optimizer_params=(('learning_rate', 0.01),),
            eval_end_callback=None,
            eval_batch_end_callback=None, initializer=Uniform(0.01),
            arg_params=None, aux_params=None, allow_missing=False,
            force_rebind=False, force_init=False, begin_epoch=0, num_epoch=None,
            validation_metric=None, monitor=None, sparse_row_id_fn=None, profile=False):

        assert num_epoch is not None, 'please specify number of epochs'

        self.bind(data_shapes=train_data.provide_data, 
                  label_shapes=train_data.provide_label + self.teacher_label_shapes,
                  for_training=True, force_rebind=force_rebind)
        super().fit(force_rebind=False, train_data=train_data, eval_data=eval_data, eval_metric=eval_metric,
                    epoch_end_callback=epoch_end_callback, batch_end_callback=batch_end_callback,
                    kvstore=kvstore, optimizer=optimizer, optimizer_params=optimizer_params,
                    eval_end_callback=eval_end_callback,
                    eval_batch_end_callback=eval_batch_end_callback, initializer=initializer,
                    arg_params=arg_params, aux_params=aux_params, allow_missing=allow_missing,
                    force_init=force_init, begin_epoch=begin_epoch,
                    num_epoch=num_epoch, validation_metric=validation_metric, monitor=monitor,
                    sparse_row_id_fn=sparse_row_id_fn, profile=profile) 
开发者ID:TuSimple,项目名称:simpledet,代码行数:25,代码来源:detection_module.py

示例5: init_params

# 需要导入模块: from mxnet import initializer [as 别名]
# 或者: from mxnet.initializer import Uniform [as 别名]
def init_params(
        self,
        initializer=Uniform(0.01),
        arg_params=None,
        aux_params=None,
        allow_missing=False,
        force_init=False,
        allow_extra=False,
    ):
        if self.params_initialized and not force_init:
            return
        assert self.binded, "call bind before initializing the parameters"
        self._curr_module.init_params(
            initializer=initializer,
            arg_params=arg_params,
            aux_params=aux_params,
            allow_missing=allow_missing,
            force_init=force_init,
        )
        self.params_initialized = True 
开发者ID:liyi14,项目名称:mx-DeepIM,代码行数:22,代码来源:module.py

示例6: init_params

# 需要导入模块: from mxnet import initializer [as 别名]
# 或者: from mxnet.initializer import Uniform [as 别名]
def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None,
                    allow_missing=False, force_init=False, allow_extra=False):
        if self.params_initialized and not force_init:
            return
        assert self.binded, 'call bind before initializing the parameters'
        self._curr_module.init_params(initializer=initializer, arg_params=arg_params,
                                      aux_params=aux_params, allow_missing=allow_missing,
                                      force_init=force_init, allow_extra=allow_extra)
        self.params_initialized = True 
开发者ID:deepinsight,项目名称:insightface,代码行数:11,代码来源:module_bak.py

示例7: init_params

# 需要导入模块: from mxnet import initializer [as 别名]
# 或者: from mxnet.initializer import Uniform [as 别名]
def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None,
                    allow_missing=False, force_init=False, allow_extra=False):
        if self.params_initialized and not force_init:
            return
        assert self.binded, 'call bind before initializing the parameters'
        self._curr_module.init_params(initializer=initializer, arg_params=arg_params,
                                      aux_params=aux_params, allow_missing=allow_missing,
                                      force_init=force_init)
        self.params_initialized = True 
开发者ID:tonysy,项目名称:Deep-Feature-Flow-Segmentation,代码行数:11,代码来源:module.py

示例8: load_params

# 需要导入模块: from mxnet import initializer [as 别名]
# 或者: from mxnet.initializer import Uniform [as 别名]
def load_params(self, inference, init=initializer.Uniform(), postfix='epoch'):
        """
        load the parameters
        :param inference: network
        :param init: initializer function
        :param postfix: postfix
        :return:
        """
        if self.args.training:
            if self.args.pretrained:
                # print('load the weights from path: %s' % self.args.model_path)
                print('load the weights for features from path: %s' % self.args.model_path)
                inference.features.load_parameters(self.args.model_path, self.args.ctx, ignore_extra=True)
                print('initialize the weights for embeds and output')
                inference.embeds.initialize(init=initializer.Xavier(magnitude=2.24), ctx=self.args.ctx)
                inference.output.initialize(init=initializer.Xavier(magnitude=2.24), ctx=self.args.ctx)
            elif self.args.model_path.endswith('.params'):
                print('load the weights from path: %s' % self.args.model_path)
                inference.load_parameters(self.args.model_path, self.args.ctx)
            elif self.args.start_epoch > 0:
                print('load the weights from path: %s' % os.path.join(self.args.ckpt, '%s-%s-%04d.params'
                                                                      % (self.args.bb, postfix, 0)))
                inference.load_parameters(os.path.join(self.args.ckpt, '%s-%s-%04d.params' %
                                          (self.args.bb, postfix, 0)), self.args.ctx)
            else:
                print('Initialize the weights')
                inference.initialize(init, ctx=self.args.ctx)
        else:
            print('load the weights from path: %s' % self.args.model_path)
            inference.load_parameters(self.args.model_path, self.args.ctx) 
开发者ID:aws-samples,项目名称:d-SNE,代码行数:32,代码来源:training_sda.py

示例9: __init__

# 需要导入模块: from mxnet import initializer [as 别名]
# 或者: from mxnet.initializer import Uniform [as 别名]
def __init__(self, planes, inplanes, upscale_factor=2, norm_layer=nn.BatchNorm, **kwargs):
        super(DUC, self).__init__()
        with self.name_scope():
            self.conv = nn.Conv2D(
                planes, in_channels=inplanes, kernel_size=3, padding=1, use_bias=False,
                weight_initializer=initializer.Uniform(scale=math.sqrt(1 / (inplanes * 3 * 3))),
                bias_initializer=initializer.Uniform(scale=math.sqrt(1 / (inplanes * 3 * 3))))
            self.bn = norm_layer(gamma_initializer=ZeroUniform(), **kwargs)
            self.relu = nn.Activation('relu')
            self.pixel_shuffle = PixelShuffle(upscale_factor) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:12,代码来源:oth_alpha_pose.py

示例10: init_params

# 需要导入模块: from mxnet import initializer [as 别名]
# 或者: from mxnet.initializer import Uniform [as 别名]
def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None,
                    allow_missing=False, force_init=False):
        if self.params_initialized and not force_init:
            return
        assert self.binded, 'call bind before initializing the parameters'
        self._curr_module.init_params(initializer=initializer, arg_params=arg_params,
                                      aux_params=aux_params, allow_missing=allow_missing,
                                      force_init=force_init)
        self.params_initialized = True 
开发者ID:wangshy31,项目名称:MANet_for_Video_Object_Detection,代码行数:11,代码来源:module.py


注:本文中的mxnet.initializer.Uniform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。