repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
apache/incubator-mxnet | example/ssd/dataset/mscoco.py | Coco._load_all | def _load_all(self, anno_file, shuffle):
"""
initialize all entries given annotation json file
Parameters:
----------
anno_file: str
annotation json file
shuffle: bool
whether to shuffle image list
"""
image_set_index = []
... | python | def _load_all(self, anno_file, shuffle):
"""
initialize all entries given annotation json file
Parameters:
----------
anno_file: str
annotation json file
shuffle: bool
whether to shuffle image list
"""
image_set_index = []
... | [
"def",
"_load_all",
"(",
"self",
",",
"anno_file",
",",
"shuffle",
")",
":",
"image_set_index",
"=",
"[",
"]",
"labels",
"=",
"[",
"]",
"coco",
"=",
"COCO",
"(",
"anno_file",
")",
"img_ids",
"=",
"coco",
".",
"getImgIds",
"(",
")",
"# deal with class nam... | initialize all entries given annotation json file
Parameters:
----------
anno_file: str
annotation json file
shuffle: bool
whether to shuffle image list | [
"initialize",
"all",
"entries",
"given",
"annotation",
"json",
"file"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/mscoco.py#L85-L138 | train |
apache/incubator-mxnet | example/rnn/word_lm/module.py | CustomStatefulModule.init_params | def init_params(self, initializer=mx.init.Uniform(0.01), **kwargs):
"""Initializes the parameters and auxiliary states.
"""
self._module.init_params(initializer=initializer, **kwargs) | python | def init_params(self, initializer=mx.init.Uniform(0.01), **kwargs):
"""Initializes the parameters and auxiliary states.
"""
self._module.init_params(initializer=initializer, **kwargs) | [
"def",
"init_params",
"(",
"self",
",",
"initializer",
"=",
"mx",
".",
"init",
".",
"Uniform",
"(",
"0.01",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_module",
".",
"init_params",
"(",
"initializer",
"=",
"initializer",
",",
"*",
"*",
"kw... | Initializes the parameters and auxiliary states. | [
"Initializes",
"the",
"parameters",
"and",
"auxiliary",
"states",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/word_lm/module.py#L61-L64 | train |
apache/incubator-mxnet | example/rnn/word_lm/module.py | CustomStatefulModule.forward | def forward(self, data_batch, is_train=None, carry_state=True):
"""Forward computation. States from previous forward computation are carried
to the current iteration if `carry_state` is set to `True`.
"""
# propagate states from the previous iteration
if carry_state:
... | python | def forward(self, data_batch, is_train=None, carry_state=True):
"""Forward computation. States from previous forward computation are carried
to the current iteration if `carry_state` is set to `True`.
"""
# propagate states from the previous iteration
if carry_state:
... | [
"def",
"forward",
"(",
"self",
",",
"data_batch",
",",
"is_train",
"=",
"None",
",",
"carry_state",
"=",
"True",
")",
":",
"# propagate states from the previous iteration",
"if",
"carry_state",
":",
"if",
"isinstance",
"(",
"self",
".",
"_next_states",
",",
"(",... | Forward computation. States from previous forward computation are carried
to the current iteration if `carry_state` is set to `True`. | [
"Forward",
"computation",
".",
"States",
"from",
"previous",
"forward",
"computation",
"are",
"carried",
"to",
"the",
"current",
"iteration",
"if",
"carry_state",
"is",
"set",
"to",
"True",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/word_lm/module.py#L78-L90 | train |
apache/incubator-mxnet | example/rnn/word_lm/module.py | CustomStatefulModule.update | def update(self, max_norm=None):
"""Updates parameters according to the installed optimizer and the gradients computed
in the previous forward-backward batch. Gradients are clipped by their global norm
if `max_norm` is set.
Parameters
----------
max_norm: float, optional... | python | def update(self, max_norm=None):
"""Updates parameters according to the installed optimizer and the gradients computed
in the previous forward-backward batch. Gradients are clipped by their global norm
if `max_norm` is set.
Parameters
----------
max_norm: float, optional... | [
"def",
"update",
"(",
"self",
",",
"max_norm",
"=",
"None",
")",
":",
"if",
"max_norm",
"is",
"not",
"None",
":",
"self",
".",
"_clip_by_global_norm",
"(",
"max_norm",
")",
"self",
".",
"_module",
".",
"update",
"(",
")"
] | Updates parameters according to the installed optimizer and the gradients computed
in the previous forward-backward batch. Gradients are clipped by their global norm
if `max_norm` is set.
Parameters
----------
max_norm: float, optional
If set, clip values of all grad... | [
"Updates",
"parameters",
"according",
"to",
"the",
"installed",
"optimizer",
"and",
"the",
"gradients",
"computed",
"in",
"the",
"previous",
"forward",
"-",
"backward",
"batch",
".",
"Gradients",
"are",
"clipped",
"by",
"their",
"global",
"norm",
"if",
"max_norm... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/word_lm/module.py#L92-L104 | train |
apache/incubator-mxnet | example/rnn/word_lm/module.py | CustomStatefulModule._clip_by_global_norm | def _clip_by_global_norm(self, max_norm):
"""Clips gradient norm.
The norm is computed over all gradients together, as if they were
concatenated into a single vector. Gradients are modified in-place.
The method is first used in
`[ICML2013] On the difficulty of training recurren... | python | def _clip_by_global_norm(self, max_norm):
"""Clips gradient norm.
The norm is computed over all gradients together, as if they were
concatenated into a single vector. Gradients are modified in-place.
The method is first used in
`[ICML2013] On the difficulty of training recurren... | [
"def",
"_clip_by_global_norm",
"(",
"self",
",",
"max_norm",
")",
":",
"assert",
"self",
".",
"_module",
".",
"binded",
"and",
"self",
".",
"_module",
".",
"params_initialized",
"and",
"self",
".",
"_module",
".",
"optimizer_initialized",
"grad_array",
"=",
"[... | Clips gradient norm.
The norm is computed over all gradients together, as if they were
concatenated into a single vector. Gradients are modified in-place.
The method is first used in
`[ICML2013] On the difficulty of training recurrent neural networks`
Parameters
------... | [
"Clips",
"gradient",
"norm",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/word_lm/module.py#L106-L129 | train |
apache/incubator-mxnet | example/gluon/dc_gan/dcgan.py | visual | def visual(title, X, name):
"""Image visualization and preservation
:param title: title
:param X: images to visualized
:param name: saved picture`s name
:return:
"""
assert len(X.shape) == 4
X = X.transpose((0, 2, 3, 1))
X = np.clip((X - np.min(X))*(255.0/(np.max(X) - np.min(X))), 0,... | python | def visual(title, X, name):
"""Image visualization and preservation
:param title: title
:param X: images to visualized
:param name: saved picture`s name
:return:
"""
assert len(X.shape) == 4
X = X.transpose((0, 2, 3, 1))
X = np.clip((X - np.min(X))*(255.0/(np.max(X) - np.min(X))), 0,... | [
"def",
"visual",
"(",
"title",
",",
"X",
",",
"name",
")",
":",
"assert",
"len",
"(",
"X",
".",
"shape",
")",
"==",
"4",
"X",
"=",
"X",
".",
"transpose",
"(",
"(",
"0",
",",
"2",
",",
"3",
",",
"1",
")",
")",
"X",
"=",
"np",
".",
"clip",
... | Image visualization and preservation
:param title: title
:param X: images to visualized
:param name: saved picture`s name
:return: | [
"Image",
"visualization",
"and",
"preservation",
":",
"param",
"title",
":",
"title",
":",
"param",
"X",
":",
"images",
"to",
"visualized",
":",
"param",
"name",
":",
"saved",
"picture",
"s",
"name",
":",
"return",
":"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/dc_gan/dcgan.py#L52-L69 | train |
apache/incubator-mxnet | example/gluon/dc_gan/dcgan.py | transformer | def transformer(data, label):
"""Get the translation of images"""
# resize to 64x64
data = mx.image.imresize(data, 64, 64)
# transpose from (64, 64, 3) to (3, 64, 64)
data = mx.nd.transpose(data, (2, 0, 1))
# normalize to [-1, 1]
data = data.astype(np.float32)/128 - 1
# if image is greys... | python | def transformer(data, label):
"""Get the translation of images"""
# resize to 64x64
data = mx.image.imresize(data, 64, 64)
# transpose from (64, 64, 3) to (3, 64, 64)
data = mx.nd.transpose(data, (2, 0, 1))
# normalize to [-1, 1]
data = data.astype(np.float32)/128 - 1
# if image is greys... | [
"def",
"transformer",
"(",
"data",
",",
"label",
")",
":",
"# resize to 64x64",
"data",
"=",
"mx",
".",
"image",
".",
"imresize",
"(",
"data",
",",
"64",
",",
"64",
")",
"# transpose from (64, 64, 3) to (3, 64, 64)",
"data",
"=",
"mx",
".",
"nd",
".",
"tra... | Get the translation of images | [
"Get",
"the",
"translation",
"of",
"images"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/dc_gan/dcgan.py#L117-L128 | train |
apache/incubator-mxnet | example/gluon/dc_gan/dcgan.py | get_dataset | def get_dataset(dataset_name):
"""Load the dataset and split it to train/valid data
:param dataset_name: string
Returns:
train_data: int array
training dataset
val_data: int array
valid dataset
"""
# mnist
if dataset == "mnist":
train_data = gluon.data.DataLoade... | python | def get_dataset(dataset_name):
"""Load the dataset and split it to train/valid data
:param dataset_name: string
Returns:
train_data: int array
training dataset
val_data: int array
valid dataset
"""
# mnist
if dataset == "mnist":
train_data = gluon.data.DataLoade... | [
"def",
"get_dataset",
"(",
"dataset_name",
")",
":",
"# mnist",
"if",
"dataset",
"==",
"\"mnist\"",
":",
"train_data",
"=",
"gluon",
".",
"data",
".",
"DataLoader",
"(",
"gluon",
".",
"data",
".",
"vision",
".",
"MNIST",
"(",
"'./data'",
",",
"train",
"=... | Load the dataset and split it to train/valid data
:param dataset_name: string
Returns:
train_data: int array
training dataset
val_data: int array
valid dataset | [
"Load",
"the",
"dataset",
"and",
"split",
"it",
"to",
"train",
"/",
"valid",
"data"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/dc_gan/dcgan.py#L132-L162 | train |
apache/incubator-mxnet | example/gluon/dc_gan/dcgan.py | get_netG | def get_netG():
"""Get net G"""
# build the generator
netG = nn.Sequential()
with netG.name_scope():
# input is Z, going into a convolution
netG.add(nn.Conv2DTranspose(ngf * 8, 4, 1, 0, use_bias=False))
netG.add(nn.BatchNorm())
netG.add(nn.Activation('relu'))
# st... | python | def get_netG():
"""Get net G"""
# build the generator
netG = nn.Sequential()
with netG.name_scope():
# input is Z, going into a convolution
netG.add(nn.Conv2DTranspose(ngf * 8, 4, 1, 0, use_bias=False))
netG.add(nn.BatchNorm())
netG.add(nn.Activation('relu'))
# st... | [
"def",
"get_netG",
"(",
")",
":",
"# build the generator",
"netG",
"=",
"nn",
".",
"Sequential",
"(",
")",
"with",
"netG",
".",
"name_scope",
"(",
")",
":",
"# input is Z, going into a convolution",
"netG",
".",
"add",
"(",
"nn",
".",
"Conv2DTranspose",
"(",
... | Get net G | [
"Get",
"net",
"G"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/dc_gan/dcgan.py#L165-L191 | train |
apache/incubator-mxnet | example/gluon/dc_gan/dcgan.py | get_netD | def get_netD():
"""Get the netD"""
# build the discriminator
netD = nn.Sequential()
with netD.name_scope():
# input is (nc) x 64 x 64
netD.add(nn.Conv2D(ndf, 4, 2, 1, use_bias=False))
netD.add(nn.LeakyReLU(0.2))
# state size. (ndf) x 32 x 32
netD.add(nn.Conv2D(ndf... | python | def get_netD():
"""Get the netD"""
# build the discriminator
netD = nn.Sequential()
with netD.name_scope():
# input is (nc) x 64 x 64
netD.add(nn.Conv2D(ndf, 4, 2, 1, use_bias=False))
netD.add(nn.LeakyReLU(0.2))
# state size. (ndf) x 32 x 32
netD.add(nn.Conv2D(ndf... | [
"def",
"get_netD",
"(",
")",
":",
"# build the discriminator",
"netD",
"=",
"nn",
".",
"Sequential",
"(",
")",
"with",
"netD",
".",
"name_scope",
"(",
")",
":",
"# input is (nc) x 64 x 64",
"netD",
".",
"add",
"(",
"nn",
".",
"Conv2D",
"(",
"ndf",
",",
"... | Get the netD | [
"Get",
"the",
"netD"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/dc_gan/dcgan.py#L194-L218 | train |
apache/incubator-mxnet | example/gluon/dc_gan/dcgan.py | get_configurations | def get_configurations(netG, netD):
"""Get configurations for net"""
# loss
loss = gluon.loss.SoftmaxCrossEntropyLoss()
# initialize the generator and the discriminator
netG.initialize(mx.init.Normal(0.02), ctx=ctx)
netD.initialize(mx.init.Normal(0.02), ctx=ctx)
# trainer for the generator... | python | def get_configurations(netG, netD):
"""Get configurations for net"""
# loss
loss = gluon.loss.SoftmaxCrossEntropyLoss()
# initialize the generator and the discriminator
netG.initialize(mx.init.Normal(0.02), ctx=ctx)
netD.initialize(mx.init.Normal(0.02), ctx=ctx)
# trainer for the generator... | [
"def",
"get_configurations",
"(",
"netG",
",",
"netD",
")",
":",
"# loss",
"loss",
"=",
"gluon",
".",
"loss",
".",
"SoftmaxCrossEntropyLoss",
"(",
")",
"# initialize the generator and the discriminator",
"netG",
".",
"initialize",
"(",
"mx",
".",
"init",
".",
"N... | Get configurations for net | [
"Get",
"configurations",
"for",
"net"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/dc_gan/dcgan.py#L221-L234 | train |
apache/incubator-mxnet | example/gluon/dc_gan/dcgan.py | main | def main():
"""Entry point to dcgan"""
print("|------- new changes!!!!!!!!!")
# to get the dataset and net configuration
train_data, val_data = get_dataset(dataset)
netG = get_netG()
netD = get_netD()
loss, trainerG, trainerD = get_configurations(netG, netD)
# set labels
real_label ... | python | def main():
"""Entry point to dcgan"""
print("|------- new changes!!!!!!!!!")
# to get the dataset and net configuration
train_data, val_data = get_dataset(dataset)
netG = get_netG()
netD = get_netD()
loss, trainerG, trainerD = get_configurations(netG, netD)
# set labels
real_label ... | [
"def",
"main",
"(",
")",
":",
"print",
"(",
"\"|------- new changes!!!!!!!!!\"",
")",
"# to get the dataset and net configuration",
"train_data",
",",
"val_data",
"=",
"get_dataset",
"(",
"dataset",
")",
"netG",
"=",
"get_netG",
"(",
")",
"netD",
"=",
"get_netD",
... | Entry point to dcgan | [
"Entry",
"point",
"to",
"dcgan"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/dc_gan/dcgan.py#L249-L348 | train |
apache/incubator-mxnet | python/mxnet/log.py | getLogger | def getLogger(name=None, filename=None, filemode=None, level=WARNING):
"""Gets a customized logger.
.. note:: `getLogger` is deprecated. Use `get_logger` instead.
"""
warnings.warn("getLogger is deprecated, Use get_logger instead.",
DeprecationWarning, stacklevel=2)
return get_lo... | python | def getLogger(name=None, filename=None, filemode=None, level=WARNING):
"""Gets a customized logger.
.. note:: `getLogger` is deprecated. Use `get_logger` instead.
"""
warnings.warn("getLogger is deprecated, Use get_logger instead.",
DeprecationWarning, stacklevel=2)
return get_lo... | [
"def",
"getLogger",
"(",
"name",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"filemode",
"=",
"None",
",",
"level",
"=",
"WARNING",
")",
":",
"warnings",
".",
"warn",
"(",
"\"getLogger is deprecated, Use get_logger instead.\"",
",",
"DeprecationWarning",
","... | Gets a customized logger.
.. note:: `getLogger` is deprecated. Use `get_logger` instead. | [
"Gets",
"a",
"customized",
"logger",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/log.py#L80-L88 | train |
apache/incubator-mxnet | python/mxnet/log.py | get_logger | def get_logger(name=None, filename=None, filemode=None, level=WARNING):
"""Gets a customized logger.
Parameters
----------
name: str, optional
Name of the logger.
filename: str, optional
The filename to which the logger's output will be sent.
filemode: str, optional
The ... | python | def get_logger(name=None, filename=None, filemode=None, level=WARNING):
"""Gets a customized logger.
Parameters
----------
name: str, optional
Name of the logger.
filename: str, optional
The filename to which the logger's output will be sent.
filemode: str, optional
The ... | [
"def",
"get_logger",
"(",
"name",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"filemode",
"=",
"None",
",",
"level",
"=",
"WARNING",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"if",
"name",
"is",
"not",
"None",
"and",... | Gets a customized logger.
Parameters
----------
name: str, optional
Name of the logger.
filename: str, optional
The filename to which the logger's output will be sent.
filemode: str, optional
The file mode to open the file (corresponding to `filename`),
default is 'a... | [
"Gets",
"a",
"customized",
"logger",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/log.py#L90-L145 | train |
apache/incubator-mxnet | example/gluon/sn_gan/data.py | transformer | def transformer(data, label):
""" data preparation """
data = mx.image.imresize(data, IMAGE_SIZE, IMAGE_SIZE)
data = mx.nd.transpose(data, (2, 0, 1))
data = data.astype(np.float32) / 128.0 - 1
return data, label | python | def transformer(data, label):
""" data preparation """
data = mx.image.imresize(data, IMAGE_SIZE, IMAGE_SIZE)
data = mx.nd.transpose(data, (2, 0, 1))
data = data.astype(np.float32) / 128.0 - 1
return data, label | [
"def",
"transformer",
"(",
"data",
",",
"label",
")",
":",
"data",
"=",
"mx",
".",
"image",
".",
"imresize",
"(",
"data",
",",
"IMAGE_SIZE",
",",
"IMAGE_SIZE",
")",
"data",
"=",
"mx",
".",
"nd",
".",
"transpose",
"(",
"data",
",",
"(",
"2",
",",
... | data preparation | [
"data",
"preparation"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/sn_gan/data.py#L30-L35 | train |
apache/incubator-mxnet | example/gluon/sn_gan/data.py | get_training_data | def get_training_data(batch_size):
""" helper function to get dataloader"""
return gluon.data.DataLoader(
CIFAR10(train=True, transform=transformer),
batch_size=batch_size, shuffle=True, last_batch='discard') | python | def get_training_data(batch_size):
""" helper function to get dataloader"""
return gluon.data.DataLoader(
CIFAR10(train=True, transform=transformer),
batch_size=batch_size, shuffle=True, last_batch='discard') | [
"def",
"get_training_data",
"(",
"batch_size",
")",
":",
"return",
"gluon",
".",
"data",
".",
"DataLoader",
"(",
"CIFAR10",
"(",
"train",
"=",
"True",
",",
"transform",
"=",
"transformer",
")",
",",
"batch_size",
"=",
"batch_size",
",",
"shuffle",
"=",
"Tr... | helper function to get dataloader | [
"helper",
"function",
"to",
"get",
"dataloader"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/sn_gan/data.py#L38-L42 | train |
apache/incubator-mxnet | python/mxnet/gluon/model_zoo/vision/resnet.py | get_resnet | def get_resnet(version, num_layers, pretrained=False, ctx=cpu(),
root=os.path.join(base.data_dir(), 'models'), **kwargs):
r"""ResNet V1 model from `"Deep Residual Learning for Image Recognition"
<http://arxiv.org/abs/1512.03385>`_ paper.
ResNet V2 model from `"Identity Mappings in Deep Residu... | python | def get_resnet(version, num_layers, pretrained=False, ctx=cpu(),
root=os.path.join(base.data_dir(), 'models'), **kwargs):
r"""ResNet V1 model from `"Deep Residual Learning for Image Recognition"
<http://arxiv.org/abs/1512.03385>`_ paper.
ResNet V2 model from `"Identity Mappings in Deep Residu... | [
"def",
"get_resnet",
"(",
"version",
",",
"num_layers",
",",
"pretrained",
"=",
"False",
",",
"ctx",
"=",
"cpu",
"(",
")",
",",
"root",
"=",
"os",
".",
"path",
".",
"join",
"(",
"base",
".",
"data_dir",
"(",
")",
",",
"'models'",
")",
",",
"*",
"... | r"""ResNet V1 model from `"Deep Residual Learning for Image Recognition"
<http://arxiv.org/abs/1512.03385>`_ paper.
ResNet V2 model from `"Identity Mappings in Deep Residual Networks"
<https://arxiv.org/abs/1603.05027>`_ paper.
Parameters
----------
version : int
Version of ResNet. Opti... | [
"r",
"ResNet",
"V1",
"model",
"from",
"Deep",
"Residual",
"Learning",
"for",
"Image",
"Recognition",
"<http",
":",
"//",
"arxiv",
".",
"org",
"/",
"abs",
"/",
"1512",
".",
"03385",
">",
"_",
"paper",
".",
"ResNet",
"V2",
"model",
"from",
"Identity",
"M... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/model_zoo/vision/resnet.py#L359-L392 | train |
apache/incubator-mxnet | python/mxnet/symbol/random.py | _random_helper | def _random_helper(random, sampler, params, shape, dtype, kwargs):
"""Helper function for random generators."""
if isinstance(params[0], Symbol):
for i in params[1:]:
assert isinstance(i, Symbol), \
"Distribution parameters must all have the same type, but got " \
... | python | def _random_helper(random, sampler, params, shape, dtype, kwargs):
"""Helper function for random generators."""
if isinstance(params[0], Symbol):
for i in params[1:]:
assert isinstance(i, Symbol), \
"Distribution parameters must all have the same type, but got " \
... | [
"def",
"_random_helper",
"(",
"random",
",",
"sampler",
",",
"params",
",",
"shape",
",",
"dtype",
",",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"params",
"[",
"0",
"]",
",",
"Symbol",
")",
":",
"for",
"i",
"in",
"params",
"[",
"1",
":",
"]",
... | Helper function for random generators. | [
"Helper",
"function",
"for",
"random",
"generators",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/random.py#L29-L45 | train |
apache/incubator-mxnet | python/mxnet/symbol/random.py | poisson | def poisson(lam=1, shape=_Null, dtype=_Null, **kwargs):
"""Draw random samples from a Poisson distribution.
Samples are distributed according to a Poisson distribution parametrized
by *lambda* (rate). Samples will always be returned as a floating point data type.
Parameters
----------
lam : fl... | python | def poisson(lam=1, shape=_Null, dtype=_Null, **kwargs):
"""Draw random samples from a Poisson distribution.
Samples are distributed according to a Poisson distribution parametrized
by *lambda* (rate). Samples will always be returned as a floating point data type.
Parameters
----------
lam : fl... | [
"def",
"poisson",
"(",
"lam",
"=",
"1",
",",
"shape",
"=",
"_Null",
",",
"dtype",
"=",
"_Null",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_random_helper",
"(",
"_internal",
".",
"_random_poisson",
",",
"_internal",
".",
"_sample_poisson",
",",
"[",
... | Draw random samples from a Poisson distribution.
Samples are distributed according to a Poisson distribution parametrized
by *lambda* (rate). Samples will always be returned as a floating point data type.
Parameters
----------
lam : float or Symbol, optional
Expectation of interval, should... | [
"Draw",
"random",
"samples",
"from",
"a",
"Poisson",
"distribution",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/random.py#L116-L143 | train |
apache/incubator-mxnet | python/mxnet/symbol/random.py | generalized_negative_binomial | def generalized_negative_binomial(mu=1, alpha=1, shape=_Null, dtype=_Null, **kwargs):
"""Draw random samples from a generalized negative binomial distribution.
Samples are distributed according to a generalized negative binomial
distribution parametrized by *mu* (mean) and *alpha* (dispersion).
*alpha*... | python | def generalized_negative_binomial(mu=1, alpha=1, shape=_Null, dtype=_Null, **kwargs):
"""Draw random samples from a generalized negative binomial distribution.
Samples are distributed according to a generalized negative binomial
distribution parametrized by *mu* (mean) and *alpha* (dispersion).
*alpha*... | [
"def",
"generalized_negative_binomial",
"(",
"mu",
"=",
"1",
",",
"alpha",
"=",
"1",
",",
"shape",
"=",
"_Null",
",",
"dtype",
"=",
"_Null",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_random_helper",
"(",
"_internal",
".",
"_random_generalized_negative_b... | Draw random samples from a generalized negative binomial distribution.
Samples are distributed according to a generalized negative binomial
distribution parametrized by *mu* (mean) and *alpha* (dispersion).
*alpha* is defined as *1/k* where *k* is the failure limit of the
number of unsuccessful experim... | [
"Draw",
"random",
"samples",
"from",
"a",
"generalized",
"negative",
"binomial",
"distribution",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/random.py#L248-L281 | train |
apache/incubator-mxnet | python/mxnet/symbol/random.py | multinomial | def multinomial(data, shape=_Null, get_prob=True, dtype='int32', **kwargs):
"""Concurrent sampling from multiple multinomial distributions.
.. note:: The input distribution must be normalized, i.e. `data` must sum to
1 along its last dimension.
Parameters
----------
data : Symbol
... | python | def multinomial(data, shape=_Null, get_prob=True, dtype='int32', **kwargs):
"""Concurrent sampling from multiple multinomial distributions.
.. note:: The input distribution must be normalized, i.e. `data` must sum to
1 along its last dimension.
Parameters
----------
data : Symbol
... | [
"def",
"multinomial",
"(",
"data",
",",
"shape",
"=",
"_Null",
",",
"get_prob",
"=",
"True",
",",
"dtype",
"=",
"'int32'",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_internal",
".",
"_sample_multinomial",
"(",
"data",
",",
"shape",
",",
"get_prob",
... | Concurrent sampling from multiple multinomial distributions.
.. note:: The input distribution must be normalized, i.e. `data` must sum to
1 along its last dimension.
Parameters
----------
data : Symbol
An *n* dimensional array whose last dimension has length `k`, where
`k... | [
"Concurrent",
"sampling",
"from",
"multiple",
"multinomial",
"distributions",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/random.py#L284-L325 | train |
apache/incubator-mxnet | example/ssd/symbol/legacy_vgg16_ssd_300.py | get_symbol_train | def get_symbol_train(num_classes=20, nms_thresh=0.5, force_suppress=False,
nms_topk=400, **kwargs):
"""
Single-shot multi-box detection with VGG 16 layers ConvNet
This is a modified version, with fc6/fc7 layers replaced by conv layers
And the network is slightly smaller than origina... | python | def get_symbol_train(num_classes=20, nms_thresh=0.5, force_suppress=False,
nms_topk=400, **kwargs):
"""
Single-shot multi-box detection with VGG 16 layers ConvNet
This is a modified version, with fc6/fc7 layers replaced by conv layers
And the network is slightly smaller than origina... | [
"def",
"get_symbol_train",
"(",
"num_classes",
"=",
"20",
",",
"nms_thresh",
"=",
"0.5",
",",
"force_suppress",
"=",
"False",
",",
"nms_topk",
"=",
"400",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"mx",
".",
"symbol",
".",
"Variable",
"(",
"name"... | Single-shot multi-box detection with VGG 16 layers ConvNet
This is a modified version, with fc6/fc7 layers replaced by conv layers
And the network is slightly smaller than original VGG 16 network
This is a training network with losses
Parameters:
----------
num_classes: int
number of ob... | [
"Single",
"-",
"shot",
"multi",
"-",
"box",
"detection",
"with",
"VGG",
"16",
"layers",
"ConvNet",
"This",
"is",
"a",
"modified",
"version",
"with",
"fc6",
"/",
"fc7",
"layers",
"replaced",
"by",
"conv",
"layers",
"And",
"the",
"network",
"is",
"slightly",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/symbol/legacy_vgg16_ssd_300.py#L22-L173 | train |
apache/incubator-mxnet | example/ssd/symbol/legacy_vgg16_ssd_300.py | get_symbol | def get_symbol(num_classes=20, nms_thresh=0.5, force_suppress=False,
nms_topk=400, **kwargs):
"""
Single-shot multi-box detection with VGG 16 layers ConvNet
This is a modified version, with fc6/fc7 layers replaced by conv layers
And the network is slightly smaller than original VGG 16 net... | python | def get_symbol(num_classes=20, nms_thresh=0.5, force_suppress=False,
nms_topk=400, **kwargs):
"""
Single-shot multi-box detection with VGG 16 layers ConvNet
This is a modified version, with fc6/fc7 layers replaced by conv layers
And the network is slightly smaller than original VGG 16 net... | [
"def",
"get_symbol",
"(",
"num_classes",
"=",
"20",
",",
"nms_thresh",
"=",
"0.5",
",",
"force_suppress",
"=",
"False",
",",
"nms_topk",
"=",
"400",
",",
"*",
"*",
"kwargs",
")",
":",
"net",
"=",
"get_symbol_train",
"(",
"num_classes",
")",
"cls_preds",
... | Single-shot multi-box detection with VGG 16 layers ConvNet
This is a modified version, with fc6/fc7 layers replaced by conv layers
And the network is slightly smaller than original VGG 16 network
This is the detection network
Parameters:
----------
num_classes: int
number of object clas... | [
"Single",
"-",
"shot",
"multi",
"-",
"box",
"detection",
"with",
"VGG",
"16",
"layers",
"ConvNet",
"This",
"is",
"a",
"modified",
"version",
"with",
"fc6",
"/",
"fc7",
"layers",
"replaced",
"by",
"conv",
"layers",
"And",
"the",
"network",
"is",
"slightly",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/symbol/legacy_vgg16_ssd_300.py#L175-L207 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.load | def load(prefix, epoch, load_optimizer_states=False, **kwargs):
"""Creates a model from previously saved checkpoint.
Parameters
----------
prefix : str
path prefix of saved model files. You should have
"prefix-symbol.json", "prefix-xxxx.params", and
o... | python | def load(prefix, epoch, load_optimizer_states=False, **kwargs):
"""Creates a model from previously saved checkpoint.
Parameters
----------
prefix : str
path prefix of saved model files. You should have
"prefix-symbol.json", "prefix-xxxx.params", and
o... | [
"def",
"load",
"(",
"prefix",
",",
"epoch",
",",
"load_optimizer_states",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"sym",
",",
"args",
",",
"auxs",
"=",
"load_checkpoint",
"(",
"prefix",
",",
"epoch",
")",
"mod",
"=",
"Module",
"(",
"symbol",
... | Creates a model from previously saved checkpoint.
Parameters
----------
prefix : str
path prefix of saved model files. You should have
"prefix-symbol.json", "prefix-xxxx.params", and
optionally "prefix-xxxx.states", where xxxx is the
epoch number.... | [
"Creates",
"a",
"model",
"from",
"previously",
"saved",
"checkpoint",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L127-L163 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.save_checkpoint | def save_checkpoint(self, prefix, epoch, save_optimizer_states=False):
"""Saves current progress to checkpoint.
Use `mx.callback.module_checkpoint` as `epoch_end_callback` to save during training.
Parameters
----------
prefix : str
The file prefix to checkpoint to.
... | python | def save_checkpoint(self, prefix, epoch, save_optimizer_states=False):
"""Saves current progress to checkpoint.
Use `mx.callback.module_checkpoint` as `epoch_end_callback` to save during training.
Parameters
----------
prefix : str
The file prefix to checkpoint to.
... | [
"def",
"save_checkpoint",
"(",
"self",
",",
"prefix",
",",
"epoch",
",",
"save_optimizer_states",
"=",
"False",
")",
":",
"self",
".",
"_symbol",
".",
"save",
"(",
"'%s-symbol.json'",
"%",
"prefix",
")",
"param_name",
"=",
"'%s-%04d.params'",
"%",
"(",
"pref... | Saves current progress to checkpoint.
Use `mx.callback.module_checkpoint` as `epoch_end_callback` to save during training.
Parameters
----------
prefix : str
The file prefix to checkpoint to.
epoch : int
The current epoch number.
save_optimizer_st... | [
"Saves",
"current",
"progress",
"to",
"checkpoint",
".",
"Use",
"mx",
".",
"callback",
".",
"module_checkpoint",
"as",
"epoch_end_callback",
"to",
"save",
"during",
"training",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L165-L185 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module._reset_bind | def _reset_bind(self):
"""Internal function to reset binded state."""
self.binded = False
self._exec_group = None
self._data_shapes = None
self._label_shapes = None | python | def _reset_bind(self):
"""Internal function to reset binded state."""
self.binded = False
self._exec_group = None
self._data_shapes = None
self._label_shapes = None | [
"def",
"_reset_bind",
"(",
"self",
")",
":",
"self",
".",
"binded",
"=",
"False",
"self",
".",
"_exec_group",
"=",
"None",
"self",
".",
"_data_shapes",
"=",
"None",
"self",
".",
"_label_shapes",
"=",
"None"
] | Internal function to reset binded state. | [
"Internal",
"function",
"to",
"reset",
"binded",
"state",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L187-L192 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.get_params | def get_params(self):
"""Gets current parameters.
Returns
-------
`(arg_params, aux_params)`
A pair of dictionaries each mapping parameter names to NDArray values.
"""
assert self.binded and self.params_initialized
if self._params_dirty:
... | python | def get_params(self):
"""Gets current parameters.
Returns
-------
`(arg_params, aux_params)`
A pair of dictionaries each mapping parameter names to NDArray values.
"""
assert self.binded and self.params_initialized
if self._params_dirty:
... | [
"def",
"get_params",
"(",
"self",
")",
":",
"assert",
"self",
".",
"binded",
"and",
"self",
".",
"params_initialized",
"if",
"self",
".",
"_params_dirty",
":",
"self",
".",
"_sync_params_from_devices",
"(",
")",
"return",
"(",
"self",
".",
"_arg_params",
","... | Gets current parameters.
Returns
-------
`(arg_params, aux_params)`
A pair of dictionaries each mapping parameter names to NDArray values. | [
"Gets",
"current",
"parameters",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L245-L257 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.init_params | def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None,
allow_missing=False, force_init=False, allow_extra=False):
"""Initializes the parameters and auxiliary states.
Parameters
----------
initializer : Initializer
Called to ini... | python | def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None,
allow_missing=False, force_init=False, allow_extra=False):
"""Initializes the parameters and auxiliary states.
Parameters
----------
initializer : Initializer
Called to ini... | [
"def",
"init_params",
"(",
"self",
",",
"initializer",
"=",
"Uniform",
"(",
"0.01",
")",
",",
"arg_params",
"=",
"None",
",",
"aux_params",
"=",
"None",
",",
"allow_missing",
"=",
"False",
",",
"force_init",
"=",
"False",
",",
"allow_extra",
"=",
"False",
... | Initializes the parameters and auxiliary states.
Parameters
----------
initializer : Initializer
Called to initialize parameters if needed.
arg_params : dict
If not ``None``, should be a dictionary of existing arg_params. Initialization
will be copied... | [
"Initializes",
"the",
"parameters",
"and",
"auxiliary",
"states",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L259-L320 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.set_params | def set_params(self, arg_params, aux_params, allow_missing=False, force_init=True,
allow_extra=False):
"""Assigns parameter and aux state values.
Parameters
----------
arg_params : dict
Dictionary of name to `NDArray`.
aux_params : dict
... | python | def set_params(self, arg_params, aux_params, allow_missing=False, force_init=True,
allow_extra=False):
"""Assigns parameter and aux state values.
Parameters
----------
arg_params : dict
Dictionary of name to `NDArray`.
aux_params : dict
... | [
"def",
"set_params",
"(",
"self",
",",
"arg_params",
",",
"aux_params",
",",
"allow_missing",
"=",
"False",
",",
"force_init",
"=",
"True",
",",
"allow_extra",
"=",
"False",
")",
":",
"if",
"not",
"allow_missing",
":",
"self",
".",
"init_params",
"(",
"ini... | Assigns parameter and aux state values.
Parameters
----------
arg_params : dict
Dictionary of name to `NDArray`.
aux_params : dict
Dictionary of name to `NDArray`.
allow_missing : bool
If ``True``, params could contain missing values, and the ... | [
"Assigns",
"parameter",
"and",
"aux",
"state",
"values",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L322-L362 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.bind | def bind(self, data_shapes, label_shapes=None, for_training=True,
inputs_need_grad=False, force_rebind=False, shared_module=None,
grad_req='write'):
"""Binds the symbols to construct executors. This is necessary before one
can perform computation with the module.
Param... | python | def bind(self, data_shapes, label_shapes=None, for_training=True,
inputs_need_grad=False, force_rebind=False, shared_module=None,
grad_req='write'):
"""Binds the symbols to construct executors. This is necessary before one
can perform computation with the module.
Param... | [
"def",
"bind",
"(",
"self",
",",
"data_shapes",
",",
"label_shapes",
"=",
"None",
",",
"for_training",
"=",
"True",
",",
"inputs_need_grad",
"=",
"False",
",",
"force_rebind",
"=",
"False",
",",
"shared_module",
"=",
"None",
",",
"grad_req",
"=",
"'write'",
... | Binds the symbols to construct executors. This is necessary before one
can perform computation with the module.
Parameters
----------
data_shapes : list of (str, tuple)
Typically is ``data_iter.provide_data``.
label_shapes : list of (str, tuple)
Typically... | [
"Binds",
"the",
"symbols",
"to",
"construct",
"executors",
".",
"This",
"is",
"necessary",
"before",
"one",
"can",
"perform",
"computation",
"with",
"the",
"module",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L364-L456 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.reshape | def reshape(self, data_shapes, label_shapes=None):
"""Reshapes the module for new input shapes.
Parameters
----------
data_shapes : list of (str, tuple)
Typically is ``data_iter.provide_data``.
label_shapes : list of (str, tuple)
Typically is ``data_iter.... | python | def reshape(self, data_shapes, label_shapes=None):
"""Reshapes the module for new input shapes.
Parameters
----------
data_shapes : list of (str, tuple)
Typically is ``data_iter.provide_data``.
label_shapes : list of (str, tuple)
Typically is ``data_iter.... | [
"def",
"reshape",
"(",
"self",
",",
"data_shapes",
",",
"label_shapes",
"=",
"None",
")",
":",
"assert",
"self",
".",
"binded",
"self",
".",
"_data_shapes",
",",
"self",
".",
"_label_shapes",
"=",
"_parse_data_desc",
"(",
"self",
".",
"data_names",
",",
"s... | Reshapes the module for new input shapes.
Parameters
----------
data_shapes : list of (str, tuple)
Typically is ``data_iter.provide_data``.
label_shapes : list of (str, tuple)
Typically is ``data_iter.provide_label``. | [
"Reshapes",
"the",
"module",
"for",
"new",
"input",
"shapes",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L458-L472 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.init_optimizer | def init_optimizer(self, kvstore='local', optimizer='sgd',
optimizer_params=(('learning_rate', 0.01),), force_init=False):
"""Installs and initializes optimizers.
Parameters
----------
kvstore : str or KVStore
Default `'local'`.
optimizer : str... | python | def init_optimizer(self, kvstore='local', optimizer='sgd',
optimizer_params=(('learning_rate', 0.01),), force_init=False):
"""Installs and initializes optimizers.
Parameters
----------
kvstore : str or KVStore
Default `'local'`.
optimizer : str... | [
"def",
"init_optimizer",
"(",
"self",
",",
"kvstore",
"=",
"'local'",
",",
"optimizer",
"=",
"'sgd'",
",",
"optimizer_params",
"=",
"(",
"(",
"'learning_rate'",
",",
"0.01",
")",
",",
")",
",",
"force_init",
"=",
"False",
")",
":",
"assert",
"self",
".",... | Installs and initializes optimizers.
Parameters
----------
kvstore : str or KVStore
Default `'local'`.
optimizer : str or Optimizer
Default `'sgd'`
optimizer_params : dict
Default `(('learning_rate', 0.01),)`. The default value is not a dictio... | [
"Installs",
"and",
"initializes",
"optimizers",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L474-L558 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.borrow_optimizer | def borrow_optimizer(self, shared_module):
"""Borrows optimizer from a shared module. Used in bucketing, where exactly the same
optimizer (esp. kvstore) is used.
Parameters
----------
shared_module : Module
"""
assert shared_module.optimizer_initialized
s... | python | def borrow_optimizer(self, shared_module):
"""Borrows optimizer from a shared module. Used in bucketing, where exactly the same
optimizer (esp. kvstore) is used.
Parameters
----------
shared_module : Module
"""
assert shared_module.optimizer_initialized
s... | [
"def",
"borrow_optimizer",
"(",
"self",
",",
"shared_module",
")",
":",
"assert",
"shared_module",
".",
"optimizer_initialized",
"self",
".",
"_optimizer",
"=",
"shared_module",
".",
"_optimizer",
"self",
".",
"_kvstore",
"=",
"shared_module",
".",
"_kvstore",
"se... | Borrows optimizer from a shared module. Used in bucketing, where exactly the same
optimizer (esp. kvstore) is used.
Parameters
----------
shared_module : Module | [
"Borrows",
"optimizer",
"from",
"a",
"shared",
"module",
".",
"Used",
"in",
"bucketing",
"where",
"exactly",
"the",
"same",
"optimizer",
"(",
"esp",
".",
"kvstore",
")",
"is",
"used",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L560-L573 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.forward | def forward(self, data_batch, is_train=None):
"""Forward computation. It supports data batches with different shapes, such as
different batch sizes or different image sizes.
If reshaping of data batch relates to modification of symbol or module, such as
changing image layout ordering or ... | python | def forward(self, data_batch, is_train=None):
"""Forward computation. It supports data batches with different shapes, such as
different batch sizes or different image sizes.
If reshaping of data batch relates to modification of symbol or module, such as
changing image layout ordering or ... | [
"def",
"forward",
"(",
"self",
",",
"data_batch",
",",
"is_train",
"=",
"None",
")",
":",
"assert",
"self",
".",
"binded",
"and",
"self",
".",
"params_initialized",
"curr_data_shapes",
"=",
"tuple",
"(",
"i",
".",
"shape",
"for",
"i",
"in",
"self",
".",
... | Forward computation. It supports data batches with different shapes, such as
different batch sizes or different image sizes.
If reshaping of data batch relates to modification of symbol or module, such as
changing image layout ordering or switching from training to predicting, module
reb... | [
"Forward",
"computation",
".",
"It",
"supports",
"data",
"batches",
"with",
"different",
"shapes",
"such",
"as",
"different",
"batch",
"sizes",
"or",
"different",
"image",
"sizes",
".",
"If",
"reshaping",
"of",
"data",
"batch",
"relates",
"to",
"modification",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L575-L627 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.backward | def backward(self, out_grads=None):
"""Backward computation.
See Also
----------
:meth:`BaseModule.backward`.
Parameters
----------
out_grads : NDArray or list of NDArray, optional
Gradient on the outputs to be propagated back.
This param... | python | def backward(self, out_grads=None):
"""Backward computation.
See Also
----------
:meth:`BaseModule.backward`.
Parameters
----------
out_grads : NDArray or list of NDArray, optional
Gradient on the outputs to be propagated back.
This param... | [
"def",
"backward",
"(",
"self",
",",
"out_grads",
"=",
"None",
")",
":",
"assert",
"self",
".",
"binded",
"and",
"self",
".",
"params_initialized",
"self",
".",
"_exec_group",
".",
"backward",
"(",
"out_grads",
"=",
"out_grads",
")"
] | Backward computation.
See Also
----------
:meth:`BaseModule.backward`.
Parameters
----------
out_grads : NDArray or list of NDArray, optional
Gradient on the outputs to be propagated back.
This parameter is only needed when bind is called
... | [
"Backward",
"computation",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L629-L644 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.update | def update(self):
"""Updates parameters according to the installed optimizer and the gradients computed
in the previous forward-backward batch.
When KVStore is used to update parameters for multi-device or multi-machine training,
a copy of the parameters are stored in KVStore. Note that... | python | def update(self):
"""Updates parameters according to the installed optimizer and the gradients computed
in the previous forward-backward batch.
When KVStore is used to update parameters for multi-device or multi-machine training,
a copy of the parameters are stored in KVStore. Note that... | [
"def",
"update",
"(",
"self",
")",
":",
"assert",
"self",
".",
"binded",
"and",
"self",
".",
"params_initialized",
"and",
"self",
".",
"optimizer_initialized",
"self",
".",
"_params_dirty",
"=",
"True",
"if",
"self",
".",
"_update_on_kvstore",
":",
"_update_pa... | Updates parameters according to the installed optimizer and the gradients computed
in the previous forward-backward batch.
When KVStore is used to update parameters for multi-device or multi-machine training,
a copy of the parameters are stored in KVStore. Note that for `row_sparse` parameters,... | [
"Updates",
"parameters",
"according",
"to",
"the",
"installed",
"optimizer",
"and",
"the",
"gradients",
"computed",
"in",
"the",
"previous",
"forward",
"-",
"backward",
"batch",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L646-L673 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.get_outputs | def get_outputs(self, merge_multi_context=True):
"""Gets outputs of the previous forward computation.
If ``merge_multi_context`` is ``True``, it is like ``[out1, out2]``. Otherwise, it
is like ``[[out1_dev1, out1_dev2], [out2_dev1, out2_dev2]]``. All the output
elements are `NDArray`. W... | python | def get_outputs(self, merge_multi_context=True):
"""Gets outputs of the previous forward computation.
If ``merge_multi_context`` is ``True``, it is like ``[out1, out2]``. Otherwise, it
is like ``[[out1_dev1, out1_dev2], [out2_dev1, out2_dev2]]``. All the output
elements are `NDArray`. W... | [
"def",
"get_outputs",
"(",
"self",
",",
"merge_multi_context",
"=",
"True",
")",
":",
"assert",
"self",
".",
"binded",
"and",
"self",
".",
"params_initialized",
"return",
"self",
".",
"_exec_group",
".",
"get_outputs",
"(",
"merge_multi_context",
"=",
"merge_mul... | Gets outputs of the previous forward computation.
If ``merge_multi_context`` is ``True``, it is like ``[out1, out2]``. Otherwise, it
is like ``[[out1_dev1, out1_dev2], [out2_dev1, out2_dev2]]``. All the output
elements are `NDArray`. When `merge_multi_context` is `False`, those `NDArray`
... | [
"Gets",
"outputs",
"of",
"the",
"previous",
"forward",
"computation",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L675-L697 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.get_input_grads | def get_input_grads(self, merge_multi_context=True):
"""Gets the gradients with respect to the inputs of the module.
If ``merge_multi_context`` is ``True``, it is like ``[grad1, grad2]``. Otherwise, it
is like ``[[grad1_dev1, grad1_dev2], [grad2_dev1, grad2_dev2]]``. All the output
elem... | python | def get_input_grads(self, merge_multi_context=True):
"""Gets the gradients with respect to the inputs of the module.
If ``merge_multi_context`` is ``True``, it is like ``[grad1, grad2]``. Otherwise, it
is like ``[[grad1_dev1, grad1_dev2], [grad2_dev1, grad2_dev2]]``. All the output
elem... | [
"def",
"get_input_grads",
"(",
"self",
",",
"merge_multi_context",
"=",
"True",
")",
":",
"assert",
"self",
".",
"binded",
"and",
"self",
".",
"params_initialized",
"and",
"self",
".",
"inputs_need_grad",
"return",
"self",
".",
"_exec_group",
".",
"get_input_gra... | Gets the gradients with respect to the inputs of the module.
If ``merge_multi_context`` is ``True``, it is like ``[grad1, grad2]``. Otherwise, it
is like ``[[grad1_dev1, grad1_dev2], [grad2_dev1, grad2_dev2]]``. All the output
elements are `NDArray`.
Parameters
----------
... | [
"Gets",
"the",
"gradients",
"with",
"respect",
"to",
"the",
"inputs",
"of",
"the",
"module",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L699-L720 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.get_states | def get_states(self, merge_multi_context=True):
"""Gets states from all devices.
If `merge_multi_context` is ``True``, it is like ``[out1, out2]``. Otherwise, it
is like ``[[out1_dev1, out1_dev2], [out2_dev1, out2_dev2]]``. All the output
elements are `NDArray`.
Parameters
... | python | def get_states(self, merge_multi_context=True):
"""Gets states from all devices.
If `merge_multi_context` is ``True``, it is like ``[out1, out2]``. Otherwise, it
is like ``[[out1_dev1, out1_dev2], [out2_dev1, out2_dev2]]``. All the output
elements are `NDArray`.
Parameters
... | [
"def",
"get_states",
"(",
"self",
",",
"merge_multi_context",
"=",
"True",
")",
":",
"assert",
"self",
".",
"binded",
"and",
"self",
".",
"params_initialized",
"return",
"self",
".",
"_exec_group",
".",
"get_states",
"(",
"merge_multi_context",
"=",
"merge_multi... | Gets states from all devices.
If `merge_multi_context` is ``True``, it is like ``[out1, out2]``. Otherwise, it
is like ``[[out1_dev1, out1_dev2], [out2_dev1, out2_dev2]]``. All the output
elements are `NDArray`.
Parameters
----------
merge_multi_context : bool
... | [
"Gets",
"states",
"from",
"all",
"devices",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L722-L743 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.update_metric | def update_metric(self, eval_metric, labels, pre_sliced=False):
"""Evaluates and accumulates evaluation metric on outputs of the last forward computation.
See Also
----------
:meth:`BaseModule.update_metric`.
Parameters
----------
eval_metric : EvalMetric
... | python | def update_metric(self, eval_metric, labels, pre_sliced=False):
"""Evaluates and accumulates evaluation metric on outputs of the last forward computation.
See Also
----------
:meth:`BaseModule.update_metric`.
Parameters
----------
eval_metric : EvalMetric
... | [
"def",
"update_metric",
"(",
"self",
",",
"eval_metric",
",",
"labels",
",",
"pre_sliced",
"=",
"False",
")",
":",
"self",
".",
"_exec_group",
".",
"update_metric",
"(",
"eval_metric",
",",
"labels",
",",
"pre_sliced",
")"
] | Evaluates and accumulates evaluation metric on outputs of the last forward computation.
See Also
----------
:meth:`BaseModule.update_metric`.
Parameters
----------
eval_metric : EvalMetric
Evaluation metric to use.
labels : list of NDArray if `pre_sl... | [
"Evaluates",
"and",
"accumulates",
"evaluation",
"metric",
"on",
"outputs",
"of",
"the",
"last",
"forward",
"computation",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L759-L775 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module._sync_params_from_devices | def _sync_params_from_devices(self):
"""Synchronizes parameters from devices to CPU. This function should be called after
calling `update` that updates the parameters on the devices, before one can read the
latest parameters from ``self._arg_params`` and ``self._aux_params``.
For row_sp... | python | def _sync_params_from_devices(self):
"""Synchronizes parameters from devices to CPU. This function should be called after
calling `update` that updates the parameters on the devices, before one can read the
latest parameters from ``self._arg_params`` and ``self._aux_params``.
For row_sp... | [
"def",
"_sync_params_from_devices",
"(",
"self",
")",
":",
"self",
".",
"_exec_group",
".",
"get_params",
"(",
"self",
".",
"_arg_params",
",",
"self",
".",
"_aux_params",
")",
"if",
"self",
".",
"_kvstore",
"and",
"self",
".",
"_update_on_kvstore",
":",
"fo... | Synchronizes parameters from devices to CPU. This function should be called after
calling `update` that updates the parameters on the devices, before one can read the
latest parameters from ``self._arg_params`` and ``self._aux_params``.
For row_sparse parameters on devices, ther are pulled from... | [
"Synchronizes",
"parameters",
"from",
"devices",
"to",
"CPU",
".",
"This",
"function",
"should",
"be",
"called",
"after",
"calling",
"update",
"that",
"updates",
"the",
"parameters",
"on",
"the",
"devices",
"before",
"one",
"can",
"read",
"the",
"latest",
"par... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L777-L791 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.save_optimizer_states | def save_optimizer_states(self, fname):
"""Saves optimizer (updater) state to a file.
Parameters
----------
fname : str
Path to output states file.
"""
assert self.optimizer_initialized
if self._update_on_kvstore:
self._kvstore.save_optim... | python | def save_optimizer_states(self, fname):
"""Saves optimizer (updater) state to a file.
Parameters
----------
fname : str
Path to output states file.
"""
assert self.optimizer_initialized
if self._update_on_kvstore:
self._kvstore.save_optim... | [
"def",
"save_optimizer_states",
"(",
"self",
",",
"fname",
")",
":",
"assert",
"self",
".",
"optimizer_initialized",
"if",
"self",
".",
"_update_on_kvstore",
":",
"self",
".",
"_kvstore",
".",
"save_optimizer_states",
"(",
"fname",
")",
"else",
":",
"with",
"o... | Saves optimizer (updater) state to a file.
Parameters
----------
fname : str
Path to output states file. | [
"Saves",
"optimizer",
"(",
"updater",
")",
"state",
"to",
"a",
"file",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L793-L807 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.load_optimizer_states | def load_optimizer_states(self, fname):
"""Loads optimizer (updater) state from a file.
Parameters
----------
fname : str
Path to input states file.
"""
assert self.optimizer_initialized
if self._update_on_kvstore:
self._kvstore.load_opti... | python | def load_optimizer_states(self, fname):
"""Loads optimizer (updater) state from a file.
Parameters
----------
fname : str
Path to input states file.
"""
assert self.optimizer_initialized
if self._update_on_kvstore:
self._kvstore.load_opti... | [
"def",
"load_optimizer_states",
"(",
"self",
",",
"fname",
")",
":",
"assert",
"self",
".",
"optimizer_initialized",
"if",
"self",
".",
"_update_on_kvstore",
":",
"self",
".",
"_kvstore",
".",
"load_optimizer_states",
"(",
"fname",
")",
"else",
":",
"self",
".... | Loads optimizer (updater) state from a file.
Parameters
----------
fname : str
Path to input states file. | [
"Loads",
"optimizer",
"(",
"updater",
")",
"state",
"from",
"a",
"file",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L809-L822 | train |
apache/incubator-mxnet | python/mxnet/module/module.py | Module.prepare | def prepare(self, data_batch, sparse_row_id_fn=None):
'''Prepares the module for processing a data batch.
Usually involves switching bucket and reshaping.
For modules that contain `row_sparse` parameters in KVStore,
it prepares the `row_sparse` parameters based on the sparse_row_id_fn.
... | python | def prepare(self, data_batch, sparse_row_id_fn=None):
'''Prepares the module for processing a data batch.
Usually involves switching bucket and reshaping.
For modules that contain `row_sparse` parameters in KVStore,
it prepares the `row_sparse` parameters based on the sparse_row_id_fn.
... | [
"def",
"prepare",
"(",
"self",
",",
"data_batch",
",",
"sparse_row_id_fn",
"=",
"None",
")",
":",
"assert",
"self",
".",
"binded",
"if",
"sparse_row_id_fn",
"is",
"not",
"None",
":",
"if",
"not",
"self",
".",
"_kvstore",
"or",
"not",
"self",
".",
"_updat... | Prepares the module for processing a data batch.
Usually involves switching bucket and reshaping.
For modules that contain `row_sparse` parameters in KVStore,
it prepares the `row_sparse` parameters based on the sparse_row_id_fn.
When KVStore is used to update parameters for multi-devi... | [
"Prepares",
"the",
"module",
"for",
"processing",
"a",
"data",
"batch",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L829-L870 | train |
apache/incubator-mxnet | python/mxnet/ndarray/random.py | _random_helper | def _random_helper(random, sampler, params, shape, dtype, ctx, out, kwargs):
"""Helper function for random generators."""
if isinstance(params[0], NDArray):
for i in params[1:]:
assert isinstance(i, NDArray), \
"Distribution parameters must all have the same type, but got " \... | python | def _random_helper(random, sampler, params, shape, dtype, ctx, out, kwargs):
"""Helper function for random generators."""
if isinstance(params[0], NDArray):
for i in params[1:]:
assert isinstance(i, NDArray), \
"Distribution parameters must all have the same type, but got " \... | [
"def",
"_random_helper",
"(",
"random",
",",
"sampler",
",",
"params",
",",
"shape",
",",
"dtype",
",",
"ctx",
",",
"out",
",",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"params",
"[",
"0",
"]",
",",
"NDArray",
")",
":",
"for",
"i",
"in",
"param... | Helper function for random generators. | [
"Helper",
"function",
"for",
"random",
"generators",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L31-L51 | train |
apache/incubator-mxnet | python/mxnet/ndarray/random.py | uniform | def uniform(low=0, high=1, shape=_Null, dtype=_Null, ctx=None, out=None, **kwargs):
"""Draw random samples from a uniform distribution.
Samples are uniformly distributed over the half-open interval *[low, high)*
(includes *low*, but excludes *high*).
Parameters
----------
low : float or NDArra... | python | def uniform(low=0, high=1, shape=_Null, dtype=_Null, ctx=None, out=None, **kwargs):
"""Draw random samples from a uniform distribution.
Samples are uniformly distributed over the half-open interval *[low, high)*
(includes *low*, but excludes *high*).
Parameters
----------
low : float or NDArra... | [
"def",
"uniform",
"(",
"low",
"=",
"0",
",",
"high",
"=",
"1",
",",
"shape",
"=",
"_Null",
",",
"dtype",
"=",
"_Null",
",",
"ctx",
"=",
"None",
",",
"out",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_random_helper",
"(",
"_interna... | Draw random samples from a uniform distribution.
Samples are uniformly distributed over the half-open interval *[low, high)*
(includes *low*, but excludes *high*).
Parameters
----------
low : float or NDArray, optional
Lower boundary of the output interval. All values generated will be
... | [
"Draw",
"random",
"samples",
"from",
"a",
"uniform",
"distribution",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L54-L110 | train |
apache/incubator-mxnet | python/mxnet/ndarray/random.py | normal | def normal(loc=0, scale=1, shape=_Null, dtype=_Null, ctx=None, out=None, **kwargs):
"""Draw random samples from a normal (Gaussian) distribution.
Samples are distributed according to a normal distribution parametrized
by *loc* (mean) and *scale* (standard deviation).
Parameters
----------
loc... | python | def normal(loc=0, scale=1, shape=_Null, dtype=_Null, ctx=None, out=None, **kwargs):
"""Draw random samples from a normal (Gaussian) distribution.
Samples are distributed according to a normal distribution parametrized
by *loc* (mean) and *scale* (standard deviation).
Parameters
----------
loc... | [
"def",
"normal",
"(",
"loc",
"=",
"0",
",",
"scale",
"=",
"1",
",",
"shape",
"=",
"_Null",
",",
"dtype",
"=",
"_Null",
",",
"ctx",
"=",
"None",
",",
"out",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_random_helper",
"(",
"_interna... | Draw random samples from a normal (Gaussian) distribution.
Samples are distributed according to a normal distribution parametrized
by *loc* (mean) and *scale* (standard deviation).
Parameters
----------
loc : float or NDArray, optional
Mean (centre) of the distribution.
scale : float ... | [
"Draw",
"random",
"samples",
"from",
"a",
"normal",
"(",
"Gaussian",
")",
"distribution",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L113-L167 | train |
apache/incubator-mxnet | python/mxnet/ndarray/random.py | randn | def randn(*shape, **kwargs):
"""Draw random samples from a normal (Gaussian) distribution.
Samples are distributed according to a normal distribution parametrized
by *loc* (mean) and *scale* (standard deviation).
Parameters
----------
loc : float or NDArray
Mean (centre) of the distri... | python | def randn(*shape, **kwargs):
"""Draw random samples from a normal (Gaussian) distribution.
Samples are distributed according to a normal distribution parametrized
by *loc* (mean) and *scale* (standard deviation).
Parameters
----------
loc : float or NDArray
Mean (centre) of the distri... | [
"def",
"randn",
"(",
"*",
"shape",
",",
"*",
"*",
"kwargs",
")",
":",
"loc",
"=",
"kwargs",
".",
"pop",
"(",
"'loc'",
",",
"0",
")",
"scale",
"=",
"kwargs",
".",
"pop",
"(",
"'scale'",
",",
"1",
")",
"dtype",
"=",
"kwargs",
".",
"pop",
"(",
"... | Draw random samples from a normal (Gaussian) distribution.
Samples are distributed according to a normal distribution parametrized
by *loc* (mean) and *scale* (standard deviation).
Parameters
----------
loc : float or NDArray
Mean (centre) of the distribution.
scale : float or NDArray... | [
"Draw",
"random",
"samples",
"from",
"a",
"normal",
"(",
"Gaussian",
")",
"distribution",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L170-L226 | train |
apache/incubator-mxnet | python/mxnet/ndarray/random.py | exponential | def exponential(scale=1, shape=_Null, dtype=_Null, ctx=None, out=None, **kwargs):
r"""Draw samples from an exponential distribution.
Its probability density function is
.. math:: f(x; \frac{1}{\beta}) = \frac{1}{\beta} \exp(-\frac{x}{\beta}),
for x > 0 and 0 elsewhere. \beta is the scale parameter, w... | python | def exponential(scale=1, shape=_Null, dtype=_Null, ctx=None, out=None, **kwargs):
r"""Draw samples from an exponential distribution.
Its probability density function is
.. math:: f(x; \frac{1}{\beta}) = \frac{1}{\beta} \exp(-\frac{x}{\beta}),
for x > 0 and 0 elsewhere. \beta is the scale parameter, w... | [
"def",
"exponential",
"(",
"scale",
"=",
"1",
",",
"shape",
"=",
"_Null",
",",
"dtype",
"=",
"_Null",
",",
"ctx",
"=",
"None",
",",
"out",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_random_helper",
"(",
"_internal",
".",
"_random_exp... | r"""Draw samples from an exponential distribution.
Its probability density function is
.. math:: f(x; \frac{1}{\beta}) = \frac{1}{\beta} \exp(-\frac{x}{\beta}),
for x > 0 and 0 elsewhere. \beta is the scale parameter, which is the
inverse of the rate parameter \lambda = 1/\beta.
Parameters
-... | [
"r",
"Draw",
"samples",
"from",
"an",
"exponential",
"distribution",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L279-L329 | train |
apache/incubator-mxnet | python/mxnet/ndarray/random.py | gamma | def gamma(alpha=1, beta=1, shape=_Null, dtype=_Null, ctx=None, out=None, **kwargs):
"""Draw random samples from a gamma distribution.
Samples are distributed according to a gamma distribution parametrized
by *alpha* (shape) and *beta* (scale).
Parameters
----------
alpha : float or NDArray, op... | python | def gamma(alpha=1, beta=1, shape=_Null, dtype=_Null, ctx=None, out=None, **kwargs):
"""Draw random samples from a gamma distribution.
Samples are distributed according to a gamma distribution parametrized
by *alpha* (shape) and *beta* (scale).
Parameters
----------
alpha : float or NDArray, op... | [
"def",
"gamma",
"(",
"alpha",
"=",
"1",
",",
"beta",
"=",
"1",
",",
"shape",
"=",
"_Null",
",",
"dtype",
"=",
"_Null",
",",
"ctx",
"=",
"None",
",",
"out",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_random_helper",
"(",
"_interna... | Draw random samples from a gamma distribution.
Samples are distributed according to a gamma distribution parametrized
by *alpha* (shape) and *beta* (scale).
Parameters
----------
alpha : float or NDArray, optional
The shape of the gamma distribution. Should be greater than zero.
beta :... | [
"Draw",
"random",
"samples",
"from",
"a",
"gamma",
"distribution",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L332-L383 | train |
apache/incubator-mxnet | python/mxnet/ndarray/random.py | negative_binomial | def negative_binomial(k=1, p=1, shape=_Null, dtype=_Null, ctx=None,
out=None, **kwargs):
"""Draw random samples from a negative binomial distribution.
Samples are distributed according to a negative binomial distribution
parametrized by *k* (limit of unsuccessful experiments) and *p* ... | python | def negative_binomial(k=1, p=1, shape=_Null, dtype=_Null, ctx=None,
out=None, **kwargs):
"""Draw random samples from a negative binomial distribution.
Samples are distributed according to a negative binomial distribution
parametrized by *k* (limit of unsuccessful experiments) and *p* ... | [
"def",
"negative_binomial",
"(",
"k",
"=",
"1",
",",
"p",
"=",
"1",
",",
"shape",
"=",
"_Null",
",",
"dtype",
"=",
"_Null",
",",
"ctx",
"=",
"None",
",",
"out",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_random_helper",
"(",
"_in... | Draw random samples from a negative binomial distribution.
Samples are distributed according to a negative binomial distribution
parametrized by *k* (limit of unsuccessful experiments) and *p* (failure
probability in each experiment). Samples will always be returned as a
floating point data type.
... | [
"Draw",
"random",
"samples",
"from",
"a",
"negative",
"binomial",
"distribution",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L386-L439 | train |
apache/incubator-mxnet | python/mxnet/ndarray/random.py | multinomial | def multinomial(data, shape=_Null, get_prob=False, out=None, dtype='int32', **kwargs):
"""Concurrent sampling from multiple multinomial distributions.
.. note:: The input distribution must be normalized, i.e. `data` must sum to
1 along its last dimension.
Parameters
----------
data :... | python | def multinomial(data, shape=_Null, get_prob=False, out=None, dtype='int32', **kwargs):
"""Concurrent sampling from multiple multinomial distributions.
.. note:: The input distribution must be normalized, i.e. `data` must sum to
1 along its last dimension.
Parameters
----------
data :... | [
"def",
"multinomial",
"(",
"data",
",",
"shape",
"=",
"_Null",
",",
"get_prob",
"=",
"False",
",",
"out",
"=",
"None",
",",
"dtype",
"=",
"'int32'",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_internal",
".",
"_sample_multinomial",
"(",
"data",
",",... | Concurrent sampling from multiple multinomial distributions.
.. note:: The input distribution must be normalized, i.e. `data` must sum to
1 along its last dimension.
Parameters
----------
data : NDArray
An *n* dimensional array whose last dimension has length `k`, where
`... | [
"Concurrent",
"sampling",
"from",
"multiple",
"multinomial",
"distributions",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L500-L562 | train |
apache/incubator-mxnet | python/mxnet/ndarray/random.py | randint | def randint(low, high, shape=_Null, dtype=_Null, ctx=None, out=None, **kwargs):
"""Draw random samples from a discrete uniform distribution.
Samples are uniformly distributed over the half-open interval *[low, high)*
(includes *low*, but excludes *high*).
Parameters
----------
low : int, requi... | python | def randint(low, high, shape=_Null, dtype=_Null, ctx=None, out=None, **kwargs):
"""Draw random samples from a discrete uniform distribution.
Samples are uniformly distributed over the half-open interval *[low, high)*
(includes *low*, but excludes *high*).
Parameters
----------
low : int, requi... | [
"def",
"randint",
"(",
"low",
",",
"high",
",",
"shape",
"=",
"_Null",
",",
"dtype",
"=",
"_Null",
",",
"ctx",
"=",
"None",
",",
"out",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_random_helper",
"(",
"_internal",
".",
"_random_randin... | Draw random samples from a discrete uniform distribution.
Samples are uniformly distributed over the half-open interval *[low, high)*
(includes *low*, but excludes *high*).
Parameters
----------
low : int, required
Lower boundary of the output interval. All values generated will be
... | [
"Draw",
"random",
"samples",
"from",
"a",
"discrete",
"uniform",
"distribution",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L604-L649 | train |
apache/incubator-mxnet | example/sparse/wide_deep/data.py | preprocess_uci_adult | def preprocess_uci_adult(data_name):
"""Some tricks of feature engineering are adapted
from tensorflow's wide and deep tutorial.
"""
csv_columns = [
"age", "workclass", "fnlwgt", "education", "education_num",
"marital_status", "occupation", "relationship", "race", "gender",
"capi... | python | def preprocess_uci_adult(data_name):
"""Some tricks of feature engineering are adapted
from tensorflow's wide and deep tutorial.
"""
csv_columns = [
"age", "workclass", "fnlwgt", "education", "education_num",
"marital_status", "occupation", "relationship", "race", "gender",
"capi... | [
"def",
"preprocess_uci_adult",
"(",
"data_name",
")",
":",
"csv_columns",
"=",
"[",
"\"age\"",
",",
"\"workclass\"",
",",
"\"fnlwgt\"",
",",
"\"education\"",
",",
"\"education_num\"",
",",
"\"marital_status\"",
",",
"\"occupation\"",
",",
"\"relationship\"",
",",
"\... | Some tricks of feature engineering are adapted
from tensorflow's wide and deep tutorial. | [
"Some",
"tricks",
"of",
"feature",
"engineering",
"are",
"adapted",
"from",
"tensorflow",
"s",
"wide",
"and",
"deep",
"tutorial",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/sparse/wide_deep/data.py#L40-L139 | train |
apache/incubator-mxnet | python/mxnet/gluon/trainer.py | Trainer._init_params | def _init_params(self):
"""Initialize parameters in the KVStore.
Parameters with incomplete initialization are ignored.
"""
assert self._kv_initialized, "Cannot initialize parameters in KVStore " \
"when KVStore is not initialized."
params_t... | python | def _init_params(self):
"""Initialize parameters in the KVStore.
Parameters with incomplete initialization are ignored.
"""
assert self._kv_initialized, "Cannot initialize parameters in KVStore " \
"when KVStore is not initialized."
params_t... | [
"def",
"_init_params",
"(",
"self",
")",
":",
"assert",
"self",
".",
"_kv_initialized",
",",
"\"Cannot initialize parameters in KVStore \"",
"\"when KVStore is not initialized.\"",
"params_to_init",
"=",
"[",
"]",
"if",
"self",
".",
"_kvstore",
":",
"for",
"param",
"i... | Initialize parameters in the KVStore.
Parameters with incomplete initialization are ignored. | [
"Initialize",
"parameters",
"in",
"the",
"KVStore",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L137-L157 | train |
apache/incubator-mxnet | python/mxnet/gluon/trainer.py | Trainer._reset_kvstore | def _reset_kvstore(self):
"""Reset kvstore."""
if self._kvstore and 'dist' in self._kvstore.type:
raise RuntimeError("Cannot reset distributed KVStore.")
self._kv_initialized = False
self._kvstore = None
self._distributed = None
self._update_on_kvstore = None
... | python | def _reset_kvstore(self):
"""Reset kvstore."""
if self._kvstore and 'dist' in self._kvstore.type:
raise RuntimeError("Cannot reset distributed KVStore.")
self._kv_initialized = False
self._kvstore = None
self._distributed = None
self._update_on_kvstore = None
... | [
"def",
"_reset_kvstore",
"(",
"self",
")",
":",
"if",
"self",
".",
"_kvstore",
"and",
"'dist'",
"in",
"self",
".",
"_kvstore",
".",
"type",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot reset distributed KVStore.\"",
")",
"self",
".",
"_kv_initialized",
"=",
"F... | Reset kvstore. | [
"Reset",
"kvstore",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L159-L167 | train |
apache/incubator-mxnet | python/mxnet/gluon/trainer.py | Trainer._init_kvstore | def _init_kvstore(self):
"""Create kvstore."""
config = self._kvstore_params
# configure kvstore, update_on_kvstore and self._distributed on three cases:
if self._contains_sparse_weight:
# If weight is sparse, kvstore must be present and the weight must be updated on kvstore.... | python | def _init_kvstore(self):
"""Create kvstore."""
config = self._kvstore_params
# configure kvstore, update_on_kvstore and self._distributed on three cases:
if self._contains_sparse_weight:
# If weight is sparse, kvstore must be present and the weight must be updated on kvstore.... | [
"def",
"_init_kvstore",
"(",
"self",
")",
":",
"config",
"=",
"self",
".",
"_kvstore_params",
"# configure kvstore, update_on_kvstore and self._distributed on three cases:",
"if",
"self",
".",
"_contains_sparse_weight",
":",
"# If weight is sparse, kvstore must be present and the w... | Create kvstore. | [
"Create",
"kvstore",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L169-L248 | train |
apache/incubator-mxnet | python/mxnet/gluon/trainer.py | Trainer.set_learning_rate | def set_learning_rate(self, lr):
"""Sets a new learning rate of the optimizer.
Parameters
----------
lr : float
The new learning rate of the optimizer.
"""
if not isinstance(self._optimizer, opt.Optimizer):
raise UserWarning("Optimizer has to be d... | python | def set_learning_rate(self, lr):
"""Sets a new learning rate of the optimizer.
Parameters
----------
lr : float
The new learning rate of the optimizer.
"""
if not isinstance(self._optimizer, opt.Optimizer):
raise UserWarning("Optimizer has to be d... | [
"def",
"set_learning_rate",
"(",
"self",
",",
"lr",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"_optimizer",
",",
"opt",
".",
"Optimizer",
")",
":",
"raise",
"UserWarning",
"(",
"\"Optimizer has to be defined before its learning \"",
"\"rate is mutated.\... | Sets a new learning rate of the optimizer.
Parameters
----------
lr : float
The new learning rate of the optimizer. | [
"Sets",
"a",
"new",
"learning",
"rate",
"of",
"the",
"optimizer",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L258-L270 | train |
apache/incubator-mxnet | python/mxnet/gluon/trainer.py | Trainer._row_sparse_pull | def _row_sparse_pull(self, parameter, out, row_id, full_idx=False):
"""Internal method to invoke pull operations on KVStore. If `full_idx` is set to True,
`kv.pull` is preferred instead of `kv.row_sparse_pull`.
"""
# initialize kv and params if not already
if not self._kv_initial... | python | def _row_sparse_pull(self, parameter, out, row_id, full_idx=False):
"""Internal method to invoke pull operations on KVStore. If `full_idx` is set to True,
`kv.pull` is preferred instead of `kv.row_sparse_pull`.
"""
# initialize kv and params if not already
if not self._kv_initial... | [
"def",
"_row_sparse_pull",
"(",
"self",
",",
"parameter",
",",
"out",
",",
"row_id",
",",
"full_idx",
"=",
"False",
")",
":",
"# initialize kv and params if not already",
"if",
"not",
"self",
".",
"_kv_initialized",
":",
"self",
".",
"_init_kvstore",
"(",
")",
... | Internal method to invoke pull operations on KVStore. If `full_idx` is set to True,
`kv.pull` is preferred instead of `kv.row_sparse_pull`. | [
"Internal",
"method",
"to",
"invoke",
"pull",
"operations",
"on",
"KVStore",
".",
"If",
"full_idx",
"is",
"set",
"to",
"True",
"kv",
".",
"pull",
"is",
"preferred",
"instead",
"of",
"kv",
".",
"row_sparse_pull",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L272-L286 | train |
apache/incubator-mxnet | python/mxnet/gluon/trainer.py | Trainer.step | def step(self, batch_size, ignore_stale_grad=False):
"""Makes one step of parameter update. Should be called after
`autograd.backward()` and outside of `record()` scope.
For normal parameter updates, `step()` should be used, which internally calls
`allreduce_grads()` and then `update()`... | python | def step(self, batch_size, ignore_stale_grad=False):
"""Makes one step of parameter update. Should be called after
`autograd.backward()` and outside of `record()` scope.
For normal parameter updates, `step()` should be used, which internally calls
`allreduce_grads()` and then `update()`... | [
"def",
"step",
"(",
"self",
",",
"batch_size",
",",
"ignore_stale_grad",
"=",
"False",
")",
":",
"rescale_grad",
"=",
"self",
".",
"_scale",
"/",
"batch_size",
"self",
".",
"_check_and_rescale_grad",
"(",
"rescale_grad",
")",
"if",
"not",
"self",
".",
"_kv_i... | Makes one step of parameter update. Should be called after
`autograd.backward()` and outside of `record()` scope.
For normal parameter updates, `step()` should be used, which internally calls
`allreduce_grads()` and then `update()`. However, if you need to get the reduced
gradients to p... | [
"Makes",
"one",
"step",
"of",
"parameter",
"update",
".",
"Should",
"be",
"called",
"after",
"autograd",
".",
"backward",
"()",
"and",
"outside",
"of",
"record",
"()",
"scope",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L298-L325 | train |
apache/incubator-mxnet | python/mxnet/gluon/trainer.py | Trainer.allreduce_grads | def allreduce_grads(self):
"""For each parameter, reduce the gradients from different contexts.
Should be called after `autograd.backward()`, outside of `record()` scope,
and before `trainer.update()`.
For normal parameter updates, `step()` should be used, which internally calls
... | python | def allreduce_grads(self):
"""For each parameter, reduce the gradients from different contexts.
Should be called after `autograd.backward()`, outside of `record()` scope,
and before `trainer.update()`.
For normal parameter updates, `step()` should be used, which internally calls
... | [
"def",
"allreduce_grads",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_kv_initialized",
":",
"self",
".",
"_init_kvstore",
"(",
")",
"if",
"self",
".",
"_params_to_init",
":",
"self",
".",
"_init_params",
"(",
")",
"assert",
"not",
"(",
"self",
"."... | For each parameter, reduce the gradients from different contexts.
Should be called after `autograd.backward()`, outside of `record()` scope,
and before `trainer.update()`.
For normal parameter updates, `step()` should be used, which internally calls
`allreduce_grads()` and then `update... | [
"For",
"each",
"parameter",
"reduce",
"the",
"gradients",
"from",
"different",
"contexts",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L327-L347 | train |
apache/incubator-mxnet | python/mxnet/gluon/trainer.py | Trainer.update | def update(self, batch_size, ignore_stale_grad=False):
"""Makes one step of parameter update.
Should be called after `autograd.backward()` and outside of `record()` scope,
and after `trainer.update()`.
For normal parameter updates, `step()` should be used, which internally calls
... | python | def update(self, batch_size, ignore_stale_grad=False):
"""Makes one step of parameter update.
Should be called after `autograd.backward()` and outside of `record()` scope,
and after `trainer.update()`.
For normal parameter updates, `step()` should be used, which internally calls
... | [
"def",
"update",
"(",
"self",
",",
"batch_size",
",",
"ignore_stale_grad",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"_kv_initialized",
":",
"self",
".",
"_init_kvstore",
"(",
")",
"if",
"self",
".",
"_params_to_init",
":",
"self",
".",
"_init_para... | Makes one step of parameter update.
Should be called after `autograd.backward()` and outside of `record()` scope,
and after `trainer.update()`.
For normal parameter updates, `step()` should be used, which internally calls
`allreduce_grads()` and then `update()`. However, if you need t... | [
"Makes",
"one",
"step",
"of",
"parameter",
"update",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L359-L390 | train |
apache/incubator-mxnet | python/mxnet/gluon/trainer.py | Trainer.save_states | def save_states(self, fname):
"""Saves trainer states (e.g. optimizer, momentum) to a file.
Parameters
----------
fname : str
Path to output states file.
Note
----
`optimizer.param_dict`, which contains Parameter information (such as
`lr_mul... | python | def save_states(self, fname):
"""Saves trainer states (e.g. optimizer, momentum) to a file.
Parameters
----------
fname : str
Path to output states file.
Note
----
`optimizer.param_dict`, which contains Parameter information (such as
`lr_mul... | [
"def",
"save_states",
"(",
"self",
",",
"fname",
")",
":",
"assert",
"self",
".",
"_optimizer",
"is",
"not",
"None",
"if",
"not",
"self",
".",
"_kv_initialized",
":",
"self",
".",
"_init_kvstore",
"(",
")",
"if",
"self",
".",
"_params_to_init",
":",
"sel... | Saves trainer states (e.g. optimizer, momentum) to a file.
Parameters
----------
fname : str
Path to output states file.
Note
----
`optimizer.param_dict`, which contains Parameter information (such as
`lr_mult` and `wd_mult`) will not be saved. | [
"Saves",
"trainer",
"states",
"(",
"e",
".",
"g",
".",
"optimizer",
"momentum",
")",
"to",
"a",
"file",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L429-L456 | train |
apache/incubator-mxnet | python/mxnet/gluon/trainer.py | Trainer.load_states | def load_states(self, fname):
"""Loads trainer states (e.g. optimizer, momentum) from a file.
Parameters
----------
fname : str
Path to input states file.
Note
----
`optimizer.param_dict`, which contains Parameter information (such as
`lr_mul... | python | def load_states(self, fname):
"""Loads trainer states (e.g. optimizer, momentum) from a file.
Parameters
----------
fname : str
Path to input states file.
Note
----
`optimizer.param_dict`, which contains Parameter information (such as
`lr_mul... | [
"def",
"load_states",
"(",
"self",
",",
"fname",
")",
":",
"if",
"not",
"self",
".",
"_kv_initialized",
":",
"self",
".",
"_init_kvstore",
"(",
")",
"if",
"self",
".",
"_params_to_init",
":",
"self",
".",
"_init_params",
"(",
")",
"if",
"self",
".",
"_... | Loads trainer states (e.g. optimizer, momentum) from a file.
Parameters
----------
fname : str
Path to input states file.
Note
----
`optimizer.param_dict`, which contains Parameter information (such as
`lr_mult` and `wd_mult`) will not be loaded from... | [
"Loads",
"trainer",
"states",
"(",
"e",
".",
"g",
".",
"optimizer",
"momentum",
")",
"from",
"a",
"file",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L458-L488 | train |
apache/incubator-mxnet | benchmark/python/sparse/util.py | estimate_density | def estimate_density(DATA_PATH, feature_size):
"""sample 10 times of a size of 1000 for estimating the density of the sparse dataset"""
if not os.path.exists(DATA_PATH):
raise Exception("Data is not there!")
density = []
P = 0.01
for _ in range(10):
num_non_zero = 0
num_sampl... | python | def estimate_density(DATA_PATH, feature_size):
"""sample 10 times of a size of 1000 for estimating the density of the sparse dataset"""
if not os.path.exists(DATA_PATH):
raise Exception("Data is not there!")
density = []
P = 0.01
for _ in range(10):
num_non_zero = 0
num_sampl... | [
"def",
"estimate_density",
"(",
"DATA_PATH",
",",
"feature_size",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"DATA_PATH",
")",
":",
"raise",
"Exception",
"(",
"\"Data is not there!\"",
")",
"density",
"=",
"[",
"]",
"P",
"=",
"0.01",
"... | sample 10 times of a size of 1000 for estimating the density of the sparse dataset | [
"sample",
"10",
"times",
"of",
"a",
"size",
"of",
"1000",
"for",
"estimating",
"the",
"density",
"of",
"the",
"sparse",
"dataset"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/benchmark/python/sparse/util.py#L21-L36 | train |
apache/incubator-mxnet | example/reinforcement-learning/a3c/launcher.py | exec_cmd | def exec_cmd(cmd, role, taskid, pass_env):
"""Execute the command line command."""
if cmd[0].find('/') == -1 and os.path.exists(cmd[0]) and os.name != 'nt':
cmd[0] = './' + cmd[0]
cmd = ' '.join(cmd)
env = os.environ.copy()
for k, v in pass_env.items():
env[k] = str(v)
env['DMLC... | python | def exec_cmd(cmd, role, taskid, pass_env):
"""Execute the command line command."""
if cmd[0].find('/') == -1 and os.path.exists(cmd[0]) and os.name != 'nt':
cmd[0] = './' + cmd[0]
cmd = ' '.join(cmd)
env = os.environ.copy()
for k, v in pass_env.items():
env[k] = str(v)
env['DMLC... | [
"def",
"exec_cmd",
"(",
"cmd",
",",
"role",
",",
"taskid",
",",
"pass_env",
")",
":",
"if",
"cmd",
"[",
"0",
"]",
".",
"find",
"(",
"'/'",
")",
"==",
"-",
"1",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"cmd",
"[",
"0",
"]",
")",
"and",
... | Execute the command line command. | [
"Execute",
"the",
"command",
"line",
"command",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/reinforcement-learning/a3c/launcher.py#L46-L77 | train |
apache/incubator-mxnet | example/reinforcement-learning/a3c/launcher.py | submit | def submit(args):
gpus = args.gpus.strip().split(',')
"""Submit function of local jobs."""
def mthread_submit(nworker, nserver, envs):
"""
customized submit script, that submit nslave jobs, each must contain args as parameter
note this can be a lambda function containing additional p... | python | def submit(args):
gpus = args.gpus.strip().split(',')
"""Submit function of local jobs."""
def mthread_submit(nworker, nserver, envs):
"""
customized submit script, that submit nslave jobs, each must contain args as parameter
note this can be a lambda function containing additional p... | [
"def",
"submit",
"(",
"args",
")",
":",
"gpus",
"=",
"args",
".",
"gpus",
".",
"strip",
"(",
")",
".",
"split",
"(",
"','",
")",
"def",
"mthread_submit",
"(",
"nworker",
",",
"nserver",
",",
"envs",
")",
":",
"\"\"\"\n customized submit script, that... | Submit function of local jobs. | [
"Submit",
"function",
"of",
"local",
"jobs",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/reinforcement-learning/a3c/launcher.py#L79-L106 | train |
apache/incubator-mxnet | example/ctc/ctc_metrics.py | CtcMetrics.ctc_label | def ctc_label(p):
"""Iterates through p, identifying non-zero and non-repeating values, and returns them in a list Parameters
----------
p: list of int
Returns
-------
list of int
"""
ret = []
p1 = [0] + p
for i, _ in enumerate(p):
... | python | def ctc_label(p):
"""Iterates through p, identifying non-zero and non-repeating values, and returns them in a list Parameters
----------
p: list of int
Returns
-------
list of int
"""
ret = []
p1 = [0] + p
for i, _ in enumerate(p):
... | [
"def",
"ctc_label",
"(",
"p",
")",
":",
"ret",
"=",
"[",
"]",
"p1",
"=",
"[",
"0",
"]",
"+",
"p",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"p",
")",
":",
"c1",
"=",
"p1",
"[",
"i",
"]",
"c2",
"=",
"p1",
"[",
"i",
"+",
"1",
"]",
"... | Iterates through p, identifying non-zero and non-repeating values, and returns them in a list Parameters
----------
p: list of int
Returns
-------
list of int | [
"Iterates",
"through",
"p",
"identifying",
"non",
"-",
"zero",
"and",
"non",
"-",
"repeating",
"values",
"and",
"returns",
"them",
"in",
"a",
"list",
"Parameters",
"----------",
"p",
":",
"list",
"of",
"int"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/ctc_metrics.py#L34-L51 | train |
apache/incubator-mxnet | example/ctc/ctc_metrics.py | CtcMetrics._remove_blank | def _remove_blank(l):
""" Removes trailing zeros in the list of integers and returns a new list of integers"""
ret = []
for i, _ in enumerate(l):
if l[i] == 0:
break
ret.append(l[i])
return ret | python | def _remove_blank(l):
""" Removes trailing zeros in the list of integers and returns a new list of integers"""
ret = []
for i, _ in enumerate(l):
if l[i] == 0:
break
ret.append(l[i])
return ret | [
"def",
"_remove_blank",
"(",
"l",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"l",
")",
":",
"if",
"l",
"[",
"i",
"]",
"==",
"0",
":",
"break",
"ret",
".",
"append",
"(",
"l",
"[",
"i",
"]",
")",
"return",
... | Removes trailing zeros in the list of integers and returns a new list of integers | [
"Removes",
"trailing",
"zeros",
"in",
"the",
"list",
"of",
"integers",
"and",
"returns",
"a",
"new",
"list",
"of",
"integers"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/ctc_metrics.py#L54-L61 | train |
apache/incubator-mxnet | example/ctc/ctc_metrics.py | CtcMetrics._lcs | def _lcs(p, l):
""" Calculates the Longest Common Subsequence between p and l (both list of int) and returns its length"""
# Dynamic Programming Finding LCS
if len(p) == 0:
return 0
P = np.array(list(p)).reshape((1, len(p)))
L = np.array(list(l)).reshape((len(l), 1))
... | python | def _lcs(p, l):
""" Calculates the Longest Common Subsequence between p and l (both list of int) and returns its length"""
# Dynamic Programming Finding LCS
if len(p) == 0:
return 0
P = np.array(list(p)).reshape((1, len(p)))
L = np.array(list(l)).reshape((len(l), 1))
... | [
"def",
"_lcs",
"(",
"p",
",",
"l",
")",
":",
"# Dynamic Programming Finding LCS",
"if",
"len",
"(",
"p",
")",
"==",
"0",
":",
"return",
"0",
"P",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"p",
")",
")",
".",
"reshape",
"(",
"(",
"1",
",",
"len... | Calculates the Longest Common Subsequence between p and l (both list of int) and returns its length | [
"Calculates",
"the",
"Longest",
"Common",
"Subsequence",
"between",
"p",
"and",
"l",
"(",
"both",
"list",
"of",
"int",
")",
"and",
"returns",
"its",
"length"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/ctc_metrics.py#L64-L81 | train |
apache/incubator-mxnet | example/ctc/ctc_metrics.py | CtcMetrics.accuracy | def accuracy(self, label, pred):
""" Simple accuracy measure: number of 100% accurate predictions divided by total number """
hit = 0.
total = 0.
batch_size = label.shape[0]
for i in range(batch_size):
l = self._remove_blank(label[i])
p = []
fo... | python | def accuracy(self, label, pred):
""" Simple accuracy measure: number of 100% accurate predictions divided by total number """
hit = 0.
total = 0.
batch_size = label.shape[0]
for i in range(batch_size):
l = self._remove_blank(label[i])
p = []
fo... | [
"def",
"accuracy",
"(",
"self",
",",
"label",
",",
"pred",
")",
":",
"hit",
"=",
"0.",
"total",
"=",
"0.",
"batch_size",
"=",
"label",
".",
"shape",
"[",
"0",
"]",
"for",
"i",
"in",
"range",
"(",
"batch_size",
")",
":",
"l",
"=",
"self",
".",
"... | Simple accuracy measure: number of 100% accurate predictions divided by total number | [
"Simple",
"accuracy",
"measure",
":",
"number",
"of",
"100%",
"accurate",
"predictions",
"divided",
"by",
"total",
"number"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/ctc_metrics.py#L83-L104 | train |
apache/incubator-mxnet | example/ctc/ctc_metrics.py | CtcMetrics.accuracy_lcs | def accuracy_lcs(self, label, pred):
""" Longest Common Subsequence accuracy measure: calculate accuracy of each prediction as LCS/length"""
hit = 0.
total = 0.
batch_size = label.shape[0]
for i in range(batch_size):
l = self._remove_blank(label[i])
p = []... | python | def accuracy_lcs(self, label, pred):
""" Longest Common Subsequence accuracy measure: calculate accuracy of each prediction as LCS/length"""
hit = 0.
total = 0.
batch_size = label.shape[0]
for i in range(batch_size):
l = self._remove_blank(label[i])
p = []... | [
"def",
"accuracy_lcs",
"(",
"self",
",",
"label",
",",
"pred",
")",
":",
"hit",
"=",
"0.",
"total",
"=",
"0.",
"batch_size",
"=",
"label",
".",
"shape",
"[",
"0",
"]",
"for",
"i",
"in",
"range",
"(",
"batch_size",
")",
":",
"l",
"=",
"self",
".",... | Longest Common Subsequence accuracy measure: calculate accuracy of each prediction as LCS/length | [
"Longest",
"Common",
"Subsequence",
"accuracy",
"measure",
":",
"calculate",
"accuracy",
"of",
"each",
"prediction",
"as",
"LCS",
"/",
"length"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/ctc_metrics.py#L106-L120 | train |
apache/incubator-mxnet | example/sparse/matrix_factorization/data.py | get_movielens_iter | def get_movielens_iter(filename, batch_size):
"""Not particularly fast code to parse the text file and load into NDArrays.
return two data iters, one for train, the other for validation.
"""
logging.info("Preparing data iterators for " + filename + " ... ")
user = []
item = []
score = []
... | python | def get_movielens_iter(filename, batch_size):
"""Not particularly fast code to parse the text file and load into NDArrays.
return two data iters, one for train, the other for validation.
"""
logging.info("Preparing data iterators for " + filename + " ... ")
user = []
item = []
score = []
... | [
"def",
"get_movielens_iter",
"(",
"filename",
",",
"batch_size",
")",
":",
"logging",
".",
"info",
"(",
"\"Preparing data iterators for \"",
"+",
"filename",
"+",
"\" ... \"",
")",
"user",
"=",
"[",
"]",
"item",
"=",
"[",
"]",
"score",
"=",
"[",
"]",
"with... | Not particularly fast code to parse the text file and load into NDArrays.
return two data iters, one for train, the other for validation. | [
"Not",
"particularly",
"fast",
"code",
"to",
"parse",
"the",
"text",
"file",
"and",
"load",
"into",
"NDArrays",
".",
"return",
"two",
"data",
"iters",
"one",
"for",
"train",
"the",
"other",
"for",
"validation",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/sparse/matrix_factorization/data.py#L29-L56 | train |
apache/incubator-mxnet | plugin/opencv/opencv.py | imdecode | def imdecode(str_img, flag=1):
"""Decode image from str buffer.
Wrapper for cv2.imdecode that uses mx.nd.NDArray
Parameters
----------
str_img : str
str buffer read from image file
flag : int
same as flag for cv2.imdecode
Returns
-------
img : NDArray
decoded... | python | def imdecode(str_img, flag=1):
"""Decode image from str buffer.
Wrapper for cv2.imdecode that uses mx.nd.NDArray
Parameters
----------
str_img : str
str buffer read from image file
flag : int
same as flag for cv2.imdecode
Returns
-------
img : NDArray
decoded... | [
"def",
"imdecode",
"(",
"str_img",
",",
"flag",
"=",
"1",
")",
":",
"hdl",
"=",
"NDArrayHandle",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXCVImdecode",
"(",
"ctypes",
".",
"c_char_p",
"(",
"str_img",
")",
",",
"mx_uint",
"(",
"len",
"(",
"str_img",
... | Decode image from str buffer.
Wrapper for cv2.imdecode that uses mx.nd.NDArray
Parameters
----------
str_img : str
str buffer read from image file
flag : int
same as flag for cv2.imdecode
Returns
-------
img : NDArray
decoded image in (width, height, channels)
... | [
"Decode",
"image",
"from",
"str",
"buffer",
".",
"Wrapper",
"for",
"cv2",
".",
"imdecode",
"that",
"uses",
"mx",
".",
"nd",
".",
"NDArray"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/plugin/opencv/opencv.py#L29-L49 | train |
apache/incubator-mxnet | plugin/opencv/opencv.py | resize | def resize(src, size, interpolation=cv2.INTER_LINEAR):
"""Decode image from str buffer.
Wrapper for cv2.imresize that uses mx.nd.NDArray
Parameters
----------
src : NDArray
image in (width, height, channels)
size : tuple
target size in (width, height)
interpolation : int
... | python | def resize(src, size, interpolation=cv2.INTER_LINEAR):
"""Decode image from str buffer.
Wrapper for cv2.imresize that uses mx.nd.NDArray
Parameters
----------
src : NDArray
image in (width, height, channels)
size : tuple
target size in (width, height)
interpolation : int
... | [
"def",
"resize",
"(",
"src",
",",
"size",
",",
"interpolation",
"=",
"cv2",
".",
"INTER_LINEAR",
")",
":",
"hdl",
"=",
"NDArrayHandle",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXCVResize",
"(",
"src",
".",
"handle",
",",
"mx_uint",
"(",
"size",
"[",... | Decode image from str buffer.
Wrapper for cv2.imresize that uses mx.nd.NDArray
Parameters
----------
src : NDArray
image in (width, height, channels)
size : tuple
target size in (width, height)
interpolation : int
same as interpolation for cv2.imresize
Returns
-... | [
"Decode",
"image",
"from",
"str",
"buffer",
".",
"Wrapper",
"for",
"cv2",
".",
"imresize",
"that",
"uses",
"mx",
".",
"nd",
".",
"NDArray"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/plugin/opencv/opencv.py#L51-L72 | train |
apache/incubator-mxnet | plugin/opencv/opencv.py | copyMakeBorder | def copyMakeBorder(src, top, bot, left, right, border_type=cv2.BORDER_CONSTANT, value=0):
"""Pad image border
Wrapper for cv2.copyMakeBorder that uses mx.nd.NDArray
Parameters
----------
src : NDArray
Image in (width, height, channels).
Others are the same with cv2.copyMakeBorder
... | python | def copyMakeBorder(src, top, bot, left, right, border_type=cv2.BORDER_CONSTANT, value=0):
"""Pad image border
Wrapper for cv2.copyMakeBorder that uses mx.nd.NDArray
Parameters
----------
src : NDArray
Image in (width, height, channels).
Others are the same with cv2.copyMakeBorder
... | [
"def",
"copyMakeBorder",
"(",
"src",
",",
"top",
",",
"bot",
",",
"left",
",",
"right",
",",
"border_type",
"=",
"cv2",
".",
"BORDER_CONSTANT",
",",
"value",
"=",
"0",
")",
":",
"hdl",
"=",
"NDArrayHandle",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"... | Pad image border
Wrapper for cv2.copyMakeBorder that uses mx.nd.NDArray
Parameters
----------
src : NDArray
Image in (width, height, channels).
Others are the same with cv2.copyMakeBorder
Returns
-------
img : NDArray
padded image | [
"Pad",
"image",
"border",
"Wrapper",
"for",
"cv2",
".",
"copyMakeBorder",
"that",
"uses",
"mx",
".",
"nd",
".",
"NDArray"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/plugin/opencv/opencv.py#L74-L94 | train |
apache/incubator-mxnet | plugin/opencv/opencv.py | fixed_crop | def fixed_crop(src, x0, y0, w, h, size=None, interpolation=cv2.INTER_CUBIC):
"""Crop src at fixed location, and (optionally) resize it to size"""
out = mx.nd.crop(src, begin=(y0, x0, 0), end=(y0+h, x0+w, int(src.shape[2])))
if size is not None and (w, h) != size:
out = resize(out, size, interpolatio... | python | def fixed_crop(src, x0, y0, w, h, size=None, interpolation=cv2.INTER_CUBIC):
"""Crop src at fixed location, and (optionally) resize it to size"""
out = mx.nd.crop(src, begin=(y0, x0, 0), end=(y0+h, x0+w, int(src.shape[2])))
if size is not None and (w, h) != size:
out = resize(out, size, interpolatio... | [
"def",
"fixed_crop",
"(",
"src",
",",
"x0",
",",
"y0",
",",
"w",
",",
"h",
",",
"size",
"=",
"None",
",",
"interpolation",
"=",
"cv2",
".",
"INTER_CUBIC",
")",
":",
"out",
"=",
"mx",
".",
"nd",
".",
"crop",
"(",
"src",
",",
"begin",
"=",
"(",
... | Crop src at fixed location, and (optionally) resize it to size | [
"Crop",
"src",
"at",
"fixed",
"location",
"and",
"(",
"optionally",
")",
"resize",
"it",
"to",
"size"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/plugin/opencv/opencv.py#L107-L112 | train |
apache/incubator-mxnet | plugin/opencv/opencv.py | random_crop | def random_crop(src, size):
"""Randomly crop src with size. Upsample result if src is smaller than size"""
h, w, _ = src.shape
new_w, new_h = scale_down((w, h), size)
x0 = random.randint(0, w - new_w)
y0 = random.randint(0, h - new_h)
out = fixed_crop(src, x0, y0, new_w, new_h, size)
retur... | python | def random_crop(src, size):
"""Randomly crop src with size. Upsample result if src is smaller than size"""
h, w, _ = src.shape
new_w, new_h = scale_down((w, h), size)
x0 = random.randint(0, w - new_w)
y0 = random.randint(0, h - new_h)
out = fixed_crop(src, x0, y0, new_w, new_h, size)
retur... | [
"def",
"random_crop",
"(",
"src",
",",
"size",
")",
":",
"h",
",",
"w",
",",
"_",
"=",
"src",
".",
"shape",
"new_w",
",",
"new_h",
"=",
"scale_down",
"(",
"(",
"w",
",",
"h",
")",
",",
"size",
")",
"x0",
"=",
"random",
".",
"randint",
"(",
"0... | Randomly crop src with size. Upsample result if src is smaller than size | [
"Randomly",
"crop",
"src",
"with",
"size",
".",
"Upsample",
"result",
"if",
"src",
"is",
"smaller",
"than",
"size"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/plugin/opencv/opencv.py#L114-L123 | train |
apache/incubator-mxnet | plugin/opencv/opencv.py | random_size_crop | def random_size_crop(src, size, min_area=0.25, ratio=(3.0/4.0, 4.0/3.0)):
"""Randomly crop src with size. Randomize area and aspect ratio"""
h, w, _ = src.shape
area = w*h
for _ in range(10):
new_area = random.uniform(min_area, 1.0) * area
new_ratio = random.uniform(*ratio)
new_w... | python | def random_size_crop(src, size, min_area=0.25, ratio=(3.0/4.0, 4.0/3.0)):
"""Randomly crop src with size. Randomize area and aspect ratio"""
h, w, _ = src.shape
area = w*h
for _ in range(10):
new_area = random.uniform(min_area, 1.0) * area
new_ratio = random.uniform(*ratio)
new_w... | [
"def",
"random_size_crop",
"(",
"src",
",",
"size",
",",
"min_area",
"=",
"0.25",
",",
"ratio",
"=",
"(",
"3.0",
"/",
"4.0",
",",
"4.0",
"/",
"3.0",
")",
")",
":",
"h",
",",
"w",
",",
"_",
"=",
"src",
".",
"shape",
"area",
"=",
"w",
"*",
"h",... | Randomly crop src with size. Randomize area and aspect ratio | [
"Randomly",
"crop",
"src",
"with",
"size",
".",
"Randomize",
"area",
"and",
"aspect",
"ratio"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/plugin/opencv/opencv.py#L131-L153 | train |
apache/incubator-mxnet | plugin/opencv/opencv.py | ImageListIter.next | def next(self):
"""Move iterator position forward"""
batch = mx.nd.zeros((self.batch_size, self.size[1], self.size[0], 3))
i = self.cur
for i in range(self.cur, min(len(self.list), self.cur+self.batch_size)):
str_img = open(self.root+self.list[i]+'.jpg').read()
im... | python | def next(self):
"""Move iterator position forward"""
batch = mx.nd.zeros((self.batch_size, self.size[1], self.size[0], 3))
i = self.cur
for i in range(self.cur, min(len(self.list), self.cur+self.batch_size)):
str_img = open(self.root+self.list[i]+'.jpg').read()
im... | [
"def",
"next",
"(",
"self",
")",
":",
"batch",
"=",
"mx",
".",
"nd",
".",
"zeros",
"(",
"(",
"self",
".",
"batch_size",
",",
"self",
".",
"size",
"[",
"1",
"]",
",",
"self",
".",
"size",
"[",
"0",
"]",
",",
"3",
")",
")",
"i",
"=",
"self",
... | Move iterator position forward | [
"Move",
"iterator",
"position",
"forward"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/plugin/opencv/opencv.py#L173-L188 | train |
apache/incubator-mxnet | example/speech_recognition/stt_metric.py | check_label_shapes | def check_label_shapes(labels, preds, shape=0):
"""Check to see if the two arrays are the same size."""
if shape == 0:
label_shape, pred_shape = len(labels), len(preds)
else:
label_shape, pred_shape = labels.shape, preds.shape
if label_shape != pred_shape:
raise ValueError("Sha... | python | def check_label_shapes(labels, preds, shape=0):
"""Check to see if the two arrays are the same size."""
if shape == 0:
label_shape, pred_shape = len(labels), len(preds)
else:
label_shape, pred_shape = labels.shape, preds.shape
if label_shape != pred_shape:
raise ValueError("Sha... | [
"def",
"check_label_shapes",
"(",
"labels",
",",
"preds",
",",
"shape",
"=",
"0",
")",
":",
"if",
"shape",
"==",
"0",
":",
"label_shape",
",",
"pred_shape",
"=",
"len",
"(",
"labels",
")",
",",
"len",
"(",
"preds",
")",
"else",
":",
"label_shape",
",... | Check to see if the two arrays are the same size. | [
"Check",
"to",
"see",
"if",
"the",
"two",
"arrays",
"are",
"the",
"same",
"size",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/speech_recognition/stt_metric.py#L25-L35 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/import_to_gluon.py | import_to_gluon | def import_to_gluon(model_file, ctx):
"""
Imports the ONNX model files, passed as a parameter, into Gluon SymbolBlock object.
Parameters
----------
model_file : str
ONNX model file name
ctx : Context or list of Context
Loads the model into one or many context(s).
Returns
... | python | def import_to_gluon(model_file, ctx):
"""
Imports the ONNX model files, passed as a parameter, into Gluon SymbolBlock object.
Parameters
----------
model_file : str
ONNX model file name
ctx : Context or list of Context
Loads the model into one or many context(s).
Returns
... | [
"def",
"import_to_gluon",
"(",
"model_file",
",",
"ctx",
")",
":",
"graph",
"=",
"GraphProto",
"(",
")",
"try",
":",
"import",
"onnx",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"\"Onnx and protobuf need to be installed. Instructions to\"",
"+",
"\" ... | Imports the ONNX model files, passed as a parameter, into Gluon SymbolBlock object.
Parameters
----------
model_file : str
ONNX model file name
ctx : Context or list of Context
Loads the model into one or many context(s).
Returns
-------
sym_block : :class:`~mxnet.gluon.Sym... | [
"Imports",
"the",
"ONNX",
"model",
"files",
"passed",
"as",
"a",
"parameter",
"into",
"Gluon",
"SymbolBlock",
"object",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/import_to_gluon.py#L24-L53 | train |
apache/incubator-mxnet | example/gluon/image_classification.py | get_model | def get_model(model, ctx, opt):
"""Model initialization."""
kwargs = {'ctx': ctx, 'pretrained': opt.use_pretrained, 'classes': classes}
if model.startswith('resnet'):
kwargs['thumbnail'] = opt.use_thumbnail
elif model.startswith('vgg'):
kwargs['batch_norm'] = opt.batch_norm
net = mo... | python | def get_model(model, ctx, opt):
"""Model initialization."""
kwargs = {'ctx': ctx, 'pretrained': opt.use_pretrained, 'classes': classes}
if model.startswith('resnet'):
kwargs['thumbnail'] = opt.use_thumbnail
elif model.startswith('vgg'):
kwargs['batch_norm'] = opt.batch_norm
net = mo... | [
"def",
"get_model",
"(",
"model",
",",
"ctx",
",",
"opt",
")",
":",
"kwargs",
"=",
"{",
"'ctx'",
":",
"ctx",
",",
"'pretrained'",
":",
"opt",
".",
"use_pretrained",
",",
"'classes'",
":",
"classes",
"}",
"if",
"model",
".",
"startswith",
"(",
"'resnet'... | Model initialization. | [
"Model",
"initialization",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/image_classification.py#L117-L134 | train |
apache/incubator-mxnet | example/gluon/image_classification.py | get_data_iters | def get_data_iters(dataset, batch_size, opt):
"""get dataset iterators"""
if dataset == 'mnist':
train_data, val_data = get_mnist_iterator(batch_size, (1, 28, 28),
num_parts=kv.num_workers, part_index=kv.rank)
elif dataset == 'cifar10':
train... | python | def get_data_iters(dataset, batch_size, opt):
"""get dataset iterators"""
if dataset == 'mnist':
train_data, val_data = get_mnist_iterator(batch_size, (1, 28, 28),
num_parts=kv.num_workers, part_index=kv.rank)
elif dataset == 'cifar10':
train... | [
"def",
"get_data_iters",
"(",
"dataset",
",",
"batch_size",
",",
"opt",
")",
":",
"if",
"dataset",
"==",
"'mnist'",
":",
"train_data",
",",
"val_data",
"=",
"get_mnist_iterator",
"(",
"batch_size",
",",
"(",
"1",
",",
"28",
",",
"28",
")",
",",
"num_part... | get dataset iterators | [
"get",
"dataset",
"iterators"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/image_classification.py#L138-L160 | train |
apache/incubator-mxnet | example/gluon/image_classification.py | update_learning_rate | def update_learning_rate(lr, trainer, epoch, ratio, steps):
"""Set the learning rate to the initial value decayed by ratio every N epochs."""
new_lr = lr * (ratio ** int(np.sum(np.array(steps) < epoch)))
trainer.set_learning_rate(new_lr)
return trainer | python | def update_learning_rate(lr, trainer, epoch, ratio, steps):
"""Set the learning rate to the initial value decayed by ratio every N epochs."""
new_lr = lr * (ratio ** int(np.sum(np.array(steps) < epoch)))
trainer.set_learning_rate(new_lr)
return trainer | [
"def",
"update_learning_rate",
"(",
"lr",
",",
"trainer",
",",
"epoch",
",",
"ratio",
",",
"steps",
")",
":",
"new_lr",
"=",
"lr",
"*",
"(",
"ratio",
"**",
"int",
"(",
"np",
".",
"sum",
"(",
"np",
".",
"array",
"(",
"steps",
")",
"<",
"epoch",
")... | Set the learning rate to the initial value decayed by ratio every N epochs. | [
"Set",
"the",
"learning",
"rate",
"to",
"the",
"initial",
"value",
"decayed",
"by",
"ratio",
"every",
"N",
"epochs",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/image_classification.py#L174-L178 | train |
apache/incubator-mxnet | python/mxnet/random.py | seed | def seed(seed_state, ctx="all"):
"""Seeds the random number generators in MXNet.
This affects the behavior of modules in MXNet that uses random number generators,
like the dropout operator and `NDArray`'s random sampling operators.
Parameters
----------
seed_state : int
The random numb... | python | def seed(seed_state, ctx="all"):
"""Seeds the random number generators in MXNet.
This affects the behavior of modules in MXNet that uses random number generators,
like the dropout operator and `NDArray`'s random sampling operators.
Parameters
----------
seed_state : int
The random numb... | [
"def",
"seed",
"(",
"seed_state",
",",
"ctx",
"=",
"\"all\"",
")",
":",
"if",
"not",
"isinstance",
"(",
"seed_state",
",",
"integer_types",
")",
":",
"raise",
"ValueError",
"(",
"'seed_state must be int'",
")",
"seed_state",
"=",
"ctypes",
".",
"c_int",
"(",... | Seeds the random number generators in MXNet.
This affects the behavior of modules in MXNet that uses random number generators,
like the dropout operator and `NDArray`'s random sampling operators.
Parameters
----------
seed_state : int
The random number seed.
ctx : Context
The ... | [
"Seeds",
"the",
"random",
"number",
"generators",
"in",
"MXNet",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/random.py#L30-L100 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | random_uniform | def random_uniform(attrs, inputs, proto_obj):
"""Draw random samples from a uniform distribtuion."""
try:
from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE
except ImportError:
raise ImportError("Onnx and protobuf need to be installed. "
"Instructions to install - http... | python | def random_uniform(attrs, inputs, proto_obj):
"""Draw random samples from a uniform distribtuion."""
try:
from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE
except ImportError:
raise ImportError("Onnx and protobuf need to be installed. "
"Instructions to install - http... | [
"def",
"random_uniform",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"try",
":",
"from",
"onnx",
".",
"mapping",
"import",
"TENSOR_TYPE_TO_NP_TYPE",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"\"Onnx and protobuf need to be installed. \"",... | Draw random samples from a uniform distribtuion. | [
"Draw",
"random",
"samples",
"from",
"a",
"uniform",
"distribtuion",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L30-L39 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | random_normal | def random_normal(attrs, inputs, proto_obj):
"""Draw random samples from a Gaussian distribution."""
try:
from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE
except ImportError:
raise ImportError("Onnx and protobuf need to be installed. "
"Instructions to install - http... | python | def random_normal(attrs, inputs, proto_obj):
"""Draw random samples from a Gaussian distribution."""
try:
from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE
except ImportError:
raise ImportError("Onnx and protobuf need to be installed. "
"Instructions to install - http... | [
"def",
"random_normal",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"try",
":",
"from",
"onnx",
".",
"mapping",
"import",
"TENSOR_TYPE_TO_NP_TYPE",
"except",
"ImportError",
":",
"raise",
"ImportError",
"(",
"\"Onnx and protobuf need to be installed. \"",
... | Draw random samples from a Gaussian distribution. | [
"Draw",
"random",
"samples",
"from",
"a",
"Gaussian",
"distribution",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L41-L51 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | add | def add(attrs, inputs, proto_obj):
"""Adding two tensors"""
new_attr = {}
if 'broadcast' in attrs and attrs['broadcast'] == 1:
broadcast_axis = attrs['axis']
op_value = translation_utils._fix_broadcast('broadcast_add', inputs,
broadcast_ax... | python | def add(attrs, inputs, proto_obj):
"""Adding two tensors"""
new_attr = {}
if 'broadcast' in attrs and attrs['broadcast'] == 1:
broadcast_axis = attrs['axis']
op_value = translation_utils._fix_broadcast('broadcast_add', inputs,
broadcast_ax... | [
"def",
"add",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attr",
"=",
"{",
"}",
"if",
"'broadcast'",
"in",
"attrs",
"and",
"attrs",
"[",
"'broadcast'",
"]",
"==",
"1",
":",
"broadcast_axis",
"=",
"attrs",
"[",
"'axis'",
"]",
"op_value... | Adding two tensors | [
"Adding",
"two",
"tensors"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L66-L75 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | mean | def mean(attrs, inputs, proto_obj):
"""Mean of all the input tensors."""
concat_input = [symbol.expand_dims(op_input, axis=0) for op_input in inputs]
concat_sym = symbol.concat(*concat_input, dim=0)
mean_sym = symbol.mean(concat_sym, axis=0)
return mean_sym, attrs, inputs | python | def mean(attrs, inputs, proto_obj):
"""Mean of all the input tensors."""
concat_input = [symbol.expand_dims(op_input, axis=0) for op_input in inputs]
concat_sym = symbol.concat(*concat_input, dim=0)
mean_sym = symbol.mean(concat_sym, axis=0)
return mean_sym, attrs, inputs | [
"def",
"mean",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"concat_input",
"=",
"[",
"symbol",
".",
"expand_dims",
"(",
"op_input",
",",
"axis",
"=",
"0",
")",
"for",
"op_input",
"in",
"inputs",
"]",
"concat_sym",
"=",
"symbol",
".",
"conc... | Mean of all the input tensors. | [
"Mean",
"of",
"all",
"the",
"input",
"tensors",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L110-L115 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | argmax | def argmax(attrs, inputs, proto_obj):
"""Returns indices of the maximum values along an axis"""
axis = attrs.get('axis', 0)
keepdims = attrs.get('keepdims', 1)
argmax_op = symbol.argmax(inputs[0], axis=axis, keepdims=keepdims)
# onnx argmax operator always expects int64 as output type
cast_attrs... | python | def argmax(attrs, inputs, proto_obj):
"""Returns indices of the maximum values along an axis"""
axis = attrs.get('axis', 0)
keepdims = attrs.get('keepdims', 1)
argmax_op = symbol.argmax(inputs[0], axis=axis, keepdims=keepdims)
# onnx argmax operator always expects int64 as output type
cast_attrs... | [
"def",
"argmax",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"axis",
"=",
"attrs",
".",
"get",
"(",
"'axis'",
",",
"0",
")",
"keepdims",
"=",
"attrs",
".",
"get",
"(",
"'keepdims'",
",",
"1",
")",
"argmax_op",
"=",
"symbol",
".",
"argm... | Returns indices of the maximum values along an axis | [
"Returns",
"indices",
"of",
"the",
"maximum",
"values",
"along",
"an",
"axis"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L146-L153 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | argmin | def argmin(attrs, inputs, proto_obj):
"""Returns indices of the minimum values along an axis."""
axis = attrs.get('axis', 0)
keepdims = attrs.get('keepdims', 1)
argmin_op = symbol.argmin(inputs[0], axis=axis, keepdims=keepdims)
# onnx argmax operator always expects int64 as output type
cast_attr... | python | def argmin(attrs, inputs, proto_obj):
"""Returns indices of the minimum values along an axis."""
axis = attrs.get('axis', 0)
keepdims = attrs.get('keepdims', 1)
argmin_op = symbol.argmin(inputs[0], axis=axis, keepdims=keepdims)
# onnx argmax operator always expects int64 as output type
cast_attr... | [
"def",
"argmin",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"axis",
"=",
"attrs",
".",
"get",
"(",
"'axis'",
",",
"0",
")",
"keepdims",
"=",
"attrs",
".",
"get",
"(",
"'keepdims'",
",",
"1",
")",
"argmin_op",
"=",
"symbol",
".",
"argm... | Returns indices of the minimum values along an axis. | [
"Returns",
"indices",
"of",
"the",
"minimum",
"values",
"along",
"an",
"axis",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L155-L162 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | maximum | def maximum(attrs, inputs, proto_obj):
"""
Elementwise maximum of arrays.
MXNet maximum compares only two symbols at a time.
ONNX can send more than two to compare.
Breaking into multiple mxnet ops to compare two symbols at a time
"""
if len(inputs) > 1:
mxnet_op = symbol.maximum(inp... | python | def maximum(attrs, inputs, proto_obj):
"""
Elementwise maximum of arrays.
MXNet maximum compares only two symbols at a time.
ONNX can send more than two to compare.
Breaking into multiple mxnet ops to compare two symbols at a time
"""
if len(inputs) > 1:
mxnet_op = symbol.maximum(inp... | [
"def",
"maximum",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"if",
"len",
"(",
"inputs",
")",
">",
"1",
":",
"mxnet_op",
"=",
"symbol",
".",
"maximum",
"(",
"inputs",
"[",
"0",
"]",
",",
"inputs",
"[",
"1",
"]",
")",
"for",
"op_inpu... | Elementwise maximum of arrays.
MXNet maximum compares only two symbols at a time.
ONNX can send more than two to compare.
Breaking into multiple mxnet ops to compare two symbols at a time | [
"Elementwise",
"maximum",
"of",
"arrays",
".",
"MXNet",
"maximum",
"compares",
"only",
"two",
"symbols",
"at",
"a",
"time",
".",
"ONNX",
"can",
"send",
"more",
"than",
"two",
"to",
"compare",
".",
"Breaking",
"into",
"multiple",
"mxnet",
"ops",
"to",
"comp... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L164-L177 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | minimum | def minimum(attrs, inputs, proto_obj):
"""Elementwise minimum of arrays."""
# MXNet minimum compares only two symbols at a time.
# ONNX can send more than two to compare.
# Breaking into multiple mxnet ops to compare two symbols at a time
if len(inputs) > 1:
mxnet_op = symbol.minimum(inputs[... | python | def minimum(attrs, inputs, proto_obj):
"""Elementwise minimum of arrays."""
# MXNet minimum compares only two symbols at a time.
# ONNX can send more than two to compare.
# Breaking into multiple mxnet ops to compare two symbols at a time
if len(inputs) > 1:
mxnet_op = symbol.minimum(inputs[... | [
"def",
"minimum",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"# MXNet minimum compares only two symbols at a time.",
"# ONNX can send more than two to compare.",
"# Breaking into multiple mxnet ops to compare two symbols at a time",
"if",
"len",
"(",
"inputs",
")",
... | Elementwise minimum of arrays. | [
"Elementwise",
"minimum",
"of",
"arrays",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L179-L190 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | concat | def concat(attrs, inputs, proto_obj):
""" Joins input arrays along a given axis. """
new_attrs = translation_utils._fix_attribute_names(attrs, {'axis': 'dim'})
return 'concat', new_attrs, inputs | python | def concat(attrs, inputs, proto_obj):
""" Joins input arrays along a given axis. """
new_attrs = translation_utils._fix_attribute_names(attrs, {'axis': 'dim'})
return 'concat', new_attrs, inputs | [
"def",
"concat",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'axis'",
":",
"'dim'",
"}",
")",
"return",
"'concat'",
",",
"new_attrs",
",",
"inputs"
] | Joins input arrays along a given axis. | [
"Joins",
"input",
"arrays",
"along",
"a",
"given",
"axis",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L219-L222 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | pad | def pad(attrs, inputs, proto_obj):
""" Add padding to input tensor"""
new_attrs = translation_utils._fix_attribute_names(attrs, {'pads' : 'pad_width',
'value' : 'constant_value'
})
n... | python | def pad(attrs, inputs, proto_obj):
""" Add padding to input tensor"""
new_attrs = translation_utils._fix_attribute_names(attrs, {'pads' : 'pad_width',
'value' : 'constant_value'
})
n... | [
"def",
"pad",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'pads'",
":",
"'pad_width'",
",",
"'value'",
":",
"'constant_value'",
"}",
")",
"new_attrs",
"... | Add padding to input tensor | [
"Add",
"padding",
"to",
"input",
"tensor"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L241-L247 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | batch_norm | def batch_norm(attrs, inputs, proto_obj):
"""Batch normalization."""
new_attrs = translation_utils._fix_attribute_names(attrs, {'epsilon': 'eps',
'is_test': 'fix_gamma'})
new_attrs = translation_utils._remove_attributes(new_attrs,
... | python | def batch_norm(attrs, inputs, proto_obj):
"""Batch normalization."""
new_attrs = translation_utils._fix_attribute_names(attrs, {'epsilon': 'eps',
'is_test': 'fix_gamma'})
new_attrs = translation_utils._remove_attributes(new_attrs,
... | [
"def",
"batch_norm",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'epsilon'",
":",
"'eps'",
",",
"'is_test'",
":",
"'fix_gamma'",
"}",
")",
"new_attrs",
... | Batch normalization. | [
"Batch",
"normalization",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L253-L266 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | instance_norm | def instance_norm(attrs, inputs, proto_obj):
"""Instance Normalization."""
new_attrs = translation_utils._fix_attribute_names(attrs, {'epsilon' : 'eps'})
new_attrs['eps'] = attrs.get('epsilon', 1e-5)
return 'InstanceNorm', new_attrs, inputs | python | def instance_norm(attrs, inputs, proto_obj):
"""Instance Normalization."""
new_attrs = translation_utils._fix_attribute_names(attrs, {'epsilon' : 'eps'})
new_attrs['eps'] = attrs.get('epsilon', 1e-5)
return 'InstanceNorm', new_attrs, inputs | [
"def",
"instance_norm",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'epsilon'",
":",
"'eps'",
"}",
")",
"new_attrs",
"[",
"'eps'",
"]",
"=",
"attrs",
... | Instance Normalization. | [
"Instance",
"Normalization",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L268-L272 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | leaky_relu | def leaky_relu(attrs, inputs, proto_obj):
"""Leaky Relu function"""
if 'alpha' in attrs:
new_attrs = translation_utils._fix_attribute_names(attrs, {'alpha' : 'slope'})
else:
new_attrs = translation_utils._add_extra_attributes(attrs, {'slope': 0.01})
return 'LeakyReLU', new_attrs, inputs | python | def leaky_relu(attrs, inputs, proto_obj):
"""Leaky Relu function"""
if 'alpha' in attrs:
new_attrs = translation_utils._fix_attribute_names(attrs, {'alpha' : 'slope'})
else:
new_attrs = translation_utils._add_extra_attributes(attrs, {'slope': 0.01})
return 'LeakyReLU', new_attrs, inputs | [
"def",
"leaky_relu",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"if",
"'alpha'",
"in",
"attrs",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'alpha'",
":",
"'slope'",
"}",
")",
"else",
":",... | Leaky Relu function | [
"Leaky",
"Relu",
"function"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L274-L280 | train |
apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | _elu | def _elu(attrs, inputs, proto_obj):
"""Elu function"""
if 'alpha' in attrs:
new_attrs = translation_utils._fix_attribute_names(attrs, {'alpha' : 'slope'})
else:
new_attrs = translation_utils._add_extra_attributes(attrs, {'slope': 1.0})
new_attrs = translation_utils._add_extra_attributes(... | python | def _elu(attrs, inputs, proto_obj):
"""Elu function"""
if 'alpha' in attrs:
new_attrs = translation_utils._fix_attribute_names(attrs, {'alpha' : 'slope'})
else:
new_attrs = translation_utils._add_extra_attributes(attrs, {'slope': 1.0})
new_attrs = translation_utils._add_extra_attributes(... | [
"def",
"_elu",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"if",
"'alpha'",
"in",
"attrs",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'alpha'",
":",
"'slope'",
"}",
")",
"else",
":",
"ne... | Elu function | [
"Elu",
"function"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L282-L289 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.