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 | num_gpus | Query CUDA for the number of GPUs present.
Raises
------
Will raise an exception on any CUDA error.
Returns
-------
count : int
The number of GPUs. | python/mxnet/context.py | def num_gpus():
"""Query CUDA for the number of GPUs present.
Raises
------
Will raise an exception on any CUDA error.
Returns
-------
count : int
The number of GPUs.
"""
count = ctypes.c_int()
check_call(_LIB.MXGetGPUCount(ctypes.byref(count)))
return count.value | def num_gpus():
"""Query CUDA for the number of GPUs present.
Raises
------
Will raise an exception on any CUDA error.
Returns
-------
count : int
The number of GPUs.
"""
count = ctypes.c_int()
check_call(_LIB.MXGetGPUCount(ctypes.byref(count)))
return count.value | [
"Query",
"CUDA",
"for",
"the",
"number",
"of",
"GPUs",
"present",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/context.py#L244-L259 | [
"def",
"num_gpus",
"(",
")",
":",
"count",
"=",
"ctypes",
".",
"c_int",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXGetGPUCount",
"(",
"ctypes",
".",
"byref",
"(",
"count",
")",
")",
")",
"return",
"count",
".",
"value"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | gpu_memory_info | Query CUDA for the free and total bytes of GPU global memory.
Parameters
----------
device_id : int, optional
The device id of the GPU device.
Raises
------
Will raise an exception on any CUDA error.
Returns
-------
(free, total) : (int, int)
The number of GPUs. | python/mxnet/context.py | def gpu_memory_info(device_id=0):
"""Query CUDA for the free and total bytes of GPU global memory.
Parameters
----------
device_id : int, optional
The device id of the GPU device.
Raises
------
Will raise an exception on any CUDA error.
Returns
-------
(free, total) : ... | def gpu_memory_info(device_id=0):
"""Query CUDA for the free and total bytes of GPU global memory.
Parameters
----------
device_id : int, optional
The device id of the GPU device.
Raises
------
Will raise an exception on any CUDA error.
Returns
-------
(free, total) : ... | [
"Query",
"CUDA",
"for",
"the",
"free",
"and",
"total",
"bytes",
"of",
"GPU",
"global",
"memory",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/context.py#L261-L283 | [
"def",
"gpu_memory_info",
"(",
"device_id",
"=",
"0",
")",
":",
"free",
"=",
"ctypes",
".",
"c_uint64",
"(",
")",
"total",
"=",
"ctypes",
".",
"c_uint64",
"(",
")",
"dev_id",
"=",
"ctypes",
".",
"c_int",
"(",
"device_id",
")",
"check_call",
"(",
"_LIB"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | current_context | Returns the current context.
By default, `mx.cpu()` is used for all the computations
and it can be overridden by using `with mx.Context(x)` statement where
x can be cpu(device_id) or gpu(device_id).
Examples
-------
>>> mx.current_context()
cpu(0)
>>> with mx.Context('gpu', 1): # Cont... | python/mxnet/context.py | def current_context():
"""Returns the current context.
By default, `mx.cpu()` is used for all the computations
and it can be overridden by using `with mx.Context(x)` statement where
x can be cpu(device_id) or gpu(device_id).
Examples
-------
>>> mx.current_context()
cpu(0)
>>> with... | def current_context():
"""Returns the current context.
By default, `mx.cpu()` is used for all the computations
and it can be overridden by using `with mx.Context(x)` statement where
x can be cpu(device_id) or gpu(device_id).
Examples
-------
>>> mx.current_context()
cpu(0)
>>> with... | [
"Returns",
"the",
"current",
"context",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/context.py#L285-L309 | [
"def",
"current_context",
"(",
")",
":",
"if",
"not",
"hasattr",
"(",
"Context",
".",
"_default_ctx",
",",
"\"value\"",
")",
":",
"Context",
".",
"_default_ctx",
".",
"value",
"=",
"Context",
"(",
"'cpu'",
",",
"0",
")",
"return",
"Context",
".",
"_defau... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | AudioFolderDataset._list_audio_files | Populates synsets - a map of index to label for the data items.
Populates the data in the dataset, making tuples of (data, label) | example/gluon/audio/urban_sounds/datasets.py | def _list_audio_files(self, root, skip_rows=0):
"""Populates synsets - a map of index to label for the data items.
Populates the data in the dataset, making tuples of (data, label)
"""
self.synsets = []
self.items = []
if not self._train_csv:
# The audio files... | def _list_audio_files(self, root, skip_rows=0):
"""Populates synsets - a map of index to label for the data items.
Populates the data in the dataset, making tuples of (data, label)
"""
self.synsets = []
self.items = []
if not self._train_csv:
# The audio files... | [
"Populates",
"synsets",
"-",
"a",
"map",
"of",
"index",
"to",
"label",
"for",
"the",
"data",
"items",
".",
"Populates",
"the",
"data",
"in",
"the",
"dataset",
"making",
"tuples",
"of",
"(",
"data",
"label",
")"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/audio/urban_sounds/datasets.py#L86-L107 | [
"def",
"_list_audio_files",
"(",
"self",
",",
"root",
",",
"skip_rows",
"=",
"0",
")",
":",
"self",
".",
"synsets",
"=",
"[",
"]",
"self",
".",
"items",
"=",
"[",
"]",
"if",
"not",
"self",
".",
"_train_csv",
":",
"# The audio files are organized in folder ... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | AudioFolderDataset.transform_first | Returns a new dataset with the first element of each sample
transformed by the transformer function `fn`.
This is useful, for example, when you only want to transform data
while keeping label as is.
lazy=False is passed to transform_first for dataset so that all tramsforms could be perf... | example/gluon/audio/urban_sounds/datasets.py | def transform_first(self, fn, lazy=False):
"""Returns a new dataset with the first element of each sample
transformed by the transformer function `fn`.
This is useful, for example, when you only want to transform data
while keeping label as is.
lazy=False is passed to transform_... | def transform_first(self, fn, lazy=False):
"""Returns a new dataset with the first element of each sample
transformed by the transformer function `fn`.
This is useful, for example, when you only want to transform data
while keeping label as is.
lazy=False is passed to transform_... | [
"Returns",
"a",
"new",
"dataset",
"with",
"the",
"first",
"element",
"of",
"each",
"sample",
"transformed",
"by",
"the",
"transformer",
"function",
"fn",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/audio/urban_sounds/datasets.py#L153-L179 | [
"def",
"transform_first",
"(",
"self",
",",
"fn",
",",
"lazy",
"=",
"False",
")",
":",
"return",
"super",
"(",
"AudioFolderDataset",
",",
"self",
")",
".",
"transform_first",
"(",
"fn",
",",
"lazy",
"=",
"lazy",
")"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | config_cython | Try to configure cython and return cython configuration | python/setup.py | def config_cython():
"""Try to configure cython and return cython configuration"""
if not with_cython:
return []
# pylint: disable=unreachable
if os.name == 'nt':
print("WARNING: Cython is not supported on Windows, will compile without cython module")
return []
try:
... | def config_cython():
"""Try to configure cython and return cython configuration"""
if not with_cython:
return []
# pylint: disable=unreachable
if os.name == 'nt':
print("WARNING: Cython is not supported on Windows, will compile without cython module")
return []
try:
... | [
"Try",
"to",
"configure",
"cython",
"and",
"return",
"cython",
"configuration"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/setup.py#L62-L100 | [
"def",
"config_cython",
"(",
")",
":",
"if",
"not",
"with_cython",
":",
"return",
"[",
"]",
"# pylint: disable=unreachable",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"print",
"(",
"\"WARNING: Cython is not supported on Windows, will compile without cython module\"",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | SymbolBase._compose | Compose symbol on inputs.
This call mutates the current symbol.
Parameters
----------
args:
provide positional arguments
kwargs:
provide keyword arguments
Returns
-------
the resulting symbol | python/mxnet/_ctypes/symbol.py | def _compose(self, *args, **kwargs):
"""Compose symbol on inputs.
This call mutates the current symbol.
Parameters
----------
args:
provide positional arguments
kwargs:
provide keyword arguments
Returns
-------
the resul... | def _compose(self, *args, **kwargs):
"""Compose symbol on inputs.
This call mutates the current symbol.
Parameters
----------
args:
provide positional arguments
kwargs:
provide keyword arguments
Returns
-------
the resul... | [
"Compose",
"symbol",
"on",
"inputs",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/_ctypes/symbol.py#L48-L88 | [
"def",
"_compose",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
"=",
"kwargs",
".",
"pop",
"(",
"'name'",
",",
"None",
")",
"if",
"name",
":",
"name",
"=",
"c_str",
"(",
"name",
")",
"if",
"len",
"(",
"args",
")",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | SymbolBase._set_attr | Set the attribute of the symbol.
Parameters
----------
**kwargs
The attributes to set | python/mxnet/_ctypes/symbol.py | def _set_attr(self, **kwargs):
"""Set the attribute of the symbol.
Parameters
----------
**kwargs
The attributes to set
"""
keys = c_str_array(kwargs.keys())
vals = c_str_array([str(s) for s in kwargs.values()])
num_args = mx_uint(len(kwargs))... | def _set_attr(self, **kwargs):
"""Set the attribute of the symbol.
Parameters
----------
**kwargs
The attributes to set
"""
keys = c_str_array(kwargs.keys())
vals = c_str_array([str(s) for s in kwargs.values()])
num_args = mx_uint(len(kwargs))... | [
"Set",
"the",
"attribute",
"of",
"the",
"symbol",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/_ctypes/symbol.py#L90-L102 | [
"def",
"_set_attr",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"keys",
"=",
"c_str_array",
"(",
"kwargs",
".",
"keys",
"(",
")",
")",
"vals",
"=",
"c_str_array",
"(",
"[",
"str",
"(",
"s",
")",
"for",
"s",
"in",
"kwargs",
".",
"values",
"(",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | get_config | Configuration factory for various networks
Parameters
----------
network : str
base network name, such as vgg_reduced, inceptionv3, resnet...
data_shape : int
input data dimension
kwargs : dict
extra arguments | example/ssd/symbol/symbol_factory.py | def get_config(network, data_shape, **kwargs):
"""Configuration factory for various networks
Parameters
----------
network : str
base network name, such as vgg_reduced, inceptionv3, resnet...
data_shape : int
input data dimension
kwargs : dict
extra arguments
"""
... | def get_config(network, data_shape, **kwargs):
"""Configuration factory for various networks
Parameters
----------
network : str
base network name, such as vgg_reduced, inceptionv3, resnet...
data_shape : int
input data dimension
kwargs : dict
extra arguments
"""
... | [
"Configuration",
"factory",
"for",
"various",
"networks"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/symbol/symbol_factory.py#L22-L101 | [
"def",
"get_config",
"(",
"network",
",",
"data_shape",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"network",
"==",
"'vgg16_reduced'",
":",
"if",
"data_shape",
">=",
"448",
":",
"from_layers",
"=",
"[",
"'relu4_3'",
",",
"'relu7'",
",",
"''",
",",
"''",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | get_symbol_train | Wrapper for get symbol for train
Parameters
----------
network : str
name for the base network symbol
data_shape : int
input shape
kwargs : dict
see symbol_builder.get_symbol_train for more details | example/ssd/symbol/symbol_factory.py | def get_symbol_train(network, data_shape, **kwargs):
"""Wrapper for get symbol for train
Parameters
----------
network : str
name for the base network symbol
data_shape : int
input shape
kwargs : dict
see symbol_builder.get_symbol_train for more details
"""
if ne... | def get_symbol_train(network, data_shape, **kwargs):
"""Wrapper for get symbol for train
Parameters
----------
network : str
name for the base network symbol
data_shape : int
input shape
kwargs : dict
see symbol_builder.get_symbol_train for more details
"""
if ne... | [
"Wrapper",
"for",
"get",
"symbol",
"for",
"train"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/symbol/symbol_factory.py#L103-L120 | [
"def",
"get_symbol_train",
"(",
"network",
",",
"data_shape",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"network",
".",
"startswith",
"(",
"'legacy'",
")",
":",
"logging",
".",
"warn",
"(",
"'Using legacy model.'",
")",
"return",
"symbol_builder",
".",
"impor... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter._set_trainer | Set the trainer this parameter is associated with. | python/mxnet/gluon/parameter.py | def _set_trainer(self, trainer):
""" Set the trainer this parameter is associated with. """
# trainer cannot be replaced for sparse params
if self._stype != 'default' and self._trainer and trainer and self._trainer is not trainer:
raise RuntimeError(
"Failed to set th... | def _set_trainer(self, trainer):
""" Set the trainer this parameter is associated with. """
# trainer cannot be replaced for sparse params
if self._stype != 'default' and self._trainer and trainer and self._trainer is not trainer:
raise RuntimeError(
"Failed to set th... | [
"Set",
"the",
"trainer",
"this",
"parameter",
"is",
"associated",
"with",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L174-L182 | [
"def",
"_set_trainer",
"(",
"self",
",",
"trainer",
")",
":",
"# trainer cannot be replaced for sparse params",
"if",
"self",
".",
"_stype",
"!=",
"'default'",
"and",
"self",
".",
"_trainer",
"and",
"trainer",
"and",
"self",
".",
"_trainer",
"is",
"not",
"traine... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter._get_row_sparse | Get row_sparse data from row_sparse parameters based on row_id. | python/mxnet/gluon/parameter.py | def _get_row_sparse(self, arr_list, ctx, row_id):
""" Get row_sparse data from row_sparse parameters based on row_id. """
# get row sparse params based on row ids
if not isinstance(row_id, ndarray.NDArray):
raise TypeError("row_id must have NDArray type, but %s is given"%(type(row_id... | def _get_row_sparse(self, arr_list, ctx, row_id):
""" Get row_sparse data from row_sparse parameters based on row_id. """
# get row sparse params based on row ids
if not isinstance(row_id, ndarray.NDArray):
raise TypeError("row_id must have NDArray type, but %s is given"%(type(row_id... | [
"Get",
"row_sparse",
"data",
"from",
"row_sparse",
"parameters",
"based",
"on",
"row_id",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L216-L228 | [
"def",
"_get_row_sparse",
"(",
"self",
",",
"arr_list",
",",
"ctx",
",",
"row_id",
")",
":",
"# get row sparse params based on row ids",
"if",
"not",
"isinstance",
"(",
"row_id",
",",
"ndarray",
".",
"NDArray",
")",
":",
"raise",
"TypeError",
"(",
"\"row_id must... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter._load_init | (Re)initializes by loading from data. | python/mxnet/gluon/parameter.py | def _load_init(self, data, ctx):
"""(Re)initializes by loading from data."""
if self.shape:
for self_dim, data_dim in zip(self.shape, data.shape):
assert self_dim in (0, data_dim), \
"Failed loading Parameter '%s' from saved params: " \
... | def _load_init(self, data, ctx):
"""(Re)initializes by loading from data."""
if self.shape:
for self_dim, data_dim in zip(self.shape, data.shape):
assert self_dim in (0, data_dim), \
"Failed loading Parameter '%s' from saved params: " \
... | [
"(",
"Re",
")",
"initializes",
"by",
"loading",
"from",
"data",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L230-L264 | [
"def",
"_load_init",
"(",
"self",
",",
"data",
",",
"ctx",
")",
":",
"if",
"self",
".",
"shape",
":",
"for",
"self_dim",
",",
"data_dim",
"in",
"zip",
"(",
"self",
".",
"shape",
",",
"data",
".",
"shape",
")",
":",
"assert",
"self_dim",
"in",
"(",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter._finish_deferred_init | Finishes deferred initialization. | python/mxnet/gluon/parameter.py | def _finish_deferred_init(self):
"""Finishes deferred initialization."""
if not self._deferred_init:
return
init, ctx, default_init, data = self._deferred_init
self._deferred_init = ()
assert self.shape is not None and np.prod(self.shape) > 0, \
"Cannot in... | def _finish_deferred_init(self):
"""Finishes deferred initialization."""
if not self._deferred_init:
return
init, ctx, default_init, data = self._deferred_init
self._deferred_init = ()
assert self.shape is not None and np.prod(self.shape) > 0, \
"Cannot in... | [
"Finishes",
"deferred",
"initialization",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L266-L285 | [
"def",
"_finish_deferred_init",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_deferred_init",
":",
"return",
"init",
",",
"ctx",
",",
"default_init",
",",
"data",
"=",
"self",
".",
"_deferred_init",
"self",
".",
"_deferred_init",
"=",
"(",
")",
"asser... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter._init_impl | Sets data and grad. | python/mxnet/gluon/parameter.py | def _init_impl(self, data, ctx_list):
"""Sets data and grad."""
self._ctx_list = list(ctx_list)
self._ctx_map = [[], []]
for i, ctx in enumerate(self._ctx_list):
dev_list = self._ctx_map[ctx.device_typeid&1]
while len(dev_list) <= ctx.device_id:
de... | def _init_impl(self, data, ctx_list):
"""Sets data and grad."""
self._ctx_list = list(ctx_list)
self._ctx_map = [[], []]
for i, ctx in enumerate(self._ctx_list):
dev_list = self._ctx_map[ctx.device_typeid&1]
while len(dev_list) <= ctx.device_id:
de... | [
"Sets",
"data",
"and",
"grad",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L287-L298 | [
"def",
"_init_impl",
"(",
"self",
",",
"data",
",",
"ctx_list",
")",
":",
"self",
".",
"_ctx_list",
"=",
"list",
"(",
"ctx_list",
")",
"self",
".",
"_ctx_map",
"=",
"[",
"[",
"]",
",",
"[",
"]",
"]",
"for",
"i",
",",
"ctx",
"in",
"enumerate",
"("... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter._init_grad | Initialize grad buffers. | python/mxnet/gluon/parameter.py | def _init_grad(self):
"""Initialize grad buffers."""
if self.grad_req == 'null':
self._grad = None
return
self._grad = [ndarray.zeros(shape=i.shape, dtype=i.dtype, ctx=i.context,
stype=self._grad_stype) for i in self._data]
au... | def _init_grad(self):
"""Initialize grad buffers."""
if self.grad_req == 'null':
self._grad = None
return
self._grad = [ndarray.zeros(shape=i.shape, dtype=i.dtype, ctx=i.context,
stype=self._grad_stype) for i in self._data]
au... | [
"Initialize",
"grad",
"buffers",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L300-L310 | [
"def",
"_init_grad",
"(",
"self",
")",
":",
"if",
"self",
".",
"grad_req",
"==",
"'null'",
":",
"self",
".",
"_grad",
"=",
"None",
"return",
"self",
".",
"_grad",
"=",
"[",
"ndarray",
".",
"zeros",
"(",
"shape",
"=",
"i",
".",
"shape",
",",
"dtype"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter._reduce | Reduce data from multiple context to cpu. | python/mxnet/gluon/parameter.py | def _reduce(self):
"""Reduce data from multiple context to cpu."""
ctx = context.cpu()
if self._stype == 'default':
block = self.list_data()
data = ndarray.add_n(*(w.copyto(ctx) for w in block)) / len(block)
else:
# fetch all rows for 'row_sparse' para... | def _reduce(self):
"""Reduce data from multiple context to cpu."""
ctx = context.cpu()
if self._stype == 'default':
block = self.list_data()
data = ndarray.add_n(*(w.copyto(ctx) for w in block)) / len(block)
else:
# fetch all rows for 'row_sparse' para... | [
"Reduce",
"data",
"from",
"multiple",
"context",
"to",
"cpu",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L312-L323 | [
"def",
"_reduce",
"(",
"self",
")",
":",
"ctx",
"=",
"context",
".",
"cpu",
"(",
")",
"if",
"self",
".",
"_stype",
"==",
"'default'",
":",
"block",
"=",
"self",
".",
"list_data",
"(",
")",
"data",
"=",
"ndarray",
".",
"add_n",
"(",
"*",
"(",
"w",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter.initialize | Initializes parameter and gradient arrays. Only used for :py:class:`NDArray` API.
Parameters
----------
init : Initializer
The initializer to use. Overrides :py:meth:`Parameter.init` and default_init.
ctx : Context or list of Context, defaults to :py:meth:`context.current_co... | python/mxnet/gluon/parameter.py | def initialize(self, init=None, ctx=None, default_init=initializer.Uniform(),
force_reinit=False):
"""Initializes parameter and gradient arrays. Only used for :py:class:`NDArray` API.
Parameters
----------
init : Initializer
The initializer to use. Overrid... | def initialize(self, init=None, ctx=None, default_init=initializer.Uniform(),
force_reinit=False):
"""Initializes parameter and gradient arrays. Only used for :py:class:`NDArray` API.
Parameters
----------
init : Initializer
The initializer to use. Overrid... | [
"Initializes",
"parameter",
"and",
"gradient",
"arrays",
".",
"Only",
"used",
"for",
":",
"py",
":",
"class",
":",
"NDArray",
"API",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L325-L391 | [
"def",
"initialize",
"(",
"self",
",",
"init",
"=",
"None",
",",
"ctx",
"=",
"None",
",",
"default_init",
"=",
"initializer",
".",
"Uniform",
"(",
")",
",",
"force_reinit",
"=",
"False",
")",
":",
"if",
"self",
".",
"_data",
"is",
"not",
"None",
"and... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter.reset_ctx | Re-assign Parameter to other contexts.
Parameters
----------
ctx : Context or list of Context, default ``context.current_context()``.
Assign Parameter to given context. If ctx is a list of Context, a
copy will be made for each context. | python/mxnet/gluon/parameter.py | def reset_ctx(self, ctx):
"""Re-assign Parameter to other contexts.
Parameters
----------
ctx : Context or list of Context, default ``context.current_context()``.
Assign Parameter to given context. If ctx is a list of Context, a
copy will be made for each context... | def reset_ctx(self, ctx):
"""Re-assign Parameter to other contexts.
Parameters
----------
ctx : Context or list of Context, default ``context.current_context()``.
Assign Parameter to given context. If ctx is a list of Context, a
copy will be made for each context... | [
"Re",
"-",
"assign",
"Parameter",
"to",
"other",
"contexts",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L393-L415 | [
"def",
"reset_ctx",
"(",
"self",
",",
"ctx",
")",
":",
"if",
"ctx",
"is",
"None",
":",
"ctx",
"=",
"[",
"context",
".",
"current_context",
"(",
")",
"]",
"if",
"isinstance",
"(",
"ctx",
",",
"Context",
")",
":",
"ctx",
"=",
"[",
"ctx",
"]",
"if",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter.set_data | Sets this parameter's value on all contexts. | python/mxnet/gluon/parameter.py | def set_data(self, data):
"""Sets this parameter's value on all contexts."""
self.shape = data.shape
if self._data is None:
assert self._deferred_init, \
"Parameter '%s' has not been initialized"%self.name
self._deferred_init = self._deferred_init[:3] + (... | def set_data(self, data):
"""Sets this parameter's value on all contexts."""
self.shape = data.shape
if self._data is None:
assert self._deferred_init, \
"Parameter '%s' has not been initialized"%self.name
self._deferred_init = self._deferred_init[:3] + (... | [
"Sets",
"this",
"parameter",
"s",
"value",
"on",
"all",
"contexts",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L418-L434 | [
"def",
"set_data",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"shape",
"=",
"data",
".",
"shape",
"if",
"self",
".",
"_data",
"is",
"None",
":",
"assert",
"self",
".",
"_deferred_init",
",",
"\"Parameter '%s' has not been initialized\"",
"%",
"self",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter.row_sparse_data | Returns a copy of the 'row_sparse' parameter on the same context as row_id's.
The copy only retains rows whose ids occur in provided row ids.
The parameter must have been initialized on this context before.
Parameters
----------
row_id: NDArray
Row ids to retain for ... | python/mxnet/gluon/parameter.py | def row_sparse_data(self, row_id):
"""Returns a copy of the 'row_sparse' parameter on the same context as row_id's.
The copy only retains rows whose ids occur in provided row ids.
The parameter must have been initialized on this context before.
Parameters
----------
row_... | def row_sparse_data(self, row_id):
"""Returns a copy of the 'row_sparse' parameter on the same context as row_id's.
The copy only retains rows whose ids occur in provided row ids.
The parameter must have been initialized on this context before.
Parameters
----------
row_... | [
"Returns",
"a",
"copy",
"of",
"the",
"row_sparse",
"parameter",
"on",
"the",
"same",
"context",
"as",
"row_id",
"s",
".",
"The",
"copy",
"only",
"retains",
"rows",
"whose",
"ids",
"occur",
"in",
"provided",
"row",
"ids",
".",
"The",
"parameter",
"must",
... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L436-L454 | [
"def",
"row_sparse_data",
"(",
"self",
",",
"row_id",
")",
":",
"if",
"self",
".",
"_stype",
"!=",
"'row_sparse'",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot return a copy of Parameter %s via row_sparse_data() \"",
"\"because its storage type is %s. Please use data() instead.... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter.list_row_sparse_data | Returns copies of the 'row_sparse' parameter on all contexts, in the same order
as creation. The copy only retains rows whose ids occur in provided row ids.
The parameter must have been initialized before.
Parameters
----------
row_id: NDArray
Row ids to retain for t... | python/mxnet/gluon/parameter.py | def list_row_sparse_data(self, row_id):
"""Returns copies of the 'row_sparse' parameter on all contexts, in the same order
as creation. The copy only retains rows whose ids occur in provided row ids.
The parameter must have been initialized before.
Parameters
----------
... | def list_row_sparse_data(self, row_id):
"""Returns copies of the 'row_sparse' parameter on all contexts, in the same order
as creation. The copy only retains rows whose ids occur in provided row ids.
The parameter must have been initialized before.
Parameters
----------
... | [
"Returns",
"copies",
"of",
"the",
"row_sparse",
"parameter",
"on",
"all",
"contexts",
"in",
"the",
"same",
"order",
"as",
"creation",
".",
"The",
"copy",
"only",
"retains",
"rows",
"whose",
"ids",
"occur",
"in",
"provided",
"row",
"ids",
".",
"The",
"param... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L456-L474 | [
"def",
"list_row_sparse_data",
"(",
"self",
",",
"row_id",
")",
":",
"if",
"self",
".",
"_stype",
"!=",
"'row_sparse'",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot return copies of Parameter '%s' on all contexts via \"",
"\"list_row_sparse_data() because its storage type is %s... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter.data | Returns a copy of this parameter on one context. Must have been
initialized on this context before. For sparse parameters, use
:py:meth:`Parameter.row_sparse_data` instead.
Parameters
----------
ctx : Context
Desired context.
Returns
-------
... | python/mxnet/gluon/parameter.py | def data(self, ctx=None):
"""Returns a copy of this parameter on one context. Must have been
initialized on this context before. For sparse parameters, use
:py:meth:`Parameter.row_sparse_data` instead.
Parameters
----------
ctx : Context
Desired context.
... | def data(self, ctx=None):
"""Returns a copy of this parameter on one context. Must have been
initialized on this context before. For sparse parameters, use
:py:meth:`Parameter.row_sparse_data` instead.
Parameters
----------
ctx : Context
Desired context.
... | [
"Returns",
"a",
"copy",
"of",
"this",
"parameter",
"on",
"one",
"context",
".",
"Must",
"have",
"been",
"initialized",
"on",
"this",
"context",
"before",
".",
"For",
"sparse",
"parameters",
"use",
":",
"py",
":",
"meth",
":",
"Parameter",
".",
"row_sparse_... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L476-L494 | [
"def",
"data",
"(",
"self",
",",
"ctx",
"=",
"None",
")",
":",
"if",
"self",
".",
"_stype",
"!=",
"'default'",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot return a copy of Parameter '%s' on ctx %s via data() \"",
"\"because its storage type is %s. Please use row_sparse_dat... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter.list_data | Returns copies of this parameter on all contexts, in the same order
as creation. For sparse parameters, use :py:meth:`Parameter.list_row_sparse_data`
instead.
Returns
-------
list of NDArrays | python/mxnet/gluon/parameter.py | def list_data(self):
"""Returns copies of this parameter on all contexts, in the same order
as creation. For sparse parameters, use :py:meth:`Parameter.list_row_sparse_data`
instead.
Returns
-------
list of NDArrays
"""
if self._stype != 'default':
... | def list_data(self):
"""Returns copies of this parameter on all contexts, in the same order
as creation. For sparse parameters, use :py:meth:`Parameter.list_row_sparse_data`
instead.
Returns
-------
list of NDArrays
"""
if self._stype != 'default':
... | [
"Returns",
"copies",
"of",
"this",
"parameter",
"on",
"all",
"contexts",
"in",
"the",
"same",
"order",
"as",
"creation",
".",
"For",
"sparse",
"parameters",
"use",
":",
"py",
":",
"meth",
":",
"Parameter",
".",
"list_row_sparse_data",
"instead",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L496-L509 | [
"def",
"list_data",
"(",
"self",
")",
":",
"if",
"self",
".",
"_stype",
"!=",
"'default'",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot return copies of Parameter '%s' on all contexts via \"",
"\"list_data() because its storage type is %s. Please use \"",
"\"row_sparse_data() ins... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter.grad | Returns a gradient buffer for this parameter on one context.
Parameters
----------
ctx : Context
Desired context. | python/mxnet/gluon/parameter.py | def grad(self, ctx=None):
"""Returns a gradient buffer for this parameter on one context.
Parameters
----------
ctx : Context
Desired context.
"""
if self._data is not None and self._grad is None:
raise RuntimeError(
"Cannot get gr... | def grad(self, ctx=None):
"""Returns a gradient buffer for this parameter on one context.
Parameters
----------
ctx : Context
Desired context.
"""
if self._data is not None and self._grad is None:
raise RuntimeError(
"Cannot get gr... | [
"Returns",
"a",
"gradient",
"buffer",
"for",
"this",
"parameter",
"on",
"one",
"context",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L511-L523 | [
"def",
"grad",
"(",
"self",
",",
"ctx",
"=",
"None",
")",
":",
"if",
"self",
".",
"_data",
"is",
"not",
"None",
"and",
"self",
".",
"_grad",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot get gradient array for Parameter '%s' \"",
"\"because grad_r... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter.list_grad | Returns gradient buffers on all contexts, in the same order
as :py:meth:`values`. | python/mxnet/gluon/parameter.py | def list_grad(self):
"""Returns gradient buffers on all contexts, in the same order
as :py:meth:`values`."""
if self._data is not None and self._grad is None:
raise RuntimeError(
"Cannot get gradient array for Parameter '%s' " \
"because grad_req='null... | def list_grad(self):
"""Returns gradient buffers on all contexts, in the same order
as :py:meth:`values`."""
if self._data is not None and self._grad is None:
raise RuntimeError(
"Cannot get gradient array for Parameter '%s' " \
"because grad_req='null... | [
"Returns",
"gradient",
"buffers",
"on",
"all",
"contexts",
"in",
"the",
"same",
"order",
"as",
":",
"py",
":",
"meth",
":",
"values",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L525-L532 | [
"def",
"list_grad",
"(",
"self",
")",
":",
"if",
"self",
".",
"_data",
"is",
"not",
"None",
"and",
"self",
".",
"_grad",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Cannot get gradient array for Parameter '%s' \"",
"\"because grad_req='null'\"",
"%",
"(",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter.list_ctx | Returns a list of contexts this parameter is initialized on. | python/mxnet/gluon/parameter.py | def list_ctx(self):
"""Returns a list of contexts this parameter is initialized on."""
if self._data is None:
if self._deferred_init:
return self._deferred_init[1]
raise RuntimeError("Parameter '%s' has not been initialized"%self.name)
return self._ctx_lis... | def list_ctx(self):
"""Returns a list of contexts this parameter is initialized on."""
if self._data is None:
if self._deferred_init:
return self._deferred_init[1]
raise RuntimeError("Parameter '%s' has not been initialized"%self.name)
return self._ctx_lis... | [
"Returns",
"a",
"list",
"of",
"contexts",
"this",
"parameter",
"is",
"initialized",
"on",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L534-L540 | [
"def",
"list_ctx",
"(",
"self",
")",
":",
"if",
"self",
".",
"_data",
"is",
"None",
":",
"if",
"self",
".",
"_deferred_init",
":",
"return",
"self",
".",
"_deferred_init",
"[",
"1",
"]",
"raise",
"RuntimeError",
"(",
"\"Parameter '%s' has not been initialized\... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter.zero_grad | Sets gradient buffer on all contexts to 0. No action is taken if
parameter is uninitialized or doesn't require gradient. | python/mxnet/gluon/parameter.py | def zero_grad(self):
"""Sets gradient buffer on all contexts to 0. No action is taken if
parameter is uninitialized or doesn't require gradient."""
if self._grad is None:
return
for i in self._grad:
ndarray.zeros_like(i, out=i) | def zero_grad(self):
"""Sets gradient buffer on all contexts to 0. No action is taken if
parameter is uninitialized or doesn't require gradient."""
if self._grad is None:
return
for i in self._grad:
ndarray.zeros_like(i, out=i) | [
"Sets",
"gradient",
"buffer",
"on",
"all",
"contexts",
"to",
"0",
".",
"No",
"action",
"is",
"taken",
"if",
"parameter",
"is",
"uninitialized",
"or",
"doesn",
"t",
"require",
"gradient",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L542-L548 | [
"def",
"zero_grad",
"(",
"self",
")",
":",
"if",
"self",
".",
"_grad",
"is",
"None",
":",
"return",
"for",
"i",
"in",
"self",
".",
"_grad",
":",
"ndarray",
".",
"zeros_like",
"(",
"i",
",",
"out",
"=",
"i",
")"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter.var | Returns a symbol representing this parameter. | python/mxnet/gluon/parameter.py | def var(self):
"""Returns a symbol representing this parameter."""
if self._var is None:
self._var = symbol.var(self.name, shape=self.shape, dtype=self.dtype,
lr_mult=self.lr_mult, wd_mult=self.wd_mult,
init=self.init, sty... | def var(self):
"""Returns a symbol representing this parameter."""
if self._var is None:
self._var = symbol.var(self.name, shape=self.shape, dtype=self.dtype,
lr_mult=self.lr_mult, wd_mult=self.wd_mult,
init=self.init, sty... | [
"Returns",
"a",
"symbol",
"representing",
"this",
"parameter",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L550-L556 | [
"def",
"var",
"(",
"self",
")",
":",
"if",
"self",
".",
"_var",
"is",
"None",
":",
"self",
".",
"_var",
"=",
"symbol",
".",
"var",
"(",
"self",
".",
"name",
",",
"shape",
"=",
"self",
".",
"shape",
",",
"dtype",
"=",
"self",
".",
"dtype",
",",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Parameter.cast | Cast data and gradient of this Parameter to a new data type.
Parameters
----------
dtype : str or numpy.dtype
The new data type. | python/mxnet/gluon/parameter.py | def cast(self, dtype):
"""Cast data and gradient of this Parameter to a new data type.
Parameters
----------
dtype : str or numpy.dtype
The new data type.
"""
self.dtype = dtype
if self._data is None:
return
with autograd.pause():
... | def cast(self, dtype):
"""Cast data and gradient of this Parameter to a new data type.
Parameters
----------
dtype : str or numpy.dtype
The new data type.
"""
self.dtype = dtype
if self._data is None:
return
with autograd.pause():
... | [
"Cast",
"data",
"and",
"gradient",
"of",
"this",
"Parameter",
"to",
"a",
"new",
"data",
"type",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L558-L574 | [
"def",
"cast",
"(",
"self",
",",
"dtype",
")",
":",
"self",
".",
"dtype",
"=",
"dtype",
"if",
"self",
".",
"_data",
"is",
"None",
":",
"return",
"with",
"autograd",
".",
"pause",
"(",
")",
":",
"self",
".",
"_data",
"=",
"[",
"i",
".",
"astype",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | ParameterDict.get | Retrieves a :py:class:`Parameter` with name ``self.prefix+name``. If not found,
:py:func:`get` will first try to retrieve it from "shared" dict. If still not
found, :py:func:`get` will create a new :py:class:`Parameter` with key-word arguments and
insert it to self.
Parameters
-... | python/mxnet/gluon/parameter.py | def get(self, name, **kwargs):
"""Retrieves a :py:class:`Parameter` with name ``self.prefix+name``. If not found,
:py:func:`get` will first try to retrieve it from "shared" dict. If still not
found, :py:func:`get` will create a new :py:class:`Parameter` with key-word arguments and
insert... | def get(self, name, **kwargs):
"""Retrieves a :py:class:`Parameter` with name ``self.prefix+name``. If not found,
:py:func:`get` will first try to retrieve it from "shared" dict. If still not
found, :py:func:`get` will create a new :py:class:`Parameter` with key-word arguments and
insert... | [
"Retrieves",
"a",
":",
"py",
":",
"class",
":",
"Parameter",
"with",
"name",
"self",
".",
"prefix",
"+",
"name",
".",
"If",
"not",
"found",
":",
"py",
":",
"func",
":",
"get",
"will",
"first",
"try",
"to",
"retrieve",
"it",
"from",
"shared",
"dict",
... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L685-L740 | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
"=",
"self",
".",
"prefix",
"+",
"name",
"param",
"=",
"self",
".",
"_get_impl",
"(",
"name",
")",
"if",
"param",
"is",
"None",
":",
"# pylint: disable=too-many-nested-b... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | ParameterDict.get_constant | Retrieves a :py:class:`.Constant` with name ``self.prefix+name``. If not found,
:py:func:`get` will first try to retrieve it from "shared" dict. If still not
found, :py:func:`get` will create a new :py:class:`.Constant` with key-word
arguments and insert it to self.
Parameters
-... | python/mxnet/gluon/parameter.py | def get_constant(self, name, value=None):
"""Retrieves a :py:class:`.Constant` with name ``self.prefix+name``. If not found,
:py:func:`get` will first try to retrieve it from "shared" dict. If still not
found, :py:func:`get` will create a new :py:class:`.Constant` with key-word
arguments... | def get_constant(self, name, value=None):
"""Retrieves a :py:class:`.Constant` with name ``self.prefix+name``. If not found,
:py:func:`get` will first try to retrieve it from "shared" dict. If still not
found, :py:func:`get` will create a new :py:class:`.Constant` with key-word
arguments... | [
"Retrieves",
"a",
":",
"py",
":",
"class",
":",
".",
"Constant",
"with",
"name",
"self",
".",
"prefix",
"+",
"name",
".",
"If",
"not",
"found",
":",
"py",
":",
"func",
":",
"get",
"will",
"first",
"try",
"to",
"retrieve",
"it",
"from",
"shared",
"d... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L742-L780 | [
"def",
"get_constant",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
")",
":",
"name",
"=",
"self",
".",
"prefix",
"+",
"name",
"param",
"=",
"self",
".",
"_get_impl",
"(",
"name",
")",
"if",
"param",
"is",
"None",
":",
"if",
"value",
"is",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | ParameterDict.update | Copies all Parameters in ``other`` to self. | python/mxnet/gluon/parameter.py | def update(self, other):
"""Copies all Parameters in ``other`` to self."""
for k, v in other.items():
if k in self._params:
assert self._params[k] is v, \
"Cannot update self with other because they have different " \
"Parameters with t... | def update(self, other):
"""Copies all Parameters in ``other`` to self."""
for k, v in other.items():
if k in self._params:
assert self._params[k] is v, \
"Cannot update self with other because they have different " \
"Parameters with t... | [
"Copies",
"all",
"Parameters",
"in",
"other",
"to",
"self",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L782-L791 | [
"def",
"update",
"(",
"self",
",",
"other",
")",
":",
"for",
"k",
",",
"v",
"in",
"other",
".",
"items",
"(",
")",
":",
"if",
"k",
"in",
"self",
".",
"_params",
":",
"assert",
"self",
".",
"_params",
"[",
"k",
"]",
"is",
"v",
",",
"\"Cannot upd... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | ParameterDict.initialize | Initializes all Parameters managed by this dictionary to be used for :py:class:`NDArray`
API. It has no effect when using :py:class:`Symbol` API.
Parameters
----------
init : Initializer
Global default Initializer to be used when :py:meth:`Parameter.init` is ``None``.
... | python/mxnet/gluon/parameter.py | def initialize(self, init=initializer.Uniform(), ctx=None, verbose=False,
force_reinit=False):
"""Initializes all Parameters managed by this dictionary to be used for :py:class:`NDArray`
API. It has no effect when using :py:class:`Symbol` API.
Parameters
----------
... | def initialize(self, init=initializer.Uniform(), ctx=None, verbose=False,
force_reinit=False):
"""Initializes all Parameters managed by this dictionary to be used for :py:class:`NDArray`
API. It has no effect when using :py:class:`Symbol` API.
Parameters
----------
... | [
"Initializes",
"all",
"Parameters",
"managed",
"by",
"this",
"dictionary",
"to",
"be",
"used",
"for",
":",
"py",
":",
"class",
":",
"NDArray",
"API",
".",
"It",
"has",
"no",
"effect",
"when",
"using",
":",
"py",
":",
"class",
":",
"Symbol",
"API",
"."
... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L793-L813 | [
"def",
"initialize",
"(",
"self",
",",
"init",
"=",
"initializer",
".",
"Uniform",
"(",
")",
",",
"ctx",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"force_reinit",
"=",
"False",
")",
":",
"if",
"verbose",
":",
"init",
".",
"set_verbosity",
"(",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | ParameterDict.setattr | Set an attribute to a new value for all Parameters.
For example, set grad_req to null if you don't need gradient w.r.t a
model's Parameters::
model.collect_params().setattr('grad_req', 'null')
or change the learning rate multiplier::
model.collect_params().setattr('lr... | python/mxnet/gluon/parameter.py | def setattr(self, name, value):
"""Set an attribute to a new value for all Parameters.
For example, set grad_req to null if you don't need gradient w.r.t a
model's Parameters::
model.collect_params().setattr('grad_req', 'null')
or change the learning rate multiplier::
... | def setattr(self, name, value):
"""Set an attribute to a new value for all Parameters.
For example, set grad_req to null if you don't need gradient w.r.t a
model's Parameters::
model.collect_params().setattr('grad_req', 'null')
or change the learning rate multiplier::
... | [
"Set",
"an",
"attribute",
"to",
"a",
"new",
"value",
"for",
"all",
"Parameters",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L832-L852 | [
"def",
"setattr",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"for",
"i",
"in",
"self",
".",
"values",
"(",
")",
":",
"setattr",
"(",
"i",
",",
"name",
",",
"value",
")"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | ParameterDict.save | Save parameters to file.
Parameters
----------
filename : str
Path to parameter file.
strip_prefix : str, default ''
Strip prefix from parameter names before saving. | python/mxnet/gluon/parameter.py | def save(self, filename, strip_prefix=''):
"""Save parameters to file.
Parameters
----------
filename : str
Path to parameter file.
strip_prefix : str, default ''
Strip prefix from parameter names before saving.
"""
arg_dict = {}
f... | def save(self, filename, strip_prefix=''):
"""Save parameters to file.
Parameters
----------
filename : str
Path to parameter file.
strip_prefix : str, default ''
Strip prefix from parameter names before saving.
"""
arg_dict = {}
f... | [
"Save",
"parameters",
"to",
"file",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L854-L877 | [
"def",
"save",
"(",
"self",
",",
"filename",
",",
"strip_prefix",
"=",
"''",
")",
":",
"arg_dict",
"=",
"{",
"}",
"for",
"param",
"in",
"self",
".",
"values",
"(",
")",
":",
"weight",
"=",
"param",
".",
"_reduce",
"(",
")",
"if",
"not",
"param",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | ParameterDict.load | Load parameters from file.
Parameters
----------
filename : str
Path to parameter file.
ctx : Context or list of Context
Context(s) initialize loaded parameters on.
allow_missing : bool, default False
Whether to silently skip loading parameter... | python/mxnet/gluon/parameter.py | def load(self, filename, ctx=None, allow_missing=False,
ignore_extra=False, restore_prefix=''):
"""Load parameters from file.
Parameters
----------
filename : str
Path to parameter file.
ctx : Context or list of Context
Context(s) initialize ... | def load(self, filename, ctx=None, allow_missing=False,
ignore_extra=False, restore_prefix=''):
"""Load parameters from file.
Parameters
----------
filename : str
Path to parameter file.
ctx : Context or list of Context
Context(s) initialize ... | [
"Load",
"parameters",
"from",
"file",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L879-L920 | [
"def",
"load",
"(",
"self",
",",
"filename",
",",
"ctx",
"=",
"None",
",",
"allow_missing",
"=",
"False",
",",
"ignore_extra",
"=",
"False",
",",
"restore_prefix",
"=",
"''",
")",
":",
"if",
"restore_prefix",
":",
"for",
"name",
"in",
"self",
".",
"key... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _make_torch_function | Create a Torch function from the FunctionHandle. | python/mxnet/torch.py | def _make_torch_function(handle):
"""Create a Torch function from the FunctionHandle."""
# Get the property of function
n_used_vars = mx_uint()
n_scalars = mx_uint()
n_mutate_vars = mx_uint()
type_mask = ctypes.c_int()
check_call(_LIB.MXFuncDescribe(
handle,
ctypes.byref(n_us... | def _make_torch_function(handle):
"""Create a Torch function from the FunctionHandle."""
# Get the property of function
n_used_vars = mx_uint()
n_scalars = mx_uint()
n_mutate_vars = mx_uint()
type_mask = ctypes.c_int()
check_call(_LIB.MXFuncDescribe(
handle,
ctypes.byref(n_us... | [
"Create",
"a",
"Torch",
"function",
"from",
"the",
"FunctionHandle",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/torch.py#L37-L163 | [
"def",
"_make_torch_function",
"(",
"handle",
")",
":",
"# Get the property of function",
"n_used_vars",
"=",
"mx_uint",
"(",
")",
"n_scalars",
"=",
"mx_uint",
"(",
")",
"n_mutate_vars",
"=",
"mx_uint",
"(",
")",
"type_mask",
"=",
"ctypes",
".",
"c_int",
"(",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _init_torch_module | List and add all the torch backed ndarray functions to current module. | python/mxnet/torch.py | def _init_torch_module():
"""List and add all the torch backed ndarray functions to current module."""
plist = ctypes.POINTER(FunctionHandle)()
size = ctypes.c_uint()
check_call(_LIB.MXListFunctions(ctypes.byref(size),
ctypes.byref(plist)))
module_obj = sys.modul... | def _init_torch_module():
"""List and add all the torch backed ndarray functions to current module."""
plist = ctypes.POINTER(FunctionHandle)()
size = ctypes.c_uint()
check_call(_LIB.MXListFunctions(ctypes.byref(size),
ctypes.byref(plist)))
module_obj = sys.modul... | [
"List",
"and",
"add",
"all",
"the",
"torch",
"backed",
"ndarray",
"functions",
"to",
"current",
"module",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/torch.py#L167-L180 | [
"def",
"_init_torch_module",
"(",
")",
":",
"plist",
"=",
"ctypes",
".",
"POINTER",
"(",
"FunctionHandle",
")",
"(",
")",
"size",
"=",
"ctypes",
".",
"c_uint",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXListFunctions",
"(",
"ctypes",
".",
"byref",
"(",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | inception_v3 | r"""Inception v3 model from
`"Rethinking the Inception Architecture for Computer Vision"
<http://arxiv.org/abs/1512.00567>`_ paper.
Parameters
----------
pretrained : bool, default False
Whether to load the pretrained weights for model.
ctx : Context, default CPU
The context in ... | python/mxnet/gluon/model_zoo/vision/inception.py | def inception_v3(pretrained=False, ctx=cpu(),
root=os.path.join(base.data_dir(), 'models'), **kwargs):
r"""Inception v3 model from
`"Rethinking the Inception Architecture for Computer Vision"
<http://arxiv.org/abs/1512.00567>`_ paper.
Parameters
----------
pretrained : bool, de... | def inception_v3(pretrained=False, ctx=cpu(),
root=os.path.join(base.data_dir(), 'models'), **kwargs):
r"""Inception v3 model from
`"Rethinking the Inception Architecture for Computer Vision"
<http://arxiv.org/abs/1512.00567>`_ paper.
Parameters
----------
pretrained : bool, de... | [
"r",
"Inception",
"v3",
"model",
"from",
"Rethinking",
"the",
"Inception",
"Architecture",
"for",
"Computer",
"Vision",
"<http",
":",
"//",
"arxiv",
".",
"org",
"/",
"abs",
"/",
"1512",
".",
"00567",
">",
"_",
"paper",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/model_zoo/vision/inception.py#L202-L221 | [
"def",
"inception_v3",
"(",
"pretrained",
"=",
"False",
",",
"ctx",
"=",
"cpu",
"(",
")",
",",
"root",
"=",
"os",
".",
"path",
".",
"join",
"(",
"base",
".",
"data_dir",
"(",
")",
",",
"'models'",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"net",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | pack | Pack a string into MXImageRecord.
Parameters
----------
header : IRHeader
Header of the image record.
``header.label`` can be a number or an array. See more detail in ``IRHeader``.
s : str
Raw image string to be packed.
Returns
-------
s : str
The packed str... | python/mxnet/recordio.py | def pack(header, s):
"""Pack a string into MXImageRecord.
Parameters
----------
header : IRHeader
Header of the image record.
``header.label`` can be a number or an array. See more detail in ``IRHeader``.
s : str
Raw image string to be packed.
Returns
-------
s ... | def pack(header, s):
"""Pack a string into MXImageRecord.
Parameters
----------
header : IRHeader
Header of the image record.
``header.label`` can be a number or an array. See more detail in ``IRHeader``.
s : str
Raw image string to be packed.
Returns
-------
s ... | [
"Pack",
"a",
"string",
"into",
"MXImageRecord",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L358-L391 | [
"def",
"pack",
"(",
"header",
",",
"s",
")",
":",
"header",
"=",
"IRHeader",
"(",
"*",
"header",
")",
"if",
"isinstance",
"(",
"header",
".",
"label",
",",
"numbers",
".",
"Number",
")",
":",
"header",
"=",
"header",
".",
"_replace",
"(",
"flag",
"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | unpack | Unpack a MXImageRecord to string.
Parameters
----------
s : str
String buffer from ``MXRecordIO.read``.
Returns
-------
header : IRHeader
Header of the image record.
s : str
Unpacked string.
Examples
--------
>>> record = mx.recordio.MXRecordIO('test.re... | python/mxnet/recordio.py | def unpack(s):
"""Unpack a MXImageRecord to string.
Parameters
----------
s : str
String buffer from ``MXRecordIO.read``.
Returns
-------
header : IRHeader
Header of the image record.
s : str
Unpacked string.
Examples
--------
>>> record = mx.record... | def unpack(s):
"""Unpack a MXImageRecord to string.
Parameters
----------
s : str
String buffer from ``MXRecordIO.read``.
Returns
-------
header : IRHeader
Header of the image record.
s : str
Unpacked string.
Examples
--------
>>> record = mx.record... | [
"Unpack",
"a",
"MXImageRecord",
"to",
"string",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L393-L421 | [
"def",
"unpack",
"(",
"s",
")",
":",
"header",
"=",
"IRHeader",
"(",
"*",
"struct",
".",
"unpack",
"(",
"_IR_FORMAT",
",",
"s",
"[",
":",
"_IR_SIZE",
"]",
")",
")",
"s",
"=",
"s",
"[",
"_IR_SIZE",
":",
"]",
"if",
"header",
".",
"flag",
">",
"0"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | unpack_img | Unpack a MXImageRecord to image.
Parameters
----------
s : str
String buffer from ``MXRecordIO.read``.
iscolor : int
Image format option for ``cv2.imdecode``.
Returns
-------
header : IRHeader
Header of the image record.
img : numpy.ndarray
Unpacked imag... | python/mxnet/recordio.py | def unpack_img(s, iscolor=-1):
"""Unpack a MXImageRecord to image.
Parameters
----------
s : str
String buffer from ``MXRecordIO.read``.
iscolor : int
Image format option for ``cv2.imdecode``.
Returns
-------
header : IRHeader
Header of the image record.
img... | def unpack_img(s, iscolor=-1):
"""Unpack a MXImageRecord to image.
Parameters
----------
s : str
String buffer from ``MXRecordIO.read``.
iscolor : int
Image format option for ``cv2.imdecode``.
Returns
-------
header : IRHeader
Header of the image record.
img... | [
"Unpack",
"a",
"MXImageRecord",
"to",
"image",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L423-L464 | [
"def",
"unpack_img",
"(",
"s",
",",
"iscolor",
"=",
"-",
"1",
")",
":",
"header",
",",
"s",
"=",
"unpack",
"(",
"s",
")",
"img",
"=",
"np",
".",
"frombuffer",
"(",
"s",
",",
"dtype",
"=",
"np",
".",
"uint8",
")",
"assert",
"cv2",
"is",
"not",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | pack_img | Pack an image into ``MXImageRecord``.
Parameters
----------
header : IRHeader
Header of the image record.
``header.label`` can be a number or an array. See more detail in ``IRHeader``.
img : numpy.ndarray
Image to be packed.
quality : int
Quality for JPEG encoding in... | python/mxnet/recordio.py | def pack_img(header, img, quality=95, img_fmt='.jpg'):
"""Pack an image into ``MXImageRecord``.
Parameters
----------
header : IRHeader
Header of the image record.
``header.label`` can be a number or an array. See more detail in ``IRHeader``.
img : numpy.ndarray
Image to be ... | def pack_img(header, img, quality=95, img_fmt='.jpg'):
"""Pack an image into ``MXImageRecord``.
Parameters
----------
header : IRHeader
Header of the image record.
``header.label`` can be a number or an array. See more detail in ``IRHeader``.
img : numpy.ndarray
Image to be ... | [
"Pack",
"an",
"image",
"into",
"MXImageRecord",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L466-L505 | [
"def",
"pack_img",
"(",
"header",
",",
"img",
",",
"quality",
"=",
"95",
",",
"img_fmt",
"=",
"'.jpg'",
")",
":",
"assert",
"cv2",
"is",
"not",
"None",
"jpg_formats",
"=",
"[",
"'.JPG'",
",",
"'.JPEG'",
"]",
"png_formats",
"=",
"[",
"'.PNG'",
"]",
"e... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | MXRecordIO.open | Opens the record file. | python/mxnet/recordio.py | def open(self):
"""Opens the record file."""
if self.flag == "w":
check_call(_LIB.MXRecordIOWriterCreate(self.uri, ctypes.byref(self.handle)))
self.writable = True
elif self.flag == "r":
check_call(_LIB.MXRecordIOReaderCreate(self.uri, ctypes.byref(self.handle... | def open(self):
"""Opens the record file."""
if self.flag == "w":
check_call(_LIB.MXRecordIOWriterCreate(self.uri, ctypes.byref(self.handle)))
self.writable = True
elif self.flag == "r":
check_call(_LIB.MXRecordIOReaderCreate(self.uri, ctypes.byref(self.handle... | [
"Opens",
"the",
"record",
"file",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L73-L84 | [
"def",
"open",
"(",
"self",
")",
":",
"if",
"self",
".",
"flag",
"==",
"\"w\"",
":",
"check_call",
"(",
"_LIB",
".",
"MXRecordIOWriterCreate",
"(",
"self",
".",
"uri",
",",
"ctypes",
".",
"byref",
"(",
"self",
".",
"handle",
")",
")",
")",
"self",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | MXRecordIO._check_pid | Check process id to ensure integrity, reset if in new process. | python/mxnet/recordio.py | def _check_pid(self, allow_reset=False):
"""Check process id to ensure integrity, reset if in new process."""
if not self.pid == current_process().pid:
if allow_reset:
self.reset()
else:
raise RuntimeError("Forbidden operation in multiple processes... | def _check_pid(self, allow_reset=False):
"""Check process id to ensure integrity, reset if in new process."""
if not self.pid == current_process().pid:
if allow_reset:
self.reset()
else:
raise RuntimeError("Forbidden operation in multiple processes... | [
"Check",
"process",
"id",
"to",
"ensure",
"integrity",
"reset",
"if",
"in",
"new",
"process",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L115-L121 | [
"def",
"_check_pid",
"(",
"self",
",",
"allow_reset",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"pid",
"==",
"current_process",
"(",
")",
".",
"pid",
":",
"if",
"allow_reset",
":",
"self",
".",
"reset",
"(",
")",
"else",
":",
"raise",
"Runtim... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | MXRecordIO.close | Closes the record file. | python/mxnet/recordio.py | def close(self):
"""Closes the record file."""
if not self.is_open:
return
if self.writable:
check_call(_LIB.MXRecordIOWriterFree(self.handle))
else:
check_call(_LIB.MXRecordIOReaderFree(self.handle))
self.is_open = False
self.pid = Non... | def close(self):
"""Closes the record file."""
if not self.is_open:
return
if self.writable:
check_call(_LIB.MXRecordIOWriterFree(self.handle))
else:
check_call(_LIB.MXRecordIOReaderFree(self.handle))
self.is_open = False
self.pid = Non... | [
"Closes",
"the",
"record",
"file",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L123-L132 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_open",
":",
"return",
"if",
"self",
".",
"writable",
":",
"check_call",
"(",
"_LIB",
".",
"MXRecordIOWriterFree",
"(",
"self",
".",
"handle",
")",
")",
"else",
":",
"check_call",
"(",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | MXRecordIO.write | Inserts a string buffer as a record.
Examples
---------
>>> record = mx.recordio.MXRecordIO('tmp.rec', 'w')
>>> for i in range(5):
... record.write('record_%d'%i)
>>> record.close()
Parameters
----------
buf : string (python2), bytes (python3)... | python/mxnet/recordio.py | def write(self, buf):
"""Inserts a string buffer as a record.
Examples
---------
>>> record = mx.recordio.MXRecordIO('tmp.rec', 'w')
>>> for i in range(5):
... record.write('record_%d'%i)
>>> record.close()
Parameters
----------
buf : ... | def write(self, buf):
"""Inserts a string buffer as a record.
Examples
---------
>>> record = mx.recordio.MXRecordIO('tmp.rec', 'w')
>>> for i in range(5):
... record.write('record_%d'%i)
>>> record.close()
Parameters
----------
buf : ... | [
"Inserts",
"a",
"string",
"buffer",
"as",
"a",
"record",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L155-L174 | [
"def",
"write",
"(",
"self",
",",
"buf",
")",
":",
"assert",
"self",
".",
"writable",
"self",
".",
"_check_pid",
"(",
"allow_reset",
"=",
"False",
")",
"check_call",
"(",
"_LIB",
".",
"MXRecordIOWriterWriteRecord",
"(",
"self",
".",
"handle",
",",
"ctypes"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | MXRecordIO.read | Returns record as a string.
Examples
---------
>>> record = mx.recordio.MXRecordIO('tmp.rec', 'r')
>>> for i in range(5):
... item = record.read()
... print(item)
record_0
record_1
record_2
record_3
record_4
>>> recor... | python/mxnet/recordio.py | def read(self):
"""Returns record as a string.
Examples
---------
>>> record = mx.recordio.MXRecordIO('tmp.rec', 'r')
>>> for i in range(5):
... item = record.read()
... print(item)
record_0
record_1
record_2
record_3
... | def read(self):
"""Returns record as a string.
Examples
---------
>>> record = mx.recordio.MXRecordIO('tmp.rec', 'r')
>>> for i in range(5):
... item = record.read()
... print(item)
record_0
record_1
record_2
record_3
... | [
"Returns",
"record",
"as",
"a",
"string",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L176-L210 | [
"def",
"read",
"(",
"self",
")",
":",
"assert",
"not",
"self",
".",
"writable",
"# trying to implicitly read from multiple processes is forbidden,",
"# there's no elegant way to handle unless lock is introduced",
"self",
".",
"_check_pid",
"(",
"allow_reset",
"=",
"False",
")... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | MXIndexedRecordIO.close | Closes the record file. | python/mxnet/recordio.py | def close(self):
"""Closes the record file."""
if not self.is_open:
return
super(MXIndexedRecordIO, self).close()
self.fidx.close() | def close(self):
"""Closes the record file."""
if not self.is_open:
return
super(MXIndexedRecordIO, self).close()
self.fidx.close() | [
"Closes",
"the",
"record",
"file",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L255-L260 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"is_open",
":",
"return",
"super",
"(",
"MXIndexedRecordIO",
",",
"self",
")",
".",
"close",
"(",
")",
"self",
".",
"fidx",
".",
"close",
"(",
")"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | MXIndexedRecordIO.seek | Sets the current read pointer position.
This function is internally called by `read_idx(idx)` to find the current
reader pointer position. It doesn't return anything. | python/mxnet/recordio.py | def seek(self, idx):
"""Sets the current read pointer position.
This function is internally called by `read_idx(idx)` to find the current
reader pointer position. It doesn't return anything."""
assert not self.writable
self._check_pid(allow_reset=True)
pos = ctypes.c_siz... | def seek(self, idx):
"""Sets the current read pointer position.
This function is internally called by `read_idx(idx)` to find the current
reader pointer position. It doesn't return anything."""
assert not self.writable
self._check_pid(allow_reset=True)
pos = ctypes.c_siz... | [
"Sets",
"the",
"current",
"read",
"pointer",
"position",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L268-L276 | [
"def",
"seek",
"(",
"self",
",",
"idx",
")",
":",
"assert",
"not",
"self",
".",
"writable",
"self",
".",
"_check_pid",
"(",
"allow_reset",
"=",
"True",
")",
"pos",
"=",
"ctypes",
".",
"c_size_t",
"(",
"self",
".",
"idx",
"[",
"idx",
"]",
")",
"chec... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | MXIndexedRecordIO.tell | Returns the current position of write head.
Examples
---------
>>> record = mx.recordio.MXIndexedRecordIO('tmp.idx', 'tmp.rec', 'w')
>>> print(record.tell())
0
>>> for i in range(5):
... record.write_idx(i, 'record_%d'%i)
... print(record.tell())
... | python/mxnet/recordio.py | def tell(self):
"""Returns the current position of write head.
Examples
---------
>>> record = mx.recordio.MXIndexedRecordIO('tmp.idx', 'tmp.rec', 'w')
>>> print(record.tell())
0
>>> for i in range(5):
... record.write_idx(i, 'record_%d'%i)
..... | def tell(self):
"""Returns the current position of write head.
Examples
---------
>>> record = mx.recordio.MXIndexedRecordIO('tmp.idx', 'tmp.rec', 'w')
>>> print(record.tell())
0
>>> for i in range(5):
... record.write_idx(i, 'record_%d'%i)
..... | [
"Returns",
"the",
"current",
"position",
"of",
"write",
"head",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L278-L298 | [
"def",
"tell",
"(",
"self",
")",
":",
"assert",
"self",
".",
"writable",
"pos",
"=",
"ctypes",
".",
"c_size_t",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXRecordIOWriterTell",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"pos",
")",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | MXIndexedRecordIO.write_idx | Inserts input record at given index.
Examples
---------
>>> for i in range(5):
... record.write_idx(i, 'record_%d'%i)
>>> record.close()
Parameters
----------
idx : int
Index of a file.
buf :
Record to write. | python/mxnet/recordio.py | def write_idx(self, idx, buf):
"""Inserts input record at given index.
Examples
---------
>>> for i in range(5):
... record.write_idx(i, 'record_%d'%i)
>>> record.close()
Parameters
----------
idx : int
Index of a file.
bu... | def write_idx(self, idx, buf):
"""Inserts input record at given index.
Examples
---------
>>> for i in range(5):
... record.write_idx(i, 'record_%d'%i)
>>> record.close()
Parameters
----------
idx : int
Index of a file.
bu... | [
"Inserts",
"input",
"record",
"at",
"given",
"index",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L316-L337 | [
"def",
"write_idx",
"(",
"self",
",",
"idx",
",",
"buf",
")",
":",
"key",
"=",
"self",
".",
"key_type",
"(",
"idx",
")",
"pos",
"=",
"self",
".",
"tell",
"(",
")",
"self",
".",
"write",
"(",
"buf",
")",
"self",
".",
"fidx",
".",
"write",
"(",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _add_new_columns | Add new metrics as new columns to selected pandas dataframe.
Parameters
----------
dataframe : pandas.DataFrame
Selected dataframe needs to be modified.
metrics : metric.EvalMetric
New metrics to be added. | python/mxnet/notebook/callback.py | def _add_new_columns(dataframe, metrics):
"""Add new metrics as new columns to selected pandas dataframe.
Parameters
----------
dataframe : pandas.DataFrame
Selected dataframe needs to be modified.
metrics : metric.EvalMetric
New metrics to be added.
"""
#TODO(leodirac): we ... | def _add_new_columns(dataframe, metrics):
"""Add new metrics as new columns to selected pandas dataframe.
Parameters
----------
dataframe : pandas.DataFrame
Selected dataframe needs to be modified.
metrics : metric.EvalMetric
New metrics to be added.
"""
#TODO(leodirac): we ... | [
"Add",
"new",
"metrics",
"as",
"new",
"columns",
"to",
"selected",
"pandas",
"dataframe",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/notebook/callback.py#L49-L62 | [
"def",
"_add_new_columns",
"(",
"dataframe",
",",
"metrics",
")",
":",
"#TODO(leodirac): we don't really need to do this on every update. Optimize",
"new_columns",
"=",
"set",
"(",
"metrics",
".",
"keys",
"(",
")",
")",
"-",
"set",
"(",
"dataframe",
".",
"columns",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | args_wrapper | Generates callback arguments for model.fit()
for a set of callback objects.
Callback objects like PandasLogger(), LiveLearningCurve()
get passed in. This assembles all their callback arguments. | python/mxnet/notebook/callback.py | def args_wrapper(*args):
"""Generates callback arguments for model.fit()
for a set of callback objects.
Callback objects like PandasLogger(), LiveLearningCurve()
get passed in. This assembles all their callback arguments.
"""
out = defaultdict(list)
for callback in args:
callback_ar... | def args_wrapper(*args):
"""Generates callback arguments for model.fit()
for a set of callback objects.
Callback objects like PandasLogger(), LiveLearningCurve()
get passed in. This assembles all their callback arguments.
"""
out = defaultdict(list)
for callback in args:
callback_ar... | [
"Generates",
"callback",
"arguments",
"for",
"model",
".",
"fit",
"()",
"for",
"a",
"set",
"of",
"callback",
"objects",
".",
"Callback",
"objects",
"like",
"PandasLogger",
"()",
"LiveLearningCurve",
"()",
"get",
"passed",
"in",
".",
"This",
"assembles",
"all",... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/notebook/callback.py#L392-L403 | [
"def",
"args_wrapper",
"(",
"*",
"args",
")",
":",
"out",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"callback",
"in",
"args",
":",
"callback_args",
"=",
"callback",
".",
"callback_args",
"(",
")",
"for",
"k",
",",
"v",
"in",
"callback_args",
".",
"i... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | PandasLogger.append_metrics | Append new metrics to selected dataframes.
Parameters
----------
metrics : metric.EvalMetric
New metrics to be added.
df_name : str
Name of the dataframe to be modified. | python/mxnet/notebook/callback.py | def append_metrics(self, metrics, df_name):
"""Append new metrics to selected dataframes.
Parameters
----------
metrics : metric.EvalMetric
New metrics to be added.
df_name : str
Name of the dataframe to be modified.
"""
dataframe = self._... | def append_metrics(self, metrics, df_name):
"""Append new metrics to selected dataframes.
Parameters
----------
metrics : metric.EvalMetric
New metrics to be added.
df_name : str
Name of the dataframe to be modified.
"""
dataframe = self._... | [
"Append",
"new",
"metrics",
"to",
"selected",
"dataframes",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/notebook/callback.py#L130-L142 | [
"def",
"append_metrics",
"(",
"self",
",",
"metrics",
",",
"df_name",
")",
":",
"dataframe",
"=",
"self",
".",
"_dataframes",
"[",
"df_name",
"]",
"_add_new_columns",
"(",
"dataframe",
",",
"metrics",
")",
"dataframe",
".",
"loc",
"[",
"len",
"(",
"datafra... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | PandasLogger.train_cb | Callback funtion for training. | python/mxnet/notebook/callback.py | def train_cb(self, param):
"""Callback funtion for training.
"""
if param.nbatch % self.frequent == 0:
self._process_batch(param, 'train') | def train_cb(self, param):
"""Callback funtion for training.
"""
if param.nbatch % self.frequent == 0:
self._process_batch(param, 'train') | [
"Callback",
"funtion",
"for",
"training",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/notebook/callback.py#L144-L148 | [
"def",
"train_cb",
"(",
"self",
",",
"param",
")",
":",
"if",
"param",
".",
"nbatch",
"%",
"self",
".",
"frequent",
"==",
"0",
":",
"self",
".",
"_process_batch",
"(",
"param",
",",
"'train'",
")"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | PandasLogger._process_batch | Update parameters for selected dataframe after a completed batch
Parameters
----------
dataframe : pandas.DataFrame
Selected dataframe needs to be modified. | python/mxnet/notebook/callback.py | def _process_batch(self, param, dataframe):
"""Update parameters for selected dataframe after a completed batch
Parameters
----------
dataframe : pandas.DataFrame
Selected dataframe needs to be modified.
"""
now = time.time()
if param.eval_metric is no... | def _process_batch(self, param, dataframe):
"""Update parameters for selected dataframe after a completed batch
Parameters
----------
dataframe : pandas.DataFrame
Selected dataframe needs to be modified.
"""
now = time.time()
if param.eval_metric is no... | [
"Update",
"parameters",
"for",
"selected",
"dataframe",
"after",
"a",
"completed",
"batch",
"Parameters",
"----------",
"dataframe",
":",
"pandas",
".",
"DataFrame",
"Selected",
"dataframe",
"needs",
"to",
"be",
"modified",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/notebook/callback.py#L155-L179 | [
"def",
"_process_batch",
"(",
"self",
",",
"param",
",",
"dataframe",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"if",
"param",
".",
"eval_metric",
"is",
"not",
"None",
":",
"metrics",
"=",
"dict",
"(",
"param",
".",
"eval_metric",
".",
"ge... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | PandasLogger.epoch_cb | Callback function after each epoch. Now it records each epoch time
and append it to epoch dataframe. | python/mxnet/notebook/callback.py | def epoch_cb(self):
"""Callback function after each epoch. Now it records each epoch time
and append it to epoch dataframe.
"""
metrics = {}
metrics['elapsed'] = self.elapsed()
now = datetime.datetime.now()
metrics['epoch_time'] = now - self.last_epoch_time
... | def epoch_cb(self):
"""Callback function after each epoch. Now it records each epoch time
and append it to epoch dataframe.
"""
metrics = {}
metrics['elapsed'] = self.elapsed()
now = datetime.datetime.now()
metrics['epoch_time'] = now - self.last_epoch_time
... | [
"Callback",
"function",
"after",
"each",
"epoch",
".",
"Now",
"it",
"records",
"each",
"epoch",
"time",
"and",
"append",
"it",
"to",
"epoch",
"dataframe",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/notebook/callback.py#L181-L190 | [
"def",
"epoch_cb",
"(",
"self",
")",
":",
"metrics",
"=",
"{",
"}",
"metrics",
"[",
"'elapsed'",
"]",
"=",
"self",
".",
"elapsed",
"(",
")",
"now",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"metrics",
"[",
"'epoch_time'",
"]",
"=",
"n... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | LiveBokehChart._push_render | Render the plot with bokeh.io and push to notebook. | python/mxnet/notebook/callback.py | def _push_render(self):
"""Render the plot with bokeh.io and push to notebook.
"""
bokeh.io.push_notebook(handle=self.handle)
self.last_update = time.time() | def _push_render(self):
"""Render the plot with bokeh.io and push to notebook.
"""
bokeh.io.push_notebook(handle=self.handle)
self.last_update = time.time() | [
"Render",
"the",
"plot",
"with",
"bokeh",
".",
"io",
"and",
"push",
"to",
"notebook",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/notebook/callback.py#L243-L247 | [
"def",
"_push_render",
"(",
"self",
")",
":",
"bokeh",
".",
"io",
".",
"push_notebook",
"(",
"handle",
"=",
"self",
".",
"handle",
")",
"self",
".",
"last_update",
"=",
"time",
".",
"time",
"(",
")"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | LiveLearningCurve._process_batch | Update selected dataframe after a completed batch
Parameters
----------
df_name : str
Selected dataframe name needs to be modified. | python/mxnet/notebook/callback.py | def _process_batch(self, param, df_name):
"""Update selected dataframe after a completed batch
Parameters
----------
df_name : str
Selected dataframe name needs to be modified.
"""
if param.eval_metric is not None:
metrics = dict(param.eval_metric.... | def _process_batch(self, param, df_name):
"""Update selected dataframe after a completed batch
Parameters
----------
df_name : str
Selected dataframe name needs to be modified.
"""
if param.eval_metric is not None:
metrics = dict(param.eval_metric.... | [
"Update",
"selected",
"dataframe",
"after",
"a",
"completed",
"batch",
"Parameters",
"----------",
"df_name",
":",
"str",
"Selected",
"dataframe",
"name",
"needs",
"to",
"be",
"modified",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/notebook/callback.py#L360-L376 | [
"def",
"_process_batch",
"(",
"self",
",",
"param",
",",
"df_name",
")",
":",
"if",
"param",
".",
"eval_metric",
"is",
"not",
"None",
":",
"metrics",
"=",
"dict",
"(",
"param",
".",
"eval_metric",
".",
"get_name_value",
"(",
")",
")",
"param",
".",
"ev... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | build_vocab | :param nested_list: list of list of string
:return: dictionary mapping from string to int, inverse of that dictionary | example/named_entity_recognition/src/ner.py | def build_vocab(nested_list):
"""
:param nested_list: list of list of string
:return: dictionary mapping from string to int, inverse of that dictionary
"""
# Build vocabulary
word_counts = Counter(itertools.chain(*nested_list))
# Mapping from index to label
vocabulary_inv = [x[0] for x ... | def build_vocab(nested_list):
"""
:param nested_list: list of list of string
:return: dictionary mapping from string to int, inverse of that dictionary
"""
# Build vocabulary
word_counts = Counter(itertools.chain(*nested_list))
# Mapping from index to label
vocabulary_inv = [x[0] for x ... | [
":",
"param",
"nested_list",
":",
"list",
"of",
"list",
"of",
"string",
":",
"return",
":",
"dictionary",
"mapping",
"from",
"string",
"to",
"int",
"inverse",
"of",
"that",
"dictionary"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/named_entity_recognition/src/ner.py#L89-L102 | [
"def",
"build_vocab",
"(",
"nested_list",
")",
":",
"# Build vocabulary",
"word_counts",
"=",
"Counter",
"(",
"itertools",
".",
"chain",
"(",
"*",
"nested_list",
")",
")",
"# Mapping from index to label",
"vocabulary_inv",
"=",
"[",
"x",
"[",
"0",
"]",
"for",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | build_iters | Reads a csv of sentences/tag sequences into a pandas dataframe.
Converts into X = array(list(int)) & Y = array(list(int))
Splits into training and test sets
Builds dictionaries mapping from index labels to labels/ indexed features to features
:param data_dir: directory to read in csv data from
:para... | example/named_entity_recognition/src/ner.py | def build_iters(data_dir, max_records, train_fraction, batch_size, buckets=None):
"""
Reads a csv of sentences/tag sequences into a pandas dataframe.
Converts into X = array(list(int)) & Y = array(list(int))
Splits into training and test sets
Builds dictionaries mapping from index labels to labels/ ... | def build_iters(data_dir, max_records, train_fraction, batch_size, buckets=None):
"""
Reads a csv of sentences/tag sequences into a pandas dataframe.
Converts into X = array(list(int)) & Y = array(list(int))
Splits into training and test sets
Builds dictionaries mapping from index labels to labels/ ... | [
"Reads",
"a",
"csv",
"of",
"sentences",
"/",
"tag",
"sequences",
"into",
"a",
"pandas",
"dataframe",
".",
"Converts",
"into",
"X",
"=",
"array",
"(",
"list",
"(",
"int",
"))",
"&",
"Y",
"=",
"array",
"(",
"list",
"(",
"int",
"))",
"Splits",
"into",
... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/named_entity_recognition/src/ner.py#L104-L146 | [
"def",
"build_iters",
"(",
"data_dir",
",",
"max_records",
",",
"train_fraction",
",",
"batch_size",
",",
"buckets",
"=",
"None",
")",
":",
"# Read in data as numpy array",
"df",
"=",
"pd",
".",
"read_pickle",
"(",
"os",
".",
"path",
".",
"join",
"(",
"data_... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | sym_gen | Build NN symbol depending on the length of the input sequence | example/named_entity_recognition/src/ner.py | def sym_gen(seq_len):
"""
Build NN symbol depending on the length of the input sequence
"""
sentence_shape = train_iter.provide_data[0][1]
char_sentence_shape = train_iter.provide_data[1][1]
entities_shape = train_iter.provide_label[0][1]
X_sent = mx.symbol.Variable(train_iter.provide_data[... | def sym_gen(seq_len):
"""
Build NN symbol depending on the length of the input sequence
"""
sentence_shape = train_iter.provide_data[0][1]
char_sentence_shape = train_iter.provide_data[1][1]
entities_shape = train_iter.provide_label[0][1]
X_sent = mx.symbol.Variable(train_iter.provide_data[... | [
"Build",
"NN",
"symbol",
"depending",
"on",
"the",
"length",
"of",
"the",
"input",
"sequence"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/named_entity_recognition/src/ner.py#L148-L203 | [
"def",
"sym_gen",
"(",
"seq_len",
")",
":",
"sentence_shape",
"=",
"train_iter",
".",
"provide_data",
"[",
"0",
"]",
"[",
"1",
"]",
"char_sentence_shape",
"=",
"train_iter",
".",
"provide_data",
"[",
"1",
"]",
"[",
"1",
"]",
"entities_shape",
"=",
"train_i... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | rand_zipfian | Draw random samples from an approximately log-uniform or Zipfian distribution.
This operation randomly samples *num_sampled* candidates the range of integers [0, range_max).
The elements of sampled_candidates are drawn with replacement from the base distribution.
The base distribution for this operator is... | python/mxnet/symbol/contrib.py | def rand_zipfian(true_classes, num_sampled, range_max):
"""Draw random samples from an approximately log-uniform or Zipfian distribution.
This operation randomly samples *num_sampled* candidates the range of integers [0, range_max).
The elements of sampled_candidates are drawn with replacement from the bas... | def rand_zipfian(true_classes, num_sampled, range_max):
"""Draw random samples from an approximately log-uniform or Zipfian distribution.
This operation randomly samples *num_sampled* candidates the range of integers [0, range_max).
The elements of sampled_candidates are drawn with replacement from the bas... | [
"Draw",
"random",
"samples",
"from",
"an",
"approximately",
"log",
"-",
"uniform",
"or",
"Zipfian",
"distribution",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/contrib.py#L39-L98 | [
"def",
"rand_zipfian",
"(",
"true_classes",
",",
"num_sampled",
",",
"range_max",
")",
":",
"assert",
"(",
"isinstance",
"(",
"true_classes",
",",
"Symbol",
")",
")",
",",
"\"unexpected type %s\"",
"%",
"type",
"(",
"true_classes",
")",
"log_range",
"=",
"math... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | foreach | Run a for loop with user-defined computation over Symbols on dimension 0.
This operator simulates a for loop and body has the computation for an iteration
of the for loop. It runs the computation in body on each slice from the input
NDArrays.
body takes two arguments as input and outputs a tuple of tw... | python/mxnet/symbol/contrib.py | def foreach(body, data, init_states, name="foreach"):
"""Run a for loop with user-defined computation over Symbols on dimension 0.
This operator simulates a for loop and body has the computation for an iteration
of the for loop. It runs the computation in body on each slice from the input
NDArrays.
... | def foreach(body, data, init_states, name="foreach"):
"""Run a for loop with user-defined computation over Symbols on dimension 0.
This operator simulates a for loop and body has the computation for an iteration
of the for loop. It runs the computation in body on each slice from the input
NDArrays.
... | [
"Run",
"a",
"for",
"loop",
"with",
"user",
"-",
"defined",
"computation",
"over",
"Symbols",
"on",
"dimension",
"0",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/contrib.py#L212-L373 | [
"def",
"foreach",
"(",
"body",
",",
"data",
",",
"init_states",
",",
"name",
"=",
"\"foreach\"",
")",
":",
"flatten_data",
",",
"data_fmt",
"=",
"_flatten",
"(",
"data",
",",
"\"foreach input\"",
")",
"_check_data",
"(",
"flatten_data",
",",
"symbol",
".",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | while_loop | Run a while loop with user-defined computation and loop condition.
This operator simulates a while loop which iterately does customized computation
as long as the condition is satisfied.
`loop_vars` is a Symbol or nested lists of Symbols on which the computation uses.
`cond` is a user-defined functio... | python/mxnet/symbol/contrib.py | def while_loop(cond, func, loop_vars, max_iterations=None, name="while_loop"):
"""Run a while loop with user-defined computation and loop condition.
This operator simulates a while loop which iterately does customized computation
as long as the condition is satisfied.
`loop_vars` is a Symbol or nested... | def while_loop(cond, func, loop_vars, max_iterations=None, name="while_loop"):
"""Run a while loop with user-defined computation and loop condition.
This operator simulates a while loop which iterately does customized computation
as long as the condition is satisfied.
`loop_vars` is a Symbol or nested... | [
"Run",
"a",
"while",
"loop",
"with",
"user",
"-",
"defined",
"computation",
"and",
"loop",
"condition",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/contrib.py#L375-L596 | [
"def",
"while_loop",
"(",
"cond",
",",
"func",
",",
"loop_vars",
",",
"max_iterations",
"=",
"None",
",",
"name",
"=",
"\"while_loop\"",
")",
":",
"def",
"_to_python_scalar",
"(",
"inputs",
",",
"type_",
",",
"name",
")",
":",
"\"\"\"Converts \"inputs\", possi... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | cond | Run an if-then-else using user-defined condition and computation
This operator simulates a if-like branch which chooses to do one of
the two customized computations according to the specified condition.
`pred` is a scalar MXNet Symbol,
indicating which branch of computation should be used.
`then_... | python/mxnet/symbol/contrib.py | def cond(pred, then_func, else_func, name="cond"):
"""Run an if-then-else using user-defined condition and computation
This operator simulates a if-like branch which chooses to do one of
the two customized computations according to the specified condition.
`pred` is a scalar MXNet Symbol,
indicati... | def cond(pred, then_func, else_func, name="cond"):
"""Run an if-then-else using user-defined condition and computation
This operator simulates a if-like branch which chooses to do one of
the two customized computations according to the specified condition.
`pred` is a scalar MXNet Symbol,
indicati... | [
"Run",
"an",
"if",
"-",
"then",
"-",
"else",
"using",
"user",
"-",
"defined",
"condition",
"and",
"computation"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/contrib.py#L598-L729 | [
"def",
"cond",
"(",
"pred",
",",
"then_func",
",",
"else_func",
",",
"name",
"=",
"\"cond\"",
")",
":",
"def",
"_create_subgraph",
"(",
"graph_vars",
",",
"graph_func",
",",
"subgraph_name",
")",
":",
"subgraph_name",
"=",
"_get_unique_subgraph_name",
"(",
"su... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Vocabulary._index_unknown_and_reserved_tokens | Indexes unknown and reserved tokens. | python/mxnet/contrib/text/vocab.py | def _index_unknown_and_reserved_tokens(self, unknown_token, reserved_tokens):
"""Indexes unknown and reserved tokens."""
self._unknown_token = unknown_token
# Thus, constants.UNKNOWN_IDX must be 0.
self._idx_to_token = [unknown_token]
if reserved_tokens is None:
sel... | def _index_unknown_and_reserved_tokens(self, unknown_token, reserved_tokens):
"""Indexes unknown and reserved tokens."""
self._unknown_token = unknown_token
# Thus, constants.UNKNOWN_IDX must be 0.
self._idx_to_token = [unknown_token]
if reserved_tokens is None:
sel... | [
"Indexes",
"unknown",
"and",
"reserved",
"tokens",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/text/vocab.py#L94-L107 | [
"def",
"_index_unknown_and_reserved_tokens",
"(",
"self",
",",
"unknown_token",
",",
"reserved_tokens",
")",
":",
"self",
".",
"_unknown_token",
"=",
"unknown_token",
"# Thus, constants.UNKNOWN_IDX must be 0.",
"self",
".",
"_idx_to_token",
"=",
"[",
"unknown_token",
"]",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Vocabulary._index_counter_keys | Indexes keys of `counter`.
Indexes keys of `counter` according to frequency thresholds such as `most_freq_count` and
`min_freq`. | python/mxnet/contrib/text/vocab.py | def _index_counter_keys(self, counter, unknown_token, reserved_tokens, most_freq_count,
min_freq):
"""Indexes keys of `counter`.
Indexes keys of `counter` according to frequency thresholds such as `most_freq_count` and
`min_freq`.
"""
assert isinsta... | def _index_counter_keys(self, counter, unknown_token, reserved_tokens, most_freq_count,
min_freq):
"""Indexes keys of `counter`.
Indexes keys of `counter` according to frequency thresholds such as `most_freq_count` and
`min_freq`.
"""
assert isinsta... | [
"Indexes",
"keys",
"of",
"counter",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/text/vocab.py#L109-L135 | [
"def",
"_index_counter_keys",
"(",
"self",
",",
"counter",
",",
"unknown_token",
",",
"reserved_tokens",
",",
"most_freq_count",
",",
"min_freq",
")",
":",
"assert",
"isinstance",
"(",
"counter",
",",
"collections",
".",
"Counter",
")",
",",
"'`counter` must be an... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Vocabulary.to_indices | Converts tokens to indices according to the vocabulary.
Parameters
----------
tokens : str or list of strs
A source token or tokens to be converted.
Returns
-------
int or list of ints
A token index or a list of token indices according to the v... | python/mxnet/contrib/text/vocab.py | def to_indices(self, tokens):
"""Converts tokens to indices according to the vocabulary.
Parameters
----------
tokens : str or list of strs
A source token or tokens to be converted.
Returns
-------
int or list of ints
A token index or a... | def to_indices(self, tokens):
"""Converts tokens to indices according to the vocabulary.
Parameters
----------
tokens : str or list of strs
A source token or tokens to be converted.
Returns
-------
int or list of ints
A token index or a... | [
"Converts",
"tokens",
"to",
"indices",
"according",
"to",
"the",
"vocabulary",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/text/vocab.py#L162-L186 | [
"def",
"to_indices",
"(",
"self",
",",
"tokens",
")",
":",
"to_reduce",
"=",
"False",
"if",
"not",
"isinstance",
"(",
"tokens",
",",
"list",
")",
":",
"tokens",
"=",
"[",
"tokens",
"]",
"to_reduce",
"=",
"True",
"indices",
"=",
"[",
"self",
".",
"tok... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | Vocabulary.to_tokens | Converts token indices to tokens according to the vocabulary.
Parameters
----------
indices : int or list of ints
A source token index or token indices to be converted.
Returns
-------
str or list of strs
A token or a list of tokens according t... | python/mxnet/contrib/text/vocab.py | def to_tokens(self, indices):
"""Converts token indices to tokens according to the vocabulary.
Parameters
----------
indices : int or list of ints
A source token index or token indices to be converted.
Returns
-------
str or list of strs
... | def to_tokens(self, indices):
"""Converts token indices to tokens according to the vocabulary.
Parameters
----------
indices : int or list of ints
A source token index or token indices to be converted.
Returns
-------
str or list of strs
... | [
"Converts",
"token",
"indices",
"to",
"tokens",
"according",
"to",
"the",
"vocabulary",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/text/vocab.py#L188-L218 | [
"def",
"to_tokens",
"(",
"self",
",",
"indices",
")",
":",
"to_reduce",
"=",
"False",
"if",
"not",
"isinstance",
"(",
"indices",
",",
"list",
")",
":",
"indices",
"=",
"[",
"indices",
"]",
"to_reduce",
"=",
"True",
"max_idx",
"=",
"len",
"(",
"self",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _make_io_iterator | Create an io iterator by handle. | python/mxnet/io/io.py | def _make_io_iterator(handle):
"""Create an io iterator by handle."""
name = ctypes.c_char_p()
desc = ctypes.c_char_p()
num_args = mx_uint()
arg_names = ctypes.POINTER(ctypes.c_char_p)()
arg_types = ctypes.POINTER(ctypes.c_char_p)()
arg_descs = ctypes.POINTER(ctypes.c_char_p)()
check_ca... | def _make_io_iterator(handle):
"""Create an io iterator by handle."""
name = ctypes.c_char_p()
desc = ctypes.c_char_p()
num_args = mx_uint()
arg_names = ctypes.POINTER(ctypes.c_char_p)()
arg_types = ctypes.POINTER(ctypes.c_char_p)()
arg_descs = ctypes.POINTER(ctypes.c_char_p)()
check_ca... | [
"Create",
"an",
"io",
"iterator",
"by",
"handle",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L899-L967 | [
"def",
"_make_io_iterator",
"(",
"handle",
")",
":",
"name",
"=",
"ctypes",
".",
"c_char_p",
"(",
")",
"desc",
"=",
"ctypes",
".",
"c_char_p",
"(",
")",
"num_args",
"=",
"mx_uint",
"(",
")",
"arg_names",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _init_io_module | List and add all the data iterators to current module. | python/mxnet/io/io.py | def _init_io_module():
"""List and add all the data iterators to current module."""
plist = ctypes.POINTER(ctypes.c_void_p)()
size = ctypes.c_uint()
check_call(_LIB.MXListDataIters(ctypes.byref(size), ctypes.byref(plist)))
module_obj = sys.modules[__name__]
for i in range(size.value):
hd... | def _init_io_module():
"""List and add all the data iterators to current module."""
plist = ctypes.POINTER(ctypes.c_void_p)()
size = ctypes.c_uint()
check_call(_LIB.MXListDataIters(ctypes.byref(size), ctypes.byref(plist)))
module_obj = sys.modules[__name__]
for i in range(size.value):
hd... | [
"List",
"and",
"add",
"all",
"the",
"data",
"iterators",
"to",
"current",
"module",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L969-L978 | [
"def",
"_init_io_module",
"(",
")",
":",
"plist",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_void_p",
")",
"(",
")",
"size",
"=",
"ctypes",
".",
"c_uint",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXListDataIters",
"(",
"ctypes",
".",
"byre... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | DataDesc.get_list | Get DataDesc list from attribute lists.
Parameters
----------
shapes : a tuple of (name_, shape_)
types : a tuple of (name_, np.dtype) | python/mxnet/io/io.py | def get_list(shapes, types):
"""Get DataDesc list from attribute lists.
Parameters
----------
shapes : a tuple of (name_, shape_)
types : a tuple of (name_, np.dtype)
"""
if types is not None:
type_dict = dict(types)
return [DataDesc(x[0]... | def get_list(shapes, types):
"""Get DataDesc list from attribute lists.
Parameters
----------
shapes : a tuple of (name_, shape_)
types : a tuple of (name_, np.dtype)
"""
if types is not None:
type_dict = dict(types)
return [DataDesc(x[0]... | [
"Get",
"DataDesc",
"list",
"from",
"attribute",
"lists",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L100-L112 | [
"def",
"get_list",
"(",
"shapes",
",",
"types",
")",
":",
"if",
"types",
"is",
"not",
"None",
":",
"type_dict",
"=",
"dict",
"(",
"types",
")",
"return",
"[",
"DataDesc",
"(",
"x",
"[",
"0",
"]",
",",
"x",
"[",
"1",
"]",
",",
"type_dict",
"[",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | DataIter.next | Get next data batch from iterator.
Returns
-------
DataBatch
The data of next batch.
Raises
------
StopIteration
If the end of the data is reached. | python/mxnet/io/io.py | def next(self):
"""Get next data batch from iterator.
Returns
-------
DataBatch
The data of next batch.
Raises
------
StopIteration
If the end of the data is reached.
"""
if self.iter_next():
return DataBatch(d... | def next(self):
"""Get next data batch from iterator.
Returns
-------
DataBatch
The data of next batch.
Raises
------
StopIteration
If the end of the data is reached.
"""
if self.iter_next():
return DataBatch(d... | [
"Get",
"next",
"data",
"batch",
"from",
"iterator",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L208-L225 | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"iter_next",
"(",
")",
":",
"return",
"DataBatch",
"(",
"data",
"=",
"self",
".",
"getdata",
"(",
")",
",",
"label",
"=",
"self",
".",
"getlabel",
"(",
")",
",",
"pad",
"=",
"self",
".",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | NDArrayIter.hard_reset | Ignore roll over data and set to start. | python/mxnet/io/io.py | def hard_reset(self):
"""Ignore roll over data and set to start."""
if self.shuffle:
self._shuffle_data()
self.cursor = -self.batch_size
self._cache_data = None
self._cache_label = None | def hard_reset(self):
"""Ignore roll over data and set to start."""
if self.shuffle:
self._shuffle_data()
self.cursor = -self.batch_size
self._cache_data = None
self._cache_label = None | [
"Ignore",
"roll",
"over",
"data",
"and",
"set",
"to",
"start",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L650-L656 | [
"def",
"hard_reset",
"(",
"self",
")",
":",
"if",
"self",
".",
"shuffle",
":",
"self",
".",
"_shuffle_data",
"(",
")",
"self",
".",
"cursor",
"=",
"-",
"self",
".",
"batch_size",
"self",
".",
"_cache_data",
"=",
"None",
"self",
".",
"_cache_label",
"="... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | NDArrayIter.reset | Resets the iterator to the beginning of the data. | python/mxnet/io/io.py | def reset(self):
"""Resets the iterator to the beginning of the data."""
if self.shuffle:
self._shuffle_data()
# the range below indicate the last batch
if self.last_batch_handle == 'roll_over' and \
self.num_data - self.batch_size < self.cursor < self.num_data:
... | def reset(self):
"""Resets the iterator to the beginning of the data."""
if self.shuffle:
self._shuffle_data()
# the range below indicate the last batch
if self.last_batch_handle == 'roll_over' and \
self.num_data - self.batch_size < self.cursor < self.num_data:
... | [
"Resets",
"the",
"iterator",
"to",
"the",
"beginning",
"of",
"the",
"data",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L658-L668 | [
"def",
"reset",
"(",
"self",
")",
":",
"if",
"self",
".",
"shuffle",
":",
"self",
".",
"_shuffle_data",
"(",
")",
"# the range below indicate the last batch",
"if",
"self",
".",
"last_batch_handle",
"==",
"'roll_over'",
"and",
"self",
".",
"num_data",
"-",
"se... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | NDArrayIter.iter_next | Increments the coursor by batch_size for next batch
and check current cursor if it exceed the number of data points. | python/mxnet/io/io.py | def iter_next(self):
"""Increments the coursor by batch_size for next batch
and check current cursor if it exceed the number of data points."""
self.cursor += self.batch_size
return self.cursor < self.num_data | def iter_next(self):
"""Increments the coursor by batch_size for next batch
and check current cursor if it exceed the number of data points."""
self.cursor += self.batch_size
return self.cursor < self.num_data | [
"Increments",
"the",
"coursor",
"by",
"batch_size",
"for",
"next",
"batch",
"and",
"check",
"current",
"cursor",
"if",
"it",
"exceed",
"the",
"number",
"of",
"data",
"points",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L670-L674 | [
"def",
"iter_next",
"(",
"self",
")",
":",
"self",
".",
"cursor",
"+=",
"self",
".",
"batch_size",
"return",
"self",
".",
"cursor",
"<",
"self",
".",
"num_data"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | NDArrayIter.next | Returns the next batch of data. | python/mxnet/io/io.py | def next(self):
"""Returns the next batch of data."""
if not self.iter_next():
raise StopIteration
data = self.getdata()
label = self.getlabel()
# iter should stop when last batch is not complete
if data[0].shape[0] != self.batch_size:
# in this case, ... | def next(self):
"""Returns the next batch of data."""
if not self.iter_next():
raise StopIteration
data = self.getdata()
label = self.getlabel()
# iter should stop when last batch is not complete
if data[0].shape[0] != self.batch_size:
# in this case, ... | [
"Returns",
"the",
"next",
"batch",
"of",
"data",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L676-L689 | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"iter_next",
"(",
")",
":",
"raise",
"StopIteration",
"data",
"=",
"self",
".",
"getdata",
"(",
")",
"label",
"=",
"self",
".",
"getlabel",
"(",
")",
"# iter should stop when last batch is not... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | NDArrayIter._getdata | Load data from underlying arrays. | python/mxnet/io/io.py | def _getdata(self, data_source, start=None, end=None):
"""Load data from underlying arrays."""
assert start is not None or end is not None, 'should at least specify start or end'
start = start if start is not None else 0
if end is None:
end = data_source[0][1].shape[0] if dat... | def _getdata(self, data_source, start=None, end=None):
"""Load data from underlying arrays."""
assert start is not None or end is not None, 'should at least specify start or end'
start = start if start is not None else 0
if end is None:
end = data_source[0][1].shape[0] if dat... | [
"Load",
"data",
"from",
"underlying",
"arrays",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L691-L706 | [
"def",
"_getdata",
"(",
"self",
",",
"data_source",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"assert",
"start",
"is",
"not",
"None",
"or",
"end",
"is",
"not",
"None",
",",
"'should at least specify start or end'",
"start",
"=",
"start"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | NDArrayIter._concat | Helper function to concat two NDArrays. | python/mxnet/io/io.py | def _concat(self, first_data, second_data):
"""Helper function to concat two NDArrays."""
assert len(first_data) == len(
second_data), 'data source should contain the same size'
if first_data and second_data:
return [
concat(
first_data... | def _concat(self, first_data, second_data):
"""Helper function to concat two NDArrays."""
assert len(first_data) == len(
second_data), 'data source should contain the same size'
if first_data and second_data:
return [
concat(
first_data... | [
"Helper",
"function",
"to",
"concat",
"two",
"NDArrays",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L708-L726 | [
"def",
"_concat",
"(",
"self",
",",
"first_data",
",",
"second_data",
")",
":",
"assert",
"len",
"(",
"first_data",
")",
"==",
"len",
"(",
"second_data",
")",
",",
"'data source should contain the same size'",
"if",
"first_data",
"and",
"second_data",
":",
"retu... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | NDArrayIter._batchify | Load data from underlying arrays, internal use only. | python/mxnet/io/io.py | def _batchify(self, data_source):
"""Load data from underlying arrays, internal use only."""
assert self.cursor < self.num_data, 'DataIter needs reset.'
# first batch of next epoch with 'roll_over'
if self.last_batch_handle == 'roll_over' and \
-self.batch_size < self.cursor ... | def _batchify(self, data_source):
"""Load data from underlying arrays, internal use only."""
assert self.cursor < self.num_data, 'DataIter needs reset.'
# first batch of next epoch with 'roll_over'
if self.last_batch_handle == 'roll_over' and \
-self.batch_size < self.cursor ... | [
"Load",
"data",
"from",
"underlying",
"arrays",
"internal",
"use",
"only",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L728-L758 | [
"def",
"_batchify",
"(",
"self",
",",
"data_source",
")",
":",
"assert",
"self",
".",
"cursor",
"<",
"self",
".",
"num_data",
",",
"'DataIter needs reset.'",
"# first batch of next epoch with 'roll_over'",
"if",
"self",
".",
"last_batch_handle",
"==",
"'roll_over'",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | NDArrayIter.getpad | Get pad value of DataBatch. | python/mxnet/io/io.py | def getpad(self):
"""Get pad value of DataBatch."""
if self.last_batch_handle == 'pad' and \
self.cursor + self.batch_size > self.num_data:
return self.cursor + self.batch_size - self.num_data
# check the first batch
elif self.last_batch_handle == 'roll_over' and \... | def getpad(self):
"""Get pad value of DataBatch."""
if self.last_batch_handle == 'pad' and \
self.cursor + self.batch_size > self.num_data:
return self.cursor + self.batch_size - self.num_data
# check the first batch
elif self.last_batch_handle == 'roll_over' and \... | [
"Get",
"pad",
"value",
"of",
"DataBatch",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L768-L778 | [
"def",
"getpad",
"(",
"self",
")",
":",
"if",
"self",
".",
"last_batch_handle",
"==",
"'pad'",
"and",
"self",
".",
"cursor",
"+",
"self",
".",
"batch_size",
">",
"self",
".",
"num_data",
":",
"return",
"self",
".",
"cursor",
"+",
"self",
".",
"batch_si... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | NDArrayIter._shuffle_data | Shuffle the data. | python/mxnet/io/io.py | def _shuffle_data(self):
"""Shuffle the data."""
# shuffle index
np.random.shuffle(self.idx)
# get the data by corresponding index
self.data = _getdata_by_idx(self.data, self.idx)
self.label = _getdata_by_idx(self.label, self.idx) | def _shuffle_data(self):
"""Shuffle the data."""
# shuffle index
np.random.shuffle(self.idx)
# get the data by corresponding index
self.data = _getdata_by_idx(self.data, self.idx)
self.label = _getdata_by_idx(self.label, self.idx) | [
"Shuffle",
"the",
"data",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L780-L786 | [
"def",
"_shuffle_data",
"(",
"self",
")",
":",
"# shuffle index",
"np",
".",
"random",
".",
"shuffle",
"(",
"self",
".",
"idx",
")",
"# get the data by corresponding index",
"self",
".",
"data",
"=",
"_getdata_by_idx",
"(",
"self",
".",
"data",
",",
"self",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _quantize_params | Given a quantized symbol and a dict of params that have not been quantized,
generate quantized params. Currently only supports quantizing the arg_params
with names of `weight` or `bias`, not aux_params. If `qsym` contains symbols
that are excluded from being quantized, their corresponding params will
no... | python/mxnet/contrib/quantization.py | def _quantize_params(qsym, params, th_dict):
"""Given a quantized symbol and a dict of params that have not been quantized,
generate quantized params. Currently only supports quantizing the arg_params
with names of `weight` or `bias`, not aux_params. If `qsym` contains symbols
that are excluded from bei... | def _quantize_params(qsym, params, th_dict):
"""Given a quantized symbol and a dict of params that have not been quantized,
generate quantized params. Currently only supports quantizing the arg_params
with names of `weight` or `bias`, not aux_params. If `qsym` contains symbols
that are excluded from bei... | [
"Given",
"a",
"quantized",
"symbol",
"and",
"a",
"dict",
"of",
"params",
"that",
"have",
"not",
"been",
"quantized",
"generate",
"quantized",
"params",
".",
"Currently",
"only",
"supports",
"quantizing",
"the",
"arg_params",
"with",
"names",
"of",
"weight",
"o... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L43-L81 | [
"def",
"_quantize_params",
"(",
"qsym",
",",
"params",
",",
"th_dict",
")",
":",
"inputs_name",
"=",
"qsym",
".",
"list_arguments",
"(",
")",
"quantized_params",
"=",
"{",
"}",
"for",
"name",
"in",
"inputs_name",
":",
"if",
"name",
".",
"endswith",
"(",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _quantize_symbol | Given a symbol object representing a neural network of data type FP32,
quantize it into a INT8 network.
Parameters
----------
sym : Symbol
FP32 neural network symbol.
excluded_sym_names : list of strings
A list of strings representing the names of the symbols that users want to excl... | python/mxnet/contrib/quantization.py | def _quantize_symbol(sym, excluded_symbols=None, offline_params=None, quantized_dtype='int8'):
"""Given a symbol object representing a neural network of data type FP32,
quantize it into a INT8 network.
Parameters
----------
sym : Symbol
FP32 neural network symbol.
excluded_sym_names : l... | def _quantize_symbol(sym, excluded_symbols=None, offline_params=None, quantized_dtype='int8'):
"""Given a symbol object representing a neural network of data type FP32,
quantize it into a INT8 network.
Parameters
----------
sym : Symbol
FP32 neural network symbol.
excluded_sym_names : l... | [
"Given",
"a",
"symbol",
"object",
"representing",
"a",
"neural",
"network",
"of",
"data",
"type",
"FP32",
"quantize",
"it",
"into",
"a",
"INT8",
"network",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L83-L124 | [
"def",
"_quantize_symbol",
"(",
"sym",
",",
"excluded_symbols",
"=",
"None",
",",
"offline_params",
"=",
"None",
",",
"quantized_dtype",
"=",
"'int8'",
")",
":",
"num_excluded_symbols",
"=",
"0",
"if",
"excluded_symbols",
"is",
"not",
"None",
":",
"assert",
"i... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _calibrate_quantized_sym | Given a dictionary containing the thresholds for quantizing the layers,
set the thresholds into the quantized symbol as the params of requantize operators. | python/mxnet/contrib/quantization.py | def _calibrate_quantized_sym(qsym, th_dict):
"""Given a dictionary containing the thresholds for quantizing the layers,
set the thresholds into the quantized symbol as the params of requantize operators.
"""
if th_dict is None or len(th_dict) == 0:
return qsym
num_layer_outputs = len(th_dict... | def _calibrate_quantized_sym(qsym, th_dict):
"""Given a dictionary containing the thresholds for quantizing the layers,
set the thresholds into the quantized symbol as the params of requantize operators.
"""
if th_dict is None or len(th_dict) == 0:
return qsym
num_layer_outputs = len(th_dict... | [
"Given",
"a",
"dictionary",
"containing",
"the",
"thresholds",
"for",
"quantizing",
"the",
"layers",
"set",
"the",
"thresholds",
"into",
"the",
"quantized",
"symbol",
"as",
"the",
"params",
"of",
"requantize",
"operators",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L179-L201 | [
"def",
"_calibrate_quantized_sym",
"(",
"qsym",
",",
"th_dict",
")",
":",
"if",
"th_dict",
"is",
"None",
"or",
"len",
"(",
"th_dict",
")",
"==",
"0",
":",
"return",
"qsym",
"num_layer_outputs",
"=",
"len",
"(",
"th_dict",
")",
"layer_output_names",
"=",
"[... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _collect_layer_output_min_max | Collect min and max values from layer outputs and save them in
a dictionary mapped by layer names. | python/mxnet/contrib/quantization.py | def _collect_layer_output_min_max(mod, data, include_layer=None,
max_num_examples=None, logger=None):
"""Collect min and max values from layer outputs and save them in
a dictionary mapped by layer names.
"""
collector = _LayerOutputMinMaxCollector(include_layer=include_... | def _collect_layer_output_min_max(mod, data, include_layer=None,
max_num_examples=None, logger=None):
"""Collect min and max values from layer outputs and save them in
a dictionary mapped by layer names.
"""
collector = _LayerOutputMinMaxCollector(include_layer=include_... | [
"Collect",
"min",
"and",
"max",
"values",
"from",
"layer",
"outputs",
"and",
"save",
"them",
"in",
"a",
"dictionary",
"mapped",
"by",
"layer",
"names",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L223-L230 | [
"def",
"_collect_layer_output_min_max",
"(",
"mod",
",",
"data",
",",
"include_layer",
"=",
"None",
",",
"max_num_examples",
"=",
"None",
",",
"logger",
"=",
"None",
")",
":",
"collector",
"=",
"_LayerOutputMinMaxCollector",
"(",
"include_layer",
"=",
"include_lay... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _collect_layer_outputs | Collect layer outputs and save them in a dictionary mapped by layer names. | python/mxnet/contrib/quantization.py | def _collect_layer_outputs(mod, data, include_layer=None, max_num_examples=None, logger=None):
"""Collect layer outputs and save them in a dictionary mapped by layer names."""
collector = _LayerOutputCollector(include_layer=include_layer, logger=logger)
num_examples = _collect_layer_statistics(mod, data, co... | def _collect_layer_outputs(mod, data, include_layer=None, max_num_examples=None, logger=None):
"""Collect layer outputs and save them in a dictionary mapped by layer names."""
collector = _LayerOutputCollector(include_layer=include_layer, logger=logger)
num_examples = _collect_layer_statistics(mod, data, co... | [
"Collect",
"layer",
"outputs",
"and",
"save",
"them",
"in",
"a",
"dictionary",
"mapped",
"by",
"layer",
"names",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L233-L237 | [
"def",
"_collect_layer_outputs",
"(",
"mod",
",",
"data",
",",
"include_layer",
"=",
"None",
",",
"max_num_examples",
"=",
"None",
",",
"logger",
"=",
"None",
")",
":",
"collector",
"=",
"_LayerOutputCollector",
"(",
"include_layer",
"=",
"include_layer",
",",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _smooth_distribution | Given a discrete distribution (may have not been normalized to 1),
smooth it by replacing zeros with eps multiplied by a scaling factor and taking the
corresponding amount off the non-zero values.
Ref: http://web.engr.illinois.edu/~hanj/cs412/bk3/KL-divergence.pdf | python/mxnet/contrib/quantization.py | def _smooth_distribution(p, eps=0.0001):
"""Given a discrete distribution (may have not been normalized to 1),
smooth it by replacing zeros with eps multiplied by a scaling factor and taking the
corresponding amount off the non-zero values.
Ref: http://web.engr.illinois.edu/~hanj/cs412/bk3/KL-divergence... | def _smooth_distribution(p, eps=0.0001):
"""Given a discrete distribution (may have not been normalized to 1),
smooth it by replacing zeros with eps multiplied by a scaling factor and taking the
corresponding amount off the non-zero values.
Ref: http://web.engr.illinois.edu/~hanj/cs412/bk3/KL-divergence... | [
"Given",
"a",
"discrete",
"distribution",
"(",
"may",
"have",
"not",
"been",
"normalized",
"to",
"1",
")",
"smooth",
"it",
"by",
"replacing",
"zeros",
"with",
"eps",
"multiplied",
"by",
"a",
"scaling",
"factor",
"and",
"taking",
"the",
"corresponding",
"amou... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L240-L257 | [
"def",
"_smooth_distribution",
"(",
"p",
",",
"eps",
"=",
"0.0001",
")",
":",
"is_zeros",
"=",
"(",
"p",
"==",
"0",
")",
".",
"astype",
"(",
"np",
".",
"float32",
")",
"is_nonzeros",
"=",
"(",
"p",
"!=",
"0",
")",
".",
"astype",
"(",
"np",
".",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _get_optimal_threshold | Given a dataset, find the optimal threshold for quantizing it.
The reference distribution is `q`, and the candidate distribution is `p`.
`q` is a truncated version of the original distribution.
Ref: http://on-demand.gputechconf.com/gtc/2017/presentation/s7310-8-bit-inference-with-tensorrt.pdf | python/mxnet/contrib/quantization.py | def _get_optimal_threshold(arr, quantized_dtype, num_bins=8001, num_quantized_bins=255):
"""Given a dataset, find the optimal threshold for quantizing it.
The reference distribution is `q`, and the candidate distribution is `p`.
`q` is a truncated version of the original distribution.
Ref: http://on-de... | def _get_optimal_threshold(arr, quantized_dtype, num_bins=8001, num_quantized_bins=255):
"""Given a dataset, find the optimal threshold for quantizing it.
The reference distribution is `q`, and the candidate distribution is `p`.
`q` is a truncated version of the original distribution.
Ref: http://on-de... | [
"Given",
"a",
"dataset",
"find",
"the",
"optimal",
"threshold",
"for",
"quantizing",
"it",
".",
"The",
"reference",
"distribution",
"is",
"q",
"and",
"the",
"candidate",
"distribution",
"is",
"p",
".",
"q",
"is",
"a",
"truncated",
"version",
"of",
"the",
"... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L261-L351 | [
"def",
"_get_optimal_threshold",
"(",
"arr",
",",
"quantized_dtype",
",",
"num_bins",
"=",
"8001",
",",
"num_quantized_bins",
"=",
"255",
")",
":",
"if",
"isinstance",
"(",
"arr",
",",
"NDArray",
")",
":",
"arr",
"=",
"arr",
".",
"asnumpy",
"(",
")",
"el... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _get_optimal_thresholds | Given a ndarray dict, find the optimal threshold for quantizing each value of the key. | python/mxnet/contrib/quantization.py | def _get_optimal_thresholds(nd_dict, quantized_dtype, num_bins=8001, num_quantized_bins=255, logger=None):
"""Given a ndarray dict, find the optimal threshold for quantizing each value of the key."""
if stats is None:
raise ImportError('scipy.stats is required for running entropy mode of calculating'
... | def _get_optimal_thresholds(nd_dict, quantized_dtype, num_bins=8001, num_quantized_bins=255, logger=None):
"""Given a ndarray dict, find the optimal threshold for quantizing each value of the key."""
if stats is None:
raise ImportError('scipy.stats is required for running entropy mode of calculating'
... | [
"Given",
"a",
"ndarray",
"dict",
"find",
"the",
"optimal",
"threshold",
"for",
"quantizing",
"each",
"value",
"of",
"the",
"key",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L355-L381 | [
"def",
"_get_optimal_thresholds",
"(",
"nd_dict",
",",
"quantized_dtype",
",",
"num_bins",
"=",
"8001",
",",
"num_quantized_bins",
"=",
"255",
",",
"logger",
"=",
"None",
")",
":",
"if",
"stats",
"is",
"None",
":",
"raise",
"ImportError",
"(",
"'scipy.stats is... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _load_sym | Given a str as a path the symbol .json file or a symbol, returns a Symbol object. | python/mxnet/contrib/quantization.py | def _load_sym(sym, logger=logging):
"""Given a str as a path the symbol .json file or a symbol, returns a Symbol object."""
if isinstance(sym, str): # sym is a symbol file path
cur_path = os.path.dirname(os.path.realpath(__file__))
symbol_file_path = os.path.join(cur_path, sym)
logger.i... | def _load_sym(sym, logger=logging):
"""Given a str as a path the symbol .json file or a symbol, returns a Symbol object."""
if isinstance(sym, str): # sym is a symbol file path
cur_path = os.path.dirname(os.path.realpath(__file__))
symbol_file_path = os.path.join(cur_path, sym)
logger.i... | [
"Given",
"a",
"str",
"as",
"a",
"path",
"the",
"symbol",
".",
"json",
"file",
"or",
"a",
"symbol",
"returns",
"a",
"Symbol",
"object",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L384-L395 | [
"def",
"_load_sym",
"(",
"sym",
",",
"logger",
"=",
"logging",
")",
":",
"if",
"isinstance",
"(",
"sym",
",",
"str",
")",
":",
"# sym is a symbol file path",
"cur_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _load_params | Given a str as a path to the .params file or a pair of params,
returns two dictionaries representing arg_params and aux_params. | python/mxnet/contrib/quantization.py | def _load_params(params, logger=logging):
"""Given a str as a path to the .params file or a pair of params,
returns two dictionaries representing arg_params and aux_params.
"""
if isinstance(params, str):
cur_path = os.path.dirname(os.path.realpath(__file__))
param_file_path = os.path.jo... | def _load_params(params, logger=logging):
"""Given a str as a path to the .params file or a pair of params,
returns two dictionaries representing arg_params and aux_params.
"""
if isinstance(params, str):
cur_path = os.path.dirname(os.path.realpath(__file__))
param_file_path = os.path.jo... | [
"Given",
"a",
"str",
"as",
"a",
"path",
"to",
"the",
".",
"params",
"file",
"or",
"a",
"pair",
"of",
"params",
"returns",
"two",
"dictionaries",
"representing",
"arg_params",
"and",
"aux_params",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L398-L420 | [
"def",
"_load_params",
"(",
"params",
",",
"logger",
"=",
"logging",
")",
":",
"if",
"isinstance",
"(",
"params",
",",
"str",
")",
":",
"cur_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | quantize_model | User-level API for generating a quantized model from a FP32 model w/ or w/o calibration.
The backend quantized operators are only enabled for Linux systems. Please do not run
inference using the quantized models on Windows for now.
The quantization implementation adopts the TensorFlow's approach:
https:... | python/mxnet/contrib/quantization.py | def quantize_model(sym, arg_params, aux_params,
data_names=('data',), label_names=('softmax_label',),
ctx=cpu(), excluded_sym_names=None, calib_mode='entropy',
calib_data=None, num_calib_examples=None, calib_layer=None,
quantized_dtype='int8', ... | def quantize_model(sym, arg_params, aux_params,
data_names=('data',), label_names=('softmax_label',),
ctx=cpu(), excluded_sym_names=None, calib_mode='entropy',
calib_data=None, num_calib_examples=None, calib_layer=None,
quantized_dtype='int8', ... | [
"User",
"-",
"level",
"API",
"for",
"generating",
"a",
"quantized",
"model",
"from",
"a",
"FP32",
"model",
"w",
"/",
"or",
"w",
"/",
"o",
"calibration",
".",
"The",
"backend",
"quantized",
"operators",
"are",
"only",
"enabled",
"for",
"Linux",
"systems",
... | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L422-L544 | [
"def",
"quantize_model",
"(",
"sym",
",",
"arg_params",
",",
"aux_params",
",",
"data_names",
"=",
"(",
"'data'",
",",
")",
",",
"label_names",
"=",
"(",
"'softmax_label'",
",",
")",
",",
"ctx",
"=",
"cpu",
"(",
")",
",",
"excluded_sym_names",
"=",
"None... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _LayerOutputCollector.collect | Callback function for collecting layer output NDArrays. | python/mxnet/contrib/quantization.py | def collect(self, name, arr):
"""Callback function for collecting layer output NDArrays."""
name = py_str(name)
if self.include_layer is not None and not self.include_layer(name):
return
handle = ctypes.cast(arr, NDArrayHandle)
arr = NDArray(handle, writable=False).co... | def collect(self, name, arr):
"""Callback function for collecting layer output NDArrays."""
name = py_str(name)
if self.include_layer is not None and not self.include_layer(name):
return
handle = ctypes.cast(arr, NDArrayHandle)
arr = NDArray(handle, writable=False).co... | [
"Callback",
"function",
"for",
"collecting",
"layer",
"output",
"NDArrays",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L137-L149 | [
"def",
"collect",
"(",
"self",
",",
"name",
",",
"arr",
")",
":",
"name",
"=",
"py_str",
"(",
"name",
")",
"if",
"self",
".",
"include_layer",
"is",
"not",
"None",
"and",
"not",
"self",
".",
"include_layer",
"(",
"name",
")",
":",
"return",
"handle",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | _LayerOutputMinMaxCollector.collect | Callback function for collecting min and max values from an NDArray. | python/mxnet/contrib/quantization.py | def collect(self, name, arr):
"""Callback function for collecting min and max values from an NDArray."""
name = py_str(name)
if self.include_layer is not None and not self.include_layer(name):
return
handle = ctypes.cast(arr, NDArrayHandle)
arr = NDArray(handle, writa... | def collect(self, name, arr):
"""Callback function for collecting min and max values from an NDArray."""
name = py_str(name)
if self.include_layer is not None and not self.include_layer(name):
return
handle = ctypes.cast(arr, NDArrayHandle)
arr = NDArray(handle, writa... | [
"Callback",
"function",
"for",
"collecting",
"min",
"and",
"max",
"values",
"from",
"an",
"NDArray",
"."
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L160-L177 | [
"def",
"collect",
"(",
"self",
",",
"name",
",",
"arr",
")",
":",
"name",
"=",
"py_str",
"(",
"name",
")",
"if",
"self",
".",
"include_layer",
"is",
"not",
"None",
"and",
"not",
"self",
".",
"include_layer",
"(",
"name",
")",
":",
"return",
"handle",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | encoder | The encoder is a CNN which takes 32x32 image as input
generates the 100 dimensional shape embedding as a sample from normal distribution
using predicted meand and variance | example/vae-gan/vaegan_mxnet.py | def encoder(nef, z_dim, batch_size, no_bias=True, fix_gamma=True, eps=1e-5 + 1e-12):
'''The encoder is a CNN which takes 32x32 image as input
generates the 100 dimensional shape embedding as a sample from normal distribution
using predicted meand and variance
'''
BatchNorm = mx.sym.BatchNorm
da... | def encoder(nef, z_dim, batch_size, no_bias=True, fix_gamma=True, eps=1e-5 + 1e-12):
'''The encoder is a CNN which takes 32x32 image as input
generates the 100 dimensional shape embedding as a sample from normal distribution
using predicted meand and variance
'''
BatchNorm = mx.sym.BatchNorm
da... | [
"The",
"encoder",
"is",
"a",
"CNN",
"which",
"takes",
"32x32",
"image",
"as",
"input",
"generates",
"the",
"100",
"dimensional",
"shape",
"embedding",
"as",
"a",
"sample",
"from",
"normal",
"distribution",
"using",
"predicted",
"meand",
"and",
"variance"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L54-L86 | [
"def",
"encoder",
"(",
"nef",
",",
"z_dim",
",",
"batch_size",
",",
"no_bias",
"=",
"True",
",",
"fix_gamma",
"=",
"True",
",",
"eps",
"=",
"1e-5",
"+",
"1e-12",
")",
":",
"BatchNorm",
"=",
"mx",
".",
"sym",
".",
"BatchNorm",
"data",
"=",
"mx",
"."... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
train | generator | The genrator is a CNN which takes 100 dimensional embedding as input
and reconstructs the input image given to the encoder | example/vae-gan/vaegan_mxnet.py | def generator(ngf, nc, no_bias=True, fix_gamma=True, eps=1e-5 + 1e-12, z_dim=100, activation='sigmoid'):
'''The genrator is a CNN which takes 100 dimensional embedding as input
and reconstructs the input image given to the encoder
'''
BatchNorm = mx.sym.BatchNorm
rand = mx.sym.Variable('rand')
... | def generator(ngf, nc, no_bias=True, fix_gamma=True, eps=1e-5 + 1e-12, z_dim=100, activation='sigmoid'):
'''The genrator is a CNN which takes 100 dimensional embedding as input
and reconstructs the input image given to the encoder
'''
BatchNorm = mx.sym.BatchNorm
rand = mx.sym.Variable('rand')
... | [
"The",
"genrator",
"is",
"a",
"CNN",
"which",
"takes",
"100",
"dimensional",
"embedding",
"as",
"input",
"and",
"reconstructs",
"the",
"input",
"image",
"given",
"to",
"the",
"encoder"
] | apache/incubator-mxnet | python | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L88-L116 | [
"def",
"generator",
"(",
"ngf",
",",
"nc",
",",
"no_bias",
"=",
"True",
",",
"fix_gamma",
"=",
"True",
",",
"eps",
"=",
"1e-5",
"+",
"1e-12",
",",
"z_dim",
"=",
"100",
",",
"activation",
"=",
"'sigmoid'",
")",
":",
"BatchNorm",
"=",
"mx",
".",
"sym... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.