本文整理匯總了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
示例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
示例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)))
)
示例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)
示例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
示例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
示例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
示例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)
示例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)
示例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