partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Module.save_checkpoint | 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... | python/mxnet/module/module.py | 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):
"""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.
... | [
"Saves",
"current",
"progress",
"to",
"checkpoint",
".",
"Use",
"mx",
".",
"callback",
".",
"module_checkpoint",
"as",
"epoch_end_callback",
"to",
"save",
"during",
"training",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L165-L185 | [
"def",
"save_checkpoint",
"(",
"self",
",",
"prefix",
",",
"epoch",
",",
"save_optimizer_states",
"=",
"False",
")",
":",
"self",
".",
"_symbol",
".",
"save",
"(",
"'%s-symbol.json'",
"%",
"prefix",
")",
"param_name",
"=",
"'%s-%04d.params'",
"%",
"(",
"pref... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module._reset_bind | Internal function to reset binded state. | python/mxnet/module/module.py | 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):
"""Internal function to reset binded state."""
self.binded = False
self._exec_group = None
self._data_shapes = None
self._label_shapes = None | [
"Internal",
"function",
"to",
"reset",
"binded",
"state",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L187-L192 | [
"def",
"_reset_bind",
"(",
"self",
")",
":",
"self",
".",
"binded",
"=",
"False",
"self",
".",
"_exec_group",
"=",
"None",
"self",
".",
"_data_shapes",
"=",
"None",
"self",
".",
"_label_shapes",
"=",
"None"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.get_params | Gets current parameters.
Returns
-------
`(arg_params, aux_params)`
A pair of dictionaries each mapping parameter names to NDArray values. | python/mxnet/module/module.py | 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):
"""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:
... | [
"Gets",
"current",
"parameters",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L245-L257 | [
"def",
"get_params",
"(",
"self",
")",
":",
"assert",
"self",
".",
"binded",
"and",
"self",
".",
"params_initialized",
"if",
"self",
".",
"_params_dirty",
":",
"self",
".",
"_sync_params_from_devices",
"(",
")",
"return",
"(",
"self",
".",
"_arg_params",
","... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.init_params | 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... | python/mxnet/module/module.py | 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 ini... | [
"Initializes",
"the",
"parameters",
"and",
"auxiliary",
"states",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L259-L320 | [
"def",
"init_params",
"(",
"self",
",",
"initializer",
"=",
"Uniform",
"(",
"0.01",
")",
",",
"arg_params",
"=",
"None",
",",
"aux_params",
"=",
"None",
",",
"allow_missing",
"=",
"False",
",",
"force_init",
"=",
"False",
",",
"allow_extra",
"=",
"False",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.set_params | 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 ... | python/mxnet/module/module.py | 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):
"""Assigns parameter and aux state values.
Parameters
----------
arg_params : dict
Dictionary of name to `NDArray`.
aux_params : dict
... | [
"Assigns",
"parameter",
"and",
"aux",
"state",
"values",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L322-L362 | [
"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... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.bind | 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... | python/mxnet/module/module.py | 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.
Param... | [
"Binds",
"the",
"symbols",
"to",
"construct",
"executors",
".",
"This",
"is",
"necessary",
"before",
"one",
"can",
"perform",
"computation",
"with",
"the",
"module",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L364-L456 | [
"def",
"bind",
"(",
"self",
",",
"data_shapes",
",",
"label_shapes",
"=",
"None",
",",
"for_training",
"=",
"True",
",",
"inputs_need_grad",
"=",
"False",
",",
"force_rebind",
"=",
"False",
",",
"shared_module",
"=",
"None",
",",
"grad_req",
"=",
"'write'",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.reshape | 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``. | python/mxnet/module/module.py | 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):
"""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.... | [
"Reshapes",
"the",
"module",
"for",
"new",
"input",
"shapes",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L458-L472 | [
"def",
"reshape",
"(",
"self",
",",
"data_shapes",
",",
"label_shapes",
"=",
"None",
")",
":",
"assert",
"self",
".",
"binded",
"self",
".",
"_data_shapes",
",",
"self",
".",
"_label_shapes",
"=",
"_parse_data_desc",
"(",
"self",
".",
"data_names",
",",
"s... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.init_optimizer | 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... | python/mxnet/module/module.py | 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):
"""Installs and initializes optimizers.
Parameters
----------
kvstore : str or KVStore
Default `'local'`.
optimizer : str... | [
"Installs",
"and",
"initializes",
"optimizers",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L474-L558 | [
"def",
"init_optimizer",
"(",
"self",
",",
"kvstore",
"=",
"'local'",
",",
"optimizer",
"=",
"'sgd'",
",",
"optimizer_params",
"=",
"(",
"(",
"'learning_rate'",
",",
"0.01",
")",
",",
")",
",",
"force_init",
"=",
"False",
")",
":",
"assert",
"self",
".",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.borrow_optimizer | Borrows optimizer from a shared module. Used in bucketing, where exactly the same
optimizer (esp. kvstore) is used.
Parameters
----------
shared_module : Module | python/mxnet/module/module.py | 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):
"""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... | [
"Borrows",
"optimizer",
"from",
"a",
"shared",
"module",
".",
"Used",
"in",
"bucketing",
"where",
"exactly",
"the",
"same",
"optimizer",
"(",
"esp",
".",
"kvstore",
")",
"is",
"used",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L560-L573 | [
"def",
"borrow_optimizer",
"(",
"self",
",",
"shared_module",
")",
":",
"assert",
"shared_module",
".",
"optimizer_initialized",
"self",
".",
"_optimizer",
"=",
"shared_module",
".",
"_optimizer",
"self",
".",
"_kvstore",
"=",
"shared_module",
".",
"_kvstore",
"se... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.forward | 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... | python/mxnet/module/module.py | 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):
"""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 ... | [
"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",
... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L575-L627 | [
"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",
".",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.backward | 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
... | python/mxnet/module/module.py | 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):
"""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... | [
"Backward",
"computation",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L629-L644 | [
"def",
"backward",
"(",
"self",
",",
"out_grads",
"=",
"None",
")",
":",
"assert",
"self",
".",
"binded",
"and",
"self",
".",
"params_initialized",
"self",
".",
"_exec_group",
".",
"backward",
"(",
"out_grads",
"=",
"out_grads",
")"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.update | 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,... | python/mxnet/module/module.py | 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):
"""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... | [
"Updates",
"parameters",
"according",
"to",
"the",
"installed",
"optimizer",
"and",
"the",
"gradients",
"computed",
"in",
"the",
"previous",
"forward",
"-",
"backward",
"batch",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L646-L673 | [
"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... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.get_outputs | 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`
... | python/mxnet/module/module.py | 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):
"""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... | [
"Gets",
"outputs",
"of",
"the",
"previous",
"forward",
"computation",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L675-L697 | [
"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... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.get_input_grads | 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
----------
... | python/mxnet/module/module.py | 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):
"""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... | [
"Gets",
"the",
"gradients",
"with",
"respect",
"to",
"the",
"inputs",
"of",
"the",
"module",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L699-L720 | [
"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... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.get_states | 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
... | python/mxnet/module/module.py | 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):
"""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
... | [
"Gets",
"states",
"from",
"all",
"devices",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L722-L743 | [
"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... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.update_metric | 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... | python/mxnet/module/module.py | 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):
"""Evaluates and accumulates evaluation metric on outputs of the last forward computation.
See Also
----------
:meth:`BaseModule.update_metric`.
Parameters
----------
eval_metric : EvalMetric
... | [
"Evaluates",
"and",
"accumulates",
"evaluation",
"metric",
"on",
"outputs",
"of",
"the",
"last",
"forward",
"computation",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L759-L775 | [
"def",
"update_metric",
"(",
"self",
",",
"eval_metric",
",",
"labels",
",",
"pre_sliced",
"=",
"False",
")",
":",
"self",
".",
"_exec_group",
".",
"update_metric",
"(",
"eval_metric",
",",
"labels",
",",
"pre_sliced",
")"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module._sync_params_from_devices | 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... | python/mxnet/module/module.py | 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):
"""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... | [
"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... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L777-L791 | [
"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... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.save_optimizer_states | Saves optimizer (updater) state to a file.
Parameters
----------
fname : str
Path to output states file. | python/mxnet/module/module.py | 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):
"""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... | [
"Saves",
"optimizer",
"(",
"updater",
")",
"state",
"to",
"a",
"file",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L793-L807 | [
"def",
"save_optimizer_states",
"(",
"self",
",",
"fname",
")",
":",
"assert",
"self",
".",
"optimizer_initialized",
"if",
"self",
".",
"_update_on_kvstore",
":",
"self",
".",
"_kvstore",
".",
"save_optimizer_states",
"(",
"fname",
")",
"else",
":",
"with",
"o... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.load_optimizer_states | Loads optimizer (updater) state from a file.
Parameters
----------
fname : str
Path to input states file. | python/mxnet/module/module.py | 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):
"""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... | [
"Loads",
"optimizer",
"(",
"updater",
")",
"state",
"from",
"a",
"file",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L809-L822 | [
"def",
"load_optimizer_states",
"(",
"self",
",",
"fname",
")",
":",
"assert",
"self",
".",
"optimizer_initialized",
"if",
"self",
".",
"_update_on_kvstore",
":",
"self",
".",
"_kvstore",
".",
"load_optimizer_states",
"(",
"fname",
")",
"else",
":",
"self",
".... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Module.prepare | 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... | python/mxnet/module/module.py | 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):
'''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.
... | [
"Prepares",
"the",
"module",
"for",
"processing",
"a",
"data",
"batch",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/module.py#L829-L870 | [
"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... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _random_helper | Helper function for random generators. | python/mxnet/ndarray/random.py | 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):
"""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 " \... | [
"Helper",
"function",
"for",
"random",
"generators",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L31-L51 | [
"def",
"_random_helper",
"(",
"random",
",",
"sampler",
",",
"params",
",",
"shape",
",",
"dtype",
",",
"ctx",
",",
"out",
",",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"params",
"[",
"0",
"]",
",",
"NDArray",
")",
":",
"for",
"i",
"in",
"param... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | uniform | 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
... | python/mxnet/ndarray/random.py | 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):
"""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... | [
"Draw",
"random",
"samples",
"from",
"a",
"uniform",
"distribution",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L54-L110 | [
"def",
"uniform",
"(",
"low",
"=",
"0",
",",
"high",
"=",
"1",
",",
"shape",
"=",
"_Null",
",",
"dtype",
"=",
"_Null",
",",
"ctx",
"=",
"None",
",",
"out",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_random_helper",
"(",
"_interna... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | normal | 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 ... | python/mxnet/ndarray/random.py | 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):
"""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... | [
"Draw",
"random",
"samples",
"from",
"a",
"normal",
"(",
"Gaussian",
")",
"distribution",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L113-L167 | [
"def",
"normal",
"(",
"loc",
"=",
"0",
",",
"scale",
"=",
"1",
",",
"shape",
"=",
"_Null",
",",
"dtype",
"=",
"_Null",
",",
"ctx",
"=",
"None",
",",
"out",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_random_helper",
"(",
"_interna... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | randn | 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... | python/mxnet/ndarray/random.py | 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):
"""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... | [
"Draw",
"random",
"samples",
"from",
"a",
"normal",
"(",
"Gaussian",
")",
"distribution",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L170-L226 | [
"def",
"randn",
"(",
"*",
"shape",
",",
"*",
"*",
"kwargs",
")",
":",
"loc",
"=",
"kwargs",
".",
"pop",
"(",
"'loc'",
",",
"0",
")",
"scale",
"=",
"kwargs",
".",
"pop",
"(",
"'scale'",
",",
"1",
")",
"dtype",
"=",
"kwargs",
".",
"pop",
"(",
"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | exponential | 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
-... | python/mxnet/ndarray/random.py | 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):
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... | [
"r",
"Draw",
"samples",
"from",
"an",
"exponential",
"distribution",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L279-L329 | [
"def",
"exponential",
"(",
"scale",
"=",
"1",
",",
"shape",
"=",
"_Null",
",",
"dtype",
"=",
"_Null",
",",
"ctx",
"=",
"None",
",",
"out",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_random_helper",
"(",
"_internal",
".",
"_random_exp... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | gamma | 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 :... | python/mxnet/ndarray/random.py | 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):
"""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... | [
"Draw",
"random",
"samples",
"from",
"a",
"gamma",
"distribution",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L332-L383 | [
"def",
"gamma",
"(",
"alpha",
"=",
"1",
",",
"beta",
"=",
"1",
",",
"shape",
"=",
"_Null",
",",
"dtype",
"=",
"_Null",
",",
"ctx",
"=",
"None",
",",
"out",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_random_helper",
"(",
"_interna... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | negative_binomial | 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.
... | python/mxnet/ndarray/random.py | 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):
"""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* ... | [
"Draw",
"random",
"samples",
"from",
"a",
"negative",
"binomial",
"distribution",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L386-L439 | [
"def",
"negative_binomial",
"(",
"k",
"=",
"1",
",",
"p",
"=",
"1",
",",
"shape",
"=",
"_Null",
",",
"dtype",
"=",
"_Null",
",",
"ctx",
"=",
"None",
",",
"out",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_random_helper",
"(",
"_in... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | multinomial | 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
`... | python/mxnet/ndarray/random.py | 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):
"""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 :... | [
"Concurrent",
"sampling",
"from",
"multiple",
"multinomial",
"distributions",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L500-L562 | [
"def",
"multinomial",
"(",
"data",
",",
"shape",
"=",
"_Null",
",",
"get_prob",
"=",
"False",
",",
"out",
"=",
"None",
",",
"dtype",
"=",
"'int32'",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_internal",
".",
"_sample_multinomial",
"(",
"data",
",",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | randint | 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
... | python/mxnet/ndarray/random.py | 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):
"""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... | [
"Draw",
"random",
"samples",
"from",
"a",
"discrete",
"uniform",
"distribution",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/random.py#L604-L649 | [
"def",
"randint",
"(",
"low",
",",
"high",
",",
"shape",
"=",
"_Null",
",",
"dtype",
"=",
"_Null",
",",
"ctx",
"=",
"None",
",",
"out",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"_random_helper",
"(",
"_internal",
".",
"_random_randin... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | preprocess_uci_adult | Some tricks of feature engineering are adapted
from tensorflow's wide and deep tutorial. | example/sparse/wide_deep/data.py | 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):
"""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... | [
"Some",
"tricks",
"of",
"feature",
"engineering",
"are",
"adapted",
"from",
"tensorflow",
"s",
"wide",
"and",
"deep",
"tutorial",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/sparse/wide_deep/data.py#L40-L139 | [
"def",
"preprocess_uci_adult",
"(",
"data_name",
")",
":",
"csv_columns",
"=",
"[",
"\"age\"",
",",
"\"workclass\"",
",",
"\"fnlwgt\"",
",",
"\"education\"",
",",
"\"education_num\"",
",",
"\"marital_status\"",
",",
"\"occupation\"",
",",
"\"relationship\"",
",",
"\... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Trainer._init_params | Initialize parameters in the KVStore.
Parameters with incomplete initialization are ignored. | python/mxnet/gluon/trainer.py | 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):
"""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... | [
"Initialize",
"parameters",
"in",
"the",
"KVStore",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L137-L157 | [
"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... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Trainer._reset_kvstore | Reset kvstore. | python/mxnet/gluon/trainer.py | 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):
"""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
... | [
"Reset",
"kvstore",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L159-L167 | [
"def",
"_reset_kvstore",
"(",
"self",
")",
":",
"if",
"self",
".",
"_kvstore",
"and",
"'dist'",
"in",
"self",
".",
"_kvstore",
".",
"type",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot reset distributed KVStore.\"",
")",
"self",
".",
"_kv_initialized",
"=",
"F... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Trainer._init_kvstore | Create kvstore. | python/mxnet/gluon/trainer.py | 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):
"""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.... | [
"Create",
"kvstore",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L169-L248 | [
"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... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Trainer.set_learning_rate | Sets a new learning rate of the optimizer.
Parameters
----------
lr : float
The new learning rate of the optimizer. | python/mxnet/gluon/trainer.py | 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):
"""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... | [
"Sets",
"a",
"new",
"learning",
"rate",
"of",
"the",
"optimizer",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L258-L270 | [
"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.\... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Trainer._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`. | python/mxnet/gluon/trainer.py | 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):
"""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... | [
"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",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L272-L286 | [
"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",
"(",
")",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Trainer.step | 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... | python/mxnet/gluon/trainer.py | 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):
"""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()`... | [
"Makes",
"one",
"step",
"of",
"parameter",
"update",
".",
"Should",
"be",
"called",
"after",
"autograd",
".",
"backward",
"()",
"and",
"outside",
"of",
"record",
"()",
"scope",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L298-L325 | [
"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... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Trainer.allreduce_grads | 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... | python/mxnet/gluon/trainer.py | 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):
"""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
... | [
"For",
"each",
"parameter",
"reduce",
"the",
"gradients",
"from",
"different",
"contexts",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L327-L347 | [
"def",
"allreduce_grads",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_kv_initialized",
":",
"self",
".",
"_init_kvstore",
"(",
")",
"if",
"self",
".",
"_params_to_init",
":",
"self",
".",
"_init_params",
"(",
")",
"assert",
"not",
"(",
"self",
"."... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Trainer.update | 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... | python/mxnet/gluon/trainer.py | 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):
"""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
... | [
"Makes",
"one",
"step",
"of",
"parameter",
"update",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L359-L390 | [
"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... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Trainer.save_states | 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. | python/mxnet/gluon/trainer.py | 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):
"""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... | [
"Saves",
"trainer",
"states",
"(",
"e",
".",
"g",
".",
"optimizer",
"momentum",
")",
"to",
"a",
"file",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L429-L456 | [
"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... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Trainer.load_states | 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... | python/mxnet/gluon/trainer.py | 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):
"""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... | [
"Loads",
"trainer",
"states",
"(",
"e",
".",
"g",
".",
"optimizer",
"momentum",
")",
"from",
"a",
"file",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/trainer.py#L458-L488 | [
"def",
"load_states",
"(",
"self",
",",
"fname",
")",
":",
"if",
"not",
"self",
".",
"_kv_initialized",
":",
"self",
".",
"_init_kvstore",
"(",
")",
"if",
"self",
".",
"_params_to_init",
":",
"self",
".",
"_init_params",
"(",
")",
"if",
"self",
".",
"_... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | estimate_density | sample 10 times of a size of 1000 for estimating the density of the sparse dataset | benchmark/python/sparse/util.py | 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):
"""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... | [
"sample",
"10",
"times",
"of",
"a",
"size",
"of",
"1000",
"for",
"estimating",
"the",
"density",
"of",
"the",
"sparse",
"dataset"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/benchmark/python/sparse/util.py#L21-L36 | [
"def",
"estimate_density",
"(",
"DATA_PATH",
",",
"feature_size",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"DATA_PATH",
")",
":",
"raise",
"Exception",
"(",
"\"Data is not there!\"",
")",
"density",
"=",
"[",
"]",
"P",
"=",
"0.01",
"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | exec_cmd | Execute the command line command. | example/reinforcement-learning/a3c/launcher.py | 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):
"""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... | [
"Execute",
"the",
"command",
"line",
"command",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/reinforcement-learning/a3c/launcher.py#L46-L77 | [
"def",
"exec_cmd",
"(",
"cmd",
",",
"role",
",",
"taskid",
",",
"pass_env",
")",
":",
"if",
"cmd",
"[",
"0",
"]",
".",
"find",
"(",
"'/'",
")",
"==",
"-",
"1",
"and",
"os",
".",
"path",
".",
"exists",
"(",
"cmd",
"[",
"0",
"]",
")",
"and",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | submit | Submit function of local jobs. | example/reinforcement-learning/a3c/launcher.py | 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(',')
"""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... | [
"Submit",
"function",
"of",
"local",
"jobs",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/reinforcement-learning/a3c/launcher.py#L79-L106 | [
"def",
"submit",
"(",
"args",
")",
":",
"gpus",
"=",
"args",
".",
"gpus",
".",
"strip",
"(",
")",
".",
"split",
"(",
"','",
")",
"def",
"mthread_submit",
"(",
"nworker",
",",
"nserver",
",",
"envs",
")",
":",
"\"\"\"\n customized submit script, that... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | CtcMetrics.ctc_label | 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 | example/ctc/ctc_metrics.py | 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):
"""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):
... | [
"Iterates",
"through",
"p",
"identifying",
"non",
"-",
"zero",
"and",
"non",
"-",
"repeating",
"values",
"and",
"returns",
"them",
"in",
"a",
"list",
"Parameters",
"----------",
"p",
":",
"list",
"of",
"int"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/ctc_metrics.py#L34-L51 | [
"def",
"ctc_label",
"(",
"p",
")",
":",
"ret",
"=",
"[",
"]",
"p1",
"=",
"[",
"0",
"]",
"+",
"p",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"p",
")",
":",
"c1",
"=",
"p1",
"[",
"i",
"]",
"c2",
"=",
"p1",
"[",
"i",
"+",
"1",
"]",
"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | CtcMetrics._remove_blank | Removes trailing zeros in the list of integers and returns a new list of integers | example/ctc/ctc_metrics.py | 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):
""" 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 | [
"Removes",
"trailing",
"zeros",
"in",
"the",
"list",
"of",
"integers",
"and",
"returns",
"a",
"new",
"list",
"of",
"integers"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/ctc_metrics.py#L54-L61 | [
"def",
"_remove_blank",
"(",
"l",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"i",
",",
"_",
"in",
"enumerate",
"(",
"l",
")",
":",
"if",
"l",
"[",
"i",
"]",
"==",
"0",
":",
"break",
"ret",
".",
"append",
"(",
"l",
"[",
"i",
"]",
")",
"return",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | CtcMetrics._lcs | Calculates the Longest Common Subsequence between p and l (both list of int) and returns its length | example/ctc/ctc_metrics.py | 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):
""" 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))
... | [
"Calculates",
"the",
"Longest",
"Common",
"Subsequence",
"between",
"p",
"and",
"l",
"(",
"both",
"list",
"of",
"int",
")",
"and",
"returns",
"its",
"length"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/ctc_metrics.py#L64-L81 | [
"def",
"_lcs",
"(",
"p",
",",
"l",
")",
":",
"# Dynamic Programming Finding LCS",
"if",
"len",
"(",
"p",
")",
"==",
"0",
":",
"return",
"0",
"P",
"=",
"np",
".",
"array",
"(",
"list",
"(",
"p",
")",
")",
".",
"reshape",
"(",
"(",
"1",
",",
"len... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | CtcMetrics.accuracy | Simple accuracy measure: number of 100% accurate predictions divided by total number | example/ctc/ctc_metrics.py | 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):
""" 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... | [
"Simple",
"accuracy",
"measure",
":",
"number",
"of",
"100%",
"accurate",
"predictions",
"divided",
"by",
"total",
"number"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/ctc_metrics.py#L83-L104 | [
"def",
"accuracy",
"(",
"self",
",",
"label",
",",
"pred",
")",
":",
"hit",
"=",
"0.",
"total",
"=",
"0.",
"batch_size",
"=",
"label",
".",
"shape",
"[",
"0",
"]",
"for",
"i",
"in",
"range",
"(",
"batch_size",
")",
":",
"l",
"=",
"self",
".",
"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | CtcMetrics.accuracy_lcs | Longest Common Subsequence accuracy measure: calculate accuracy of each prediction as LCS/length | example/ctc/ctc_metrics.py | 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):
""" 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 = []... | [
"Longest",
"Common",
"Subsequence",
"accuracy",
"measure",
":",
"calculate",
"accuracy",
"of",
"each",
"prediction",
"as",
"LCS",
"/",
"length"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/ctc_metrics.py#L106-L120 | [
"def",
"accuracy_lcs",
"(",
"self",
",",
"label",
",",
"pred",
")",
":",
"hit",
"=",
"0.",
"total",
"=",
"0.",
"batch_size",
"=",
"label",
".",
"shape",
"[",
"0",
"]",
"for",
"i",
"in",
"range",
"(",
"batch_size",
")",
":",
"l",
"=",
"self",
".",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | get_movielens_iter | Not particularly fast code to parse the text file and load into NDArrays.
return two data iters, one for train, the other for validation. | example/sparse/matrix_factorization/data.py | 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):
"""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 = []
... | [
"Not",
"particularly",
"fast",
"code",
"to",
"parse",
"the",
"text",
"file",
"and",
"load",
"into",
"NDArrays",
".",
"return",
"two",
"data",
"iters",
"one",
"for",
"train",
"the",
"other",
"for",
"validation",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/sparse/matrix_factorization/data.py#L29-L56 | [
"def",
"get_movielens_iter",
"(",
"filename",
",",
"batch_size",
")",
":",
"logging",
".",
"info",
"(",
"\"Preparing data iterators for \"",
"+",
"filename",
"+",
"\" ... \"",
")",
"user",
"=",
"[",
"]",
"item",
"=",
"[",
"]",
"score",
"=",
"[",
"]",
"with... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | imdecode | 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)
... | plugin/opencv/opencv.py | 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):
"""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... | [
"Decode",
"image",
"from",
"str",
"buffer",
".",
"Wrapper",
"for",
"cv2",
".",
"imdecode",
"that",
"uses",
"mx",
".",
"nd",
".",
"NDArray"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/plugin/opencv/opencv.py#L29-L49 | [
"def",
"imdecode",
"(",
"str_img",
",",
"flag",
"=",
"1",
")",
":",
"hdl",
"=",
"NDArrayHandle",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXCVImdecode",
"(",
"ctypes",
".",
"c_char_p",
"(",
"str_img",
")",
",",
"mx_uint",
"(",
"len",
"(",
"str_img",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | resize | 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
-... | plugin/opencv/opencv.py | 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):
"""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
... | [
"Decode",
"image",
"from",
"str",
"buffer",
".",
"Wrapper",
"for",
"cv2",
".",
"imresize",
"that",
"uses",
"mx",
".",
"nd",
".",
"NDArray"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/plugin/opencv/opencv.py#L51-L72 | [
"def",
"resize",
"(",
"src",
",",
"size",
",",
"interpolation",
"=",
"cv2",
".",
"INTER_LINEAR",
")",
":",
"hdl",
"=",
"NDArrayHandle",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXCVResize",
"(",
"src",
".",
"handle",
",",
"mx_uint",
"(",
"size",
"[",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | copyMakeBorder | 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 | plugin/opencv/opencv.py | 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):
"""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
... | [
"Pad",
"image",
"border",
"Wrapper",
"for",
"cv2",
".",
"copyMakeBorder",
"that",
"uses",
"mx",
".",
"nd",
".",
"NDArray"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/plugin/opencv/opencv.py#L74-L94 | [
"def",
"copyMakeBorder",
"(",
"src",
",",
"top",
",",
"bot",
",",
"left",
",",
"right",
",",
"border_type",
"=",
"cv2",
".",
"BORDER_CONSTANT",
",",
"value",
"=",
"0",
")",
":",
"hdl",
"=",
"NDArrayHandle",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | fixed_crop | Crop src at fixed location, and (optionally) resize it to size | plugin/opencv/opencv.py | 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):
"""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... | [
"Crop",
"src",
"at",
"fixed",
"location",
"and",
"(",
"optionally",
")",
"resize",
"it",
"to",
"size"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/plugin/opencv/opencv.py#L107-L112 | [
"def",
"fixed_crop",
"(",
"src",
",",
"x0",
",",
"y0",
",",
"w",
",",
"h",
",",
"size",
"=",
"None",
",",
"interpolation",
"=",
"cv2",
".",
"INTER_CUBIC",
")",
":",
"out",
"=",
"mx",
".",
"nd",
".",
"crop",
"(",
"src",
",",
"begin",
"=",
"(",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | random_crop | Randomly crop src with size. Upsample result if src is smaller than size | plugin/opencv/opencv.py | 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):
"""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... | [
"Randomly",
"crop",
"src",
"with",
"size",
".",
"Upsample",
"result",
"if",
"src",
"is",
"smaller",
"than",
"size"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/plugin/opencv/opencv.py#L114-L123 | [
"def",
"random_crop",
"(",
"src",
",",
"size",
")",
":",
"h",
",",
"w",
",",
"_",
"=",
"src",
".",
"shape",
"new_w",
",",
"new_h",
"=",
"scale_down",
"(",
"(",
"w",
",",
"h",
")",
",",
"size",
")",
"x0",
"=",
"random",
".",
"randint",
"(",
"0... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | random_size_crop | Randomly crop src with size. Randomize area and aspect ratio | plugin/opencv/opencv.py | 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)):
"""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... | [
"Randomly",
"crop",
"src",
"with",
"size",
".",
"Randomize",
"area",
"and",
"aspect",
"ratio"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/plugin/opencv/opencv.py#L131-L153 | [
"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",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | ImageListIter.next | Move iterator position forward | plugin/opencv/opencv.py | 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):
"""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... | [
"Move",
"iterator",
"position",
"forward"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/plugin/opencv/opencv.py#L173-L188 | [
"def",
"next",
"(",
"self",
")",
":",
"batch",
"=",
"mx",
".",
"nd",
".",
"zeros",
"(",
"(",
"self",
".",
"batch_size",
",",
"self",
".",
"size",
"[",
"1",
"]",
",",
"self",
".",
"size",
"[",
"0",
"]",
",",
"3",
")",
")",
"i",
"=",
"self",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | check_label_shapes | Check to see if the two arrays are the same size. | example/speech_recognition/stt_metric.py | 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):
"""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... | [
"Check",
"to",
"see",
"if",
"the",
"two",
"arrays",
"are",
"the",
"same",
"size",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/speech_recognition/stt_metric.py#L25-L35 | [
"def",
"check_label_shapes",
"(",
"labels",
",",
"preds",
",",
"shape",
"=",
"0",
")",
":",
"if",
"shape",
"==",
"0",
":",
"label_shape",
",",
"pred_shape",
"=",
"len",
"(",
"labels",
")",
",",
"len",
"(",
"preds",
")",
"else",
":",
"label_shape",
",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | import_to_gluon | 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... | python/mxnet/contrib/onnx/onnx2mx/import_to_gluon.py | 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):
"""
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
... | [
"Imports",
"the",
"ONNX",
"model",
"files",
"passed",
"as",
"a",
"parameter",
"into",
"Gluon",
"SymbolBlock",
"object",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/import_to_gluon.py#L24-L53 | [
"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\"",
"+",
"\" ... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | get_model | Model initialization. | example/gluon/image_classification.py | 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):
"""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... | [
"Model",
"initialization",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/image_classification.py#L117-L134 | [
"def",
"get_model",
"(",
"model",
",",
"ctx",
",",
"opt",
")",
":",
"kwargs",
"=",
"{",
"'ctx'",
":",
"ctx",
",",
"'pretrained'",
":",
"opt",
".",
"use_pretrained",
",",
"'classes'",
":",
"classes",
"}",
"if",
"model",
".",
"startswith",
"(",
"'resnet'... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | get_data_iters | get dataset iterators | example/gluon/image_classification.py | 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):
"""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... | [
"get",
"dataset",
"iterators"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/image_classification.py#L138-L160 | [
"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... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | update_learning_rate | Set the learning rate to the initial value decayed by ratio every N epochs. | example/gluon/image_classification.py | 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):
"""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 | [
"Set",
"the",
"learning",
"rate",
"to",
"the",
"initial",
"value",
"decayed",
"by",
"ratio",
"every",
"N",
"epochs",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/image_classification.py#L174-L178 | [
"def",
"update_learning_rate",
"(",
"lr",
",",
"trainer",
",",
"epoch",
",",
"ratio",
",",
"steps",
")",
":",
"new_lr",
"=",
"lr",
"*",
"(",
"ratio",
"**",
"int",
"(",
"np",
".",
"sum",
"(",
"np",
".",
"array",
"(",
"steps",
")",
"<",
"epoch",
")... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | seed | 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 ... | python/mxnet/random.py | 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"):
"""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... | [
"Seeds",
"the",
"random",
"number",
"generators",
"in",
"MXNet",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/random.py#L30-L100 | [
"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",
"(",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | random_uniform | Draw random samples from a uniform distribtuion. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | 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):
"""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... | [
"Draw",
"random",
"samples",
"from",
"a",
"uniform",
"distribtuion",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L30-L39 | [
"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. \"",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | random_normal | Draw random samples from a Gaussian distribution. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | 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):
"""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... | [
"Draw",
"random",
"samples",
"from",
"a",
"Gaussian",
"distribution",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L41-L51 | [
"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. \"",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | add | Adding two tensors | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | 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):
"""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... | [
"Adding",
"two",
"tensors"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L66-L75 | [
"def",
"add",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attr",
"=",
"{",
"}",
"if",
"'broadcast'",
"in",
"attrs",
"and",
"attrs",
"[",
"'broadcast'",
"]",
"==",
"1",
":",
"broadcast_axis",
"=",
"attrs",
"[",
"'axis'",
"]",
"op_value... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | mean | Mean of all the input tensors. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | 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):
"""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 | [
"Mean",
"of",
"all",
"the",
"input",
"tensors",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L110-L115 | [
"def",
"mean",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"concat_input",
"=",
"[",
"symbol",
".",
"expand_dims",
"(",
"op_input",
",",
"axis",
"=",
"0",
")",
"for",
"op_input",
"in",
"inputs",
"]",
"concat_sym",
"=",
"symbol",
".",
"conc... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | argmax | Returns indices of the maximum values along an axis | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | 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):
"""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... | [
"Returns",
"indices",
"of",
"the",
"maximum",
"values",
"along",
"an",
"axis"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L146-L153 | [
"def",
"argmax",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"axis",
"=",
"attrs",
".",
"get",
"(",
"'axis'",
",",
"0",
")",
"keepdims",
"=",
"attrs",
".",
"get",
"(",
"'keepdims'",
",",
"1",
")",
"argmax_op",
"=",
"symbol",
".",
"argm... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | argmin | Returns indices of the minimum values along an axis. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | 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):
"""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... | [
"Returns",
"indices",
"of",
"the",
"minimum",
"values",
"along",
"an",
"axis",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L155-L162 | [
"def",
"argmin",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"axis",
"=",
"attrs",
".",
"get",
"(",
"'axis'",
",",
"0",
")",
"keepdims",
"=",
"attrs",
".",
"get",
"(",
"'keepdims'",
",",
"1",
")",
"argmin_op",
"=",
"symbol",
".",
"argm... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | maximum | 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 | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | 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):
"""
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... | [
"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... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L164-L177 | [
"def",
"maximum",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"if",
"len",
"(",
"inputs",
")",
">",
"1",
":",
"mxnet_op",
"=",
"symbol",
".",
"maximum",
"(",
"inputs",
"[",
"0",
"]",
",",
"inputs",
"[",
"1",
"]",
")",
"for",
"op_inpu... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | minimum | Elementwise minimum of arrays. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | 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):
"""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[... | [
"Elementwise",
"minimum",
"of",
"arrays",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L179-L190 | [
"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",
")",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | concat | Joins input arrays along a given axis. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | 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):
""" Joins input arrays along a given axis. """
new_attrs = translation_utils._fix_attribute_names(attrs, {'axis': 'dim'})
return 'concat', new_attrs, inputs | [
"Joins",
"input",
"arrays",
"along",
"a",
"given",
"axis",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L219-L222 | [
"def",
"concat",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'axis'",
":",
"'dim'",
"}",
")",
"return",
"'concat'",
",",
"new_attrs",
",",
"inputs"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | pad | Add padding to input tensor | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | 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):
""" Add padding to input tensor"""
new_attrs = translation_utils._fix_attribute_names(attrs, {'pads' : 'pad_width',
'value' : 'constant_value'
})
n... | [
"Add",
"padding",
"to",
"input",
"tensor"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L241-L247 | [
"def",
"pad",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'pads'",
":",
"'pad_width'",
",",
"'value'",
":",
"'constant_value'",
"}",
")",
"new_attrs",
"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | batch_norm | Batch normalization. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | 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):
"""Batch normalization."""
new_attrs = translation_utils._fix_attribute_names(attrs, {'epsilon': 'eps',
'is_test': 'fix_gamma'})
new_attrs = translation_utils._remove_attributes(new_attrs,
... | [
"Batch",
"normalization",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L253-L266 | [
"def",
"batch_norm",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'epsilon'",
":",
"'eps'",
",",
"'is_test'",
":",
"'fix_gamma'",
"}",
")",
"new_attrs",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | instance_norm | Instance Normalization. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | 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):
"""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 | [
"Instance",
"Normalization",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L268-L272 | [
"def",
"instance_norm",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'epsilon'",
":",
"'eps'",
"}",
")",
"new_attrs",
"[",
"'eps'",
"]",
"=",
"attrs",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | leaky_relu | Leaky Relu function | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | 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):
"""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 | [
"Leaky",
"Relu",
"function"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L274-L280 | [
"def",
"leaky_relu",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"if",
"'alpha'",
"in",
"attrs",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'alpha'",
":",
"'slope'",
"}",
")",
"else",
":",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _elu | Elu function | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | 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):
"""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(... | [
"Elu",
"function"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L282-L289 | [
"def",
"_elu",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"if",
"'alpha'",
"in",
"attrs",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'alpha'",
":",
"'slope'",
"}",
")",
"else",
":",
"ne... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _prelu | PRelu function | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def _prelu(attrs, inputs, proto_obj):
"""PRelu function"""
new_attrs = translation_utils._add_extra_attributes(attrs, {'act_type': 'prelu'})
return 'LeakyReLU', new_attrs, inputs | def _prelu(attrs, inputs, proto_obj):
"""PRelu function"""
new_attrs = translation_utils._add_extra_attributes(attrs, {'act_type': 'prelu'})
return 'LeakyReLU', new_attrs, inputs | [
"PRelu",
"function"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L291-L294 | [
"def",
"_prelu",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_add_extra_attributes",
"(",
"attrs",
",",
"{",
"'act_type'",
":",
"'prelu'",
"}",
")",
"return",
"'LeakyReLU'",
",",
"new_attrs",
",",
"in... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _selu | Selu function | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def _selu(attrs, inputs, proto_obj):
"""Selu function"""
new_attrs = translation_utils._add_extra_attributes(attrs, {'act_type': 'selu'})
return 'LeakyReLU', new_attrs, inputs | def _selu(attrs, inputs, proto_obj):
"""Selu function"""
new_attrs = translation_utils._add_extra_attributes(attrs, {'act_type': 'selu'})
return 'LeakyReLU', new_attrs, inputs | [
"Selu",
"function"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L296-L299 | [
"def",
"_selu",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_add_extra_attributes",
"(",
"attrs",
",",
"{",
"'act_type'",
":",
"'selu'",
"}",
")",
"return",
"'LeakyReLU'",
",",
"new_attrs",
",",
"inpu... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | softmax | Softmax function. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def softmax(attrs, inputs, proto_obj):
"""Softmax function."""
if 'axis' not in attrs:
attrs = translation_utils._add_extra_attributes(attrs, {'axis': 1})
return 'softmax', attrs, inputs | def softmax(attrs, inputs, proto_obj):
"""Softmax function."""
if 'axis' not in attrs:
attrs = translation_utils._add_extra_attributes(attrs, {'axis': 1})
return 'softmax', attrs, inputs | [
"Softmax",
"function",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L301-L305 | [
"def",
"softmax",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"if",
"'axis'",
"not",
"in",
"attrs",
":",
"attrs",
"=",
"translation_utils",
".",
"_add_extra_attributes",
"(",
"attrs",
",",
"{",
"'axis'",
":",
"1",
"}",
")",
"return",
"'softm... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | softplus | Applies the sofplus activation function element-wise to the input. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def softplus(attrs, inputs, proto_obj):
"""Applies the sofplus activation function element-wise to the input."""
new_attrs = translation_utils._add_extra_attributes(attrs, {'act_type' : 'softrelu'})
return 'Activation', new_attrs, inputs | def softplus(attrs, inputs, proto_obj):
"""Applies the sofplus activation function element-wise to the input."""
new_attrs = translation_utils._add_extra_attributes(attrs, {'act_type' : 'softrelu'})
return 'Activation', new_attrs, inputs | [
"Applies",
"the",
"sofplus",
"activation",
"function",
"element",
"-",
"wise",
"to",
"the",
"input",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L312-L315 | [
"def",
"softplus",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_add_extra_attributes",
"(",
"attrs",
",",
"{",
"'act_type'",
":",
"'softrelu'",
"}",
")",
"return",
"'Activation'",
",",
"new_attrs",
",",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | conv | Compute N-D convolution on (N+2)-D input. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def conv(attrs, inputs, proto_obj):
"""Compute N-D convolution on (N+2)-D input."""
new_attrs = translation_utils._fix_attribute_names(attrs, {'kernel_shape' : 'kernel',
'strides' : 'stride',
... | def conv(attrs, inputs, proto_obj):
"""Compute N-D convolution on (N+2)-D input."""
new_attrs = translation_utils._fix_attribute_names(attrs, {'kernel_shape' : 'kernel',
'strides' : 'stride',
... | [
"Compute",
"N",
"-",
"D",
"convolution",
"on",
"(",
"N",
"+",
"2",
")",
"-",
"D",
"input",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L317-L346 | [
"def",
"conv",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'kernel_shape'",
":",
"'kernel'",
",",
"'strides'",
":",
"'stride'",
",",
"'pads'",
":",
"'pa... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | deconv | Computes transposed convolution of the input tensor. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def deconv(attrs, inputs, proto_obj):
"""Computes transposed convolution of the input tensor."""
new_attrs = translation_utils._fix_attribute_names(attrs, {'kernel_shape' : 'kernel',
'strides' : 'stride',
... | def deconv(attrs, inputs, proto_obj):
"""Computes transposed convolution of the input tensor."""
new_attrs = translation_utils._fix_attribute_names(attrs, {'kernel_shape' : 'kernel',
'strides' : 'stride',
... | [
"Computes",
"transposed",
"convolution",
"of",
"the",
"input",
"tensor",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L348-L377 | [
"def",
"deconv",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'kernel_shape'",
":",
"'kernel'",
",",
"'strides'",
":",
"'stride'",
",",
"'pads'",
":",
"'... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | fully_connected | Applies a linear transformation: Y=XWT+b. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def fully_connected(attrs, inputs, proto_obj):
"""Applies a linear transformation: Y=XWT+b."""
new_attrs = translation_utils._remove_attributes(attrs, ['axis'])
new_attrs = translation_utils._fix_bias('FullyConnected', new_attrs, len(inputs))
new_attrs = translation_utils._fix_channels('FullyConnected... | def fully_connected(attrs, inputs, proto_obj):
"""Applies a linear transformation: Y=XWT+b."""
new_attrs = translation_utils._remove_attributes(attrs, ['axis'])
new_attrs = translation_utils._fix_bias('FullyConnected', new_attrs, len(inputs))
new_attrs = translation_utils._fix_channels('FullyConnected... | [
"Applies",
"a",
"linear",
"transformation",
":",
"Y",
"=",
"XWT",
"+",
"b",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L379-L387 | [
"def",
"fully_connected",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_remove_attributes",
"(",
"attrs",
",",
"[",
"'axis'",
"]",
")",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_bias",
"(",
"'Ful... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | global_maxpooling | Performs max pooling on the input. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def global_maxpooling(attrs, inputs, proto_obj):
"""Performs max pooling on the input."""
new_attrs = translation_utils._add_extra_attributes(attrs, {'global_pool': True,
'kernel': (1, 1),
... | def global_maxpooling(attrs, inputs, proto_obj):
"""Performs max pooling on the input."""
new_attrs = translation_utils._add_extra_attributes(attrs, {'global_pool': True,
'kernel': (1, 1),
... | [
"Performs",
"max",
"pooling",
"on",
"the",
"input",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L390-L395 | [
"def",
"global_maxpooling",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_add_extra_attributes",
"(",
"attrs",
",",
"{",
"'global_pool'",
":",
"True",
",",
"'kernel'",
":",
"(",
"1",
",",
"1",
")",
"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | global_avgpooling | Performs avg pooling on the input. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def global_avgpooling(attrs, inputs, proto_obj):
"""Performs avg pooling on the input."""
new_attrs = translation_utils._add_extra_attributes(attrs, {'global_pool': True,
'kernel': (1, 1),
... | def global_avgpooling(attrs, inputs, proto_obj):
"""Performs avg pooling on the input."""
new_attrs = translation_utils._add_extra_attributes(attrs, {'global_pool': True,
'kernel': (1, 1),
... | [
"Performs",
"avg",
"pooling",
"on",
"the",
"input",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L398-L403 | [
"def",
"global_avgpooling",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_add_extra_attributes",
"(",
"attrs",
",",
"{",
"'global_pool'",
":",
"True",
",",
"'kernel'",
":",
"(",
"1",
",",
"1",
")",
"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | global_lppooling | Performs global lp pooling on the input. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def global_lppooling(attrs, inputs, proto_obj):
"""Performs global lp pooling on the input."""
p_value = attrs.get('p', 2)
new_attrs = translation_utils._add_extra_attributes(attrs, {'global_pool': True,
'kernel': (1, 1),
... | def global_lppooling(attrs, inputs, proto_obj):
"""Performs global lp pooling on the input."""
p_value = attrs.get('p', 2)
new_attrs = translation_utils._add_extra_attributes(attrs, {'global_pool': True,
'kernel': (1, 1),
... | [
"Performs",
"global",
"lp",
"pooling",
"on",
"the",
"input",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L405-L413 | [
"def",
"global_lppooling",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"p_value",
"=",
"attrs",
".",
"get",
"(",
"'p'",
",",
"2",
")",
"new_attrs",
"=",
"translation_utils",
".",
"_add_extra_attributes",
"(",
"attrs",
",",
"{",
"'global_pool'",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | linalg_gemm | Performs general matrix multiplication and accumulation | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def linalg_gemm(attrs, inputs, proto_obj):
"""Performs general matrix multiplication and accumulation"""
trans_a = 0
trans_b = 0
alpha = 1
beta = 1
if 'transA' in attrs:
trans_a = attrs['transA']
if 'transB' in attrs:
trans_b = attrs['transB']
if 'alpha' in attrs:
... | def linalg_gemm(attrs, inputs, proto_obj):
"""Performs general matrix multiplication and accumulation"""
trans_a = 0
trans_b = 0
alpha = 1
beta = 1
if 'transA' in attrs:
trans_a = attrs['transA']
if 'transB' in attrs:
trans_b = attrs['transB']
if 'alpha' in attrs:
... | [
"Performs",
"general",
"matrix",
"multiplication",
"and",
"accumulation"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L415-L437 | [
"def",
"linalg_gemm",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"trans_a",
"=",
"0",
"trans_b",
"=",
"0",
"alpha",
"=",
"1",
"beta",
"=",
"1",
"if",
"'transA'",
"in",
"attrs",
":",
"trans_a",
"=",
"attrs",
"[",
"'transA'",
"]",
"if",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | local_response_norm | Local Response Normalization. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def local_response_norm(attrs, inputs, proto_obj):
"""Local Response Normalization."""
new_attrs = translation_utils._fix_attribute_names(attrs,
{'bias': 'knorm',
'size' : 'nsize'})
return 'LRN', n... | def local_response_norm(attrs, inputs, proto_obj):
"""Local Response Normalization."""
new_attrs = translation_utils._fix_attribute_names(attrs,
{'bias': 'knorm',
'size' : 'nsize'})
return 'LRN', n... | [
"Local",
"Response",
"Normalization",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L439-L444 | [
"def",
"local_response_norm",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'bias'",
":",
"'knorm'",
",",
"'size'",
":",
"'nsize'",
"}",
")",
"return",
"'... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | dropout | Dropout Regularization. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def dropout(attrs, inputs, proto_obj):
"""Dropout Regularization."""
mode = 'training'
if 'is_test' in attrs and attrs['is_test'] == 0:
mode = 'always'
new_attrs = translation_utils._fix_attribute_names(attrs,
{'ratio': 'p'})
new_attrs =... | def dropout(attrs, inputs, proto_obj):
"""Dropout Regularization."""
mode = 'training'
if 'is_test' in attrs and attrs['is_test'] == 0:
mode = 'always'
new_attrs = translation_utils._fix_attribute_names(attrs,
{'ratio': 'p'})
new_attrs =... | [
"Dropout",
"Regularization",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L446-L455 | [
"def",
"dropout",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"mode",
"=",
"'training'",
"if",
"'is_test'",
"in",
"attrs",
"and",
"attrs",
"[",
"'is_test'",
"]",
"==",
"0",
":",
"mode",
"=",
"'always'",
"new_attrs",
"=",
"translation_utils",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | reshape | Reshape the given array by the shape attribute. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def reshape(attrs, inputs, proto_obj):
"""Reshape the given array by the shape attribute."""
if len(inputs) == 1:
return 'reshape', attrs, inputs[0]
reshape_shape = list(proto_obj._params[inputs[1].name].asnumpy())
reshape_shape = [int(i) for i in reshape_shape]
new_attrs = {'shape': reshape... | def reshape(attrs, inputs, proto_obj):
"""Reshape the given array by the shape attribute."""
if len(inputs) == 1:
return 'reshape', attrs, inputs[0]
reshape_shape = list(proto_obj._params[inputs[1].name].asnumpy())
reshape_shape = [int(i) for i in reshape_shape]
new_attrs = {'shape': reshape... | [
"Reshape",
"the",
"given",
"array",
"by",
"the",
"shape",
"attribute",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L458-L465 | [
"def",
"reshape",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"if",
"len",
"(",
"inputs",
")",
"==",
"1",
":",
"return",
"'reshape'",
",",
"attrs",
",",
"inputs",
"[",
"0",
"]",
"reshape_shape",
"=",
"list",
"(",
"proto_obj",
".",
"_para... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | cast | Cast input to a given dtype | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def cast(attrs, inputs, proto_obj):
""" Cast input to a given dtype"""
try:
from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE
except ImportError:
raise ImportError("Onnx and protobuf need to be installed. "
+ "Instructions to install - https://github.com/onnx/onnx")
... | def cast(attrs, inputs, proto_obj):
""" Cast input to a given dtype"""
try:
from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE
except ImportError:
raise ImportError("Onnx and protobuf need to be installed. "
+ "Instructions to install - https://github.com/onnx/onnx")
... | [
"Cast",
"input",
"to",
"a",
"given",
"dtype"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L467-L476 | [
"def",
"cast",
"(",
"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. \"",
"+",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | split | Splits an array along a particular axis into multiple sub-arrays. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def split(attrs, inputs, proto_obj):
"""Splits an array along a particular axis into multiple sub-arrays."""
split_list = attrs.get('split') if 'split' in attrs else []
new_attrs = translation_utils._fix_attribute_names(attrs,
{'split' : 'num_outputs'})... | def split(attrs, inputs, proto_obj):
"""Splits an array along a particular axis into multiple sub-arrays."""
split_list = attrs.get('split') if 'split' in attrs else []
new_attrs = translation_utils._fix_attribute_names(attrs,
{'split' : 'num_outputs'})... | [
"Splits",
"an",
"array",
"along",
"a",
"particular",
"axis",
"into",
"multiple",
"sub",
"-",
"arrays",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L478-L498 | [
"def",
"split",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"split_list",
"=",
"attrs",
".",
"get",
"(",
"'split'",
")",
"if",
"'split'",
"in",
"attrs",
"else",
"[",
"]",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _slice | Returns a slice of the input tensor along multiple axes. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def _slice(attrs, inputs, proto_obj):
"""Returns a slice of the input tensor along multiple axes."""
new_attrs = translation_utils._fix_attribute_names(attrs,
{'axes' : 'axis',
'ends' : 'end',
... | def _slice(attrs, inputs, proto_obj):
"""Returns a slice of the input tensor along multiple axes."""
new_attrs = translation_utils._fix_attribute_names(attrs,
{'axes' : 'axis',
'ends' : 'end',
... | [
"Returns",
"a",
"slice",
"of",
"the",
"input",
"tensor",
"along",
"multiple",
"axes",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L500-L515 | [
"def",
"_slice",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'axes'",
":",
"'axis'",
",",
"'ends'",
":",
"'end'",
",",
"'starts'",
":",
"'begin'",
"}"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | transpose | Transpose the input array. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def transpose(attrs, inputs, proto_obj):
"""Transpose the input array."""
new_attrs = translation_utils._fix_attribute_names(attrs,
{'perm' : 'axes'})
return 'transpose', new_attrs, inputs | def transpose(attrs, inputs, proto_obj):
"""Transpose the input array."""
new_attrs = translation_utils._fix_attribute_names(attrs,
{'perm' : 'axes'})
return 'transpose', new_attrs, inputs | [
"Transpose",
"the",
"input",
"array",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L517-L521 | [
"def",
"transpose",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'perm'",
":",
"'axes'",
"}",
")",
"return",
"'transpose'",
",",
"new_attrs",
",",
"input... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | squeeze | Remove single-dimensional entries from the shape of a tensor. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def squeeze(attrs, inputs, proto_obj):
"""Remove single-dimensional entries from the shape of a tensor."""
new_attrs = translation_utils._fix_attribute_names(attrs,
{'axes' : 'axis'})
return 'squeeze', new_attrs, inputs | def squeeze(attrs, inputs, proto_obj):
"""Remove single-dimensional entries from the shape of a tensor."""
new_attrs = translation_utils._fix_attribute_names(attrs,
{'axes' : 'axis'})
return 'squeeze', new_attrs, inputs | [
"Remove",
"single",
"-",
"dimensional",
"entries",
"from",
"the",
"shape",
"of",
"a",
"tensor",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L523-L527 | [
"def",
"squeeze",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'axes'",
":",
"'axis'",
"}",
")",
"return",
"'squeeze'",
",",
"new_attrs",
",",
"inputs"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | unsqueeze | Inserts a new axis of size 1 into the array shape | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def unsqueeze(attrs, inputs, cls):
"""Inserts a new axis of size 1 into the array shape"""
# MXNet can only add one axis at a time.
mxnet_op = inputs[0]
for axis in attrs["axes"]:
mxnet_op = symbol.expand_dims(mxnet_op, axis=axis)
return mxnet_op, attrs, inputs | def unsqueeze(attrs, inputs, cls):
"""Inserts a new axis of size 1 into the array shape"""
# MXNet can only add one axis at a time.
mxnet_op = inputs[0]
for axis in attrs["axes"]:
mxnet_op = symbol.expand_dims(mxnet_op, axis=axis)
return mxnet_op, attrs, inputs | [
"Inserts",
"a",
"new",
"axis",
"of",
"size",
"1",
"into",
"the",
"array",
"shape"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L529-L536 | [
"def",
"unsqueeze",
"(",
"attrs",
",",
"inputs",
",",
"cls",
")",
":",
"# MXNet can only add one axis at a time.",
"mxnet_op",
"=",
"inputs",
"[",
"0",
"]",
"for",
"axis",
"in",
"attrs",
"[",
"\"axes\"",
"]",
":",
"mxnet_op",
"=",
"symbol",
".",
"expand_dims... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | flatten | Flattens the input array into a 2-D array by collapsing the higher dimensions. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def flatten(attrs, inputs, proto_obj):
"""Flattens the input array into a 2-D array by collapsing the higher dimensions."""
#Mxnet does not have axis support. By default uses axis=1
if 'axis' in attrs and attrs['axis'] != 1:
raise RuntimeError("Flatten operator only supports axis=1")
new_attrs =... | def flatten(attrs, inputs, proto_obj):
"""Flattens the input array into a 2-D array by collapsing the higher dimensions."""
#Mxnet does not have axis support. By default uses axis=1
if 'axis' in attrs and attrs['axis'] != 1:
raise RuntimeError("Flatten operator only supports axis=1")
new_attrs =... | [
"Flattens",
"the",
"input",
"array",
"into",
"a",
"2",
"-",
"D",
"array",
"by",
"collapsing",
"the",
"higher",
"dimensions",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L538-L544 | [
"def",
"flatten",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"#Mxnet does not have axis support. By default uses axis=1",
"if",
"'axis'",
"in",
"attrs",
"and",
"attrs",
"[",
"'axis'",
"]",
"!=",
"1",
":",
"raise",
"RuntimeError",
"(",
"\"Flatten oper... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | clip | Clips (limits) the values in an array. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def clip(attrs, inputs, proto_obj):
"""Clips (limits) the values in an array."""
new_attrs = translation_utils._fix_attribute_names(attrs, {'min' : 'a_min',
'max' : 'a_max'})
if 'a_max' not in new_attrs:
new_attrs = translation_utils._ad... | def clip(attrs, inputs, proto_obj):
"""Clips (limits) the values in an array."""
new_attrs = translation_utils._fix_attribute_names(attrs, {'min' : 'a_min',
'max' : 'a_max'})
if 'a_max' not in new_attrs:
new_attrs = translation_utils._ad... | [
"Clips",
"(",
"limits",
")",
"the",
"values",
"in",
"an",
"array",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L546-L554 | [
"def",
"clip",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'min'",
":",
"'a_min'",
",",
"'max'",
":",
"'a_max'",
"}",
")",
"if",
"'a_max'",
"not",
"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | power | Returns element-wise result of base element raised to powers from exp element. | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def power(attrs, inputs, proto_obj):
"""Returns element-wise result of base element raised to powers from exp element."""
new_attrs = translation_utils._fix_attribute_names(attrs, {'exponent':'exp'})
if 'broadcast' in attrs:
new_attrs = translation_utils._remove_attributes(new_attrs, ['broadcast'])
... | def power(attrs, inputs, proto_obj):
"""Returns element-wise result of base element raised to powers from exp element."""
new_attrs = translation_utils._fix_attribute_names(attrs, {'exponent':'exp'})
if 'broadcast' in attrs:
new_attrs = translation_utils._remove_attributes(new_attrs, ['broadcast'])
... | [
"Returns",
"element",
"-",
"wise",
"result",
"of",
"base",
"element",
"raised",
"to",
"powers",
"from",
"exp",
"element",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L569-L580 | [
"def",
"power",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'exponent'",
":",
"'exp'",
"}",
")",
"if",
"'broadcast'",
"in",
"attrs",
":",
"new_attrs",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | reduce_max | Reduce the array along a given axis by maximum value | python/mxnet/contrib/onnx/onnx2mx/_op_translations.py | def reduce_max(attrs, inputs, proto_obj):
"""Reduce the array along a given axis by maximum value"""
new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'})
return 'max', new_attrs, inputs | def reduce_max(attrs, inputs, proto_obj):
"""Reduce the array along a given axis by maximum value"""
new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'})
return 'max', new_attrs, inputs | [
"Reduce",
"the",
"array",
"along",
"a",
"given",
"axis",
"by",
"maximum",
"value"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L615-L618 | [
"def",
"reduce_max",
"(",
"attrs",
",",
"inputs",
",",
"proto_obj",
")",
":",
"new_attrs",
"=",
"translation_utils",
".",
"_fix_attribute_names",
"(",
"attrs",
",",
"{",
"'axes'",
":",
"'axis'",
"}",
")",
"return",
"'max'",
",",
"new_attrs",
",",
"inputs"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.