repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.get_children | def get_children(self):
"""Gets a new grouped symbol whose output contains
inputs to output nodes of the original symbol.
Example
-------
>>> x = mx.sym.Variable('x')
>>> y = mx.sym.Variable('y')
>>> z = mx.sym.Variable('z')
>>> a = y+z
>>> b = x+... | python | def get_children(self):
"""Gets a new grouped symbol whose output contains
inputs to output nodes of the original symbol.
Example
-------
>>> x = mx.sym.Variable('x')
>>> y = mx.sym.Variable('y')
>>> z = mx.sym.Variable('z')
>>> a = y+z
>>> b = x+... | [
"def",
"get_children",
"(",
"self",
")",
":",
"handle",
"=",
"SymbolHandle",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolGetChildren",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"handle",
")",
")",
")",
"ret",
"=",
"Symbol",
"... | Gets a new grouped symbol whose output contains
inputs to output nodes of the original symbol.
Example
-------
>>> x = mx.sym.Variable('x')
>>> y = mx.sym.Variable('y')
>>> z = mx.sym.Variable('z')
>>> a = y+z
>>> b = x+a
>>> b.get_children()
... | [
"Gets",
"a",
"new",
"grouped",
"symbol",
"whose",
"output",
"contains",
"inputs",
"to",
"output",
"nodes",
"of",
"the",
"original",
"symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L680-L710 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.list_arguments | def list_arguments(self):
"""Lists all the arguments in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_arguments
['a', 'b']
Returns
-------
args : list of string
Li... | python | def list_arguments(self):
"""Lists all the arguments in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_arguments
['a', 'b']
Returns
-------
args : list of string
Li... | [
"def",
"list_arguments",
"(",
"self",
")",
":",
"size",
"=",
"ctypes",
".",
"c_uint",
"(",
")",
"sarr",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_char_p",
")",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolListArguments",
"(",
"self",
... | Lists all the arguments in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_arguments
['a', 'b']
Returns
-------
args : list of string
List containing the names of all the ar... | [
"Lists",
"all",
"the",
"arguments",
"in",
"the",
"symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L712-L732 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.list_outputs | def list_outputs(self):
"""Lists all the outputs in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_outputs()
['_plus12_output']
Returns
-------
list of str
List of ... | python | def list_outputs(self):
"""Lists all the outputs in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_outputs()
['_plus12_output']
Returns
-------
list of str
List of ... | [
"def",
"list_outputs",
"(",
"self",
")",
":",
"size",
"=",
"ctypes",
".",
"c_uint",
"(",
")",
"sarr",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_char_p",
")",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolListOutputs",
"(",
"self",
".",... | Lists all the outputs in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_outputs()
['_plus12_output']
Returns
-------
list of str
List of all the outputs.
For mo... | [
"Lists",
"all",
"the",
"outputs",
"in",
"the",
"symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L734-L757 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.list_auxiliary_states | def list_auxiliary_states(self):
"""Lists all the auxiliary states in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_auxiliary_states()
[]
Example of auxiliary states in `BatchNorm`.
... | python | def list_auxiliary_states(self):
"""Lists all the auxiliary states in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_auxiliary_states()
[]
Example of auxiliary states in `BatchNorm`.
... | [
"def",
"list_auxiliary_states",
"(",
"self",
")",
":",
"size",
"=",
"ctypes",
".",
"c_uint",
"(",
")",
"sarr",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_char_p",
")",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolListAuxiliaryStates",
"(",... | Lists all the auxiliary states in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_auxiliary_states()
[]
Example of auxiliary states in `BatchNorm`.
>>> data = mx.symbol.Variable('data')
... | [
"Lists",
"all",
"the",
"auxiliary",
"states",
"in",
"the",
"symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L779-L815 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.list_inputs | def list_inputs(self):
"""Lists all arguments and auxiliary states of this Symbol.
Returns
-------
inputs : list of str
List of all inputs.
Examples
--------
>>> bn = mx.sym.BatchNorm(name='bn')
>>> bn.list_arguments()
['bn_data', 'bn... | python | def list_inputs(self):
"""Lists all arguments and auxiliary states of this Symbol.
Returns
-------
inputs : list of str
List of all inputs.
Examples
--------
>>> bn = mx.sym.BatchNorm(name='bn')
>>> bn.list_arguments()
['bn_data', 'bn... | [
"def",
"list_inputs",
"(",
"self",
")",
":",
"size",
"=",
"ctypes",
".",
"c_uint",
"(",
")",
"sarr",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_char_p",
")",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"NNSymbolListInputNames",
"(",
"self",
".... | Lists all arguments and auxiliary states of this Symbol.
Returns
-------
inputs : list of str
List of all inputs.
Examples
--------
>>> bn = mx.sym.BatchNorm(name='bn')
>>> bn.list_arguments()
['bn_data', 'bn_gamma', 'bn_beta']
>>> bn... | [
"Lists",
"all",
"arguments",
"and",
"auxiliary",
"states",
"of",
"this",
"Symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L817-L839 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.infer_type | def infer_type(self, *args, **kwargs):
"""Infers the type of all arguments and all outputs, given the known types
for some arguments.
This function takes the known types of some arguments in either positional way
or keyword argument way as input. It returns a tuple of `None` values
... | python | def infer_type(self, *args, **kwargs):
"""Infers the type of all arguments and all outputs, given the known types
for some arguments.
This function takes the known types of some arguments in either positional way
or keyword argument way as input. It returns a tuple of `None` values
... | [
"def",
"infer_type",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"_infer_type_impl",
"(",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"res",
"[",
"1",
"]",
"is",
"Non... | Infers the type of all arguments and all outputs, given the known types
for some arguments.
This function takes the known types of some arguments in either positional way
or keyword argument way as input. It returns a tuple of `None` values
if there is not enough information to deduce t... | [
"Infers",
"the",
"type",
"of",
"all",
"arguments",
"and",
"all",
"outputs",
"given",
"the",
"known",
"types",
"for",
"some",
"arguments",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L841-L908 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol._infer_type_impl | def _infer_type_impl(self, partial, *args, **kwargs):
"""The actual implementation for calling type inference API."""
# pylint: disable=too-many-locals
if len(args) != 0 and len(kwargs) != 0:
raise ValueError('Can only specify known argument \
types either by posi... | python | def _infer_type_impl(self, partial, *args, **kwargs):
"""The actual implementation for calling type inference API."""
# pylint: disable=too-many-locals
if len(args) != 0 and len(kwargs) != 0:
raise ValueError('Can only specify known argument \
types either by posi... | [
"def",
"_infer_type_impl",
"(",
"self",
",",
"partial",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=too-many-locals",
"if",
"len",
"(",
"args",
")",
"!=",
"0",
"and",
"len",
"(",
"kwargs",
")",
"!=",
"0",
":",
"raise",
"Valu... | The actual implementation for calling type inference API. | [
"The",
"actual",
"implementation",
"for",
"calling",
"type",
"inference",
"API",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L958-L1015 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.infer_shape | def infer_shape(self, *args, **kwargs):
"""Infers the shapes of all arguments and all outputs given the known shapes of
some arguments.
This function takes the known shapes of some arguments in either positional way
or keyword argument way as input. It returns a tuple of `None` values
... | python | def infer_shape(self, *args, **kwargs):
"""Infers the shapes of all arguments and all outputs given the known shapes of
some arguments.
This function takes the known shapes of some arguments in either positional way
or keyword argument way as input. It returns a tuple of `None` values
... | [
"def",
"infer_shape",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"_infer_shape_impl",
"(",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"res",
"[",
"1",
"]",
"is",
"N... | Infers the shapes of all arguments and all outputs given the known shapes of
some arguments.
This function takes the known shapes of some arguments in either positional way
or keyword argument way as input. It returns a tuple of `None` values
if there is not enough information to deduce... | [
"Infers",
"the",
"shapes",
"of",
"all",
"arguments",
"and",
"all",
"outputs",
"given",
"the",
"known",
"shapes",
"of",
"some",
"arguments",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1018-L1102 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol._infer_shape_impl | def _infer_shape_impl(self, partial, *args, **kwargs):
"""The actual implementation for calling shape inference API."""
# pylint: disable=too-many-locals
if len(args) != 0 and len(kwargs) != 0:
raise ValueError('Can only specify known argument \
shapes either by p... | python | def _infer_shape_impl(self, partial, *args, **kwargs):
"""The actual implementation for calling shape inference API."""
# pylint: disable=too-many-locals
if len(args) != 0 and len(kwargs) != 0:
raise ValueError('Can only specify known argument \
shapes either by p... | [
"def",
"_infer_shape_impl",
"(",
"self",
",",
"partial",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=too-many-locals",
"if",
"len",
"(",
"args",
")",
"!=",
"0",
"and",
"len",
"(",
"kwargs",
")",
"!=",
"0",
":",
"raise",
"Val... | The actual implementation for calling shape inference API. | [
"The",
"actual",
"implementation",
"for",
"calling",
"shape",
"inference",
"API",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1153-L1222 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.save | def save(self, fname):
"""Saves symbol to a file.
You can also use pickle to do the job if you only work on python.
The advantage of `load`/`save` functions is that the file contents are language agnostic.
This means the model saved by one language binding can be loaded by a different
... | python | def save(self, fname):
"""Saves symbol to a file.
You can also use pickle to do the job if you only work on python.
The advantage of `load`/`save` functions is that the file contents are language agnostic.
This means the model saved by one language binding can be loaded by a different
... | [
"def",
"save",
"(",
"self",
",",
"fname",
")",
":",
"if",
"not",
"isinstance",
"(",
"fname",
",",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'fname need to be string'",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolSaveToFile",
"(",
"self",
".",
... | Saves symbol to a file.
You can also use pickle to do the job if you only work on python.
The advantage of `load`/`save` functions is that the file contents are language agnostic.
This means the model saved by one language binding can be loaded by a different
language binding of `MXNet`... | [
"Saves",
"symbol",
"to",
"a",
"file",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1278-L1302 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.tojson | def tojson(self):
"""Saves symbol to a JSON string.
See Also
--------
symbol.load_json : Used to load symbol from JSON string.
"""
json_str = ctypes.c_char_p()
check_call(_LIB.MXSymbolSaveToJSON(self.handle, ctypes.byref(json_str)))
return py_str(json_str... | python | def tojson(self):
"""Saves symbol to a JSON string.
See Also
--------
symbol.load_json : Used to load symbol from JSON string.
"""
json_str = ctypes.c_char_p()
check_call(_LIB.MXSymbolSaveToJSON(self.handle, ctypes.byref(json_str)))
return py_str(json_str... | [
"def",
"tojson",
"(",
"self",
")",
":",
"json_str",
"=",
"ctypes",
".",
"c_char_p",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolSaveToJSON",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"json_str",
")",
")",
")",
"return",
"py_s... | Saves symbol to a JSON string.
See Also
--------
symbol.load_json : Used to load symbol from JSON string. | [
"Saves",
"symbol",
"to",
"a",
"JSON",
"string",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1304-L1313 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol._get_ndarray_inputs | def _get_ndarray_inputs(arg_key, args, arg_names, allow_missing):
"""Helper function to get NDArray lists handles from various inputs.
Parameters
----------
arg_key : str
The name of argument, used for error message.
args : list of NDArray or dict of str to NDArray
... | python | def _get_ndarray_inputs(arg_key, args, arg_names, allow_missing):
"""Helper function to get NDArray lists handles from various inputs.
Parameters
----------
arg_key : str
The name of argument, used for error message.
args : list of NDArray or dict of str to NDArray
... | [
"def",
"_get_ndarray_inputs",
"(",
"arg_key",
",",
"args",
",",
"arg_names",
",",
"allow_missing",
")",
":",
"# setup args",
"arg_handles",
"=",
"[",
"]",
"arg_arrays",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"args",
",",
"list",
")",
":",
"if",
"len",
"... | Helper function to get NDArray lists handles from various inputs.
Parameters
----------
arg_key : str
The name of argument, used for error message.
args : list of NDArray or dict of str to NDArray
Input arguments to the symbols.
If type is list of ND... | [
"Helper",
"function",
"to",
"get",
"NDArray",
"lists",
"handles",
"from",
"various",
"inputs",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1316-L1372 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.simple_bind | def simple_bind(self, ctx, grad_req='write', type_dict=None, stype_dict=None,
group2ctx=None, shared_arg_names=None, shared_exec=None,
shared_buffer=None, **kwargs):
"""Bind current symbol to get an executor, allocate all the arguments needed.
Allows specifying da... | python | def simple_bind(self, ctx, grad_req='write', type_dict=None, stype_dict=None,
group2ctx=None, shared_arg_names=None, shared_exec=None,
shared_buffer=None, **kwargs):
"""Bind current symbol to get an executor, allocate all the arguments needed.
Allows specifying da... | [
"def",
"simple_bind",
"(",
"self",
",",
"ctx",
",",
"grad_req",
"=",
"'write'",
",",
"type_dict",
"=",
"None",
",",
"stype_dict",
"=",
"None",
",",
"group2ctx",
"=",
"None",
",",
"shared_arg_names",
"=",
"None",
",",
"shared_exec",
"=",
"None",
",",
"sha... | Bind current symbol to get an executor, allocate all the arguments needed.
Allows specifying data types.
This function simplifies the binding procedure. You need to specify only input data shapes.
Before binding the executor, the function allocates arguments and auxiliary states
that we... | [
"Bind",
"current",
"symbol",
"to",
"get",
"an",
"executor",
"allocate",
"all",
"the",
"arguments",
"needed",
".",
"Allows",
"specifying",
"data",
"types",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1375-L1637 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.bind | def bind(self, ctx, args, args_grad=None, grad_req='write',
aux_states=None, group2ctx=None, shared_exec=None):
"""Binds the current symbol to an executor and returns it.
We first declare the computation and then bind to the data to run.
This function returns an executor which prov... | python | def bind(self, ctx, args, args_grad=None, grad_req='write',
aux_states=None, group2ctx=None, shared_exec=None):
"""Binds the current symbol to an executor and returns it.
We first declare the computation and then bind to the data to run.
This function returns an executor which prov... | [
"def",
"bind",
"(",
"self",
",",
"ctx",
",",
"args",
",",
"args_grad",
"=",
"None",
",",
"grad_req",
"=",
"'write'",
",",
"aux_states",
"=",
"None",
",",
"group2ctx",
"=",
"None",
",",
"shared_exec",
"=",
"None",
")",
":",
"# pylint: disable=too-many-local... | Binds the current symbol to an executor and returns it.
We first declare the computation and then bind to the data to run.
This function returns an executor which provides method `forward()` method for evaluation
and a `outputs()` method to get all the results.
Example
-------
... | [
"Binds",
"the",
"current",
"symbol",
"to",
"an",
"executor",
"and",
"returns",
"it",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1639-L1795 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.gradient | def gradient(self, wrt):
"""Gets the autodiff of current symbol.
This function can only be used if current symbol is a loss function.
.. note:: This function is currently not implemented.
Parameters
----------
wrt : Array of String
keyword arguments of the ... | python | def gradient(self, wrt):
"""Gets the autodiff of current symbol.
This function can only be used if current symbol is a loss function.
.. note:: This function is currently not implemented.
Parameters
----------
wrt : Array of String
keyword arguments of the ... | [
"def",
"gradient",
"(",
"self",
",",
"wrt",
")",
":",
"handle",
"=",
"SymbolHandle",
"(",
")",
"c_wrt",
"=",
"c_str_array",
"(",
"wrt",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolGrad",
"(",
"self",
".",
"handle",
",",
"mx_uint",
"(",
"len",
"(",
... | Gets the autodiff of current symbol.
This function can only be used if current symbol is a loss function.
.. note:: This function is currently not implemented.
Parameters
----------
wrt : Array of String
keyword arguments of the symbol that the gradients are taken.... | [
"Gets",
"the",
"autodiff",
"of",
"current",
"symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1797-L1820 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.eval | def eval(self, ctx=None, **kwargs):
"""Evaluates a symbol given arguments.
The `eval` method combines a call to `bind` (which returns an executor)
with a call to `forward` (executor method).
For the common use case, where you might repeatedly evaluate with same arguments,
eval i... | python | def eval(self, ctx=None, **kwargs):
"""Evaluates a symbol given arguments.
The `eval` method combines a call to `bind` (which returns an executor)
with a call to `forward` (executor method).
For the common use case, where you might repeatedly evaluate with same arguments,
eval i... | [
"def",
"eval",
"(",
"self",
",",
"ctx",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ctx",
"is",
"None",
":",
"ctx",
"=",
"current_context",
"(",
")",
"return",
"self",
".",
"bind",
"(",
"ctx",
",",
"kwargs",
")",
".",
"forward",
"(",
... | Evaluates a symbol given arguments.
The `eval` method combines a call to `bind` (which returns an executor)
with a call to `forward` (executor method).
For the common use case, where you might repeatedly evaluate with same arguments,
eval is slow.
In that case, you should call `... | [
"Evaluates",
"a",
"symbol",
"given",
"arguments",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1824-L1862 | train |
apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.get_backend_symbol | def get_backend_symbol(self, backend):
"""Return symbol for target backend.
Parameters
----------
backend : str
The backend names.
Returns
-------
out : Symbol
The created Symbol for target backend.
"""
out = SymbolHandle(... | python | def get_backend_symbol(self, backend):
"""Return symbol for target backend.
Parameters
----------
backend : str
The backend names.
Returns
-------
out : Symbol
The created Symbol for target backend.
"""
out = SymbolHandle(... | [
"def",
"get_backend_symbol",
"(",
"self",
",",
"backend",
")",
":",
"out",
"=",
"SymbolHandle",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXGenBackendSubgraph",
"(",
"self",
".",
"handle",
",",
"c_str",
"(",
"backend",
")",
",",
"ctypes",
".",
"byref",
... | Return symbol for target backend.
Parameters
----------
backend : str
The backend names.
Returns
-------
out : Symbol
The created Symbol for target backend. | [
"Return",
"symbol",
"for",
"target",
"backend",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L2536-L2551 | train |
apache/incubator-mxnet | python/mxnet/gluon/contrib/nn/basic_layers.py | PixelShuffle1D.hybrid_forward | def hybrid_forward(self, F, x):
"""Perform pixel-shuffling on the input."""
f = self._factor
# (N, C*f, W)
x = F.reshape(x, (0, -4, -1, f, 0)) # (N, C, f, W)
x = F.transpose(x, (0, 1, 3, 2)) # (N, C, W, f)
x = F.reshape(x, (0, 0, ... | python | def hybrid_forward(self, F, x):
"""Perform pixel-shuffling on the input."""
f = self._factor
# (N, C*f, W)
x = F.reshape(x, (0, -4, -1, f, 0)) # (N, C, f, W)
x = F.transpose(x, (0, 1, 3, 2)) # (N, C, W, f)
x = F.reshape(x, (0, 0, ... | [
"def",
"hybrid_forward",
"(",
"self",
",",
"F",
",",
"x",
")",
":",
"f",
"=",
"self",
".",
"_factor",
"# (N, C*f, W)",
"x",
"=",
"F",
".",
"reshape",
"(",
"x",
",",
"(",
"0",
",",
"-",
"4",
",",
"-",
"1",
",",
"f",
",",
"0",
")",
")",
"# (N... | Perform pixel-shuffling on the input. | [
"Perform",
"pixel",
"-",
"shuffling",
"on",
"the",
"input",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/contrib/nn/basic_layers.py#L279-L286 | train |
apache/incubator-mxnet | python/mxnet/gluon/contrib/nn/basic_layers.py | PixelShuffle2D.hybrid_forward | def hybrid_forward(self, F, x):
"""Perform pixel-shuffling on the input."""
f1, f2 = self._factors
# (N, f1*f2*C, H, W)
x = F.reshape(x, (0, -4, -1, f1 * f2, 0, 0)) # (N, C, f1*f2, H, W)
x = F.reshape(x, (0, 0, -4, f1, f2, 0, 0)) ... | python | def hybrid_forward(self, F, x):
"""Perform pixel-shuffling on the input."""
f1, f2 = self._factors
# (N, f1*f2*C, H, W)
x = F.reshape(x, (0, -4, -1, f1 * f2, 0, 0)) # (N, C, f1*f2, H, W)
x = F.reshape(x, (0, 0, -4, f1, f2, 0, 0)) ... | [
"def",
"hybrid_forward",
"(",
"self",
",",
"F",
",",
"x",
")",
":",
"f1",
",",
"f2",
"=",
"self",
".",
"_factors",
"# (N, f1*f2*C, H, W)",
"x",
"=",
"F",
".",
"reshape",
"(",
"x",
",",
"(",
"0",
",",
"-",
"4",
",",
"-",
"1",
",",
"f1",
"*",
"... | Perform pixel-shuffling on the input. | [
"Perform",
"pixel",
"-",
"shuffling",
"on",
"the",
"input",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/contrib/nn/basic_layers.py#L340-L348 | train |
apache/incubator-mxnet | python/mxnet/gluon/contrib/nn/basic_layers.py | PixelShuffle3D.hybrid_forward | def hybrid_forward(self, F, x):
"""Perform pixel-shuffling on the input."""
# `transpose` doesn't support 8D, need other implementation
f1, f2, f3 = self._factors
# (N, C*f1*f2*f3, D, H, W)
x = F.reshape(x, (0, -4, -1, f1 * f2... | python | def hybrid_forward(self, F, x):
"""Perform pixel-shuffling on the input."""
# `transpose` doesn't support 8D, need other implementation
f1, f2, f3 = self._factors
# (N, C*f1*f2*f3, D, H, W)
x = F.reshape(x, (0, -4, -1, f1 * f2... | [
"def",
"hybrid_forward",
"(",
"self",
",",
"F",
",",
"x",
")",
":",
"# `transpose` doesn't support 8D, need other implementation",
"f1",
",",
"f2",
",",
"f3",
"=",
"self",
".",
"_factors",
"# (N, C*f1*f2*f3, D, H, W)",
"x",
"=",
"F",
".",
"reshape",
"(",
"x",
... | Perform pixel-shuffling on the input. | [
"Perform",
"pixel",
"-",
"shuffling",
"on",
"the",
"input",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/contrib/nn/basic_layers.py#L402-L416 | train |
apache/incubator-mxnet | ci/util.py | retry | def retry(target_exception, tries=4, delay_s=1, backoff=2):
"""Retry calling the decorated function using an exponential backoff.
http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/
original from: http://wiki.python.org/moin/PythonDecoratorLibrary#Retry
:param target_exception: t... | python | def retry(target_exception, tries=4, delay_s=1, backoff=2):
"""Retry calling the decorated function using an exponential backoff.
http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/
original from: http://wiki.python.org/moin/PythonDecoratorLibrary#Retry
:param target_exception: t... | [
"def",
"retry",
"(",
"target_exception",
",",
"tries",
"=",
"4",
",",
"delay_s",
"=",
"1",
",",
"backoff",
"=",
"2",
")",
":",
"import",
"time",
"from",
"functools",
"import",
"wraps",
"def",
"decorated_retry",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
... | Retry calling the decorated function using an exponential backoff.
http://www.saltycrane.com/blog/2009/11/trying-out-retry-decorator-python/
original from: http://wiki.python.org/moin/PythonDecoratorLibrary#Retry
:param target_exception: the exception to check. may be a tuple of
exceptions to chec... | [
"Retry",
"calling",
"the",
"decorated",
"function",
"using",
"an",
"exponential",
"backoff",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/util.py#L45-L81 | train |
apache/incubator-mxnet | tools/coreml/converter/utils.py | load_model | def load_model(model_name, epoch_num, data_shapes, label_shapes, label_names, gpus=''):
"""Returns a module loaded with the provided model.
Parameters
----------
model_name: str
Prefix of the MXNet model name as stored on the local directory.
epoch_num : int
Epoch number of model w... | python | def load_model(model_name, epoch_num, data_shapes, label_shapes, label_names, gpus=''):
"""Returns a module loaded with the provided model.
Parameters
----------
model_name: str
Prefix of the MXNet model name as stored on the local directory.
epoch_num : int
Epoch number of model w... | [
"def",
"load_model",
"(",
"model_name",
",",
"epoch_num",
",",
"data_shapes",
",",
"label_shapes",
",",
"label_names",
",",
"gpus",
"=",
"''",
")",
":",
"sym",
",",
"arg_params",
",",
"aux_params",
"=",
"mx",
".",
"model",
".",
"load_checkpoint",
"(",
"mod... | Returns a module loaded with the provided model.
Parameters
----------
model_name: str
Prefix of the MXNet model name as stored on the local directory.
epoch_num : int
Epoch number of model we would like to load.
input_shape: tuple
The shape of the input data in the form o... | [
"Returns",
"a",
"module",
"loaded",
"with",
"the",
"provided",
"model",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/utils.py#L21-L65 | train |
apache/incubator-mxnet | tools/coreml/converter/utils.py | create_module | def create_module(sym, data_shapes, label_shapes, label_names, gpus=''):
"""Creates a new MXNet module.
Parameters
----------
sym : Symbol
An MXNet symbol.
input_shape: tuple
The shape of the input data in the form of (batch_size, channels, height, width)
files: list of string... | python | def create_module(sym, data_shapes, label_shapes, label_names, gpus=''):
"""Creates a new MXNet module.
Parameters
----------
sym : Symbol
An MXNet symbol.
input_shape: tuple
The shape of the input data in the form of (batch_size, channels, height, width)
files: list of string... | [
"def",
"create_module",
"(",
"sym",
",",
"data_shapes",
",",
"label_shapes",
",",
"label_names",
",",
"gpus",
"=",
"''",
")",
":",
"if",
"gpus",
"==",
"''",
":",
"devices",
"=",
"mx",
".",
"cpu",
"(",
")",
"else",
":",
"devices",
"=",
"[",
"mx",
".... | Creates a new MXNet module.
Parameters
----------
sym : Symbol
An MXNet symbol.
input_shape: tuple
The shape of the input data in the form of (batch_size, channels, height, width)
files: list of strings
List of URLs pertaining to files that need to be downloaded in order t... | [
"Creates",
"a",
"new",
"MXNet",
"module",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/utils.py#L68-L117 | train |
apache/incubator-mxnet | example/ssd/evaluate/evaluate_net.py | evaluate_net | def evaluate_net(net, path_imgrec, num_classes, num_batch, mean_pixels, data_shape,
model_prefix, epoch, ctx=mx.cpu(), batch_size=32,
path_imglist="", nms_thresh=0.45, force_nms=False,
ovp_thresh=0.5, use_difficult=False, class_names=None,
voc07_metric... | python | def evaluate_net(net, path_imgrec, num_classes, num_batch, mean_pixels, data_shape,
model_prefix, epoch, ctx=mx.cpu(), batch_size=32,
path_imglist="", nms_thresh=0.45, force_nms=False,
ovp_thresh=0.5, use_difficult=False, class_names=None,
voc07_metric... | [
"def",
"evaluate_net",
"(",
"net",
",",
"path_imgrec",
",",
"num_classes",
",",
"num_batch",
",",
"mean_pixels",
",",
"data_shape",
",",
"model_prefix",
",",
"epoch",
",",
"ctx",
"=",
"mx",
".",
"cpu",
"(",
")",
",",
"batch_size",
"=",
"32",
",",
"path_i... | evalute network given validation record file
Parameters:
----------
net : str or None
Network name or use None to load from json without modifying
path_imgrec : str
path to the record validation file
path_imglist : str
path to the list file to replace labels in record file, ... | [
"evalute",
"network",
"given",
"validation",
"record",
"file"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/evaluate/evaluate_net.py#L34-L133 | train |
apache/incubator-mxnet | python/mxnet/module/python_module.py | PythonModule.init_params | def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None,
allow_missing=False, force_init=False, allow_extra=False):
"""Initializes the parameters and auxiliary states. By default this function
does nothing. Subclass should override this method if contains pa... | python | def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None,
allow_missing=False, force_init=False, allow_extra=False):
"""Initializes the parameters and auxiliary states. By default this function
does nothing. Subclass should override this method if contains pa... | [
"def",
"init_params",
"(",
"self",
",",
"initializer",
"=",
"Uniform",
"(",
"0.01",
")",
",",
"arg_params",
"=",
"None",
",",
"aux_params",
"=",
"None",
",",
"allow_missing",
"=",
"False",
",",
"force_init",
"=",
"False",
",",
"allow_extra",
"=",
"False",
... | Initializes the parameters and auxiliary states. By default this function
does nothing. Subclass should override this method if contains parameters.
Parameters
----------
initializer : Initializer
Called to initialize parameters if needed.
arg_params : dict
... | [
"Initializes",
"the",
"parameters",
"and",
"auxiliary",
"states",
".",
"By",
"default",
"this",
"function",
"does",
"nothing",
".",
"Subclass",
"should",
"override",
"this",
"method",
"if",
"contains",
"parameters",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/python_module.py#L107-L132 | train |
apache/incubator-mxnet | python/mxnet/module/python_module.py | PythonModule.update_metric | def update_metric(self, eval_metric, labels, pre_sliced=False):
"""Evaluates and accumulates evaluation metric on outputs of the last forward computation.
Subclass should override this method if needed.
Parameters
----------
eval_metric : EvalMetric
labels : list of NDAr... | python | def update_metric(self, eval_metric, labels, pre_sliced=False):
"""Evaluates and accumulates evaluation metric on outputs of the last forward computation.
Subclass should override this method if needed.
Parameters
----------
eval_metric : EvalMetric
labels : list of NDAr... | [
"def",
"update_metric",
"(",
"self",
",",
"eval_metric",
",",
"labels",
",",
"pre_sliced",
"=",
"False",
")",
":",
"if",
"self",
".",
"_label_shapes",
"is",
"None",
":",
"# since we do not need labels, we are probably not a module with a loss",
"# function or predictions,... | Evaluates and accumulates evaluation metric on outputs of the last forward computation.
Subclass should override this method if needed.
Parameters
----------
eval_metric : EvalMetric
labels : list of NDArray
Typically ``data_batch.label``. | [
"Evaluates",
"and",
"accumulates",
"evaluation",
"metric",
"on",
"outputs",
"of",
"the",
"last",
"forward",
"computation",
".",
"Subclass",
"should",
"override",
"this",
"method",
"if",
"needed",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/python_module.py#L141-L160 | train |
apache/incubator-mxnet | python/mxnet/module/python_module.py | PythonModule.bind | def bind(self, data_shapes, label_shapes=None, for_training=True,
inputs_need_grad=False, force_rebind=False, shared_module=None,
grad_req='write'):
"""Binds the symbols to construct executors. This is necessary before one
can perform computation with the module.
Param... | python | def bind(self, data_shapes, label_shapes=None, for_training=True,
inputs_need_grad=False, force_rebind=False, shared_module=None,
grad_req='write'):
"""Binds the symbols to construct executors. This is necessary before one
can perform computation with the module.
Param... | [
"def",
"bind",
"(",
"self",
",",
"data_shapes",
",",
"label_shapes",
"=",
"None",
",",
"for_training",
"=",
"True",
",",
"inputs_need_grad",
"=",
"False",
",",
"force_rebind",
"=",
"False",
",",
"shared_module",
"=",
"None",
",",
"grad_req",
"=",
"'write'",
... | Binds the symbols to construct executors. This is necessary before one
can perform computation with the module.
Parameters
----------
data_shapes : list of (str, tuple)
Typically is ``data_iter.provide_data``.
label_shapes : list of (str, tuple)
Typically... | [
"Binds",
"the",
"symbols",
"to",
"construct",
"executors",
".",
"This",
"is",
"necessary",
"before",
"one",
"can",
"perform",
"computation",
"with",
"the",
"module",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/python_module.py#L165-L213 | train |
apache/incubator-mxnet | python/mxnet/module/python_module.py | PythonLossModule.forward | def forward(self, data_batch, is_train=None):
"""Forward computation. Here we do nothing but to keep a reference to
the scores and the labels so that we can do backward computation.
Parameters
----------
data_batch : DataBatch
Could be anything with similar API imple... | python | def forward(self, data_batch, is_train=None):
"""Forward computation. Here we do nothing but to keep a reference to
the scores and the labels so that we can do backward computation.
Parameters
----------
data_batch : DataBatch
Could be anything with similar API imple... | [
"def",
"forward",
"(",
"self",
",",
"data_batch",
",",
"is_train",
"=",
"None",
")",
":",
"self",
".",
"_scores",
"=",
"data_batch",
".",
"data",
"[",
"0",
"]",
"if",
"is_train",
"is",
"None",
":",
"is_train",
"=",
"self",
".",
"for_training",
"if",
... | Forward computation. Here we do nothing but to keep a reference to
the scores and the labels so that we can do backward computation.
Parameters
----------
data_batch : DataBatch
Could be anything with similar API implemented.
is_train : bool
Default is ``... | [
"Forward",
"computation",
".",
"Here",
"we",
"do",
"nothing",
"but",
"to",
"keep",
"a",
"reference",
"to",
"the",
"scores",
"and",
"the",
"labels",
"so",
"that",
"we",
"can",
"do",
"backward",
"computation",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/python_module.py#L285-L302 | train |
apache/incubator-mxnet | python/mxnet/module/python_module.py | PythonLossModule._backward_impl | def _backward_impl(self):
"""Actual implementation of the backward computation. The computation
should take ``self._scores`` and ``self._labels`` and then compute the
gradients with respect to the scores, store it as an `NDArray` in
``self._scores_grad``.
Instead of defining a s... | python | def _backward_impl(self):
"""Actual implementation of the backward computation. The computation
should take ``self._scores`` and ``self._labels`` and then compute the
gradients with respect to the scores, store it as an `NDArray` in
``self._scores_grad``.
Instead of defining a s... | [
"def",
"_backward_impl",
"(",
"self",
")",
":",
"if",
"self",
".",
"_grad_func",
"is",
"not",
"None",
":",
"grad",
"=",
"self",
".",
"_grad_func",
"(",
"self",
".",
"_scores",
",",
"self",
".",
"_labels",
")",
"if",
"not",
"isinstance",
"(",
"grad",
... | Actual implementation of the backward computation. The computation
should take ``self._scores`` and ``self._labels`` and then compute the
gradients with respect to the scores, store it as an `NDArray` in
``self._scores_grad``.
Instead of defining a subclass and overriding this function,... | [
"Actual",
"implementation",
"of",
"the",
"backward",
"computation",
".",
"The",
"computation",
"should",
"take",
"self",
".",
"_scores",
"and",
"self",
".",
"_labels",
"and",
"then",
"compute",
"the",
"gradients",
"with",
"respect",
"to",
"the",
"scores",
"sto... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/python_module.py#L331-L347 | train |
apache/incubator-mxnet | python/mxnet/rnn/io.py | encode_sentences | def encode_sentences(sentences, vocab=None, invalid_label=-1, invalid_key='\n',
start_label=0, unknown_token=None):
"""Encode sentences and (optionally) build a mapping
from string tokens to integer indices. Unknown keys
will be added to vocabulary.
Parameters
----------
se... | python | def encode_sentences(sentences, vocab=None, invalid_label=-1, invalid_key='\n',
start_label=0, unknown_token=None):
"""Encode sentences and (optionally) build a mapping
from string tokens to integer indices. Unknown keys
will be added to vocabulary.
Parameters
----------
se... | [
"def",
"encode_sentences",
"(",
"sentences",
",",
"vocab",
"=",
"None",
",",
"invalid_label",
"=",
"-",
"1",
",",
"invalid_key",
"=",
"'\\n'",
",",
"start_label",
"=",
"0",
",",
"unknown_token",
"=",
"None",
")",
":",
"idx",
"=",
"start_label",
"if",
"vo... | Encode sentences and (optionally) build a mapping
from string tokens to integer indices. Unknown keys
will be added to vocabulary.
Parameters
----------
sentences : list of list of str
A list of sentences to encode. Each sentence
should be a list of string tokens.
vocab : None o... | [
"Encode",
"sentences",
"and",
"(",
"optionally",
")",
"build",
"a",
"mapping",
"from",
"string",
"tokens",
"to",
"integer",
"indices",
".",
"Unknown",
"keys",
"will",
"be",
"added",
"to",
"vocabulary",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/io.py#L30-L82 | train |
apache/incubator-mxnet | python/mxnet/rnn/io.py | BucketSentenceIter.reset | def reset(self):
"""Resets the iterator to the beginning of the data."""
self.curr_idx = 0
random.shuffle(self.idx)
for buck in self.data:
np.random.shuffle(buck)
self.nddata = []
self.ndlabel = []
for buck in self.data:
label = np.empty_l... | python | def reset(self):
"""Resets the iterator to the beginning of the data."""
self.curr_idx = 0
random.shuffle(self.idx)
for buck in self.data:
np.random.shuffle(buck)
self.nddata = []
self.ndlabel = []
for buck in self.data:
label = np.empty_l... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"curr_idx",
"=",
"0",
"random",
".",
"shuffle",
"(",
"self",
".",
"idx",
")",
"for",
"buck",
"in",
"self",
".",
"data",
":",
"np",
".",
"random",
".",
"shuffle",
"(",
"buck",
")",
"self",
".",
... | Resets the iterator to the beginning of the data. | [
"Resets",
"the",
"iterator",
"to",
"the",
"beginning",
"of",
"the",
"data",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/io.py#L174-L188 | train |
apache/incubator-mxnet | python/mxnet/rnn/io.py | BucketSentenceIter.next | def next(self):
"""Returns the next batch of data."""
if self.curr_idx == len(self.idx):
raise StopIteration
i, j = self.idx[self.curr_idx]
self.curr_idx += 1
if self.major_axis == 1:
data = self.nddata[i][j:j+self.batch_size].T
label = self.n... | python | def next(self):
"""Returns the next batch of data."""
if self.curr_idx == len(self.idx):
raise StopIteration
i, j = self.idx[self.curr_idx]
self.curr_idx += 1
if self.major_axis == 1:
data = self.nddata[i][j:j+self.batch_size].T
label = self.n... | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"curr_idx",
"==",
"len",
"(",
"self",
".",
"idx",
")",
":",
"raise",
"StopIteration",
"i",
",",
"j",
"=",
"self",
".",
"idx",
"[",
"self",
".",
"curr_idx",
"]",
"self",
".",
"curr_idx",
"+=... | Returns the next batch of data. | [
"Returns",
"the",
"next",
"batch",
"of",
"data",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/io.py#L190-L211 | train |
apache/incubator-mxnet | example/speech_recognition/singleton.py | Singleton.getInstance | def getInstance(self):
"""
Returns the singleton instance. Upon its first call, it creates a
new instance of the decorated class and calls its `__init__` method.
On all subsequent calls, the already created instance is returned.
"""
try:
return self._instance... | python | def getInstance(self):
"""
Returns the singleton instance. Upon its first call, it creates a
new instance of the decorated class and calls its `__init__` method.
On all subsequent calls, the already created instance is returned.
"""
try:
return self._instance... | [
"def",
"getInstance",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"_instance",
"except",
"AttributeError",
":",
"self",
".",
"_instance",
"=",
"self",
".",
"_decorated",
"(",
")",
"return",
"self",
".",
"_instance"
] | Returns the singleton instance. Upon its first call, it creates a
new instance of the decorated class and calls its `__init__` method.
On all subsequent calls, the already created instance is returned. | [
"Returns",
"the",
"singleton",
"instance",
".",
"Upon",
"its",
"first",
"call",
"it",
"creates",
"a",
"new",
"instance",
"of",
"the",
"decorated",
"class",
"and",
"calls",
"its",
"__init__",
"method",
".",
"On",
"all",
"subsequent",
"calls",
"the",
"already"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/speech_recognition/singleton.py#L41-L52 | train |
apache/incubator-mxnet | example/gluon/lipnet/infer.py | main | def main():
"""
Description : run lipnet training code using argument info
"""
parser = argparse.ArgumentParser()
parser.add_argument('--batch_size', type=int, default=64)
parser.add_argument('--image_path', type=str, default='./data/datasets/')
parser.add_argument('--align_path', type=str, ... | python | def main():
"""
Description : run lipnet training code using argument info
"""
parser = argparse.ArgumentParser()
parser.add_argument('--batch_size', type=int, default=64)
parser.add_argument('--image_path', type=str, default='./data/datasets/')
parser.add_argument('--align_path', type=str, ... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'--batch_size'",
",",
"type",
"=",
"int",
",",
"default",
"=",
"64",
")",
"parser",
".",
"add_argument",
"(",
"'--image_path'",
... | Description : run lipnet training code using argument info | [
"Description",
":",
"run",
"lipnet",
"training",
"code",
"using",
"argument",
"info"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/infer.py#L26-L48 | train |
apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | RNNParams.get | def get(self, name, **kwargs):
"""Get the variable given a name if one exists or create a new one if missing.
Parameters
----------
name : str
name of the variable
**kwargs :
more arguments that's passed to symbol.Variable
"""
name = self.... | python | def get(self, name, **kwargs):
"""Get the variable given a name if one exists or create a new one if missing.
Parameters
----------
name : str
name of the variable
**kwargs :
more arguments that's passed to symbol.Variable
"""
name = self.... | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
"=",
"self",
".",
"_prefix",
"+",
"name",
"if",
"name",
"not",
"in",
"self",
".",
"_params",
":",
"self",
".",
"_params",
"[",
"name",
"]",
"=",
"symbol",
".",
"... | Get the variable given a name if one exists or create a new one if missing.
Parameters
----------
name : str
name of the variable
**kwargs :
more arguments that's passed to symbol.Variable | [
"Get",
"the",
"variable",
"given",
"a",
"name",
"if",
"one",
"exists",
"or",
"create",
"a",
"new",
"one",
"if",
"missing",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L92-L105 | train |
apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | BaseRNNCell.reset | def reset(self):
"""Reset before re-using the cell for another graph."""
self._init_counter = -1
self._counter = -1
if hasattr(self, '_cells'):
for cell in self._cells:
cell.reset() | python | def reset(self):
"""Reset before re-using the cell for another graph."""
self._init_counter = -1
self._counter = -1
if hasattr(self, '_cells'):
for cell in self._cells:
cell.reset() | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"_init_counter",
"=",
"-",
"1",
"self",
".",
"_counter",
"=",
"-",
"1",
"if",
"hasattr",
"(",
"self",
",",
"'_cells'",
")",
":",
"for",
"cell",
"in",
"self",
".",
"_cells",
":",
"cell",
".",
"re... | Reset before re-using the cell for another graph. | [
"Reset",
"before",
"re",
"-",
"using",
"the",
"cell",
"for",
"another",
"graph",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L133-L139 | train |
apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | BaseRNNCell.begin_state | def begin_state(self, func=symbol.zeros, **kwargs):
"""Initial state for this cell.
Parameters
----------
func : callable, default symbol.zeros
Function for creating initial state. Can be symbol.zeros,
symbol.uniform, symbol.Variable etc.
Use symbol.V... | python | def begin_state(self, func=symbol.zeros, **kwargs):
"""Initial state for this cell.
Parameters
----------
func : callable, default symbol.zeros
Function for creating initial state. Can be symbol.zeros,
symbol.uniform, symbol.Variable etc.
Use symbol.V... | [
"def",
"begin_state",
"(",
"self",
",",
"func",
"=",
"symbol",
".",
"zeros",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"not",
"self",
".",
"_modified",
",",
"\"After applying modifier cells (e.g. DropoutCell) the base \"",
"\"cell cannot be called directly. Call the ... | Initial state for this cell.
Parameters
----------
func : callable, default symbol.zeros
Function for creating initial state. Can be symbol.zeros,
symbol.uniform, symbol.Variable etc.
Use symbol.Variable if you want to directly
feed input as state... | [
"Initial",
"state",
"for",
"this",
"cell",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L190-L223 | train |
apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | BaseRNNCell.unpack_weights | def unpack_weights(self, args):
"""Unpack fused weight matrices into separate
weight matrices.
For example, say you use a module object `mod` to run a network that has an lstm cell.
In `mod.get_params()[0]`, the lstm parameters are all represented as a single big vector.
`cell.u... | python | def unpack_weights(self, args):
"""Unpack fused weight matrices into separate
weight matrices.
For example, say you use a module object `mod` to run a network that has an lstm cell.
In `mod.get_params()[0]`, the lstm parameters are all represented as a single big vector.
`cell.u... | [
"def",
"unpack_weights",
"(",
"self",
",",
"args",
")",
":",
"args",
"=",
"args",
".",
"copy",
"(",
")",
"if",
"not",
"self",
".",
"_gate_names",
":",
"return",
"args",
"h",
"=",
"self",
".",
"_num_hidden",
"for",
"group_name",
"in",
"[",
"'i2h'",
",... | Unpack fused weight matrices into separate
weight matrices.
For example, say you use a module object `mod` to run a network that has an lstm cell.
In `mod.get_params()[0]`, the lstm parameters are all represented as a single big vector.
`cell.unpack_weights(mod.get_params()[0])` will un... | [
"Unpack",
"fused",
"weight",
"matrices",
"into",
"separate",
"weight",
"matrices",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L225-L263 | train |
apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | BaseRNNCell.pack_weights | def pack_weights(self, args):
"""Pack separate weight matrices into a single packed
weight.
Parameters
----------
args : dict of str -> NDArray
Dictionary containing unpacked weights.
Returns
-------
args : dict of str -> NDArray
... | python | def pack_weights(self, args):
"""Pack separate weight matrices into a single packed
weight.
Parameters
----------
args : dict of str -> NDArray
Dictionary containing unpacked weights.
Returns
-------
args : dict of str -> NDArray
... | [
"def",
"pack_weights",
"(",
"self",
",",
"args",
")",
":",
"args",
"=",
"args",
".",
"copy",
"(",
")",
"if",
"not",
"self",
".",
"_gate_names",
":",
"return",
"args",
"for",
"group_name",
"in",
"[",
"'i2h'",
",",
"'h2h'",
"]",
":",
"weight",
"=",
"... | Pack separate weight matrices into a single packed
weight.
Parameters
----------
args : dict of str -> NDArray
Dictionary containing unpacked weights.
Returns
-------
args : dict of str -> NDArray
Dictionary with packed weights associated... | [
"Pack",
"separate",
"weight",
"matrices",
"into",
"a",
"single",
"packed",
"weight",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L265-L293 | train |
apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | BaseRNNCell.unroll | def unroll(self, length, inputs, begin_state=None, layout='NTC', merge_outputs=None):
"""Unroll an RNN cell across time steps.
Parameters
----------
length : int
Number of steps to unroll.
inputs : Symbol, list of Symbol, or None
If `inputs` is a single S... | python | def unroll(self, length, inputs, begin_state=None, layout='NTC', merge_outputs=None):
"""Unroll an RNN cell across time steps.
Parameters
----------
length : int
Number of steps to unroll.
inputs : Symbol, list of Symbol, or None
If `inputs` is a single S... | [
"def",
"unroll",
"(",
"self",
",",
"length",
",",
"inputs",
",",
"begin_state",
"=",
"None",
",",
"layout",
"=",
"'NTC'",
",",
"merge_outputs",
"=",
"None",
")",
":",
"self",
".",
"reset",
"(",
")",
"inputs",
",",
"_",
"=",
"_normalize_sequence",
"(",
... | Unroll an RNN cell across time steps.
Parameters
----------
length : int
Number of steps to unroll.
inputs : Symbol, list of Symbol, or None
If `inputs` is a single Symbol (usually the output
of Embedding symbol), it should have shape
(bat... | [
"Unroll",
"an",
"RNN",
"cell",
"across",
"time",
"steps",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L295-L351 | train |
apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | BaseRNNCell._get_activation | def _get_activation(self, inputs, activation, **kwargs):
"""Get activation function. Convert if is string"""
if isinstance(activation, string_types):
return symbol.Activation(inputs, act_type=activation, **kwargs)
else:
return activation(inputs, **kwargs) | python | def _get_activation(self, inputs, activation, **kwargs):
"""Get activation function. Convert if is string"""
if isinstance(activation, string_types):
return symbol.Activation(inputs, act_type=activation, **kwargs)
else:
return activation(inputs, **kwargs) | [
"def",
"_get_activation",
"(",
"self",
",",
"inputs",
",",
"activation",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"activation",
",",
"string_types",
")",
":",
"return",
"symbol",
".",
"Activation",
"(",
"inputs",
",",
"act_type",
"=",
... | Get activation function. Convert if is string | [
"Get",
"activation",
"function",
".",
"Convert",
"if",
"is",
"string"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L354-L359 | train |
apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | FusedRNNCell._slice_weights | def _slice_weights(self, arr, li, lh):
"""slice fused rnn weights"""
args = {}
gate_names = self._gate_names
directions = self._directions
b = len(directions)
p = 0
for layer in range(self._num_layers):
for direction in directions:
for... | python | def _slice_weights(self, arr, li, lh):
"""slice fused rnn weights"""
args = {}
gate_names = self._gate_names
directions = self._directions
b = len(directions)
p = 0
for layer in range(self._num_layers):
for direction in directions:
for... | [
"def",
"_slice_weights",
"(",
"self",
",",
"arr",
",",
"li",
",",
"lh",
")",
":",
"args",
"=",
"{",
"}",
"gate_names",
"=",
"self",
".",
"_gate_names",
"directions",
"=",
"self",
".",
"_directions",
"b",
"=",
"len",
"(",
"directions",
")",
"p",
"=",
... | slice fused rnn weights | [
"slice",
"fused",
"rnn",
"weights"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L600-L637 | train |
apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | FusedRNNCell.unfuse | def unfuse(self):
"""Unfuse the fused RNN in to a stack of rnn cells.
Returns
-------
cell : mxnet.rnn.SequentialRNNCell
unfused cell that can be used for stepping, and can run on CPU.
"""
stack = SequentialRNNCell()
get_cell = {'rnn_relu': lambda cel... | python | def unfuse(self):
"""Unfuse the fused RNN in to a stack of rnn cells.
Returns
-------
cell : mxnet.rnn.SequentialRNNCell
unfused cell that can be used for stepping, and can run on CPU.
"""
stack = SequentialRNNCell()
get_cell = {'rnn_relu': lambda cel... | [
"def",
"unfuse",
"(",
"self",
")",
":",
"stack",
"=",
"SequentialRNNCell",
"(",
")",
"get_cell",
"=",
"{",
"'rnn_relu'",
":",
"lambda",
"cell_prefix",
":",
"RNNCell",
"(",
"self",
".",
"_num_hidden",
",",
"activation",
"=",
"'relu'",
",",
"prefix",
"=",
... | Unfuse the fused RNN in to a stack of rnn cells.
Returns
-------
cell : mxnet.rnn.SequentialRNNCell
unfused cell that can be used for stepping, and can run on CPU. | [
"Unfuse",
"the",
"fused",
"RNN",
"in",
"to",
"a",
"stack",
"of",
"rnn",
"cells",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L714-L745 | train |
apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | SequentialRNNCell.add | def add(self, cell):
"""Append a cell into the stack.
Parameters
----------
cell : BaseRNNCell
The cell to be appended. During unroll, previous cell's output (or raw inputs if
no previous cell) is used as the input to this cell.
"""
self._cells.ap... | python | def add(self, cell):
"""Append a cell into the stack.
Parameters
----------
cell : BaseRNNCell
The cell to be appended. During unroll, previous cell's output (or raw inputs if
no previous cell) is used as the input to this cell.
"""
self._cells.ap... | [
"def",
"add",
"(",
"self",
",",
"cell",
")",
":",
"self",
".",
"_cells",
".",
"append",
"(",
"cell",
")",
"if",
"self",
".",
"_override_cell_params",
":",
"assert",
"cell",
".",
"_own_params",
",",
"\"Either specify params for SequentialRNNCell \"",
"\"or child ... | Append a cell into the stack.
Parameters
----------
cell : BaseRNNCell
The cell to be appended. During unroll, previous cell's output (or raw inputs if
no previous cell) is used as the input to this cell. | [
"Append",
"a",
"cell",
"into",
"the",
"stack",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L761-L776 | train |
apache/incubator-mxnet | tools/caffe_converter/compare_layers.py | read_image | def read_image(img_path, image_dims=None, mean=None):
"""
Reads an image from file path or URL, optionally resizing to given image dimensions and
subtracting mean.
:param img_path: path to file, or url to download
:param image_dims: image dimensions to resize to, or None
:param mean: mean file t... | python | def read_image(img_path, image_dims=None, mean=None):
"""
Reads an image from file path or URL, optionally resizing to given image dimensions and
subtracting mean.
:param img_path: path to file, or url to download
:param image_dims: image dimensions to resize to, or None
:param mean: mean file t... | [
"def",
"read_image",
"(",
"img_path",
",",
"image_dims",
"=",
"None",
",",
"mean",
"=",
"None",
")",
":",
"import",
"urllib",
"filename",
"=",
"img_path",
".",
"split",
"(",
"\"/\"",
")",
"[",
"-",
"1",
"]",
"if",
"img_path",
".",
"startswith",
"(",
... | Reads an image from file path or URL, optionally resizing to given image dimensions and
subtracting mean.
:param img_path: path to file, or url to download
:param image_dims: image dimensions to resize to, or None
:param mean: mean file to subtract, or None
:return: loaded image, in RGB format | [
"Reads",
"an",
"image",
"from",
"file",
"path",
"or",
"URL",
"optionally",
"resizing",
"to",
"given",
"image",
"dimensions",
"and",
"subtracting",
"mean",
".",
":",
"param",
"img_path",
":",
"path",
"to",
"file",
"or",
"url",
"to",
"download",
":",
"param"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/compare_layers.py#L32-L63 | train |
apache/incubator-mxnet | tools/caffe_converter/compare_layers.py | _ch_dev | def _ch_dev(arg_params, aux_params, ctx):
"""
Changes device of given mxnet arguments
:param arg_params: arguments
:param aux_params: auxiliary parameters
:param ctx: new device context
:return: arguments and auxiliary parameters on new device
"""
new_args = dict()
new_auxs = dict()
... | python | def _ch_dev(arg_params, aux_params, ctx):
"""
Changes device of given mxnet arguments
:param arg_params: arguments
:param aux_params: auxiliary parameters
:param ctx: new device context
:return: arguments and auxiliary parameters on new device
"""
new_args = dict()
new_auxs = dict()
... | [
"def",
"_ch_dev",
"(",
"arg_params",
",",
"aux_params",
",",
"ctx",
")",
":",
"new_args",
"=",
"dict",
"(",
")",
"new_auxs",
"=",
"dict",
"(",
")",
"for",
"k",
",",
"v",
"in",
"arg_params",
".",
"items",
"(",
")",
":",
"new_args",
"[",
"k",
"]",
... | Changes device of given mxnet arguments
:param arg_params: arguments
:param aux_params: auxiliary parameters
:param ctx: new device context
:return: arguments and auxiliary parameters on new device | [
"Changes",
"device",
"of",
"given",
"mxnet",
"arguments",
":",
"param",
"arg_params",
":",
"arguments",
":",
"param",
"aux_params",
":",
"auxiliary",
"parameters",
":",
"param",
"ctx",
":",
"new",
"device",
"context",
":",
"return",
":",
"arguments",
"and",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/compare_layers.py#L66-L80 | train |
apache/incubator-mxnet | tools/caffe_converter/compare_layers.py | convert_and_compare_caffe_to_mxnet | def convert_and_compare_caffe_to_mxnet(image_url, gpu, caffe_prototxt_path, caffe_model_path,
caffe_mean, mean_diff_allowed, max_diff_allowed):
"""
Run the layer comparison on a caffe model, given its prototxt, weights and mean.
The comparison is done by inferring on a... | python | def convert_and_compare_caffe_to_mxnet(image_url, gpu, caffe_prototxt_path, caffe_model_path,
caffe_mean, mean_diff_allowed, max_diff_allowed):
"""
Run the layer comparison on a caffe model, given its prototxt, weights and mean.
The comparison is done by inferring on a... | [
"def",
"convert_and_compare_caffe_to_mxnet",
"(",
"image_url",
",",
"gpu",
",",
"caffe_prototxt_path",
",",
"caffe_model_path",
",",
"caffe_mean",
",",
"mean_diff_allowed",
",",
"max_diff_allowed",
")",
":",
"import",
"caffe",
"from",
"caffe_proto_utils",
"import",
"rea... | Run the layer comparison on a caffe model, given its prototxt, weights and mean.
The comparison is done by inferring on a given image using both caffe and mxnet model
:param image_url: image file or url to run inference on
:param gpu: gpu to use, -1 for cpu
:param caffe_prototxt_path: path to caffe prot... | [
"Run",
"the",
"layer",
"comparison",
"on",
"a",
"caffe",
"model",
"given",
"its",
"prototxt",
"weights",
"and",
"mean",
".",
"The",
"comparison",
"is",
"done",
"by",
"inferring",
"on",
"a",
"given",
"image",
"using",
"both",
"caffe",
"and",
"mxnet",
"model... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/compare_layers.py#L83-L146 | train |
apache/incubator-mxnet | tools/caffe_converter/compare_layers.py | _bfs | def _bfs(root_node, process_node):
"""
Implementation of Breadth-first search (BFS) on caffe network DAG
:param root_node: root node of caffe network DAG
:param process_node: function to run on each node
"""
from collections import deque
seen_nodes = set()
next_nodes = deque()
see... | python | def _bfs(root_node, process_node):
"""
Implementation of Breadth-first search (BFS) on caffe network DAG
:param root_node: root node of caffe network DAG
:param process_node: function to run on each node
"""
from collections import deque
seen_nodes = set()
next_nodes = deque()
see... | [
"def",
"_bfs",
"(",
"root_node",
",",
"process_node",
")",
":",
"from",
"collections",
"import",
"deque",
"seen_nodes",
"=",
"set",
"(",
")",
"next_nodes",
"=",
"deque",
"(",
")",
"seen_nodes",
".",
"add",
"(",
"root_node",
")",
"next_nodes",
".",
"append"... | Implementation of Breadth-first search (BFS) on caffe network DAG
:param root_node: root node of caffe network DAG
:param process_node: function to run on each node | [
"Implementation",
"of",
"Breadth",
"-",
"first",
"search",
"(",
"BFS",
")",
"on",
"caffe",
"network",
"DAG",
":",
"param",
"root_node",
":",
"root",
"node",
"of",
"caffe",
"network",
"DAG",
":",
"param",
"process_node",
":",
"function",
"to",
"run",
"on",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/compare_layers.py#L149-L173 | train |
apache/incubator-mxnet | tools/caffe_converter/compare_layers.py | compare_layers_from_nets | def compare_layers_from_nets(caffe_net, arg_params, aux_params, exe, layer_name_to_record,
top_to_layers, mean_diff_allowed, max_diff_allowed):
"""
Compare layer by layer of a caffe network with mxnet network
:param caffe_net: loaded caffe network
:param arg_params: argument... | python | def compare_layers_from_nets(caffe_net, arg_params, aux_params, exe, layer_name_to_record,
top_to_layers, mean_diff_allowed, max_diff_allowed):
"""
Compare layer by layer of a caffe network with mxnet network
:param caffe_net: loaded caffe network
:param arg_params: argument... | [
"def",
"compare_layers_from_nets",
"(",
"caffe_net",
",",
"arg_params",
",",
"aux_params",
",",
"exe",
",",
"layer_name_to_record",
",",
"top_to_layers",
",",
"mean_diff_allowed",
",",
"max_diff_allowed",
")",
":",
"import",
"re",
"log_format",
"=",
"' {0:<40} {1:<4... | Compare layer by layer of a caffe network with mxnet network
:param caffe_net: loaded caffe network
:param arg_params: arguments
:param aux_params: auxiliary parameters
:param exe: mxnet model
:param layer_name_to_record: map between caffe layer and information record
:param top_to_layers: map b... | [
"Compare",
"layer",
"by",
"layer",
"of",
"a",
"caffe",
"network",
"with",
"mxnet",
"network",
":",
"param",
"caffe_net",
":",
"loaded",
"caffe",
"network",
":",
"param",
"arg_params",
":",
"arguments",
":",
"param",
"aux_params",
":",
"auxiliary",
"parameters"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/compare_layers.py#L176-L335 | train |
apache/incubator-mxnet | tools/caffe_converter/compare_layers.py | main | def main():
"""Entrypoint for compare_layers"""
parser = argparse.ArgumentParser(
description='Tool for testing caffe to mxnet conversion layer by layer')
parser.add_argument('--image_url', type=str,
default='https://github.com/dmlc/web-data/raw/master/mxnet/doc/'\
... | python | def main():
"""Entrypoint for compare_layers"""
parser = argparse.ArgumentParser(
description='Tool for testing caffe to mxnet conversion layer by layer')
parser.add_argument('--image_url', type=str,
default='https://github.com/dmlc/web-data/raw/master/mxnet/doc/'\
... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Tool for testing caffe to mxnet conversion layer by layer'",
")",
"parser",
".",
"add_argument",
"(",
"'--image_url'",
",",
"type",
"=",
"str",
",",
"default",... | Entrypoint for compare_layers | [
"Entrypoint",
"for",
"compare_layers"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/compare_layers.py#L338-L364 | train |
apache/incubator-mxnet | example/bayesian-methods/utils.py | get_executor | def get_executor(sym, ctx, data_inputs, initializer=None):
"""Get executor to Stochastic Gradient Langevin Dynamics and/or Bayesian Dark Knowledge"""
data_shapes = {k: v.shape for k, v in data_inputs.items()}
arg_names = sym.list_arguments()
aux_names = sym.list_auxiliary_states()
param_names = list... | python | def get_executor(sym, ctx, data_inputs, initializer=None):
"""Get executor to Stochastic Gradient Langevin Dynamics and/or Bayesian Dark Knowledge"""
data_shapes = {k: v.shape for k, v in data_inputs.items()}
arg_names = sym.list_arguments()
aux_names = sym.list_auxiliary_states()
param_names = list... | [
"def",
"get_executor",
"(",
"sym",
",",
"ctx",
",",
"data_inputs",
",",
"initializer",
"=",
"None",
")",
":",
"data_shapes",
"=",
"{",
"k",
":",
"v",
".",
"shape",
"for",
"k",
",",
"v",
"in",
"data_inputs",
".",
"items",
"(",
")",
"}",
"arg_names",
... | Get executor to Stochastic Gradient Langevin Dynamics and/or Bayesian Dark Knowledge | [
"Get",
"executor",
"to",
"Stochastic",
"Gradient",
"Langevin",
"Dynamics",
"and",
"/",
"or",
"Bayesian",
"Dark",
"Knowledge"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/utils.py#L49-L66 | train |
apache/incubator-mxnet | example/bayesian-methods/utils.py | copy_param | def copy_param(exe, new_param=None):
"""Create copy of parameters"""
if new_param is None:
new_param = {k: nd.empty(v.shape, ctx=mx.cpu()) for k, v in exe.arg_dict.items()}
for k, v in new_param.items():
exe.arg_dict[k].copyto(v)
return new_param | python | def copy_param(exe, new_param=None):
"""Create copy of parameters"""
if new_param is None:
new_param = {k: nd.empty(v.shape, ctx=mx.cpu()) for k, v in exe.arg_dict.items()}
for k, v in new_param.items():
exe.arg_dict[k].copyto(v)
return new_param | [
"def",
"copy_param",
"(",
"exe",
",",
"new_param",
"=",
"None",
")",
":",
"if",
"new_param",
"is",
"None",
":",
"new_param",
"=",
"{",
"k",
":",
"nd",
".",
"empty",
"(",
"v",
".",
"shape",
",",
"ctx",
"=",
"mx",
".",
"cpu",
"(",
")",
")",
"for"... | Create copy of parameters | [
"Create",
"copy",
"of",
"parameters"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/utils.py#L69-L75 | train |
apache/incubator-mxnet | example/ctc/lstm_ocr_train.py | parse_args | def parse_args():
"""Parse command line arguments"""
parser = argparse.ArgumentParser()
parser.add_argument("font_path", help="Path to ttf font file or directory containing ttf files")
parser.add_argument("--loss", help="'ctc' or 'warpctc' loss [Default 'ctc']", default='ctc')
parser.add_argument("-... | python | def parse_args():
"""Parse command line arguments"""
parser = argparse.ArgumentParser()
parser.add_argument("font_path", help="Path to ttf font file or directory containing ttf files")
parser.add_argument("--loss", help="'ctc' or 'warpctc' loss [Default 'ctc']", default='ctc')
parser.add_argument("-... | [
"def",
"parse_args",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"\"font_path\"",
",",
"help",
"=",
"\"Path to ttf font file or directory containing ttf files\"",
")",
"parser",
".",
"add_argument",
... | Parse command line arguments | [
"Parse",
"command",
"line",
"arguments"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/lstm_ocr_train.py#L44-L55 | train |
apache/incubator-mxnet | example/ctc/lstm_ocr_train.py | main | def main():
"""Program entry point"""
args = parse_args()
if not any(args.loss == s for s in ['ctc', 'warpctc']):
raise ValueError("Invalid loss '{}' (must be 'ctc' or 'warpctc')".format(args.loss))
hp = Hyperparams()
# Start a multiprocessor captcha image generator
mp_captcha = MPDigi... | python | def main():
"""Program entry point"""
args = parse_args()
if not any(args.loss == s for s in ['ctc', 'warpctc']):
raise ValueError("Invalid loss '{}' (must be 'ctc' or 'warpctc')".format(args.loss))
hp = Hyperparams()
# Start a multiprocessor captcha image generator
mp_captcha = MPDigi... | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"parse_args",
"(",
")",
"if",
"not",
"any",
"(",
"args",
".",
"loss",
"==",
"s",
"for",
"s",
"in",
"[",
"'ctc'",
",",
"'warpctc'",
"]",
")",
":",
"raise",
"ValueError",
"(",
"\"Invalid loss '{}' (must be 'ctc'... | Program entry point | [
"Program",
"entry",
"point"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/lstm_ocr_train.py#L58-L121 | train |
apache/incubator-mxnet | example/gluon/style_transfer/main.py | optimize | def optimize(args):
""" Gatys et al. CVPR 2017
ref: Image Style Transfer Using Convolutional Neural Networks
"""
if args.cuda:
ctx = mx.gpu(0)
else:
ctx = mx.cpu(0)
# load the content and style target
content_image = utils.tensor_load_rgbimage(args.content_image,ctx, size=... | python | def optimize(args):
""" Gatys et al. CVPR 2017
ref: Image Style Transfer Using Convolutional Neural Networks
"""
if args.cuda:
ctx = mx.gpu(0)
else:
ctx = mx.cpu(0)
# load the content and style target
content_image = utils.tensor_load_rgbimage(args.content_image,ctx, size=... | [
"def",
"optimize",
"(",
"args",
")",
":",
"if",
"args",
".",
"cuda",
":",
"ctx",
"=",
"mx",
".",
"gpu",
"(",
"0",
")",
"else",
":",
"ctx",
"=",
"mx",
".",
"cpu",
"(",
"0",
")",
"# load the content and style target",
"content_image",
"=",
"utils",
"."... | Gatys et al. CVPR 2017
ref: Image Style Transfer Using Convolutional Neural Networks | [
"Gatys",
"et",
"al",
".",
"CVPR",
"2017",
"ref",
":",
"Image",
"Style",
"Transfer",
"Using",
"Convolutional",
"Neural",
"Networks"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/style_transfer/main.py#L153-L204 | train |
apache/incubator-mxnet | example/bayesian-methods/bdk_demo.py | get_mnist_sym | def get_mnist_sym(output_op=None, num_hidden=400):
"""Get symbol of mnist"""
net = mx.symbol.Variable('data')
net = mx.symbol.FullyConnected(data=net, name='mnist_fc1', num_hidden=num_hidden)
net = mx.symbol.Activation(data=net, name='mnist_relu1', act_type="relu")
net = mx.symbol.FullyConnected(dat... | python | def get_mnist_sym(output_op=None, num_hidden=400):
"""Get symbol of mnist"""
net = mx.symbol.Variable('data')
net = mx.symbol.FullyConnected(data=net, name='mnist_fc1', num_hidden=num_hidden)
net = mx.symbol.Activation(data=net, name='mnist_relu1', act_type="relu")
net = mx.symbol.FullyConnected(dat... | [
"def",
"get_mnist_sym",
"(",
"output_op",
"=",
"None",
",",
"num_hidden",
"=",
"400",
")",
":",
"net",
"=",
"mx",
".",
"symbol",
".",
"Variable",
"(",
"'data'",
")",
"net",
"=",
"mx",
".",
"symbol",
".",
"FullyConnected",
"(",
"data",
"=",
"net",
","... | Get symbol of mnist | [
"Get",
"symbol",
"of",
"mnist"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L106-L118 | train |
apache/incubator-mxnet | example/bayesian-methods/bdk_demo.py | synthetic_grad | def synthetic_grad(X, theta, sigma1, sigma2, sigmax, rescale_grad=1.0, grad=None):
"""Get synthetic gradient value"""
if grad is None:
grad = nd.empty(theta.shape, theta.context)
theta1 = theta.asnumpy()[0]
theta2 = theta.asnumpy()[1]
v1 = sigma1 ** 2
v2 = sigma2 ** 2
vx = sigmax ** ... | python | def synthetic_grad(X, theta, sigma1, sigma2, sigmax, rescale_grad=1.0, grad=None):
"""Get synthetic gradient value"""
if grad is None:
grad = nd.empty(theta.shape, theta.context)
theta1 = theta.asnumpy()[0]
theta2 = theta.asnumpy()[1]
v1 = sigma1 ** 2
v2 = sigma2 ** 2
vx = sigmax ** ... | [
"def",
"synthetic_grad",
"(",
"X",
",",
"theta",
",",
"sigma1",
",",
"sigma2",
",",
"sigmax",
",",
"rescale_grad",
"=",
"1.0",
",",
"grad",
"=",
"None",
")",
":",
"if",
"grad",
"is",
"None",
":",
"grad",
"=",
"nd",
".",
"empty",
"(",
"theta",
".",
... | Get synthetic gradient value | [
"Get",
"synthetic",
"gradient",
"value"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L121-L139 | train |
apache/incubator-mxnet | example/bayesian-methods/bdk_demo.py | get_toy_sym | def get_toy_sym(teacher=True, teacher_noise_precision=None):
"""Get toy symbol"""
if teacher:
net = mx.symbol.Variable('data')
net = mx.symbol.FullyConnected(data=net, name='teacher_fc1', num_hidden=100)
net = mx.symbol.Activation(data=net, name='teacher_relu1', act_type="relu")
... | python | def get_toy_sym(teacher=True, teacher_noise_precision=None):
"""Get toy symbol"""
if teacher:
net = mx.symbol.Variable('data')
net = mx.symbol.FullyConnected(data=net, name='teacher_fc1', num_hidden=100)
net = mx.symbol.Activation(data=net, name='teacher_relu1', act_type="relu")
... | [
"def",
"get_toy_sym",
"(",
"teacher",
"=",
"True",
",",
"teacher_noise_precision",
"=",
"None",
")",
":",
"if",
"teacher",
":",
"net",
"=",
"mx",
".",
"symbol",
".",
"Variable",
"(",
"'data'",
")",
"net",
"=",
"mx",
".",
"symbol",
".",
"FullyConnected",
... | Get toy symbol | [
"Get",
"toy",
"symbol"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L142-L158 | train |
apache/incubator-mxnet | example/bayesian-methods/bdk_demo.py | run_mnist_DistilledSGLD | def run_mnist_DistilledSGLD(num_training=50000, gpu_id=None):
"""Run DistilledSGLD on mnist dataset"""
X, Y, X_test, Y_test = load_mnist(num_training)
minibatch_size = 100
if num_training >= 10000:
num_hidden = 800
total_iter_num = 1000000
teacher_learning_rate = 1E-6
stu... | python | def run_mnist_DistilledSGLD(num_training=50000, gpu_id=None):
"""Run DistilledSGLD on mnist dataset"""
X, Y, X_test, Y_test = load_mnist(num_training)
minibatch_size = 100
if num_training >= 10000:
num_hidden = 800
total_iter_num = 1000000
teacher_learning_rate = 1E-6
stu... | [
"def",
"run_mnist_DistilledSGLD",
"(",
"num_training",
"=",
"50000",
",",
"gpu_id",
"=",
"None",
")",
":",
"X",
",",
"Y",
",",
"X_test",
",",
"Y_test",
"=",
"load_mnist",
"(",
"num_training",
")",
"minibatch_size",
"=",
"100",
"if",
"num_training",
">=",
"... | Run DistilledSGLD on mnist dataset | [
"Run",
"DistilledSGLD",
"on",
"mnist",
"dataset"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L196-L237 | train |
apache/incubator-mxnet | example/bayesian-methods/bdk_demo.py | run_toy_SGLD | def run_toy_SGLD(gpu_id=None):
"""Run SGLD on toy dataset"""
X, Y, X_test, Y_test = load_toy()
minibatch_size = 1
teacher_noise_precision = 1.0 / 9.0
net = get_toy_sym(True, teacher_noise_precision)
data_shape = (minibatch_size,) + X.shape[1::]
data_inputs = {'data': nd.zeros(data_shape, ctx... | python | def run_toy_SGLD(gpu_id=None):
"""Run SGLD on toy dataset"""
X, Y, X_test, Y_test = load_toy()
minibatch_size = 1
teacher_noise_precision = 1.0 / 9.0
net = get_toy_sym(True, teacher_noise_precision)
data_shape = (minibatch_size,) + X.shape[1::]
data_inputs = {'data': nd.zeros(data_shape, ctx... | [
"def",
"run_toy_SGLD",
"(",
"gpu_id",
"=",
"None",
")",
":",
"X",
",",
"Y",
",",
"X_test",
",",
"Y_test",
"=",
"load_toy",
"(",
")",
"minibatch_size",
"=",
"1",
"teacher_noise_precision",
"=",
"1.0",
"/",
"9.0",
"net",
"=",
"get_toy_sym",
"(",
"True",
... | Run SGLD on toy dataset | [
"Run",
"SGLD",
"on",
"toy",
"dataset"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L240-L265 | train |
apache/incubator-mxnet | example/bayesian-methods/bdk_demo.py | run_toy_DistilledSGLD | def run_toy_DistilledSGLD(gpu_id):
"""Run DistilledSGLD on toy dataset"""
X, Y, X_test, Y_test = load_toy()
minibatch_size = 1
teacher_noise_precision = 1.0
teacher_net = get_toy_sym(True, teacher_noise_precision)
student_net = get_toy_sym(False)
data_shape = (minibatch_size,) + X.shape[1::]... | python | def run_toy_DistilledSGLD(gpu_id):
"""Run DistilledSGLD on toy dataset"""
X, Y, X_test, Y_test = load_toy()
minibatch_size = 1
teacher_noise_precision = 1.0
teacher_net = get_toy_sym(True, teacher_noise_precision)
student_net = get_toy_sym(False)
data_shape = (minibatch_size,) + X.shape[1::]... | [
"def",
"run_toy_DistilledSGLD",
"(",
"gpu_id",
")",
":",
"X",
",",
"Y",
",",
"X_test",
",",
"Y_test",
"=",
"load_toy",
"(",
")",
"minibatch_size",
"=",
"1",
"teacher_noise_precision",
"=",
"1.0",
"teacher_net",
"=",
"get_toy_sym",
"(",
"True",
",",
"teacher_... | Run DistilledSGLD on toy dataset | [
"Run",
"DistilledSGLD",
"on",
"toy",
"dataset"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L268-L297 | train |
apache/incubator-mxnet | example/bayesian-methods/bdk_demo.py | run_toy_HMC | def run_toy_HMC(gpu_id=None):
"""Run HMC on toy dataset"""
X, Y, X_test, Y_test = load_toy()
minibatch_size = Y.shape[0]
noise_precision = 1 / 9.0
net = get_toy_sym(True, noise_precision)
data_shape = (minibatch_size,) + X.shape[1::]
data_inputs = {'data': nd.zeros(data_shape, ctx=dev(gpu_id... | python | def run_toy_HMC(gpu_id=None):
"""Run HMC on toy dataset"""
X, Y, X_test, Y_test = load_toy()
minibatch_size = Y.shape[0]
noise_precision = 1 / 9.0
net = get_toy_sym(True, noise_precision)
data_shape = (minibatch_size,) + X.shape[1::]
data_inputs = {'data': nd.zeros(data_shape, ctx=dev(gpu_id... | [
"def",
"run_toy_HMC",
"(",
"gpu_id",
"=",
"None",
")",
":",
"X",
",",
"Y",
",",
"X_test",
",",
"Y_test",
"=",
"load_toy",
"(",
")",
"minibatch_size",
"=",
"Y",
".",
"shape",
"[",
"0",
"]",
"noise_precision",
"=",
"1",
"/",
"9.0",
"net",
"=",
"get_t... | Run HMC on toy dataset | [
"Run",
"HMC",
"on",
"toy",
"dataset"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L300-L312 | train |
apache/incubator-mxnet | example/bayesian-methods/bdk_demo.py | run_synthetic_SGLD | def run_synthetic_SGLD():
"""Run synthetic SGLD"""
theta1 = 0
theta2 = 1
sigma1 = numpy.sqrt(10)
sigma2 = 1
sigmax = numpy.sqrt(2)
X = load_synthetic(theta1=theta1, theta2=theta2, sigmax=sigmax, num=100)
minibatch_size = 1
total_iter_num = 1000000
lr_scheduler = SGLDScheduler(beg... | python | def run_synthetic_SGLD():
"""Run synthetic SGLD"""
theta1 = 0
theta2 = 1
sigma1 = numpy.sqrt(10)
sigma2 = 1
sigmax = numpy.sqrt(2)
X = load_synthetic(theta1=theta1, theta2=theta2, sigmax=sigmax, num=100)
minibatch_size = 1
total_iter_num = 1000000
lr_scheduler = SGLDScheduler(beg... | [
"def",
"run_synthetic_SGLD",
"(",
")",
":",
"theta1",
"=",
"0",
"theta2",
"=",
"1",
"sigma1",
"=",
"numpy",
".",
"sqrt",
"(",
"10",
")",
"sigma2",
"=",
"1",
"sigmax",
"=",
"numpy",
".",
"sqrt",
"(",
"2",
")",
"X",
"=",
"load_synthetic",
"(",
"theta... | Run synthetic SGLD | [
"Run",
"synthetic",
"SGLD"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L315-L349 | train |
apache/incubator-mxnet | example/ssd/tools/prepare_dataset.py | load_pascal | def load_pascal(image_set, year, devkit_path, shuffle=False):
"""
wrapper function for loading pascal voc dataset
Parameters:
----------
image_set : str
train, trainval...
year : str
2007, 2012 or combinations splitted by comma
devkit_path : str
root directory of dat... | python | def load_pascal(image_set, year, devkit_path, shuffle=False):
"""
wrapper function for loading pascal voc dataset
Parameters:
----------
image_set : str
train, trainval...
year : str
2007, 2012 or combinations splitted by comma
devkit_path : str
root directory of dat... | [
"def",
"load_pascal",
"(",
"image_set",
",",
"year",
",",
"devkit_path",
",",
"shuffle",
"=",
"False",
")",
":",
"image_set",
"=",
"[",
"y",
".",
"strip",
"(",
")",
"for",
"y",
"in",
"image_set",
".",
"split",
"(",
"','",
")",
"]",
"assert",
"image_s... | wrapper function for loading pascal voc dataset
Parameters:
----------
image_set : str
train, trainval...
year : str
2007, 2012 or combinations splitted by comma
devkit_path : str
root directory of dataset
shuffle : bool
whether to shuffle initial list
Retur... | [
"wrapper",
"function",
"for",
"loading",
"pascal",
"voc",
"dataset"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/tools/prepare_dataset.py#L31-L68 | train |
apache/incubator-mxnet | example/ssd/tools/prepare_dataset.py | load_coco | def load_coco(image_set, dirname, shuffle=False):
"""
wrapper function for loading ms coco dataset
Parameters:
----------
image_set : str
train2014, val2014, valminusminival2014, minival2014
dirname: str
root dir for coco
shuffle: boolean
initial shuffle
"""
... | python | def load_coco(image_set, dirname, shuffle=False):
"""
wrapper function for loading ms coco dataset
Parameters:
----------
image_set : str
train2014, val2014, valminusminival2014, minival2014
dirname: str
root dir for coco
shuffle: boolean
initial shuffle
"""
... | [
"def",
"load_coco",
"(",
"image_set",
",",
"dirname",
",",
"shuffle",
"=",
"False",
")",
":",
"anno_files",
"=",
"[",
"'instances_'",
"+",
"y",
".",
"strip",
"(",
")",
"+",
"'.json'",
"for",
"y",
"in",
"image_set",
".",
"split",
"(",
"','",
")",
"]",... | wrapper function for loading ms coco dataset
Parameters:
----------
image_set : str
train2014, val2014, valminusminival2014, minival2014
dirname: str
root dir for coco
shuffle: boolean
initial shuffle | [
"wrapper",
"function",
"for",
"loading",
"ms",
"coco",
"dataset"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/tools/prepare_dataset.py#L70-L92 | train |
apache/incubator-mxnet | example/named_entity_recognition/src/iterators.py | BucketNerIter.reset | def reset(self):
"""Resets the iterator to the beginning of the data."""
self.curr_idx = 0
#shuffle data in each bucket
random.shuffle(self.idx)
for i, buck in enumerate(self.sentences):
self.indices[i], self.sentences[i], self.characters[i], self.label[i] = shuffle(s... | python | def reset(self):
"""Resets the iterator to the beginning of the data."""
self.curr_idx = 0
#shuffle data in each bucket
random.shuffle(self.idx)
for i, buck in enumerate(self.sentences):
self.indices[i], self.sentences[i], self.characters[i], self.label[i] = shuffle(s... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"curr_idx",
"=",
"0",
"#shuffle data in each bucket",
"random",
".",
"shuffle",
"(",
"self",
".",
"idx",
")",
"for",
"i",
",",
"buck",
"in",
"enumerate",
"(",
"self",
".",
"sentences",
")",
":",
"self... | Resets the iterator to the beginning of the data. | [
"Resets",
"the",
"iterator",
"to",
"the",
"beginning",
"of",
"the",
"data",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/named_entity_recognition/src/iterators.py#L135-L157 | train |
apache/incubator-mxnet | example/named_entity_recognition/src/iterators.py | BucketNerIter.next | def next(self):
"""Returns the next batch of data."""
if self.curr_idx == len(self.idx):
raise StopIteration
#i = batches index, j = starting record
i, j = self.idx[self.curr_idx]
self.curr_idx += 1
indices = self.ndindex[i][j:j + self.batch_size]
se... | python | def next(self):
"""Returns the next batch of data."""
if self.curr_idx == len(self.idx):
raise StopIteration
#i = batches index, j = starting record
i, j = self.idx[self.curr_idx]
self.curr_idx += 1
indices = self.ndindex[i][j:j + self.batch_size]
se... | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"curr_idx",
"==",
"len",
"(",
"self",
".",
"idx",
")",
":",
"raise",
"StopIteration",
"#i = batches index, j = starting record",
"i",
",",
"j",
"=",
"self",
".",
"idx",
"[",
"self",
".",
"curr_idx"... | Returns the next batch of data. | [
"Returns",
"the",
"next",
"batch",
"of",
"data",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/named_entity_recognition/src/iterators.py#L159-L175 | train |
apache/incubator-mxnet | tools/coreml/converter/_layers.py | convert_reshape | def convert_reshape(net, node, module, builder):
"""Converts a reshape layer from mxnet to coreml.
This doesn't currently handle the deprecated parameters for the reshape layer.
Parameters
----------
network: net
An mxnet network object.
layer: node
Node to convert.
modul... | python | def convert_reshape(net, node, module, builder):
"""Converts a reshape layer from mxnet to coreml.
This doesn't currently handle the deprecated parameters for the reshape layer.
Parameters
----------
network: net
An mxnet network object.
layer: node
Node to convert.
modul... | [
"def",
"convert_reshape",
"(",
"net",
",",
"node",
",",
"module",
",",
"builder",
")",
":",
"input_name",
",",
"output_name",
"=",
"_get_input_output_name",
"(",
"net",
",",
"node",
")",
"name",
"=",
"node",
"[",
"'name'",
"]",
"target_shape",
"=",
"node",... | Converts a reshape layer from mxnet to coreml.
This doesn't currently handle the deprecated parameters for the reshape layer.
Parameters
----------
network: net
An mxnet network object.
layer: node
Node to convert.
module: module
A module for MXNet
builder: Neura... | [
"Converts",
"a",
"reshape",
"layer",
"from",
"mxnet",
"to",
"coreml",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L81-L113 | train |
apache/incubator-mxnet | tools/coreml/converter/_layers.py | convert_transpose | def convert_transpose(net, node, module, builder):
"""Convert a transpose layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A... | python | def convert_transpose(net, node, module, builder):
"""Convert a transpose layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A... | [
"def",
"convert_transpose",
"(",
"net",
",",
"node",
",",
"module",
",",
"builder",
")",
":",
"input_name",
",",
"output_name",
"=",
"_get_input_output_name",
"(",
"net",
",",
"node",
")",
"name",
"=",
"node",
"[",
"'name'",
"]",
"param",
"=",
"_get_attrs"... | Convert a transpose layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"a",
"transpose",
"layer",
"from",
"mxnet",
"to",
"coreml",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L116-L138 | train |
apache/incubator-mxnet | tools/coreml/converter/_layers.py | convert_flatten | def convert_flatten(net, node, module, builder):
"""Convert a flatten layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neu... | python | def convert_flatten(net, node, module, builder):
"""Convert a flatten layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neu... | [
"def",
"convert_flatten",
"(",
"net",
",",
"node",
",",
"module",
",",
"builder",
")",
":",
"input_name",
",",
"output_name",
"=",
"_get_input_output_name",
"(",
"net",
",",
"node",
")",
"name",
"=",
"node",
"[",
"'name'",
"]",
"mode",
"=",
"0",
"# CHANN... | Convert a flatten layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"a",
"flatten",
"layer",
"from",
"mxnet",
"to",
"coreml",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L141-L161 | train |
apache/incubator-mxnet | tools/coreml/converter/_layers.py | convert_softmax | def convert_softmax(net, node, module, builder):
"""Convert a softmax layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neu... | python | def convert_softmax(net, node, module, builder):
"""Convert a softmax layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neu... | [
"def",
"convert_softmax",
"(",
"net",
",",
"node",
",",
"module",
",",
"builder",
")",
":",
"input_name",
",",
"output_name",
"=",
"_get_input_output_name",
"(",
"net",
",",
"node",
")",
"name",
"=",
"node",
"[",
"'name'",
"]",
"builder",
".",
"add_softmax... | Convert a softmax layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"a",
"softmax",
"layer",
"from",
"mxnet",
"to",
"coreml",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L164-L185 | train |
apache/incubator-mxnet | tools/coreml/converter/_layers.py | convert_activation | def convert_activation(net, node, module, builder):
"""Convert an activation layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
... | python | def convert_activation(net, node, module, builder):
"""Convert an activation layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
... | [
"def",
"convert_activation",
"(",
"net",
",",
"node",
",",
"module",
",",
"builder",
")",
":",
"input_name",
",",
"output_name",
"=",
"_get_input_output_name",
"(",
"net",
",",
"node",
")",
"name",
"=",
"node",
"[",
"'name'",
"]",
"mx_non_linearity",
"=",
... | Convert an activation layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"an",
"activation",
"layer",
"from",
"mxnet",
"to",
"coreml",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L188-L220 | train |
apache/incubator-mxnet | tools/coreml/converter/_layers.py | convert_leakyrelu | def convert_leakyrelu(net, node, module, builder):
"""Convert a leakyrelu layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A... | python | def convert_leakyrelu(net, node, module, builder):
"""Convert a leakyrelu layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A... | [
"def",
"convert_leakyrelu",
"(",
"net",
",",
"node",
",",
"module",
",",
"builder",
")",
":",
"input_name",
",",
"output_name",
"=",
"_get_input_output_name",
"(",
"net",
",",
"node",
")",
"name",
"=",
"node",
"[",
"'name'",
"]",
"inputs",
"=",
"node",
"... | Convert a leakyrelu layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"a",
"leakyrelu",
"layer",
"from",
"mxnet",
"to",
"coreml",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L223-L263 | train |
apache/incubator-mxnet | tools/coreml/converter/_layers.py | convert_elementwise_add | def convert_elementwise_add(net, node, module, builder):
"""Convert an elementwise add layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuil... | python | def convert_elementwise_add(net, node, module, builder):
"""Convert an elementwise add layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuil... | [
"def",
"convert_elementwise_add",
"(",
"net",
",",
"node",
",",
"module",
",",
"builder",
")",
":",
"input_names",
",",
"output_name",
"=",
"_get_input_output_name",
"(",
"net",
",",
"node",
",",
"[",
"0",
",",
"1",
"]",
")",
"name",
"=",
"node",
"[",
... | Convert an elementwise add layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"an",
"elementwise",
"add",
"layer",
"from",
"mxnet",
"to",
"coreml",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L266-L287 | train |
apache/incubator-mxnet | tools/coreml/converter/_layers.py | convert_convolution | def convert_convolution(net, node, module, builder):
"""Convert a convolution layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
... | python | def convert_convolution(net, node, module, builder):
"""Convert a convolution layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
... | [
"def",
"convert_convolution",
"(",
"net",
",",
"node",
",",
"module",
",",
"builder",
")",
":",
"input_name",
",",
"output_name",
"=",
"_get_input_output_name",
"(",
"net",
",",
"node",
")",
"name",
"=",
"node",
"[",
"'name'",
"]",
"param",
"=",
"_get_attr... | Convert a convolution layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"a",
"convolution",
"layer",
"from",
"mxnet",
"to",
"coreml",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L337-L415 | train |
apache/incubator-mxnet | tools/coreml/converter/_layers.py | convert_pooling | def convert_pooling(net, node, module, builder):
"""Convert a pooling layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neu... | python | def convert_pooling(net, node, module, builder):
"""Convert a pooling layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neu... | [
"def",
"convert_pooling",
"(",
"net",
",",
"node",
",",
"module",
",",
"builder",
")",
":",
"input_name",
",",
"output_name",
"=",
"_get_input_output_name",
"(",
"net",
",",
"node",
")",
"name",
"=",
"node",
"[",
"'name'",
"]",
"param",
"=",
"_get_attrs",
... | Convert a pooling layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"a",
"pooling",
"layer",
"from",
"mxnet",
"to",
"coreml",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L418-L494 | train |
apache/incubator-mxnet | tools/coreml/converter/_layers.py | convert_batchnorm | def convert_batchnorm(net, node, module, builder):
"""Convert a batchnorm layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A... | python | def convert_batchnorm(net, node, module, builder):
"""Convert a batchnorm layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A... | [
"def",
"convert_batchnorm",
"(",
"net",
",",
"node",
",",
"module",
",",
"builder",
")",
":",
"input_name",
",",
"output_name",
"=",
"_get_input_output_name",
"(",
"net",
",",
"node",
")",
"name",
"=",
"node",
"[",
"'name'",
"]",
"inputs",
"=",
"node",
"... | Convert a batchnorm layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"a",
"batchnorm",
"layer",
"from",
"mxnet",
"to",
"coreml",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L497-L545 | train |
apache/incubator-mxnet | tools/coreml/converter/_layers.py | convert_concat | def convert_concat(net, node, module, builder):
"""Convert concat layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neural ... | python | def convert_concat(net, node, module, builder):
"""Convert concat layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neural ... | [
"def",
"convert_concat",
"(",
"net",
",",
"node",
",",
"module",
",",
"builder",
")",
":",
"# Get input and output names",
"input_names",
",",
"output_name",
"=",
"_get_input_output_name",
"(",
"net",
",",
"node",
",",
"'all'",
")",
"name",
"=",
"node",
"[",
... | Convert concat layer from mxnet to coreml.
Parameters
----------
network: net
A mxnet network object.
layer: node
Node to convert.
module: module
An module for MXNet
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"concat",
"layer",
"from",
"mxnet",
"to",
"coreml",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L548-L570 | train |
apache/incubator-mxnet | tools/launch.py | dmlc_opts | def dmlc_opts(opts):
"""convert from mxnet's opts to dmlc's opts
"""
args = ['--num-workers', str(opts.num_workers),
'--num-servers', str(opts.num_servers),
'--cluster', opts.launcher,
'--host-file', opts.hostfile,
'--sync-dst-dir', opts.sync_dst_dir]
# c... | python | def dmlc_opts(opts):
"""convert from mxnet's opts to dmlc's opts
"""
args = ['--num-workers', str(opts.num_workers),
'--num-servers', str(opts.num_servers),
'--cluster', opts.launcher,
'--host-file', opts.hostfile,
'--sync-dst-dir', opts.sync_dst_dir]
# c... | [
"def",
"dmlc_opts",
"(",
"opts",
")",
":",
"args",
"=",
"[",
"'--num-workers'",
",",
"str",
"(",
"opts",
".",
"num_workers",
")",
",",
"'--num-servers'",
",",
"str",
"(",
"opts",
".",
"num_servers",
")",
",",
"'--cluster'",
",",
"opts",
".",
"launcher",
... | convert from mxnet's opts to dmlc's opts | [
"convert",
"from",
"mxnet",
"s",
"opts",
"to",
"dmlc",
"s",
"opts"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/launch.py#L31-L54 | train |
apache/incubator-mxnet | python/mxnet/gluon/rnn/rnn_layer.py | _RNNLayer._unfuse | def _unfuse(self):
"""Unfuses the fused RNN in to a stack of rnn cells."""
assert not self._projection_size, "_unfuse does not support projection layer yet!"
assert not self._lstm_state_clip_min and not self._lstm_state_clip_max, \
"_unfuse does not support state clipping yet!"
... | python | def _unfuse(self):
"""Unfuses the fused RNN in to a stack of rnn cells."""
assert not self._projection_size, "_unfuse does not support projection layer yet!"
assert not self._lstm_state_clip_min and not self._lstm_state_clip_max, \
"_unfuse does not support state clipping yet!"
... | [
"def",
"_unfuse",
"(",
"self",
")",
":",
"assert",
"not",
"self",
".",
"_projection_size",
",",
"\"_unfuse does not support projection layer yet!\"",
"assert",
"not",
"self",
".",
"_lstm_state_clip_min",
"and",
"not",
"self",
".",
"_lstm_state_clip_max",
",",
"\"_unfu... | Unfuses the fused RNN in to a stack of rnn cells. | [
"Unfuses",
"the",
"fused",
"RNN",
"in",
"to",
"a",
"stack",
"of",
"rnn",
"cells",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/rnn/rnn_layer.py#L144-L181 | train |
apache/incubator-mxnet | python/mxnet/gluon/rnn/rnn_layer.py | _RNNLayer.begin_state | def begin_state(self, batch_size=0, func=ndarray.zeros, **kwargs):
"""Initial state for this cell.
Parameters
----------
batch_size: int
Only required for `NDArray` API. Size of the batch ('N' in layout).
Dimension of the input.
func : callable, default `... | python | def begin_state(self, batch_size=0, func=ndarray.zeros, **kwargs):
"""Initial state for this cell.
Parameters
----------
batch_size: int
Only required for `NDArray` API. Size of the batch ('N' in layout).
Dimension of the input.
func : callable, default `... | [
"def",
"begin_state",
"(",
"self",
",",
"batch_size",
"=",
"0",
",",
"func",
"=",
"ndarray",
".",
"zeros",
",",
"*",
"*",
"kwargs",
")",
":",
"states",
"=",
"[",
"]",
"for",
"i",
",",
"info",
"in",
"enumerate",
"(",
"self",
".",
"state_info",
"(",
... | Initial state for this cell.
Parameters
----------
batch_size: int
Only required for `NDArray` API. Size of the batch ('N' in layout).
Dimension of the input.
func : callable, default `ndarray.zeros`
Function for creating initial state.
F... | [
"Initial",
"state",
"for",
"this",
"cell",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/rnn/rnn_layer.py#L187-L220 | train |
apache/incubator-mxnet | python/mxnet/gluon/rnn/rnn_layer.py | _RNNLayer._forward_kernel | def _forward_kernel(self, F, inputs, states, **kwargs):
""" forward using CUDNN or CPU kenrel"""
if self._layout == 'NTC':
inputs = F.swapaxes(inputs, dim1=0, dim2=1)
if self._projection_size is None:
params = (kwargs['{}{}_{}_{}'.format(d, l, g, t)].reshape(-1)
... | python | def _forward_kernel(self, F, inputs, states, **kwargs):
""" forward using CUDNN or CPU kenrel"""
if self._layout == 'NTC':
inputs = F.swapaxes(inputs, dim1=0, dim2=1)
if self._projection_size is None:
params = (kwargs['{}{}_{}_{}'.format(d, l, g, t)].reshape(-1)
... | [
"def",
"_forward_kernel",
"(",
"self",
",",
"F",
",",
"inputs",
",",
"states",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_layout",
"==",
"'NTC'",
":",
"inputs",
"=",
"F",
".",
"swapaxes",
"(",
"inputs",
",",
"dim1",
"=",
"0",
",",
"d... | forward using CUDNN or CPU kenrel | [
"forward",
"using",
"CUDNN",
"or",
"CPU",
"kenrel"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/rnn/rnn_layer.py#L244-L280 | train |
apache/incubator-mxnet | ci/docker/qemu/vmcontrol.py | wait_ssh_open | def wait_ssh_open(server, port, keep_waiting=None, timeout=None):
""" Wait for network service to appear
@param server: host to connect to (str)
@param port: port (int)
@param timeout: in seconds, if None or 0 wait forever
@return: True of False, if timeout is None may return only Tr... | python | def wait_ssh_open(server, port, keep_waiting=None, timeout=None):
""" Wait for network service to appear
@param server: host to connect to (str)
@param port: port (int)
@param timeout: in seconds, if None or 0 wait forever
@return: True of False, if timeout is None may return only Tr... | [
"def",
"wait_ssh_open",
"(",
"server",
",",
"port",
",",
"keep_waiting",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"import",
"socket",
"import",
"errno",
"import",
"time",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"'wait_ssh_open'",
")",
"sle... | Wait for network service to appear
@param server: host to connect to (str)
@param port: port (int)
@param timeout: in seconds, if None or 0 wait forever
@return: True of False, if timeout is None may return only True or
throw unhandled network exception | [
"Wait",
"for",
"network",
"service",
"to",
"appear"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/docker/qemu/vmcontrol.py#L236-L302 | train |
apache/incubator-mxnet | ci/docker/qemu/vmcontrol.py | wait_port_open | def wait_port_open(server, port, timeout=None):
""" Wait for network service to appear
@param server: host to connect to (str)
@param port: port (int)
@param timeout: in seconds, if None or 0 wait forever
@return: True of False, if timeout is None may return only True or
... | python | def wait_port_open(server, port, timeout=None):
""" Wait for network service to appear
@param server: host to connect to (str)
@param port: port (int)
@param timeout: in seconds, if None or 0 wait forever
@return: True of False, if timeout is None may return only True or
... | [
"def",
"wait_port_open",
"(",
"server",
",",
"port",
",",
"timeout",
"=",
"None",
")",
":",
"import",
"socket",
"import",
"errno",
"import",
"time",
"sleep_s",
"=",
"0",
"if",
"timeout",
":",
"from",
"time",
"import",
"time",
"as",
"now",
"# time module is... | Wait for network service to appear
@param server: host to connect to (str)
@param port: port (int)
@param timeout: in seconds, if None or 0 wait forever
@return: True of False, if timeout is None may return only True or
throw unhandled network exception | [
"Wait",
"for",
"network",
"service",
"to",
"appear"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/docker/qemu/vmcontrol.py#L305-L359 | train |
apache/incubator-mxnet | python/mxnet/visualization.py | print_summary | def print_summary(symbol, shape=None, line_length=120, positions=[.44, .64, .74, 1.]):
"""Convert symbol for detail information.
Parameters
----------
symbol: Symbol
Symbol to be visualized.
shape: dict
A dict of shapes, str->shape (tuple), given input shapes.
line_length: int
... | python | def print_summary(symbol, shape=None, line_length=120, positions=[.44, .64, .74, 1.]):
"""Convert symbol for detail information.
Parameters
----------
symbol: Symbol
Symbol to be visualized.
shape: dict
A dict of shapes, str->shape (tuple), given input shapes.
line_length: int
... | [
"def",
"print_summary",
"(",
"symbol",
",",
"shape",
"=",
"None",
",",
"line_length",
"=",
"120",
",",
"positions",
"=",
"[",
".44",
",",
".64",
",",
".74",
",",
"1.",
"]",
")",
":",
"if",
"not",
"isinstance",
"(",
"symbol",
",",
"Symbol",
")",
":"... | Convert symbol for detail information.
Parameters
----------
symbol: Symbol
Symbol to be visualized.
shape: dict
A dict of shapes, str->shape (tuple), given input shapes.
line_length: int
Rotal length of printed lines
positions: list
Relative or absolute position... | [
"Convert",
"symbol",
"for",
"detail",
"information",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/visualization.py#L47-L209 | train |
apache/incubator-mxnet | python/mxnet/visualization.py | plot_network | def plot_network(symbol, title="plot", save_format='pdf', shape=None, dtype=None, node_attrs={},
hide_weights=True):
"""Creates a visualization (Graphviz digraph object) of the given computation graph.
Graphviz must be installed for this function to work.
Parameters
----------
titl... | python | def plot_network(symbol, title="plot", save_format='pdf', shape=None, dtype=None, node_attrs={},
hide_weights=True):
"""Creates a visualization (Graphviz digraph object) of the given computation graph.
Graphviz must be installed for this function to work.
Parameters
----------
titl... | [
"def",
"plot_network",
"(",
"symbol",
",",
"title",
"=",
"\"plot\"",
",",
"save_format",
"=",
"'pdf'",
",",
"shape",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"node_attrs",
"=",
"{",
"}",
",",
"hide_weights",
"=",
"True",
")",
":",
"# todo add shape s... | Creates a visualization (Graphviz digraph object) of the given computation graph.
Graphviz must be installed for this function to work.
Parameters
----------
title: str, optional
Title of the generated visualization.
symbol: Symbol
A symbol from the computation graph. The generated ... | [
"Creates",
"a",
"visualization",
"(",
"Graphviz",
"digraph",
"object",
")",
"of",
"the",
"given",
"computation",
"graph",
".",
"Graphviz",
"must",
"be",
"installed",
"for",
"this",
"function",
"to",
"work",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/visualization.py#L211-L423 | train |
apache/incubator-mxnet | example/distributed_training/cifar10_dist.py | evaluate_accuracy | def evaluate_accuracy(data_iterator, network):
""" Measure the accuracy of ResNet
Parameters
----------
data_iterator: Iter
examples of dataset
network:
ResNet
Returns
----------
tuple of array element
"""
acc = mx.metric.Accuracy()
# Iterate through data and l... | python | def evaluate_accuracy(data_iterator, network):
""" Measure the accuracy of ResNet
Parameters
----------
data_iterator: Iter
examples of dataset
network:
ResNet
Returns
----------
tuple of array element
"""
acc = mx.metric.Accuracy()
# Iterate through data and l... | [
"def",
"evaluate_accuracy",
"(",
"data_iterator",
",",
"network",
")",
":",
"acc",
"=",
"mx",
".",
"metric",
".",
"Accuracy",
"(",
")",
"# Iterate through data and label",
"for",
"i",
",",
"(",
"data",
",",
"label",
")",
"in",
"enumerate",
"(",
"data_iterato... | Measure the accuracy of ResNet
Parameters
----------
data_iterator: Iter
examples of dataset
network:
ResNet
Returns
----------
tuple of array element | [
"Measure",
"the",
"accuracy",
"of",
"ResNet"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/distributed_training/cifar10_dist.py#L110-L142 | train |
apache/incubator-mxnet | example/distributed_training/cifar10_dist.py | train_batch | def train_batch(batch_list, context, network, gluon_trainer):
""" Training with multiple GPUs
Parameters
----------
batch_list: List
list of dataset
context: List
a list of all GPUs to be used for training
network:
ResNet
gluon_trainer:
rain module of gluon
"""
... | python | def train_batch(batch_list, context, network, gluon_trainer):
""" Training with multiple GPUs
Parameters
----------
batch_list: List
list of dataset
context: List
a list of all GPUs to be used for training
network:
ResNet
gluon_trainer:
rain module of gluon
"""
... | [
"def",
"train_batch",
"(",
"batch_list",
",",
"context",
",",
"network",
",",
"gluon_trainer",
")",
":",
"# Split and load data into multiple GPUs",
"data",
"=",
"batch_list",
"[",
"0",
"]",
"data",
"=",
"gluon",
".",
"utils",
".",
"split_and_load",
"(",
"data",... | Training with multiple GPUs
Parameters
----------
batch_list: List
list of dataset
context: List
a list of all GPUs to be used for training
network:
ResNet
gluon_trainer:
rain module of gluon | [
"Training",
"with",
"multiple",
"GPUs"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/distributed_training/cifar10_dist.py#L163-L190 | train |
apache/incubator-mxnet | python/mxnet/contrib/tensorrt.py | get_optimized_symbol | def get_optimized_symbol(executor):
"""
Take an executor's underlying symbol graph and return its generated optimized version.
Parameters
----------
executor :
An executor for which you want to see an optimized symbol. Getting an optimized symbol
is useful to compare and verify the ... | python | def get_optimized_symbol(executor):
"""
Take an executor's underlying symbol graph and return its generated optimized version.
Parameters
----------
executor :
An executor for which you want to see an optimized symbol. Getting an optimized symbol
is useful to compare and verify the ... | [
"def",
"get_optimized_symbol",
"(",
"executor",
")",
":",
"handle",
"=",
"SymbolHandle",
"(",
")",
"try",
":",
"check_call",
"(",
"_LIB",
".",
"MXExecutorGetOptimizedSymbol",
"(",
"executor",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"handle",
")",
")... | Take an executor's underlying symbol graph and return its generated optimized version.
Parameters
----------
executor :
An executor for which you want to see an optimized symbol. Getting an optimized symbol
is useful to compare and verify the work TensorRT has done against a legacy behaviou... | [
"Take",
"an",
"executor",
"s",
"underlying",
"symbol",
"graph",
"and",
"return",
"its",
"generated",
"optimized",
"version",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/tensorrt.py#L50-L73 | train |
apache/incubator-mxnet | python/mxnet/contrib/tensorrt.py | tensorrt_bind | def tensorrt_bind(symbol, ctx, all_params, type_dict=None, stype_dict=None, group2ctx=None,
**kwargs):
"""Bind current symbol to get an optimized trt executor.
Parameters
----------
symbol : Symbol
The symbol you wish to bind, and optimize with TensorRT.
ctx : Context
... | python | def tensorrt_bind(symbol, ctx, all_params, type_dict=None, stype_dict=None, group2ctx=None,
**kwargs):
"""Bind current symbol to get an optimized trt executor.
Parameters
----------
symbol : Symbol
The symbol you wish to bind, and optimize with TensorRT.
ctx : Context
... | [
"def",
"tensorrt_bind",
"(",
"symbol",
",",
"ctx",
",",
"all_params",
",",
"type_dict",
"=",
"None",
",",
"stype_dict",
"=",
"None",
",",
"group2ctx",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'shared_buffer'",
"]",
"=",
"all_params... | Bind current symbol to get an optimized trt executor.
Parameters
----------
symbol : Symbol
The symbol you wish to bind, and optimize with TensorRT.
ctx : Context
The device context the generated executor to run on.
all_params : Dict of str->ndarray
A dictionary of mapping... | [
"Bind",
"current",
"symbol",
"to",
"get",
"an",
"optimized",
"trt",
"executor",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/tensorrt.py#L76-L110 | train |
apache/incubator-mxnet | example/image-classification/symbols/vgg.py | get_symbol | def get_symbol(num_classes, num_layers=11, batch_norm=False, dtype='float32', **kwargs):
"""
Parameters
----------
num_classes : int, default 1000
Number of classification classes.
num_layers : int
Number of layers for the variant of densenet. Options are 11, 13, 16, 19.
batch_no... | python | def get_symbol(num_classes, num_layers=11, batch_norm=False, dtype='float32', **kwargs):
"""
Parameters
----------
num_classes : int, default 1000
Number of classification classes.
num_layers : int
Number of layers for the variant of densenet. Options are 11, 13, 16, 19.
batch_no... | [
"def",
"get_symbol",
"(",
"num_classes",
",",
"num_layers",
"=",
"11",
",",
"batch_norm",
"=",
"False",
",",
"dtype",
"=",
"'float32'",
",",
"*",
"*",
"kwargs",
")",
":",
"vgg_spec",
"=",
"{",
"11",
":",
"(",
"[",
"1",
",",
"1",
",",
"2",
",",
"2... | Parameters
----------
num_classes : int, default 1000
Number of classification classes.
num_layers : int
Number of layers for the variant of densenet. Options are 11, 13, 16, 19.
batch_norm : bool, default False
Use batch normalization.
dtype: str, float32 or float16
... | [
"Parameters",
"----------",
"num_classes",
":",
"int",
"default",
"1000",
"Number",
"of",
"classification",
"classes",
".",
"num_layers",
":",
"int",
"Number",
"of",
"layers",
"for",
"the",
"variant",
"of",
"densenet",
".",
"Options",
"are",
"11",
"13",
"16",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/image-classification/symbols/vgg.py#L48-L76 | train |
apache/incubator-mxnet | example/ssd/detect/detector.py | Detector.create_batch | def create_batch(self, frame):
"""
:param frame: an (w,h,channels) numpy array (image)
:return: DataBatch of (1,channels,data_shape,data_shape)
"""
frame_resize = mx.nd.array(cv2.resize(frame, (self.data_shape[0], self.data_shape[1])))
#frame_resize = mx.img.imresize(fram... | python | def create_batch(self, frame):
"""
:param frame: an (w,h,channels) numpy array (image)
:return: DataBatch of (1,channels,data_shape,data_shape)
"""
frame_resize = mx.nd.array(cv2.resize(frame, (self.data_shape[0], self.data_shape[1])))
#frame_resize = mx.img.imresize(fram... | [
"def",
"create_batch",
"(",
"self",
",",
"frame",
")",
":",
"frame_resize",
"=",
"mx",
".",
"nd",
".",
"array",
"(",
"cv2",
".",
"resize",
"(",
"frame",
",",
"(",
"self",
".",
"data_shape",
"[",
"0",
"]",
",",
"self",
".",
"data_shape",
"[",
"1",
... | :param frame: an (w,h,channels) numpy array (image)
:return: DataBatch of (1,channels,data_shape,data_shape) | [
":",
"param",
"frame",
":",
"an",
"(",
"w",
"h",
"channels",
")",
"numpy",
"array",
"(",
"image",
")",
":",
"return",
":",
"DataBatch",
"of",
"(",
"1",
"channels",
"data_shape",
"data_shape",
")"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/detect/detector.py#L66-L80 | train |
apache/incubator-mxnet | example/ssd/detect/detector.py | Detector.detect_iter | def detect_iter(self, det_iter, show_timer=False):
"""
detect all images in iterator
Parameters:
----------
det_iter : DetIter
iterator for all testing images
show_timer : Boolean
whether to print out detection exec time
Returns:
... | python | def detect_iter(self, det_iter, show_timer=False):
"""
detect all images in iterator
Parameters:
----------
det_iter : DetIter
iterator for all testing images
show_timer : Boolean
whether to print out detection exec time
Returns:
... | [
"def",
"detect_iter",
"(",
"self",
",",
"det_iter",
",",
"show_timer",
"=",
"False",
")",
":",
"num_images",
"=",
"det_iter",
".",
"_size",
"if",
"not",
"isinstance",
"(",
"det_iter",
",",
"mx",
".",
"io",
".",
"PrefetchingIter",
")",
":",
"det_iter",
"=... | detect all images in iterator
Parameters:
----------
det_iter : DetIter
iterator for all testing images
show_timer : Boolean
whether to print out detection exec time
Returns:
----------
list of detection results | [
"detect",
"all",
"images",
"in",
"iterator"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/detect/detector.py#L82-L107 | train |
apache/incubator-mxnet | example/ssd/detect/detector.py | Detector.detect_batch | def detect_batch(self, batch):
"""
Return detections for batch
:param batch:
:return:
"""
self.mod.forward(batch, is_train=False)
detections = self.mod.get_outputs()[0]
positive_detections = Detector.filter_positive_detections(detections)
return po... | python | def detect_batch(self, batch):
"""
Return detections for batch
:param batch:
:return:
"""
self.mod.forward(batch, is_train=False)
detections = self.mod.get_outputs()[0]
positive_detections = Detector.filter_positive_detections(detections)
return po... | [
"def",
"detect_batch",
"(",
"self",
",",
"batch",
")",
":",
"self",
".",
"mod",
".",
"forward",
"(",
"batch",
",",
"is_train",
"=",
"False",
")",
"detections",
"=",
"self",
".",
"mod",
".",
"get_outputs",
"(",
")",
"[",
"0",
"]",
"positive_detections",... | Return detections for batch
:param batch:
:return: | [
"Return",
"detections",
"for",
"batch",
":",
"param",
"batch",
":",
":",
"return",
":"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/detect/detector.py#L109-L118 | train |
apache/incubator-mxnet | example/ssd/detect/detector.py | Detector.im_detect | def im_detect(self, im_list, root_dir=None, extension=None, show_timer=False):
"""
wrapper for detecting multiple images
Parameters:
----------
im_list : list of str
image path or list of image paths
root_dir : str
directory of input images, optio... | python | def im_detect(self, im_list, root_dir=None, extension=None, show_timer=False):
"""
wrapper for detecting multiple images
Parameters:
----------
im_list : list of str
image path or list of image paths
root_dir : str
directory of input images, optio... | [
"def",
"im_detect",
"(",
"self",
",",
"im_list",
",",
"root_dir",
"=",
"None",
",",
"extension",
"=",
"None",
",",
"show_timer",
"=",
"False",
")",
":",
"test_db",
"=",
"TestDB",
"(",
"im_list",
",",
"root_dir",
"=",
"root_dir",
",",
"extension",
"=",
... | wrapper for detecting multiple images
Parameters:
----------
im_list : list of str
image path or list of image paths
root_dir : str
directory of input images, optional if image path already
has full directory information
extension : str
... | [
"wrapper",
"for",
"detecting",
"multiple",
"images"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/detect/detector.py#L120-L142 | train |
apache/incubator-mxnet | example/ssd/detect/detector.py | Detector.visualize_detection | def visualize_detection(self, img, dets, classes=[], thresh=0.6):
"""
visualize detections in one image
Parameters:
----------
img : numpy.array
image, in bgr format
dets : numpy.array
ssd detections, numpy.array([[id, score, x1, y1, x2, y2]...])
... | python | def visualize_detection(self, img, dets, classes=[], thresh=0.6):
"""
visualize detections in one image
Parameters:
----------
img : numpy.array
image, in bgr format
dets : numpy.array
ssd detections, numpy.array([[id, score, x1, y1, x2, y2]...])
... | [
"def",
"visualize_detection",
"(",
"self",
",",
"img",
",",
"dets",
",",
"classes",
"=",
"[",
"]",
",",
"thresh",
"=",
"0.6",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"random",
"plt",
".",
"imshow",
"(",
"img",
")",
"he... | visualize detections in one image
Parameters:
----------
img : numpy.array
image, in bgr format
dets : numpy.array
ssd detections, numpy.array([[id, score, x1, y1, x2, y2]...])
each row is one object
classes : tuple or list of str
... | [
"visualize",
"detections",
"in",
"one",
"image"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/detect/detector.py#L144-L189 | train |
apache/incubator-mxnet | example/ssd/detect/detector.py | Detector.filter_positive_detections | def filter_positive_detections(detections):
"""
First column (class id) is -1 for negative detections
:param detections:
:return:
"""
class_idx = 0
assert(isinstance(detections, mx.nd.NDArray) or isinstance(detections, np.ndarray))
detections_per_image = [... | python | def filter_positive_detections(detections):
"""
First column (class id) is -1 for negative detections
:param detections:
:return:
"""
class_idx = 0
assert(isinstance(detections, mx.nd.NDArray) or isinstance(detections, np.ndarray))
detections_per_image = [... | [
"def",
"filter_positive_detections",
"(",
"detections",
")",
":",
"class_idx",
"=",
"0",
"assert",
"(",
"isinstance",
"(",
"detections",
",",
"mx",
".",
"nd",
".",
"NDArray",
")",
"or",
"isinstance",
"(",
"detections",
",",
"np",
".",
"ndarray",
")",
")",
... | First column (class id) is -1 for negative detections
:param detections:
:return: | [
"First",
"column",
"(",
"class",
"id",
")",
"is",
"-",
"1",
"for",
"negative",
"detections",
":",
"param",
"detections",
":",
":",
"return",
":"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/detect/detector.py#L192-L210 | train |
apache/incubator-mxnet | example/ssd/detect/detector.py | Detector.detect_and_visualize | def detect_and_visualize(self, im_list, root_dir=None, extension=None,
classes=[], thresh=0.6, show_timer=False):
"""
wrapper for im_detect and visualize_detection
Parameters:
----------
im_list : list of str or str
image path or list of ... | python | def detect_and_visualize(self, im_list, root_dir=None, extension=None,
classes=[], thresh=0.6, show_timer=False):
"""
wrapper for im_detect and visualize_detection
Parameters:
----------
im_list : list of str or str
image path or list of ... | [
"def",
"detect_and_visualize",
"(",
"self",
",",
"im_list",
",",
"root_dir",
"=",
"None",
",",
"extension",
"=",
"None",
",",
"classes",
"=",
"[",
"]",
",",
"thresh",
"=",
"0.6",
",",
"show_timer",
"=",
"False",
")",
":",
"dets",
"=",
"self",
".",
"i... | wrapper for im_detect and visualize_detection
Parameters:
----------
im_list : list of str or str
image path or list of image paths
root_dir : str or None
directory of input images, optional if image path already
has full directory information
... | [
"wrapper",
"for",
"im_detect",
"and",
"visualize_detection"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/detect/detector.py#L212-L238 | train |
apache/incubator-mxnet | tools/caffe_converter/caffe_proto_utils.py | process_network_proto | def process_network_proto(caffe_root, deploy_proto):
"""
Runs the caffe upgrade tool on the prototxt to create a prototxt in the latest format.
This enable us to work just with latest structures, instead of supporting all the variants
:param caffe_root: link to caffe root folder, where the upgrade tool... | python | def process_network_proto(caffe_root, deploy_proto):
"""
Runs the caffe upgrade tool on the prototxt to create a prototxt in the latest format.
This enable us to work just with latest structures, instead of supporting all the variants
:param caffe_root: link to caffe root folder, where the upgrade tool... | [
"def",
"process_network_proto",
"(",
"caffe_root",
",",
"deploy_proto",
")",
":",
"processed_deploy_proto",
"=",
"deploy_proto",
"+",
"\".processed\"",
"from",
"shutil",
"import",
"copyfile",
"copyfile",
"(",
"deploy_proto",
",",
"processed_deploy_proto",
")",
"# run up... | Runs the caffe upgrade tool on the prototxt to create a prototxt in the latest format.
This enable us to work just with latest structures, instead of supporting all the variants
:param caffe_root: link to caffe root folder, where the upgrade tool is located
:param deploy_proto: name of the original prototx... | [
"Runs",
"the",
"caffe",
"upgrade",
"tool",
"on",
"the",
"prototxt",
"to",
"create",
"a",
"prototxt",
"in",
"the",
"latest",
"format",
".",
"This",
"enable",
"us",
"to",
"work",
"just",
"with",
"latest",
"structures",
"instead",
"of",
"supporting",
"all",
"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/caffe_proto_utils.py#L22-L42 | train |
apache/incubator-mxnet | tools/caffe_converter/caffe_proto_utils.py | read_network_dag | def read_network_dag(processed_deploy_prototxt):
"""
Reads from the caffe prototxt the network structure
:param processed_deploy_prototxt: name of prototxt to load, preferably the prototxt should
be processed before using a call to process_network_proto()
:return: network_def, layer_name_to_record,... | python | def read_network_dag(processed_deploy_prototxt):
"""
Reads from the caffe prototxt the network structure
:param processed_deploy_prototxt: name of prototxt to load, preferably the prototxt should
be processed before using a call to process_network_proto()
:return: network_def, layer_name_to_record,... | [
"def",
"read_network_dag",
"(",
"processed_deploy_prototxt",
")",
":",
"from",
"caffe",
".",
"proto",
"import",
"caffe_pb2",
"from",
"google",
".",
"protobuf",
"import",
"text_format",
"# pylint: disable=relative-import",
"from",
"collections",
"import",
"OrderedDict",
... | Reads from the caffe prototxt the network structure
:param processed_deploy_prototxt: name of prototxt to load, preferably the prototxt should
be processed before using a call to process_network_proto()
:return: network_def, layer_name_to_record, top_to_layers
network_def: caffe network structure, give... | [
"Reads",
"from",
"the",
"caffe",
"prototxt",
"the",
"network",
"structure",
":",
"param",
"processed_deploy_prototxt",
":",
"name",
"of",
"prototxt",
"to",
"load",
"preferably",
"the",
"prototxt",
"should",
"be",
"processed",
"before",
"using",
"a",
"call",
"to"... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/caffe_proto_utils.py#L117-L182 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.