partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
load_model
Loads a serialized ModelProto into memory @params f can be a file-like object (has "read" function) or a string containing a file name format is for future use @return Loaded in-memory ModelProto
onnx/__init__.py
def load_model(f, format=None, load_external_data=True): # type: (Union[IO[bytes], Text], Optional[Any], bool) -> ModelProto ''' Loads a serialized ModelProto into memory @params f can be a file-like object (has "read" function) or a string containing a file name format is for future use @ret...
def load_model(f, format=None, load_external_data=True): # type: (Union[IO[bytes], Text], Optional[Any], bool) -> ModelProto ''' Loads a serialized ModelProto into memory @params f can be a file-like object (has "read" function) or a string containing a file name format is for future use @ret...
[ "Loads", "a", "serialized", "ModelProto", "into", "memory" ]
onnx/onnx
python
https://github.com/onnx/onnx/blob/2f7dc10f03a072526d94b6820cedbf2a1ec5a2c4/onnx/__init__.py#L102-L122
[ "def", "load_model", "(", "f", ",", "format", "=", "None", ",", "load_external_data", "=", "True", ")", ":", "# type: (Union[IO[bytes], Text], Optional[Any], bool) -> ModelProto", "s", "=", "_load_bytes", "(", "f", ")", "model", "=", "load_model_from_string", "(", "...
2f7dc10f03a072526d94b6820cedbf2a1ec5a2c4
train
load_tensor
Loads a serialized TensorProto into memory @params f can be a file-like object (has "read" function) or a string containing a file name format is for future use @return Loaded in-memory TensorProto
onnx/__init__.py
def load_tensor(f, format=None): # type: (Union[IO[bytes], Text], Optional[Any]) -> TensorProto ''' Loads a serialized TensorProto into memory @params f can be a file-like object (has "read" function) or a string containing a file name format is for future use @return Loaded in-memory Ten...
def load_tensor(f, format=None): # type: (Union[IO[bytes], Text], Optional[Any]) -> TensorProto ''' Loads a serialized TensorProto into memory @params f can be a file-like object (has "read" function) or a string containing a file name format is for future use @return Loaded in-memory Ten...
[ "Loads", "a", "serialized", "TensorProto", "into", "memory" ]
onnx/onnx
python
https://github.com/onnx/onnx/blob/2f7dc10f03a072526d94b6820cedbf2a1ec5a2c4/onnx/__init__.py#L125-L137
[ "def", "load_tensor", "(", "f", ",", "format", "=", "None", ")", ":", "# type: (Union[IO[bytes], Text], Optional[Any]) -> TensorProto", "s", "=", "_load_bytes", "(", "f", ")", "return", "load_tensor_from_string", "(", "s", ",", "format", "=", "format", ")" ]
2f7dc10f03a072526d94b6820cedbf2a1ec5a2c4
train
save_model
Saves the ModelProto to the specified path. @params proto should be a in-memory ModelProto f can be a file-like object (has "write" function) or a string containing a file name format is for future use
onnx/__init__.py
def save_model(proto, f, format=None): # type: (Union[ModelProto, bytes], Union[IO[bytes], Text], Optional[Any]) -> None ''' Saves the ModelProto to the specified path. @params proto should be a in-memory ModelProto f can be a file-like object (has "write" function) or a string containing a file n...
def save_model(proto, f, format=None): # type: (Union[ModelProto, bytes], Union[IO[bytes], Text], Optional[Any]) -> None ''' Saves the ModelProto to the specified path. @params proto should be a in-memory ModelProto f can be a file-like object (has "write" function) or a string containing a file n...
[ "Saves", "the", "ModelProto", "to", "the", "specified", "path", "." ]
onnx/onnx
python
https://github.com/onnx/onnx/blob/2f7dc10f03a072526d94b6820cedbf2a1ec5a2c4/onnx/__init__.py#L168-L186
[ "def", "save_model", "(", "proto", ",", "f", ",", "format", "=", "None", ")", ":", "# type: (Union[ModelProto, bytes], Union[IO[bytes], Text], Optional[Any]) -> None", "if", "isinstance", "(", "proto", ",", "bytes", ")", ":", "proto", "=", "_deserialize", "(", "prot...
2f7dc10f03a072526d94b6820cedbf2a1ec5a2c4
train
polish_model
This function combines several useful utility functions together.
onnx/utils.py
def polish_model(model): # type: (ModelProto) -> ModelProto ''' This function combines several useful utility functions together. ''' onnx.checker.check_model(model) onnx.helper.strip_doc_string(model) model = onnx.shape_inference.infer_shapes(model) model = onnx.optimizer.optimize(mode...
def polish_model(model): # type: (ModelProto) -> ModelProto ''' This function combines several useful utility functions together. ''' onnx.checker.check_model(model) onnx.helper.strip_doc_string(model) model = onnx.shape_inference.infer_shapes(model) model = onnx.optimizer.optimize(mode...
[ "This", "function", "combines", "several", "useful", "utility", "functions", "together", "." ]
onnx/onnx
python
https://github.com/onnx/onnx/blob/2f7dc10f03a072526d94b6820cedbf2a1ec5a2c4/onnx/utils.py#L14-L23
[ "def", "polish_model", "(", "model", ")", ":", "# type: (ModelProto) -> ModelProto", "onnx", ".", "checker", ".", "check_model", "(", "model", ")", "onnx", ".", "helper", ".", "strip_doc_string", "(", "model", ")", "model", "=", "onnx", ".", "shape_inference", ...
2f7dc10f03a072526d94b6820cedbf2a1ec5a2c4
train
dynamic_unroll
Unrolls an RNN cell across time steps. Currently, 'TNC' is a preferred layout. unroll on the input of this layout runs much faster. Parameters ---------- cell : an object whose base class is RNNCell. The RNN cell to run on the input sequence. inputs : Symbol It should have shap...
python/mxnet/gluon/contrib/rnn/rnn_cell.py
def dynamic_unroll(cell, inputs, begin_state, drop_inputs=0, drop_outputs=0, layout='TNC', valid_length=None): """Unrolls an RNN cell across time steps. Currently, 'TNC' is a preferred layout. unroll on the input of this layout runs much faster. Parameters ---------- cell : ...
def dynamic_unroll(cell, inputs, begin_state, drop_inputs=0, drop_outputs=0, layout='TNC', valid_length=None): """Unrolls an RNN cell across time steps. Currently, 'TNC' is a preferred layout. unroll on the input of this layout runs much faster. Parameters ---------- cell : ...
[ "Unrolls", "an", "RNN", "cell", "across", "time", "steps", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/contrib/rnn/rnn_cell.py#L326-L437
[ "def", "dynamic_unroll", "(", "cell", ",", "inputs", ",", "begin_state", ",", "drop_inputs", "=", "0", ",", "drop_outputs", "=", "0", ",", "layout", "=", "'TNC'", ",", "valid_length", "=", "None", ")", ":", "# Merge is always True, so we don't need length.", "in...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
VariationalDropoutCell.unroll
Unrolls 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 (ba...
python/mxnet/gluon/contrib/rnn/rnn_cell.py
def unroll(self, length, inputs, begin_state=None, layout='NTC', merge_outputs=None, valid_length=None): """Unrolls an RNN cell across time steps. Parameters ---------- length : int Number of steps to unroll. inputs : Symbol, list of Symbol, or None ...
def unroll(self, length, inputs, begin_state=None, layout='NTC', merge_outputs=None, valid_length=None): """Unrolls an RNN cell across time steps. Parameters ---------- length : int Number of steps to unroll. inputs : Symbol, list of Symbol, or None ...
[ "Unrolls", "an", "RNN", "cell", "across", "time", "steps", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/contrib/rnn/rnn_cell.py#L117-L195
[ "def", "unroll", "(", "self", ",", "length", ",", "inputs", ",", "begin_state", "=", "None", ",", "layout", "=", "'NTC'", ",", "merge_outputs", "=", "None", ",", "valid_length", "=", "None", ")", ":", "# Dropout on inputs and outputs can be performed on the whole ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_fix_attribute_names
Change attribute names as per values in change_map dictionary. Parameters ---------- :param attrs : dict Dict of operator attributes :param change_map : dict Dict of onnx attribute name to mxnet attribute names. Returns ------- :return new_attr : dict Converted dict of operator attributes.
python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py
def _fix_attribute_names(attrs, change_map): """ Change attribute names as per values in change_map dictionary. Parameters ---------- :param attrs : dict Dict of operator attributes :param change_map : dict Dict of onnx attribute name to mxnet attribute names. Returns ------- :retur...
def _fix_attribute_names(attrs, change_map): """ Change attribute names as per values in change_map dictionary. Parameters ---------- :param attrs : dict Dict of operator attributes :param change_map : dict Dict of onnx attribute name to mxnet attribute names. Returns ------- :retur...
[ "Change", "attribute", "names", "as", "per", "values", "in", "change_map", "dictionary", ".", "Parameters", "----------", ":", "param", "attrs", ":", "dict", "Dict", "of", "operator", "attributes", ":", "param", "change_map", ":", "dict", "Dict", "of", "onnx",...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py#L29-L47
[ "def", "_fix_attribute_names", "(", "attrs", ",", "change_map", ")", ":", "new_attr", "=", "{", "}", "for", "k", "in", "attrs", ".", "keys", "(", ")", ":", "if", "k", "in", "change_map", ":", "new_attr", "[", "change_map", "[", "k", "]", "]", "=", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_remove_attributes
Removes attributes in the remove list from the input attribute dict :param attrs : Dict of operator attributes :param remove_list : list of attributes to be removed :return new_attr : Dict of operator attributes without the listed attributes.
python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py
def _remove_attributes(attrs, remove_list): """ Removes attributes in the remove list from the input attribute dict :param attrs : Dict of operator attributes :param remove_list : list of attributes to be removed :return new_attr : Dict of operator attributes without the listed attributes. """ ...
def _remove_attributes(attrs, remove_list): """ Removes attributes in the remove list from the input attribute dict :param attrs : Dict of operator attributes :param remove_list : list of attributes to be removed :return new_attr : Dict of operator attributes without the listed attributes. """ ...
[ "Removes", "attributes", "in", "the", "remove", "list", "from", "the", "input", "attribute", "dict", ":", "param", "attrs", ":", "Dict", "of", "operator", "attributes", ":", "param", "remove_list", ":", "list", "of", "attributes", "to", "be", "removed" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py#L49-L61
[ "def", "_remove_attributes", "(", "attrs", ",", "remove_list", ")", ":", "new_attrs", "=", "{", "}", "for", "attr", "in", "attrs", ".", "keys", "(", ")", ":", "if", "attr", "not", "in", "remove_list", ":", "new_attrs", "[", "attr", "]", "=", "attrs", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_add_extra_attributes
:param attrs: Current Attribute list :param extraAttrMap: Additional attributes to be added :return: new_attr
python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py
def _add_extra_attributes(attrs, extra_attr_map): """ :param attrs: Current Attribute list :param extraAttrMap: Additional attributes to be added :return: new_attr """ for attr in extra_attr_map: if attr not in attrs: attrs[attr] = extra_attr_map[attr] return attrs
def _add_extra_attributes(attrs, extra_attr_map): """ :param attrs: Current Attribute list :param extraAttrMap: Additional attributes to be added :return: new_attr """ for attr in extra_attr_map: if attr not in attrs: attrs[attr] = extra_attr_map[attr] return attrs
[ ":", "param", "attrs", ":", "Current", "Attribute", "list", ":", "param", "extraAttrMap", ":", "Additional", "attributes", "to", "be", "added", ":", "return", ":", "new_attr" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py#L63-L72
[ "def", "_add_extra_attributes", "(", "attrs", ",", "extra_attr_map", ")", ":", "for", "attr", "in", "extra_attr_map", ":", "if", "attr", "not", "in", "attrs", ":", "attrs", "[", "attr", "]", "=", "extra_attr_map", "[", "attr", "]", "return", "attrs" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_pad_sequence_fix
Changing onnx's pads sequence to match with mxnet's pad_width mxnet: (x1_begin, x1_end, ... , xn_begin, xn_end) onnx: (x1_begin, x2_begin, ... , xn_end, xn_end)
python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py
def _pad_sequence_fix(attr, kernel_dim=None): """Changing onnx's pads sequence to match with mxnet's pad_width mxnet: (x1_begin, x1_end, ... , xn_begin, xn_end) onnx: (x1_begin, x2_begin, ... , xn_end, xn_end)""" new_attr = () if len(attr) % 2 == 0: for index in range(int(len(attr) / 2)): ...
def _pad_sequence_fix(attr, kernel_dim=None): """Changing onnx's pads sequence to match with mxnet's pad_width mxnet: (x1_begin, x1_end, ... , xn_begin, xn_end) onnx: (x1_begin, x2_begin, ... , xn_end, xn_end)""" new_attr = () if len(attr) % 2 == 0: for index in range(int(len(attr) / 2)): ...
[ "Changing", "onnx", "s", "pads", "sequence", "to", "match", "with", "mxnet", "s", "pad_width", "mxnet", ":", "(", "x1_begin", "x1_end", "...", "xn_begin", "xn_end", ")", "onnx", ":", "(", "x1_begin", "x2_begin", "...", "xn_end", "xn_end", ")" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py#L75-L88
[ "def", "_pad_sequence_fix", "(", "attr", ",", "kernel_dim", "=", "None", ")", ":", "new_attr", "=", "(", ")", "if", "len", "(", "attr", ")", "%", "2", "==", "0", ":", "for", "index", "in", "range", "(", "int", "(", "len", "(", "attr", ")", "/", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_fix_pooling
onnx pooling operator supports asymmetrical padding Adding pad operator before pooling in mxnet to work with onnx
python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py
def _fix_pooling(pool_type, inputs, new_attr): """onnx pooling operator supports asymmetrical padding Adding pad operator before pooling in mxnet to work with onnx""" stride = new_attr.get('stride') kernel = new_attr.get('kernel') padding = new_attr.get('pad') p_value = new_attr.get('p_value') ...
def _fix_pooling(pool_type, inputs, new_attr): """onnx pooling operator supports asymmetrical padding Adding pad operator before pooling in mxnet to work with onnx""" stride = new_attr.get('stride') kernel = new_attr.get('kernel') padding = new_attr.get('pad') p_value = new_attr.get('p_value') ...
[ "onnx", "pooling", "operator", "supports", "asymmetrical", "padding", "Adding", "pad", "operator", "before", "pooling", "in", "mxnet", "to", "work", "with", "onnx" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py#L91-L146
[ "def", "_fix_pooling", "(", "pool_type", ",", "inputs", ",", "new_attr", ")", ":", "stride", "=", "new_attr", ".", "get", "(", "'stride'", ")", "kernel", "=", "new_attr", ".", "get", "(", "'kernel'", ")", "padding", "=", "new_attr", ".", "get", "(", "'...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_fix_bias
A workaround for 'use_bias' attribute since onnx don't provide this attribute, we have to check the number of inputs to decide it.
python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py
def _fix_bias(op_name, attrs, num_inputs): """A workaround for 'use_bias' attribute since onnx don't provide this attribute, we have to check the number of inputs to decide it.""" if num_inputs == 3: attrs['no_bias'] = False elif num_inputs == 2: attrs['no_bias'] = True else: ...
def _fix_bias(op_name, attrs, num_inputs): """A workaround for 'use_bias' attribute since onnx don't provide this attribute, we have to check the number of inputs to decide it.""" if num_inputs == 3: attrs['no_bias'] = False elif num_inputs == 2: attrs['no_bias'] = True else: ...
[ "A", "workaround", "for", "use_bias", "attribute", "since", "onnx", "don", "t", "provide", "this", "attribute", "we", "have", "to", "check", "the", "number", "of", "inputs", "to", "decide", "it", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py#L148-L157
[ "def", "_fix_bias", "(", "op_name", ",", "attrs", ",", "num_inputs", ")", ":", "if", "num_inputs", "==", "3", ":", "attrs", "[", "'no_bias'", "]", "=", "False", "elif", "num_inputs", "==", "2", ":", "attrs", "[", "'no_bias'", "]", "=", "True", "else", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_fix_broadcast
A workaround to reshape bias term to (1, num_channel).
python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py
def _fix_broadcast(op_name, inputs, broadcast_axis, proto_obj): """A workaround to reshape bias term to (1, num_channel).""" if int(len(proto_obj._params)) > 0: assert len(list(inputs)) == 2 input0_shape = get_input_shape(inputs[0], proto_obj) #creating reshape shape reshape_sha...
def _fix_broadcast(op_name, inputs, broadcast_axis, proto_obj): """A workaround to reshape bias term to (1, num_channel).""" if int(len(proto_obj._params)) > 0: assert len(list(inputs)) == 2 input0_shape = get_input_shape(inputs[0], proto_obj) #creating reshape shape reshape_sha...
[ "A", "workaround", "to", "reshape", "bias", "term", "to", "(", "1", "num_channel", ")", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py#L159-L173
[ "def", "_fix_broadcast", "(", "op_name", ",", "inputs", ",", "broadcast_axis", ",", "proto_obj", ")", ":", "if", "int", "(", "len", "(", "proto_obj", ".", "_params", ")", ")", ">", "0", ":", "assert", "len", "(", "list", "(", "inputs", ")", ")", "=="...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_fix_channels
A workaround for getting 'channels' or 'units' since onnx don't provide these attributes. We check the shape of weights provided to get the number.
python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py
def _fix_channels(op_name, attrs, inputs, proto_obj): """A workaround for getting 'channels' or 'units' since onnx don't provide these attributes. We check the shape of weights provided to get the number. """ weight_name = inputs[1].name if not weight_name in proto_obj._params: raise ValueEr...
def _fix_channels(op_name, attrs, inputs, proto_obj): """A workaround for getting 'channels' or 'units' since onnx don't provide these attributes. We check the shape of weights provided to get the number. """ weight_name = inputs[1].name if not weight_name in proto_obj._params: raise ValueEr...
[ "A", "workaround", "for", "getting", "channels", "or", "units", "since", "onnx", "don", "t", "provide", "these", "attributes", ".", "We", "check", "the", "shape", "of", "weights", "provided", "to", "get", "the", "number", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py#L176-L198
[ "def", "_fix_channels", "(", "op_name", ",", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "weight_name", "=", "inputs", "[", "1", "]", ".", "name", "if", "not", "weight_name", "in", "proto_obj", ".", "_params", ":", "raise", "ValueError", "(", "\"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_fix_gemm
Using FullyConnected operator in place of linalg_gemm to perform same operation
python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py
def _fix_gemm(op_name, inputs, old_attr, proto_obj): """Using FullyConnected operator in place of linalg_gemm to perform same operation""" op_sym = getattr(symbol, op_name, None) alpha = float(old_attr.get('alpha', 1.0)) beta = float(old_attr.get('beta', 1.0)) trans_a = int(old_attr.get('transA', 0)...
def _fix_gemm(op_name, inputs, old_attr, proto_obj): """Using FullyConnected operator in place of linalg_gemm to perform same operation""" op_sym = getattr(symbol, op_name, None) alpha = float(old_attr.get('alpha', 1.0)) beta = float(old_attr.get('beta', 1.0)) trans_a = int(old_attr.get('transA', 0)...
[ "Using", "FullyConnected", "operator", "in", "place", "of", "linalg_gemm", "to", "perform", "same", "operation" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py#L201-L214
[ "def", "_fix_gemm", "(", "op_name", ",", "inputs", ",", "old_attr", ",", "proto_obj", ")", ":", "op_sym", "=", "getattr", "(", "symbol", ",", "op_name", ",", "None", ")", "alpha", "=", "float", "(", "old_attr", ".", "get", "(", "'alpha'", ",", "1.0", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_input_shape
Helper function to obtain the shape of an array
python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py
def get_input_shape(sym, proto_obj): """Helper function to obtain the shape of an array""" arg_params = proto_obj.arg_dict aux_params = proto_obj.aux_dict model_input_shape = [data[1] for data in proto_obj.model_metadata.get('input_tensor_data')] data_names = [data[0] for data in proto_obj.model_...
def get_input_shape(sym, proto_obj): """Helper function to obtain the shape of an array""" arg_params = proto_obj.arg_dict aux_params = proto_obj.aux_dict model_input_shape = [data[1] for data in proto_obj.model_metadata.get('input_tensor_data')] data_names = [data[0] for data in proto_obj.model_...
[ "Helper", "function", "to", "obtain", "the", "shape", "of", "an", "array" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_translation_utils.py#L216-L247
[ "def", "get_input_shape", "(", "sym", ",", "proto_obj", ")", ":", "arg_params", "=", "proto_obj", ".", "arg_dict", "aux_params", "=", "proto_obj", ".", "aux_dict", "model_input_shape", "=", "[", "data", "[", "1", "]", "for", "data", "in", "proto_obj", ".", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
imresize
r"""Resize image with OpenCV. .. note:: `imresize` uses OpenCV (not the CV2 Python library). MXNet must have been built with USE_OPENCV=1 for `imresize` to work. Parameters ---------- src : NDArray source image w : int, required Width of resized image. h : int, required ...
python/mxnet/image/image.py
def imresize(src, w, h, *args, **kwargs): r"""Resize image with OpenCV. .. note:: `imresize` uses OpenCV (not the CV2 Python library). MXNet must have been built with USE_OPENCV=1 for `imresize` to work. Parameters ---------- src : NDArray source image w : int, required ...
def imresize(src, w, h, *args, **kwargs): r"""Resize image with OpenCV. .. note:: `imresize` uses OpenCV (not the CV2 Python library). MXNet must have been built with USE_OPENCV=1 for `imresize` to work. Parameters ---------- src : NDArray source image w : int, required ...
[ "r", "Resize", "image", "with", "OpenCV", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L86-L140
[ "def", "imresize", "(", "src", ",", "w", ",", "h", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "_internal", ".", "_cvimresize", "(", "src", ",", "w", ",", "h", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
imdecode
Decode an image to an NDArray. .. note:: `imdecode` uses OpenCV (not the CV2 Python library). MXNet must have been built with USE_OPENCV=1 for `imdecode` to work. Parameters ---------- buf : str/bytes/bytearray or numpy.ndarray Binary image data as string or numpy ndarray. flag : in...
python/mxnet/image/image.py
def imdecode(buf, *args, **kwargs): """Decode an image to an NDArray. .. note:: `imdecode` uses OpenCV (not the CV2 Python library). MXNet must have been built with USE_OPENCV=1 for `imdecode` to work. Parameters ---------- buf : str/bytes/bytearray or numpy.ndarray Binary image dat...
def imdecode(buf, *args, **kwargs): """Decode an image to an NDArray. .. note:: `imdecode` uses OpenCV (not the CV2 Python library). MXNet must have been built with USE_OPENCV=1 for `imdecode` to work. Parameters ---------- buf : str/bytes/bytearray or numpy.ndarray Binary image dat...
[ "Decode", "an", "image", "to", "an", "NDArray", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L143-L198
[ "def", "imdecode", "(", "buf", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "buf", ",", "nd", ".", "NDArray", ")", ":", "if", "sys", ".", "version_info", "[", "0", "]", "==", "3", "and", "not", "isinstance"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
scale_down
Scales down crop size if it's larger than image size. If width/height of the crop is larger than the width/height of the image, sets the width/height to the width/height of the image. Parameters ---------- src_size : tuple of int Size of the image in (width, height) format. size : tupl...
python/mxnet/image/image.py
def scale_down(src_size, size): """Scales down crop size if it's larger than image size. If width/height of the crop is larger than the width/height of the image, sets the width/height to the width/height of the image. Parameters ---------- src_size : tuple of int Size of the image in ...
def scale_down(src_size, size): """Scales down crop size if it's larger than image size. If width/height of the crop is larger than the width/height of the image, sets the width/height to the width/height of the image. Parameters ---------- src_size : tuple of int Size of the image in ...
[ "Scales", "down", "crop", "size", "if", "it", "s", "larger", "than", "image", "size", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L201-L233
[ "def", "scale_down", "(", "src_size", ",", "size", ")", ":", "w", ",", "h", "=", "size", "sw", ",", "sh", "=", "src_size", "if", "sh", "<", "h", ":", "w", ",", "h", "=", "float", "(", "w", "*", "sh", ")", "/", "h", ",", "sh", "if", "sw", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
copyMakeBorder
Pad image border with OpenCV. Parameters ---------- src : NDArray source image top : int, required Top margin. bot : int, required Bottom margin. left : int, required Left margin. right : int, required Right margin. type : int, optional, default='...
python/mxnet/image/image.py
def copyMakeBorder(src, top, bot, left, right, *args, **kwargs): """Pad image border with OpenCV. Parameters ---------- src : NDArray source image top : int, required Top margin. bot : int, required Bottom margin. left : int, required Left margin. right :...
def copyMakeBorder(src, top, bot, left, right, *args, **kwargs): """Pad image border with OpenCV. Parameters ---------- src : NDArray source image top : int, required Top margin. bot : int, required Bottom margin. left : int, required Left margin. right :...
[ "Pad", "image", "border", "with", "OpenCV", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L236-L286
[ "def", "copyMakeBorder", "(", "src", ",", "top", ",", "bot", ",", "left", ",", "right", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "_internal", ".", "_cvcopyMakeBorder", "(", "src", ",", "top", ",", "bot", ",", "left", ",", "rig...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_get_interp_method
Get the interpolation method for resize functions. The major purpose of this function is to wrap a random interp method selection and a auto-estimation method. Parameters ---------- interp : int interpolation method for all resizing operations Possible values: 0: Nearest Ne...
python/mxnet/image/image.py
def _get_interp_method(interp, sizes=()): """Get the interpolation method for resize functions. The major purpose of this function is to wrap a random interp method selection and a auto-estimation method. Parameters ---------- interp : int interpolation method for all resizing operation...
def _get_interp_method(interp, sizes=()): """Get the interpolation method for resize functions. The major purpose of this function is to wrap a random interp method selection and a auto-estimation method. Parameters ---------- interp : int interpolation method for all resizing operation...
[ "Get", "the", "interpolation", "method", "for", "resize", "functions", ".", "The", "major", "purpose", "of", "this", "function", "is", "to", "wrap", "a", "random", "interp", "method", "selection", "and", "a", "auto", "-", "estimation", "method", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L289-L341
[ "def", "_get_interp_method", "(", "interp", ",", "sizes", "=", "(", ")", ")", ":", "if", "interp", "==", "9", ":", "if", "sizes", ":", "assert", "len", "(", "sizes", ")", "==", "4", "oh", ",", "ow", ",", "nh", ",", "nw", "=", "sizes", "if", "nh...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
resize_short
Resizes shorter edge to size. .. note:: `resize_short` uses OpenCV (not the CV2 Python library). MXNet must have been built with OpenCV for `resize_short` to work. Resizes the original image by setting the shorter edge to size and setting the longer edge accordingly. Resizing function is called...
python/mxnet/image/image.py
def resize_short(src, size, interp=2): """Resizes shorter edge to size. .. note:: `resize_short` uses OpenCV (not the CV2 Python library). MXNet must have been built with OpenCV for `resize_short` to work. Resizes the original image by setting the shorter edge to size and setting the longer edg...
def resize_short(src, size, interp=2): """Resizes shorter edge to size. .. note:: `resize_short` uses OpenCV (not the CV2 Python library). MXNet must have been built with OpenCV for `resize_short` to work. Resizes the original image by setting the shorter edge to size and setting the longer edg...
[ "Resizes", "shorter", "edge", "to", "size", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L344-L403
[ "def", "resize_short", "(", "src", ",", "size", ",", "interp", "=", "2", ")", ":", "h", ",", "w", ",", "_", "=", "src", ".", "shape", "if", "h", ">", "w", ":", "new_h", ",", "new_w", "=", "size", "*", "h", "//", "w", ",", "size", "else", ":...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
fixed_crop
Crop src at fixed location, and (optionally) resize it to size. Parameters ---------- src : NDArray Input image x0 : int Left boundary of the cropping area y0 : int Top boundary of the cropping area w : int Width of the cropping area h : int Height of...
python/mxnet/image/image.py
def fixed_crop(src, x0, y0, w, h, size=None, interp=2): """Crop src at fixed location, and (optionally) resize it to size. Parameters ---------- src : NDArray Input image x0 : int Left boundary of the cropping area y0 : int Top boundary of the cropping area w : int ...
def fixed_crop(src, x0, y0, w, h, size=None, interp=2): """Crop src at fixed location, and (optionally) resize it to size. Parameters ---------- src : NDArray Input image x0 : int Left boundary of the cropping area y0 : int Top boundary of the cropping area w : int ...
[ "Crop", "src", "at", "fixed", "location", "and", "(", "optionally", ")", "resize", "it", "to", "size", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L406-L435
[ "def", "fixed_crop", "(", "src", ",", "x0", ",", "y0", ",", "w", ",", "h", ",", "size", "=", "None", ",", "interp", "=", "2", ")", ":", "out", "=", "nd", ".", "slice", "(", "src", ",", "begin", "=", "(", "y0", ",", "x0", ",", "0", ")", ",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
center_crop
Crops the image `src` to the given `size` by trimming on all four sides and preserving the center of the image. Upsamples if `src` is smaller than `size`. .. note:: This requires MXNet to be compiled with USE_OPENCV. Parameters ---------- src : NDArray Binary source image data. siz...
python/mxnet/image/image.py
def center_crop(src, size, interp=2): """Crops the image `src` to the given `size` by trimming on all four sides and preserving the center of the image. Upsamples if `src` is smaller than `size`. .. note:: This requires MXNet to be compiled with USE_OPENCV. Parameters ---------- src : NDAr...
def center_crop(src, size, interp=2): """Crops the image `src` to the given `size` by trimming on all four sides and preserving the center of the image. Upsamples if `src` is smaller than `size`. .. note:: This requires MXNet to be compiled with USE_OPENCV. Parameters ---------- src : NDAr...
[ "Crops", "the", "image", "src", "to", "the", "given", "size", "by", "trimming", "on", "all", "four", "sides", "and", "preserving", "the", "center", "of", "the", "image", ".", "Upsamples", "if", "src", "is", "smaller", "than", "size", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L477-L523
[ "def", "center_crop", "(", "src", ",", "size", ",", "interp", "=", "2", ")", ":", "h", ",", "w", ",", "_", "=", "src", ".", "shape", "new_w", ",", "new_h", "=", "scale_down", "(", "(", "w", ",", "h", ")", ",", "size", ")", "x0", "=", "int", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
color_normalize
Normalize src with mean and std. Parameters ---------- src : NDArray Input image mean : NDArray RGB mean to be subtracted std : NDArray RGB standard deviation to be divided Returns ------- NDArray An `NDArray` containing the normalized image.
python/mxnet/image/image.py
def color_normalize(src, mean, std=None): """Normalize src with mean and std. Parameters ---------- src : NDArray Input image mean : NDArray RGB mean to be subtracted std : NDArray RGB standard deviation to be divided Returns ------- NDArray An `NDAr...
def color_normalize(src, mean, std=None): """Normalize src with mean and std. Parameters ---------- src : NDArray Input image mean : NDArray RGB mean to be subtracted std : NDArray RGB standard deviation to be divided Returns ------- NDArray An `NDAr...
[ "Normalize", "src", "with", "mean", "and", "std", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L526-L547
[ "def", "color_normalize", "(", "src", ",", "mean", ",", "std", "=", "None", ")", ":", "if", "mean", "is", "not", "None", ":", "src", "-=", "mean", "if", "std", "is", "not", "None", ":", "src", "/=", "std", "return", "src" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
random_size_crop
Randomly crop src with size. Randomize area and aspect ratio. Parameters ---------- src : NDArray Input image size : tuple of (int, int) Size of the crop formatted as (width, height). area : float in (0, 1] or tuple of (float, float) If tuple, minimum area and maximum area t...
python/mxnet/image/image.py
def random_size_crop(src, size, area, ratio, interp=2, **kwargs): """Randomly crop src with size. Randomize area and aspect ratio. Parameters ---------- src : NDArray Input image size : tuple of (int, int) Size of the crop formatted as (width, height). area : float in (0, 1] or ...
def random_size_crop(src, size, area, ratio, interp=2, **kwargs): """Randomly crop src with size. Randomize area and aspect ratio. Parameters ---------- src : NDArray Input image size : tuple of (int, int) Size of the crop formatted as (width, height). area : float in (0, 1] or ...
[ "Randomly", "crop", "src", "with", "size", ".", "Randomize", "area", "and", "aspect", "ratio", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L550-L602
[ "def", "random_size_crop", "(", "src", ",", "size", ",", "area", ",", "ratio", ",", "interp", "=", "2", ",", "*", "*", "kwargs", ")", ":", "h", ",", "w", ",", "_", "=", "src", ".", "shape", "src_area", "=", "h", "*", "w", "if", "'min_area'", "i...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
CreateAugmenter
Creates an augmenter list. Parameters ---------- data_shape : tuple of int Shape for output data resize : int Resize shorter edge if larger than 0 at the begining rand_crop : bool Whether to enable random cropping other than center crop rand_resize : bool Whether...
python/mxnet/image/image.py
def CreateAugmenter(data_shape, resize=0, rand_crop=False, rand_resize=False, rand_mirror=False, mean=None, std=None, brightness=0, contrast=0, saturation=0, hue=0, pca_noise=0, rand_gray=0, inter_method=2): """Creates an augmenter list. Parameters ---------- dat...
def CreateAugmenter(data_shape, resize=0, rand_crop=False, rand_resize=False, rand_mirror=False, mean=None, std=None, brightness=0, contrast=0, saturation=0, hue=0, pca_noise=0, rand_gray=0, inter_method=2): """Creates an augmenter list. Parameters ---------- dat...
[ "Creates", "an", "augmenter", "list", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L1015-L1126
[ "def", "CreateAugmenter", "(", "data_shape", ",", "resize", "=", "0", ",", "rand_crop", "=", "False", ",", "rand_resize", "=", "False", ",", "rand_mirror", "=", "False", ",", "mean", "=", "None", ",", "std", "=", "None", ",", "brightness", "=", "0", ",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Augmenter.dumps
Saves the Augmenter to string Returns ------- str JSON formatted string that describes the Augmenter.
python/mxnet/image/image.py
def dumps(self): """Saves the Augmenter to string Returns ------- str JSON formatted string that describes the Augmenter. """ return json.dumps([self.__class__.__name__.lower(), self._kwargs])
def dumps(self): """Saves the Augmenter to string Returns ------- str JSON formatted string that describes the Augmenter. """ return json.dumps([self.__class__.__name__.lower(), self._kwargs])
[ "Saves", "the", "Augmenter", "to", "string" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L616-L624
[ "def", "dumps", "(", "self", ")", ":", "return", "json", ".", "dumps", "(", "[", "self", ".", "__class__", ".", "__name__", ".", "lower", "(", ")", ",", "self", ".", "_kwargs", "]", ")" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SequentialAug.dumps
Override the default to avoid duplicate dump.
python/mxnet/image/image.py
def dumps(self): """Override the default to avoid duplicate dump.""" return [self.__class__.__name__.lower(), [x.dumps() for x in self.ts]]
def dumps(self): """Override the default to avoid duplicate dump.""" return [self.__class__.__name__.lower(), [x.dumps() for x in self.ts]]
[ "Override", "the", "default", "to", "avoid", "duplicate", "dump", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L643-L645
[ "def", "dumps", "(", "self", ")", ":", "return", "[", "self", ".", "__class__", ".", "__name__", ".", "lower", "(", ")", ",", "[", "x", ".", "dumps", "(", ")", "for", "x", "in", "self", ".", "ts", "]", "]" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
ImageIter.reset
Resets the iterator to the beginning of the data.
python/mxnet/image/image.py
def reset(self): """Resets the iterator to the beginning of the data.""" if self.seq is not None and self.shuffle: random.shuffle(self.seq) if self.last_batch_handle != 'roll_over' or \ self._cache_data is None: if self.imgrec is not None: self...
def reset(self): """Resets the iterator to the beginning of the data.""" if self.seq is not None and self.shuffle: random.shuffle(self.seq) if self.last_batch_handle != 'roll_over' or \ self._cache_data is None: if self.imgrec is not None: self...
[ "Resets", "the", "iterator", "to", "the", "beginning", "of", "the", "data", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L1278-L1288
[ "def", "reset", "(", "self", ")", ":", "if", "self", ".", "seq", "is", "not", "None", "and", "self", ".", "shuffle", ":", "random", ".", "shuffle", "(", "self", ".", "seq", ")", "if", "self", ".", "last_batch_handle", "!=", "'roll_over'", "or", "self...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
ImageIter.hard_reset
Resets the iterator and ignore roll over data
python/mxnet/image/image.py
def hard_reset(self): """Resets the iterator and ignore roll over data""" if self.seq is not None and self.shuffle: random.shuffle(self.seq) if self.imgrec is not None: self.imgrec.reset() self.cur = 0 self._allow_read = True self._cache_data = Non...
def hard_reset(self): """Resets the iterator and ignore roll over data""" if self.seq is not None and self.shuffle: random.shuffle(self.seq) if self.imgrec is not None: self.imgrec.reset() self.cur = 0 self._allow_read = True self._cache_data = Non...
[ "Resets", "the", "iterator", "and", "ignore", "roll", "over", "data" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L1290-L1300
[ "def", "hard_reset", "(", "self", ")", ":", "if", "self", ".", "seq", "is", "not", "None", "and", "self", ".", "shuffle", ":", "random", ".", "shuffle", "(", "self", ".", "seq", ")", "if", "self", ".", "imgrec", "is", "not", "None", ":", "self", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
ImageIter.next_sample
Helper function for reading in next sample.
python/mxnet/image/image.py
def next_sample(self): """Helper function for reading in next sample.""" if self._allow_read is False: raise StopIteration if self.seq is not None: if self.cur < self.num_image: idx = self.seq[self.cur] else: if self.last_batch_...
def next_sample(self): """Helper function for reading in next sample.""" if self._allow_read is False: raise StopIteration if self.seq is not None: if self.cur < self.num_image: idx = self.seq[self.cur] else: if self.last_batch_...
[ "Helper", "function", "for", "reading", "in", "next", "sample", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L1302-L1331
[ "def", "next_sample", "(", "self", ")", ":", "if", "self", ".", "_allow_read", "is", "False", ":", "raise", "StopIteration", "if", "self", ".", "seq", "is", "not", "None", ":", "if", "self", ".", "cur", "<", "self", ".", "num_image", ":", "idx", "=",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
ImageIter._batchify
Helper function for batchifying data
python/mxnet/image/image.py
def _batchify(self, batch_data, batch_label, start=0): """Helper function for batchifying data""" i = start batch_size = self.batch_size try: while i < batch_size: label, s = self.next_sample() data = self.imdecode(s) try: ...
def _batchify(self, batch_data, batch_label, start=0): """Helper function for batchifying data""" i = start batch_size = self.batch_size try: while i < batch_size: label, s = self.next_sample() data = self.imdecode(s) try: ...
[ "Helper", "function", "for", "batchifying", "data" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L1333-L1354
[ "def", "_batchify", "(", "self", ",", "batch_data", ",", "batch_label", ",", "start", "=", "0", ")", ":", "i", "=", "start", "batch_size", "=", "self", ".", "batch_size", "try", ":", "while", "i", "<", "batch_size", ":", "label", ",", "s", "=", "self...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
ImageIter.imdecode
Decodes a string or byte string to an NDArray. See mx.img.imdecode for more details.
python/mxnet/image/image.py
def imdecode(self, s): """Decodes a string or byte string to an NDArray. See mx.img.imdecode for more details.""" def locate(): """Locate the image file/index if decode fails.""" if self.seq is not None: idx = self.seq[(self.cur % self.num_image) - 1] ...
def imdecode(self, s): """Decodes a string or byte string to an NDArray. See mx.img.imdecode for more details.""" def locate(): """Locate the image file/index if decode fails.""" if self.seq is not None: idx = self.seq[(self.cur % self.num_image) - 1] ...
[ "Decodes", "a", "string", "or", "byte", "string", "to", "an", "NDArray", ".", "See", "mx", ".", "img", ".", "imdecode", "for", "more", "details", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L1409-L1428
[ "def", "imdecode", "(", "self", ",", "s", ")", ":", "def", "locate", "(", ")", ":", "\"\"\"Locate the image file/index if decode fails.\"\"\"", "if", "self", ".", "seq", "is", "not", "None", ":", "idx", "=", "self", ".", "seq", "[", "(", "self", ".", "cu...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
ImageIter.read_image
Reads an input image `fname` and returns the decoded raw bytes. Examples -------- >>> dataIter.read_image('Face.jpg') # returns decoded raw bytes.
python/mxnet/image/image.py
def read_image(self, fname): """Reads an input image `fname` and returns the decoded raw bytes. Examples -------- >>> dataIter.read_image('Face.jpg') # returns decoded raw bytes. """ with open(os.path.join(self.path_root, fname), 'rb') as fin: img = fin.read()...
def read_image(self, fname): """Reads an input image `fname` and returns the decoded raw bytes. Examples -------- >>> dataIter.read_image('Face.jpg') # returns decoded raw bytes. """ with open(os.path.join(self.path_root, fname), 'rb') as fin: img = fin.read()...
[ "Reads", "an", "input", "image", "fname", "and", "returns", "the", "decoded", "raw", "bytes", ".", "Examples", "--------", ">>>", "dataIter", ".", "read_image", "(", "Face", ".", "jpg", ")", "#", "returns", "decoded", "raw", "bytes", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L1430-L1438
[ "def", "read_image", "(", "self", ",", "fname", ")", ":", "with", "open", "(", "os", ".", "path", ".", "join", "(", "self", ".", "path_root", ",", "fname", ")", ",", "'rb'", ")", "as", "fin", ":", "img", "=", "fin", ".", "read", "(", ")", "retu...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
facc
evaluate accuracy
example/gluon/sn_gan/train.py
def facc(label, pred): """ evaluate accuracy """ pred = pred.ravel() label = label.ravel() return ((pred > 0.5) == label).mean()
def facc(label, pred): """ evaluate accuracy """ pred = pred.ravel() label = label.ravel() return ((pred > 0.5) == label).mean()
[ "evaluate", "accuracy" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/sn_gan/train.py#L68-L72
[ "def", "facc", "(", "label", ",", "pred", ")", ":", "pred", "=", "pred", ".", "ravel", "(", ")", "label", "=", "label", ".", "ravel", "(", ")", "return", "(", "(", "pred", ">", "0.5", ")", "==", "label", ")", ".", "mean", "(", ")" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
word_to_vector
Convert character vectors to integer vectors.
example/gluon/lipnet/utils/common.py
def word_to_vector(word): """ Convert character vectors to integer vectors. """ vector = [] for char in list(word): vector.append(char2int(char)) return vector
def word_to_vector(word): """ Convert character vectors to integer vectors. """ vector = [] for char in list(word): vector.append(char2int(char)) return vector
[ "Convert", "character", "vectors", "to", "integer", "vectors", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/utils/common.py#L46-L53
[ "def", "word_to_vector", "(", "word", ")", ":", "vector", "=", "[", "]", "for", "char", "in", "list", "(", "word", ")", ":", "vector", ".", "append", "(", "char2int", "(", "char", ")", ")", "return", "vector" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
vector_to_word
Convert integer vectors to character vectors.
example/gluon/lipnet/utils/common.py
def vector_to_word(vector): """ Convert integer vectors to character vectors. """ word = "" for vec in vector: word = word + int2char(vec) return word
def vector_to_word(vector): """ Convert integer vectors to character vectors. """ word = "" for vec in vector: word = word + int2char(vec) return word
[ "Convert", "integer", "vectors", "to", "character", "vectors", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/utils/common.py#L56-L63
[ "def", "vector_to_word", "(", "vector", ")", ":", "word", "=", "\"\"", "for", "vec", "in", "vector", ":", "word", "=", "word", "+", "int2char", "(", "vec", ")", "return", "word" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
char_conv
Convert integer vectors to character vectors for batch.
example/gluon/lipnet/utils/common.py
def char_conv(out): """ Convert integer vectors to character vectors for batch. """ out_conv = list() for i in range(out.shape[0]): tmp_str = '' for j in range(out.shape[1]): if int(out[i][j]) >= 0: tmp_char = int2char(int(out[i][j])) if in...
def char_conv(out): """ Convert integer vectors to character vectors for batch. """ out_conv = list() for i in range(out.shape[0]): tmp_str = '' for j in range(out.shape[1]): if int(out[i][j]) >= 0: tmp_char = int2char(int(out[i][j])) if in...
[ "Convert", "integer", "vectors", "to", "character", "vectors", "for", "batch", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/utils/common.py#L66-L80
[ "def", "char_conv", "(", "out", ")", ":", "out_conv", "=", "list", "(", ")", "for", "i", "in", "range", "(", "out", ".", "shape", "[", "0", "]", ")", ":", "tmp_str", "=", "''", "for", "j", "in", "range", "(", "out", ".", "shape", "[", "1", "]...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
add_pooling_with_padding_types
Add a pooling layer to the model. This is our own implementation of add_pooling since current CoreML's version (0.5.0) of builder doesn't provide support for padding types apart from valid. This support will be added in the next release of coremltools. When that happens, this can be removed. Par...
tools/coreml/converter/_add_pooling.py
def add_pooling_with_padding_types(builder, name, height, width, stride_height, stride_width, layer_type, padding_type, input_name, output_name, padding_top = 0, padding_bottom = 0, padding_left = 0, padding_right = 0, same_padding_asymmetry_mode = 'BOTTOM_RIGHT_HEAVY', exclude_pad_a...
def add_pooling_with_padding_types(builder, name, height, width, stride_height, stride_width, layer_type, padding_type, input_name, output_name, padding_top = 0, padding_bottom = 0, padding_left = 0, padding_right = 0, same_padding_asymmetry_mode = 'BOTTOM_RIGHT_HEAVY', exclude_pad_a...
[ "Add", "a", "pooling", "layer", "to", "the", "model", ".", "This", "is", "our", "own", "implementation", "of", "add_pooling", "since", "current", "CoreML", "s", "version", "(", "0", ".", "5", ".", "0", ")", "of", "builder", "doesn", "t", "provide", "su...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_add_pooling.py#L21-L118
[ "def", "add_pooling_with_padding_types", "(", "builder", ",", "name", ",", "height", ",", "width", ",", "stride_height", ",", "stride_width", ",", "layer_type", ",", "padding_type", ",", "input_name", ",", "output_name", ",", "padding_top", "=", "0", ",", "paddi...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_frames
Get path to all the frame in view SAX and contain complete frames
example/kaggle-ndsb2/Preprocessing.py
def get_frames(root_path): """Get path to all the frame in view SAX and contain complete frames""" ret = [] for root, _, files in os.walk(root_path): root=root.replace('\\','/') files=[s for s in files if ".dcm" in s] if len(files) == 0 or not files[0].endswith(".dcm") or root.find("sax") ...
def get_frames(root_path): """Get path to all the frame in view SAX and contain complete frames""" ret = [] for root, _, files in os.walk(root_path): root=root.replace('\\','/') files=[s for s in files if ".dcm" in s] if len(files) == 0 or not files[0].endswith(".dcm") or root.find("sax") ...
[ "Get", "path", "to", "all", "the", "frame", "in", "view", "SAX", "and", "contain", "complete", "frames" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/kaggle-ndsb2/Preprocessing.py#L39-L53
[ "def", "get_frames", "(", "root_path", ")", ":", "ret", "=", "[", "]", "for", "root", ",", "_", ",", "files", "in", "os", ".", "walk", "(", "root_path", ")", ":", "root", "=", "root", ".", "replace", "(", "'\\\\'", ",", "'/'", ")", "files", "=", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
write_data_csv
Write data to csv file
example/kaggle-ndsb2/Preprocessing.py
def write_data_csv(fname, frames, preproc): """Write data to csv file""" fdata = open(fname, "w") dr = Parallel()(delayed(get_data)(lst,preproc) for lst in frames) data,result = zip(*dr) for entry in data: fdata.write(','.join(entry)+'\r\n') print("All finished, %d slices in total" % len(data)) ...
def write_data_csv(fname, frames, preproc): """Write data to csv file""" fdata = open(fname, "w") dr = Parallel()(delayed(get_data)(lst,preproc) for lst in frames) data,result = zip(*dr) for entry in data: fdata.write(','.join(entry)+'\r\n') print("All finished, %d slices in total" % len(data)) ...
[ "Write", "data", "to", "csv", "file" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/kaggle-ndsb2/Preprocessing.py#L94-L104
[ "def", "write_data_csv", "(", "fname", ",", "frames", ",", "preproc", ")", ":", "fdata", "=", "open", "(", "fname", ",", "\"w\"", ")", "dr", "=", "Parallel", "(", ")", "(", "delayed", "(", "get_data", ")", "(", "lst", ",", "preproc", ")", "for", "l...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
crop_resize
crop center and resize
example/kaggle-ndsb2/Preprocessing.py
def crop_resize(img, size): """crop center and resize""" if img.shape[0] < img.shape[1]: img = img.T # we crop image from center short_egde = min(img.shape[:2]) yy = int((img.shape[0] - short_egde) / 2) xx = int((img.shape[1] - short_egde) / 2) crop_img = img[yy : yy + short_egde, xx : xx + ...
def crop_resize(img, size): """crop center and resize""" if img.shape[0] < img.shape[1]: img = img.T # we crop image from center short_egde = min(img.shape[:2]) yy = int((img.shape[0] - short_egde) / 2) xx = int((img.shape[1] - short_egde) / 2) crop_img = img[yy : yy + short_egde, xx : xx + ...
[ "crop", "center", "and", "resize" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/kaggle-ndsb2/Preprocessing.py#L107-L119
[ "def", "crop_resize", "(", "img", ",", "size", ")", ":", "if", "img", ".", "shape", "[", "0", "]", "<", "img", ".", "shape", "[", "1", "]", ":", "img", "=", "img", ".", "T", "# we crop image from center", "short_egde", "=", "min", "(", "img", ".", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_generator
construct and return generator
example/gluon/sn_gan/model.py
def get_generator(): """ construct and return generator """ g_net = gluon.nn.Sequential() with g_net.name_scope(): g_net.add(gluon.nn.Conv2DTranspose( channels=512, kernel_size=4, strides=1, padding=0, use_bias=False)) g_net.add(gluon.nn.BatchNorm()) g_net.add(gluon.nn.L...
def get_generator(): """ construct and return generator """ g_net = gluon.nn.Sequential() with g_net.name_scope(): g_net.add(gluon.nn.Conv2DTranspose( channels=512, kernel_size=4, strides=1, padding=0, use_bias=False)) g_net.add(gluon.nn.BatchNorm()) g_net.add(gluon.nn.L...
[ "construct", "and", "return", "generator" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/sn_gan/model.py#L89-L117
[ "def", "get_generator", "(", ")", ":", "g_net", "=", "gluon", ".", "nn", ".", "Sequential", "(", ")", "with", "g_net", ".", "name_scope", "(", ")", ":", "g_net", ".", "add", "(", "gluon", ".", "nn", ".", "Conv2DTranspose", "(", "channels", "=", "512"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_descriptor
construct and return descriptor
example/gluon/sn_gan/model.py
def get_descriptor(ctx): """ construct and return descriptor """ d_net = gluon.nn.Sequential() with d_net.name_scope(): d_net.add(SNConv2D(num_filter=64, kernel_size=4, strides=2, padding=1, in_channels=3, ctx=ctx)) d_net.add(gluon.nn.LeakyReLU(0.2)) d_net.add(SNConv2D(num_filter=1...
def get_descriptor(ctx): """ construct and return descriptor """ d_net = gluon.nn.Sequential() with d_net.name_scope(): d_net.add(SNConv2D(num_filter=64, kernel_size=4, strides=2, padding=1, in_channels=3, ctx=ctx)) d_net.add(gluon.nn.LeakyReLU(0.2)) d_net.add(SNConv2D(num_filter=1...
[ "construct", "and", "return", "descriptor" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/sn_gan/model.py#L120-L139
[ "def", "get_descriptor", "(", "ctx", ")", ":", "d_net", "=", "gluon", ".", "nn", ".", "Sequential", "(", ")", "with", "d_net", ".", "name_scope", "(", ")", ":", "d_net", ".", "add", "(", "SNConv2D", "(", "num_filter", "=", "64", ",", "kernel_size", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SNConv2D._spectral_norm
spectral normalization
example/gluon/sn_gan/model.py
def _spectral_norm(self): """ spectral normalization """ w = self.params.get('weight').data(self.ctx) w_mat = nd.reshape(w, [w.shape[0], -1]) _u = self.u.data(self.ctx) _v = None for _ in range(POWER_ITERATION): _v = nd.L2Normalization(nd.dot(_u, w_mat)) ...
def _spectral_norm(self): """ spectral normalization """ w = self.params.get('weight').data(self.ctx) w_mat = nd.reshape(w, [w.shape[0], -1]) _u = self.u.data(self.ctx) _v = None for _ in range(POWER_ITERATION): _v = nd.L2Normalization(nd.dot(_u, w_mat)) ...
[ "spectral", "normalization" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/sn_gan/model.py#L55-L74
[ "def", "_spectral_norm", "(", "self", ")", ":", "w", "=", "self", ".", "params", ".", "get", "(", "'weight'", ")", ".", "data", "(", "self", ".", "ctx", ")", "w_mat", "=", "nd", ".", "reshape", "(", "w", ",", "[", "w", ".", "shape", "[", "0", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
conv_output_length
Compute the length of the output sequence after 1D convolution along time. Note that this function is in line with the function used in Convolution1D class from Keras. Params: input_length (int): Length of the input sequence. filter_size (int): Width of the convolution kernel. ...
example/speech_recognition/stt_utils.py
def conv_output_length(input_length, filter_size, border_mode, stride, dilation=1): """ Compute the length of the output sequence after 1D convolution along time. Note that this function is in line with the function used in Convolution1D class from Keras. Params: i...
def conv_output_length(input_length, filter_size, border_mode, stride, dilation=1): """ Compute the length of the output sequence after 1D convolution along time. Note that this function is in line with the function used in Convolution1D class from Keras. Params: i...
[ "Compute", "the", "length", "of", "the", "output", "sequence", "after", "1D", "convolution", "along", "time", ".", "Note", "that", "this", "function", "is", "in", "line", "with", "the", "function", "used", "in", "Convolution1D", "class", "from", "Keras", "."...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/speech_recognition/stt_utils.py#L30-L50
[ "def", "conv_output_length", "(", "input_length", ",", "filter_size", ",", "border_mode", ",", "stride", ",", "dilation", "=", "1", ")", ":", "if", "input_length", "is", "None", ":", "return", "None", "assert", "border_mode", "in", "{", "'same'", ",", "'vali...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
spectrogram
Compute the spectrogram for a real signal. The parameters follow the naming convention of matplotlib.mlab.specgram Args: samples (1D array): input audio signal fft_length (int): number of elements in fft window sample_rate (scalar): sample rate hop_length (int): hop length (r...
example/speech_recognition/stt_utils.py
def spectrogram(samples, fft_length=256, sample_rate=2, hop_length=128): """ Compute the spectrogram for a real signal. The parameters follow the naming convention of matplotlib.mlab.specgram Args: samples (1D array): input audio signal fft_length (int): number of elements in fft win...
def spectrogram(samples, fft_length=256, sample_rate=2, hop_length=128): """ Compute the spectrogram for a real signal. The parameters follow the naming convention of matplotlib.mlab.specgram Args: samples (1D array): input audio signal fft_length (int): number of elements in fft win...
[ "Compute", "the", "spectrogram", "for", "a", "real", "signal", ".", "The", "parameters", "follow", "the", "naming", "convention", "of", "matplotlib", ".", "mlab", ".", "specgram", "Args", ":", "samples", "(", "1D", "array", ")", ":", "input", "audio", "sig...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/speech_recognition/stt_utils.py#L53-L104
[ "def", "spectrogram", "(", "samples", ",", "fft_length", "=", "256", ",", "sample_rate", "=", "2", ",", "hop_length", "=", "128", ")", ":", "assert", "not", "np", ".", "iscomplexobj", "(", "samples", ")", ",", "\"Must not pass in complex numbers\"", "window", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
spectrogram_from_file
Calculate the log of linear spectrogram from FFT energy Params: filename (str): Path to the audio file step (int): Step size in milliseconds between windows window (int): FFT window size in milliseconds max_freq (int): Only FFT bins corresponding to frequencies between [0...
example/speech_recognition/stt_utils.py
def spectrogram_from_file(filename, step=10, window=20, max_freq=None, eps=1e-14, overwrite=False, save_feature_as_csvfile=False): """ Calculate the log of linear spectrogram from FFT energy Params: filename (str): Path to the audio file step (int): Step size in millise...
def spectrogram_from_file(filename, step=10, window=20, max_freq=None, eps=1e-14, overwrite=False, save_feature_as_csvfile=False): """ Calculate the log of linear spectrogram from FFT energy Params: filename (str): Path to the audio file step (int): Step size in millise...
[ "Calculate", "the", "log", "of", "linear", "spectrogram", "from", "FFT", "energy", "Params", ":", "filename", "(", "str", ")", ":", "Path", "to", "the", "audio", "file", "step", "(", "int", ")", ":", "Step", "size", "in", "milliseconds", "between", "wind...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/speech_recognition/stt_utils.py#L107-L146
[ "def", "spectrogram_from_file", "(", "filename", ",", "step", "=", "10", ",", "window", "=", "20", ",", "max_freq", "=", "None", ",", "eps", "=", "1e-14", ",", "overwrite", "=", "False", ",", "save_feature_as_csvfile", "=", "False", ")", ":", "csvfilename"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
RandCropper.sample
generate random cropping boxes according to parameters if satifactory crops generated, apply to ground-truth as well Parameters: ---------- label : numpy.array (n x 5 matrix) ground-truths Returns: ---------- list of (crop_box, label) tuples, if fail...
example/ssd/tools/rand_sampler.py
def sample(self, label): """ generate random cropping boxes according to parameters if satifactory crops generated, apply to ground-truth as well Parameters: ---------- label : numpy.array (n x 5 matrix) ground-truths Returns: ---------- ...
def sample(self, label): """ generate random cropping boxes according to parameters if satifactory crops generated, apply to ground-truth as well Parameters: ---------- label : numpy.array (n x 5 matrix) ground-truths Returns: ---------- ...
[ "generate", "random", "cropping", "boxes", "according", "to", "parameters", "if", "satifactory", "crops", "generated", "apply", "to", "ground", "-", "truth", "as", "well" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/tools/rand_sampler.py#L93-L145
[ "def", "sample", "(", "self", ",", "label", ")", ":", "samples", "=", "[", "]", "count", "=", "0", "for", "trial", "in", "range", "(", "self", ".", "max_trials", ")", ":", "if", "count", ">=", "self", ".", "max_sample", ":", "return", "samples", "s...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
RandCropper._check_satisfy
check if overlap with any gt box is larger than threshold
example/ssd/tools/rand_sampler.py
def _check_satisfy(self, rand_box, gt_boxes): """ check if overlap with any gt box is larger than threshold """ l, t, r, b = rand_box num_gt = gt_boxes.shape[0] ls = np.ones(num_gt) * l ts = np.ones(num_gt) * t rs = np.ones(num_gt) * r bs = np.ones...
def _check_satisfy(self, rand_box, gt_boxes): """ check if overlap with any gt box is larger than threshold """ l, t, r, b = rand_box num_gt = gt_boxes.shape[0] ls = np.ones(num_gt) * l ts = np.ones(num_gt) * t rs = np.ones(num_gt) * r bs = np.ones...
[ "check", "if", "overlap", "with", "any", "gt", "box", "is", "larger", "than", "threshold" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/tools/rand_sampler.py#L147-L192
[ "def", "_check_satisfy", "(", "self", ",", "rand_box", ",", "gt_boxes", ")", ":", "l", ",", "t", ",", "r", ",", "b", "=", "rand_box", "num_gt", "=", "gt_boxes", ".", "shape", "[", "0", "]", "ls", "=", "np", ".", "ones", "(", "num_gt", ")", "*", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
RandPadder.sample
generate random padding boxes according to parameters if satifactory padding generated, apply to ground-truth as well Parameters: ---------- label : numpy.array (n x 5 matrix) ground-truths Returns: ---------- list of (crop_box, label) tuples, if fai...
example/ssd/tools/rand_sampler.py
def sample(self, label): """ generate random padding boxes according to parameters if satifactory padding generated, apply to ground-truth as well Parameters: ---------- label : numpy.array (n x 5 matrix) ground-truths Returns: ---------- ...
def sample(self, label): """ generate random padding boxes according to parameters if satifactory padding generated, apply to ground-truth as well Parameters: ---------- label : numpy.array (n x 5 matrix) ground-truths Returns: ---------- ...
[ "generate", "random", "padding", "boxes", "according", "to", "parameters", "if", "satifactory", "padding", "generated", "apply", "to", "ground", "-", "truth", "as", "well" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/tools/rand_sampler.py#L232-L287
[ "def", "sample", "(", "self", ",", "label", ")", ":", "samples", "=", "[", "]", "count", "=", "0", "for", "trial", "in", "range", "(", "self", ".", "max_trials", ")", ":", "if", "count", ">=", "self", ".", "max_sample", ":", "return", "samples", "s...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
measure_cost
Measure time cost of running a function
benchmark/python/sparse/dot.py
def measure_cost(repeat, scipy_trans_lhs, scipy_dns_lhs, func_name, *args, **kwargs): """Measure time cost of running a function """ mx.nd.waitall() args_list = [] for arg in args: args_list.append(arg) start = time.time() if scipy_trans_lhs: args_list[0] = np.transpose(args_...
def measure_cost(repeat, scipy_trans_lhs, scipy_dns_lhs, func_name, *args, **kwargs): """Measure time cost of running a function """ mx.nd.waitall() args_list = [] for arg in args: args_list.append(arg) start = time.time() if scipy_trans_lhs: args_list[0] = np.transpose(args_...
[ "Measure", "time", "cost", "of", "running", "a", "function" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/benchmark/python/sparse/dot.py#L110-L125
[ "def", "measure_cost", "(", "repeat", ",", "scipy_trans_lhs", ",", "scipy_dns_lhs", ",", "func_name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "mx", ".", "nd", ".", "waitall", "(", ")", "args_list", "=", "[", "]", "for", "arg", "in", "arg...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
COCO.info
Print information about the annotation file. :return:
example/ssd/dataset/pycocotools/coco.py
def info(self): """ Print information about the annotation file. :return: """ for key, value in self.dataset['info'].items(): print('{}: {}'.format(key, value))
def info(self): """ Print information about the annotation file. :return: """ for key, value in self.dataset['info'].items(): print('{}: {}'.format(key, value))
[ "Print", "information", "about", "the", "annotation", "file", ".", ":", "return", ":" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/pycocotools/coco.py#L116-L122
[ "def", "info", "(", "self", ")", ":", "for", "key", ",", "value", "in", "self", ".", "dataset", "[", "'info'", "]", ".", "items", "(", ")", ":", "print", "(", "'{}: {}'", ".", "format", "(", "key", ",", "value", ")", ")" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
COCO.getCatIds
filtering parameters. default skips that filter. :param catNms (str array) : get cats for given cat names :param supNms (str array) : get cats for given supercategory names :param catIds (int array) : get cats for given cat ids :return: ids (int array) : integer array of cat ids
example/ssd/dataset/pycocotools/coco.py
def getCatIds(self, catNms=[], supNms=[], catIds=[]): """ filtering parameters. default skips that filter. :param catNms (str array) : get cats for given cat names :param supNms (str array) : get cats for given supercategory names :param catIds (int array) : get cats for given...
def getCatIds(self, catNms=[], supNms=[], catIds=[]): """ filtering parameters. default skips that filter. :param catNms (str array) : get cats for given cat names :param supNms (str array) : get cats for given supercategory names :param catIds (int array) : get cats for given...
[ "filtering", "parameters", ".", "default", "skips", "that", "filter", ".", ":", "param", "catNms", "(", "str", "array", ")", ":", "get", "cats", "for", "given", "cat", "names", ":", "param", "supNms", "(", "str", "array", ")", ":", "get", "cats", "for"...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/pycocotools/coco.py#L152-L172
[ "def", "getCatIds", "(", "self", ",", "catNms", "=", "[", "]", ",", "supNms", "=", "[", "]", ",", "catIds", "=", "[", "]", ")", ":", "catNms", "=", "catNms", "if", "type", "(", "catNms", ")", "==", "list", "else", "[", "catNms", "]", "supNms", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
COCO.loadAnns
Load anns with the specified ids. :param ids (int array) : integer ids specifying anns :return: anns (object array) : loaded ann objects
example/ssd/dataset/pycocotools/coco.py
def loadAnns(self, ids=[]): """ Load anns with the specified ids. :param ids (int array) : integer ids specifying anns :return: anns (object array) : loaded ann objects """ if type(ids) == list: return [self.anns[id] for id in ids] elif type(ids)...
def loadAnns(self, ids=[]): """ Load anns with the specified ids. :param ids (int array) : integer ids specifying anns :return: anns (object array) : loaded ann objects """ if type(ids) == list: return [self.anns[id] for id in ids] elif type(ids)...
[ "Load", "anns", "with", "the", "specified", "ids", ".", ":", "param", "ids", "(", "int", "array", ")", ":", "integer", "ids", "specifying", "anns", ":", "return", ":", "anns", "(", "object", "array", ")", ":", "loaded", "ann", "objects" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/pycocotools/coco.py#L195-L204
[ "def", "loadAnns", "(", "self", ",", "ids", "=", "[", "]", ")", ":", "if", "type", "(", "ids", ")", "==", "list", ":", "return", "[", "self", ".", "anns", "[", "id", "]", "for", "id", "in", "ids", "]", "elif", "type", "(", "ids", ")", "==", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
COCO.loadCats
Load cats with the specified ids. :param ids (int array) : integer ids specifying cats :return: cats (object array) : loaded cat objects
example/ssd/dataset/pycocotools/coco.py
def loadCats(self, ids=[]): """ Load cats with the specified ids. :param ids (int array) : integer ids specifying cats :return: cats (object array) : loaded cat objects """ if type(ids) == list: return [self.cats[id] for id in ids] elif type(ids)...
def loadCats(self, ids=[]): """ Load cats with the specified ids. :param ids (int array) : integer ids specifying cats :return: cats (object array) : loaded cat objects """ if type(ids) == list: return [self.cats[id] for id in ids] elif type(ids)...
[ "Load", "cats", "with", "the", "specified", "ids", ".", ":", "param", "ids", "(", "int", "array", ")", ":", "integer", "ids", "specifying", "cats", ":", "return", ":", "cats", "(", "object", "array", ")", ":", "loaded", "cat", "objects" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/pycocotools/coco.py#L206-L215
[ "def", "loadCats", "(", "self", ",", "ids", "=", "[", "]", ")", ":", "if", "type", "(", "ids", ")", "==", "list", ":", "return", "[", "self", ".", "cats", "[", "id", "]", "for", "id", "in", "ids", "]", "elif", "type", "(", "ids", ")", "==", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
COCO.loadImgs
Load anns with the specified ids. :param ids (int array) : integer ids specifying img :return: imgs (object array) : loaded img objects
example/ssd/dataset/pycocotools/coco.py
def loadImgs(self, ids=[]): """ Load anns with the specified ids. :param ids (int array) : integer ids specifying img :return: imgs (object array) : loaded img objects """ if type(ids) == list: return [self.imgs[id] for id in ids] elif type(ids) ...
def loadImgs(self, ids=[]): """ Load anns with the specified ids. :param ids (int array) : integer ids specifying img :return: imgs (object array) : loaded img objects """ if type(ids) == list: return [self.imgs[id] for id in ids] elif type(ids) ...
[ "Load", "anns", "with", "the", "specified", "ids", ".", ":", "param", "ids", "(", "int", "array", ")", ":", "integer", "ids", "specifying", "img", ":", "return", ":", "imgs", "(", "object", "array", ")", ":", "loaded", "img", "objects" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/pycocotools/coco.py#L217-L226
[ "def", "loadImgs", "(", "self", ",", "ids", "=", "[", "]", ")", ":", "if", "type", "(", "ids", ")", "==", "list", ":", "return", "[", "self", ".", "imgs", "[", "id", "]", "for", "id", "in", "ids", "]", "elif", "type", "(", "ids", ")", "==", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
COCO.showAnns
Display the specified annotations. :param anns (array of object): annotations to display :return: None
example/ssd/dataset/pycocotools/coco.py
def showAnns(self, anns): """ Display the specified annotations. :param anns (array of object): annotations to display :return: None """ if len(anns) == 0: return 0 if 'segmentation' in anns[0] or 'keypoints' in anns[0]: datasetType = 'inst...
def showAnns(self, anns): """ Display the specified annotations. :param anns (array of object): annotations to display :return: None """ if len(anns) == 0: return 0 if 'segmentation' in anns[0] or 'keypoints' in anns[0]: datasetType = 'inst...
[ "Display", "the", "specified", "annotations", ".", ":", "param", "anns", "(", "array", "of", "object", ")", ":", "annotations", "to", "display", ":", "return", ":", "None" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/pycocotools/coco.py#L228-L277
[ "def", "showAnns", "(", "self", ",", "anns", ")", ":", "if", "len", "(", "anns", ")", "==", "0", ":", "return", "0", "if", "'segmentation'", "in", "anns", "[", "0", "]", "or", "'keypoints'", "in", "anns", "[", "0", "]", ":", "datasetType", "=", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
COCO.download
Download COCO images from mscoco.org server. :param tarDir (str): COCO results directory name imgIds (list): images to be downloaded :return:
example/ssd/dataset/pycocotools/coco.py
def download(self, tarDir = None, imgIds = [] ): ''' Download COCO images from mscoco.org server. :param tarDir (str): COCO results directory name imgIds (list): images to be downloaded :return: ''' if tarDir is None: print('Please specify targe...
def download(self, tarDir = None, imgIds = [] ): ''' Download COCO images from mscoco.org server. :param tarDir (str): COCO results directory name imgIds (list): images to be downloaded :return: ''' if tarDir is None: print('Please specify targe...
[ "Download", "COCO", "images", "from", "mscoco", ".", "org", "server", ".", ":", "param", "tarDir", "(", "str", ")", ":", "COCO", "results", "directory", "name", "imgIds", "(", "list", ")", ":", "images", "to", "be", "downloaded", ":", "return", ":" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/pycocotools/coco.py#L342-L364
[ "def", "download", "(", "self", ",", "tarDir", "=", "None", ",", "imgIds", "=", "[", "]", ")", ":", "if", "tarDir", "is", "None", ":", "print", "(", "'Please specify target directory'", ")", "return", "-", "1", "if", "len", "(", "imgIds", ")", "==", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
COCO.loadNumpyAnnotations
Convert result data from a numpy array [Nx7] where each row contains {imageID,x1,y1,w,h,score,class} :param data (numpy.ndarray) :return: annotations (python nested list)
example/ssd/dataset/pycocotools/coco.py
def loadNumpyAnnotations(self, data): """ Convert result data from a numpy array [Nx7] where each row contains {imageID,x1,y1,w,h,score,class} :param data (numpy.ndarray) :return: annotations (python nested list) """ print('Converting ndarray to lists...') assert...
def loadNumpyAnnotations(self, data): """ Convert result data from a numpy array [Nx7] where each row contains {imageID,x1,y1,w,h,score,class} :param data (numpy.ndarray) :return: annotations (python nested list) """ print('Converting ndarray to lists...') assert...
[ "Convert", "result", "data", "from", "a", "numpy", "array", "[", "Nx7", "]", "where", "each", "row", "contains", "{", "imageID", "x1", "y1", "w", "h", "score", "class", "}", ":", "param", "data", "(", "numpy", ".", "ndarray", ")", ":", "return", ":",...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/pycocotools/coco.py#L366-L387
[ "def", "loadNumpyAnnotations", "(", "self", ",", "data", ")", ":", "print", "(", "'Converting ndarray to lists...'", ")", "assert", "(", "type", "(", "data", ")", "==", "np", ".", "ndarray", ")", "print", "(", "data", ".", "shape", ")", "assert", "(", "d...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
COCO.annToRLE
Convert annotation which can be polygons, uncompressed RLE to RLE. :return: binary mask (numpy 2D array)
example/ssd/dataset/pycocotools/coco.py
def annToRLE(self, ann): """ Convert annotation which can be polygons, uncompressed RLE to RLE. :return: binary mask (numpy 2D array) """ t = self.imgs[ann['image_id']] h, w = t['height'], t['width'] segm = ann['segmentation'] if type(segm) == list: ...
def annToRLE(self, ann): """ Convert annotation which can be polygons, uncompressed RLE to RLE. :return: binary mask (numpy 2D array) """ t = self.imgs[ann['image_id']] h, w = t['height'], t['width'] segm = ann['segmentation'] if type(segm) == list: ...
[ "Convert", "annotation", "which", "can", "be", "polygons", "uncompressed", "RLE", "to", "RLE", ".", ":", "return", ":", "binary", "mask", "(", "numpy", "2D", "array", ")" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/pycocotools/coco.py#L389-L410
[ "def", "annToRLE", "(", "self", ",", "ann", ")", ":", "t", "=", "self", ".", "imgs", "[", "ann", "[", "'image_id'", "]", "]", "h", ",", "w", "=", "t", "[", "'height'", "]", ",", "t", "[", "'width'", "]", "segm", "=", "ann", "[", "'segmentation'...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
save_model
Save cnn model Returns ---------- callback: A callback function that can be passed as epoch_end_callback to fit
example/cnn_chinese_text_classification/text_cnn.py
def save_model(): """Save cnn model Returns ---------- callback: A callback function that can be passed as epoch_end_callback to fit """ if not os.path.exists("checkpoint"): os.mkdir("checkpoint") return mx.callback.do_checkpoint("checkpoint/checkpoint", args.save_period)
def save_model(): """Save cnn model Returns ---------- callback: A callback function that can be passed as epoch_end_callback to fit """ if not os.path.exists("checkpoint"): os.mkdir("checkpoint") return mx.callback.do_checkpoint("checkpoint/checkpoint", args.save_period)
[ "Save", "cnn", "model", "Returns", "----------", "callback", ":", "A", "callback", "function", "that", "can", "be", "passed", "as", "epoch_end_callback", "to", "fit" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_chinese_text_classification/text_cnn.py#L67-L75
[ "def", "save_model", "(", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "\"checkpoint\"", ")", ":", "os", ".", "mkdir", "(", "\"checkpoint\"", ")", "return", "mx", ".", "callback", ".", "do_checkpoint", "(", "\"checkpoint/checkpoint\"", ","...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
highway
Construct highway net Parameters ---------- data: Returns ---------- Highway Networks
example/cnn_chinese_text_classification/text_cnn.py
def highway(data): """Construct highway net Parameters ---------- data: Returns ---------- Highway Networks """ _data = data high_weight = mx.sym.Variable('high_weight') high_bias = mx.sym.Variable('high_bias') high_fc = mx.sym.FullyConnected(data=data, weight=high_weight...
def highway(data): """Construct highway net Parameters ---------- data: Returns ---------- Highway Networks """ _data = data high_weight = mx.sym.Variable('high_weight') high_bias = mx.sym.Variable('high_bias') high_fc = mx.sym.FullyConnected(data=data, weight=high_weight...
[ "Construct", "highway", "net", "Parameters", "----------", "data", ":", "Returns", "----------", "Highway", "Networks" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_chinese_text_classification/text_cnn.py#L78-L99
[ "def", "highway", "(", "data", ")", ":", "_data", "=", "data", "high_weight", "=", "mx", ".", "sym", ".", "Variable", "(", "'high_weight'", ")", "high_bias", "=", "mx", ".", "sym", ".", "Variable", "(", "'high_bias'", ")", "high_fc", "=", "mx", ".", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
train
Train cnn model Parameters ---------- symbol_data: symbol train_iterator: DataIter Train DataIter valid_iterator: DataIter Valid DataIter data_column_names: list of str Defaults to ('data') for a typical model used in image classific...
example/cnn_chinese_text_classification/text_cnn.py
def train(symbol_data, train_iterator, valid_iterator, data_column_names, target_names): """Train cnn model Parameters ---------- symbol_data: symbol train_iterator: DataIter Train DataIter valid_iterator: DataIter Valid DataIter data_column_names: lis...
def train(symbol_data, train_iterator, valid_iterator, data_column_names, target_names): """Train cnn model Parameters ---------- symbol_data: symbol train_iterator: DataIter Train DataIter valid_iterator: DataIter Valid DataIter data_column_names: lis...
[ "Train", "cnn", "model", "Parameters", "----------", "symbol_data", ":", "symbol", "train_iterator", ":", "DataIter", "Train", "DataIter", "valid_iterator", ":", "DataIter", "Valid", "DataIter", "data_column_names", ":", "list", "of", "str", "Defaults", "to", "(", ...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_chinese_text_classification/text_cnn.py#L232-L280
[ "def", "train", "(", "symbol_data", ",", "train_iterator", ",", "valid_iterator", ",", "data_column_names", ",", "target_names", ")", ":", "devs", "=", "mx", ".", "cpu", "(", ")", "# default setting", "if", "args", ".", "gpus", "is", "not", "None", ":", "f...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
default_batchify_fn
Collate data into batch.
python/mxnet/gluon/data/dataloader.py
def default_batchify_fn(data): """Collate data into batch.""" if isinstance(data[0], nd.NDArray): return nd.stack(*data) elif isinstance(data[0], tuple): data = zip(*data) return [default_batchify_fn(i) for i in data] else: data = np.asarray(data) return nd.array(...
def default_batchify_fn(data): """Collate data into batch.""" if isinstance(data[0], nd.NDArray): return nd.stack(*data) elif isinstance(data[0], tuple): data = zip(*data) return [default_batchify_fn(i) for i in data] else: data = np.asarray(data) return nd.array(...
[ "Collate", "data", "into", "batch", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L127-L136
[ "def", "default_batchify_fn", "(", "data", ")", ":", "if", "isinstance", "(", "data", "[", "0", "]", ",", "nd", ".", "NDArray", ")", ":", "return", "nd", ".", "stack", "(", "*", "data", ")", "elif", "isinstance", "(", "data", "[", "0", "]", ",", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
default_mp_batchify_fn
Collate data into batch. Use shared memory for stacking.
python/mxnet/gluon/data/dataloader.py
def default_mp_batchify_fn(data): """Collate data into batch. Use shared memory for stacking.""" if isinstance(data[0], nd.NDArray): out = nd.empty((len(data),) + data[0].shape, dtype=data[0].dtype, ctx=context.Context('cpu_shared', 0)) return nd.stack(*data, out=out) ...
def default_mp_batchify_fn(data): """Collate data into batch. Use shared memory for stacking.""" if isinstance(data[0], nd.NDArray): out = nd.empty((len(data),) + data[0].shape, dtype=data[0].dtype, ctx=context.Context('cpu_shared', 0)) return nd.stack(*data, out=out) ...
[ "Collate", "data", "into", "batch", ".", "Use", "shared", "memory", "for", "stacking", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L139-L151
[ "def", "default_mp_batchify_fn", "(", "data", ")", ":", "if", "isinstance", "(", "data", "[", "0", "]", ",", "nd", ".", "NDArray", ")", ":", "out", "=", "nd", ".", "empty", "(", "(", "len", "(", "data", ")", ",", ")", "+", "data", "[", "0", "]"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_as_in_context
Move data into new context.
python/mxnet/gluon/data/dataloader.py
def _as_in_context(data, ctx): """Move data into new context.""" if isinstance(data, nd.NDArray): return data.as_in_context(ctx) elif isinstance(data, (list, tuple)): return [_as_in_context(d, ctx) for d in data] return data
def _as_in_context(data, ctx): """Move data into new context.""" if isinstance(data, nd.NDArray): return data.as_in_context(ctx) elif isinstance(data, (list, tuple)): return [_as_in_context(d, ctx) for d in data] return data
[ "Move", "data", "into", "new", "context", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L154-L160
[ "def", "_as_in_context", "(", "data", ",", "ctx", ")", ":", "if", "isinstance", "(", "data", ",", "nd", ".", "NDArray", ")", ":", "return", "data", ".", "as_in_context", "(", "ctx", ")", "elif", "isinstance", "(", "data", ",", "(", "list", ",", "tupl...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
worker_loop_v1
Worker loop for multiprocessing DataLoader.
python/mxnet/gluon/data/dataloader.py
def worker_loop_v1(dataset, key_queue, data_queue, batchify_fn): """Worker loop for multiprocessing DataLoader.""" while True: idx, samples = key_queue.get() if idx is None: break batch = batchify_fn([dataset[i] for i in samples]) data_queue.put((idx, batch))
def worker_loop_v1(dataset, key_queue, data_queue, batchify_fn): """Worker loop for multiprocessing DataLoader.""" while True: idx, samples = key_queue.get() if idx is None: break batch = batchify_fn([dataset[i] for i in samples]) data_queue.put((idx, batch))
[ "Worker", "loop", "for", "multiprocessing", "DataLoader", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L163-L170
[ "def", "worker_loop_v1", "(", "dataset", ",", "key_queue", ",", "data_queue", ",", "batchify_fn", ")", ":", "while", "True", ":", "idx", ",", "samples", "=", "key_queue", ".", "get", "(", ")", "if", "idx", "is", "None", ":", "break", "batch", "=", "bat...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
fetcher_loop_v1
Fetcher loop for fetching data from queue and put in reorder dict.
python/mxnet/gluon/data/dataloader.py
def fetcher_loop_v1(data_queue, data_buffer, pin_memory=False, pin_device_id=0, data_buffer_lock=None): """Fetcher loop for fetching data from queue and put in reorder dict.""" while True: idx, batch = data_queue.get() if idx is None: break if pin_memory: ...
def fetcher_loop_v1(data_queue, data_buffer, pin_memory=False, pin_device_id=0, data_buffer_lock=None): """Fetcher loop for fetching data from queue and put in reorder dict.""" while True: idx, batch = data_queue.get() if idx is None: break if pin_memory: ...
[ "Fetcher", "loop", "for", "fetching", "data", "from", "queue", "and", "put", "in", "reorder", "dict", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L172-L187
[ "def", "fetcher_loop_v1", "(", "data_queue", ",", "data_buffer", ",", "pin_memory", "=", "False", ",", "pin_device_id", "=", "0", ",", "data_buffer_lock", "=", "None", ")", ":", "while", "True", ":", "idx", ",", "batch", "=", "data_queue", ".", "get", "(",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_worker_fn
Function for processing data in worker process.
python/mxnet/gluon/data/dataloader.py
def _worker_fn(samples, batchify_fn, dataset=None): """Function for processing data in worker process.""" # pylint: disable=unused-argument # it is required that each worker process has to fork a new MXIndexedRecordIO handle # preserving dataset as global variable can save tons of overhead and is safe i...
def _worker_fn(samples, batchify_fn, dataset=None): """Function for processing data in worker process.""" # pylint: disable=unused-argument # it is required that each worker process has to fork a new MXIndexedRecordIO handle # preserving dataset as global variable can save tons of overhead and is safe i...
[ "Function", "for", "processing", "data", "in", "worker", "process", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L394-L403
[ "def", "_worker_fn", "(", "samples", ",", "batchify_fn", ",", "dataset", "=", "None", ")", ":", "# pylint: disable=unused-argument", "# it is required that each worker process has to fork a new MXIndexedRecordIO handle", "# preserving dataset as global variable can save tons of overhead ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
ConnectionWrapper.send
Send object
python/mxnet/gluon/data/dataloader.py
def send(self, obj): """Send object""" buf = io.BytesIO() ForkingPickler(buf, pickle.HIGHEST_PROTOCOL).dump(obj) self.send_bytes(buf.getvalue())
def send(self, obj): """Send object""" buf = io.BytesIO() ForkingPickler(buf, pickle.HIGHEST_PROTOCOL).dump(obj) self.send_bytes(buf.getvalue())
[ "Send", "object" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L81-L85
[ "def", "send", "(", "self", ",", "obj", ")", ":", "buf", "=", "io", ".", "BytesIO", "(", ")", "ForkingPickler", "(", "buf", ",", "pickle", ".", "HIGHEST_PROTOCOL", ")", ".", "dump", "(", "obj", ")", "self", ".", "send_bytes", "(", "buf", ".", "getv...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_MultiWorkerIterV1._push_next
Assign next batch workload to workers.
python/mxnet/gluon/data/dataloader.py
def _push_next(self): """Assign next batch workload to workers.""" r = next(self._iter, None) if r is None: return self._key_queue.put((self._sent_idx, r)) self._sent_idx += 1
def _push_next(self): """Assign next batch workload to workers.""" r = next(self._iter, None) if r is None: return self._key_queue.put((self._sent_idx, r)) self._sent_idx += 1
[ "Assign", "next", "batch", "workload", "to", "workers", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L237-L243
[ "def", "_push_next", "(", "self", ")", ":", "r", "=", "next", "(", "self", ".", "_iter", ",", "None", ")", "if", "r", "is", "None", ":", "return", "self", ".", "_key_queue", ".", "put", "(", "(", "self", ".", "_sent_idx", ",", "r", ")", ")", "s...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_MultiWorkerIterV1.shutdown
Shutdown internal workers by pushing terminate signals.
python/mxnet/gluon/data/dataloader.py
def shutdown(self): """Shutdown internal workers by pushing terminate signals.""" if not self._shutdown: # send shutdown signal to the fetcher and join data queue first # Remark: loop_fetcher need to be joined prior to the workers. # otherwise, the the fet...
def shutdown(self): """Shutdown internal workers by pushing terminate signals.""" if not self._shutdown: # send shutdown signal to the fetcher and join data queue first # Remark: loop_fetcher need to be joined prior to the workers. # otherwise, the the fet...
[ "Shutdown", "internal", "workers", "by", "pushing", "terminate", "signals", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L266-L281
[ "def", "shutdown", "(", "self", ")", ":", "if", "not", "self", ".", "_shutdown", ":", "# send shutdown signal to the fetcher and join data queue first", "# Remark: loop_fetcher need to be joined prior to the workers.", "# otherwise, the the fetcher may fail at getting data", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_MultiWorkerIter._push_next
Assign next batch workload to workers.
python/mxnet/gluon/data/dataloader.py
def _push_next(self): """Assign next batch workload to workers.""" r = next(self._iter, None) if r is None: return async_ret = self._worker_pool.apply_async( self._worker_fn, (r, self._batchify_fn, self._dataset)) self._data_buffer[self._sent_idx] = async_...
def _push_next(self): """Assign next batch workload to workers.""" r = next(self._iter, None) if r is None: return async_ret = self._worker_pool.apply_async( self._worker_fn, (r, self._batchify_fn, self._dataset)) self._data_buffer[self._sent_idx] = async_...
[ "Assign", "next", "batch", "workload", "to", "workers", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L431-L439
[ "def", "_push_next", "(", "self", ")", ":", "r", "=", "next", "(", "self", ".", "_iter", ",", "None", ")", "if", "r", "is", "None", ":", "return", "async_ret", "=", "self", ".", "_worker_pool", ".", "apply_async", "(", "self", ".", "_worker_fn", ",",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_ctype_key_value
Returns ctype arrays for the key-value args, and the whether string keys are used. For internal use only.
python/mxnet/kvstore.py
def _ctype_key_value(keys, vals): """ Returns ctype arrays for the key-value args, and the whether string keys are used. For internal use only. """ if isinstance(keys, (tuple, list)): assert(len(keys) == len(vals)) c_keys = [] c_vals = [] use_str_keys = None f...
def _ctype_key_value(keys, vals): """ Returns ctype arrays for the key-value args, and the whether string keys are used. For internal use only. """ if isinstance(keys, (tuple, list)): assert(len(keys) == len(vals)) c_keys = [] c_vals = [] use_str_keys = None f...
[ "Returns", "ctype", "arrays", "for", "the", "key", "-", "value", "args", "and", "the", "whether", "string", "keys", "are", "used", ".", "For", "internal", "use", "only", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L33-L66
[ "def", "_ctype_key_value", "(", "keys", ",", "vals", ")", ":", "if", "isinstance", "(", "keys", ",", "(", "tuple", ",", "list", ")", ")", ":", "assert", "(", "len", "(", "keys", ")", "==", "len", "(", "vals", ")", ")", "c_keys", "=", "[", "]", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_ctype_dict
Returns ctype arrays for keys and values(converted to strings) in a dictionary
python/mxnet/kvstore.py
def _ctype_dict(param_dict): """ Returns ctype arrays for keys and values(converted to strings) in a dictionary """ assert(isinstance(param_dict, dict)), \ "unexpected type for param_dict: " + str(type(param_dict)) c_keys = c_array(ctypes.c_char_p, [c_str(k) for k in param_dict.keys()]) ...
def _ctype_dict(param_dict): """ Returns ctype arrays for keys and values(converted to strings) in a dictionary """ assert(isinstance(param_dict, dict)), \ "unexpected type for param_dict: " + str(type(param_dict)) c_keys = c_array(ctypes.c_char_p, [c_str(k) for k in param_dict.keys()]) ...
[ "Returns", "ctype", "arrays", "for", "keys", "and", "values", "(", "converted", "to", "strings", ")", "in", "a", "dictionary" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L68-L76
[ "def", "_ctype_dict", "(", "param_dict", ")", ":", "assert", "(", "isinstance", "(", "param_dict", ",", "dict", ")", ")", ",", "\"unexpected type for param_dict: \"", "+", "str", "(", "type", "(", "param_dict", ")", ")", "c_keys", "=", "c_array", "(", "ctype...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_updater_wrapper
A wrapper for the user-defined handle.
python/mxnet/kvstore.py
def _updater_wrapper(updater): """A wrapper for the user-defined handle.""" def updater_handle(key, lhs_handle, rhs_handle, _): """ ctypes function """ lhs = _ndarray_cls(NDArrayHandle(lhs_handle)) rhs = _ndarray_cls(NDArrayHandle(rhs_handle)) updater(key, lhs, rhs) return up...
def _updater_wrapper(updater): """A wrapper for the user-defined handle.""" def updater_handle(key, lhs_handle, rhs_handle, _): """ ctypes function """ lhs = _ndarray_cls(NDArrayHandle(lhs_handle)) rhs = _ndarray_cls(NDArrayHandle(rhs_handle)) updater(key, lhs, rhs) return up...
[ "A", "wrapper", "for", "the", "user", "-", "defined", "handle", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L78-L85
[ "def", "_updater_wrapper", "(", "updater", ")", ":", "def", "updater_handle", "(", "key", ",", "lhs_handle", ",", "rhs_handle", ",", "_", ")", ":", "\"\"\" ctypes function \"\"\"", "lhs", "=", "_ndarray_cls", "(", "NDArrayHandle", "(", "lhs_handle", ")", ")", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
create
Creates a new KVStore. For single machine training, there are two commonly used types: ``local``: Copies all gradients to CPU memory and updates weights there. ``device``: Aggregates gradients and updates weights on GPUs. With this setting, the KVStore also attempts to use GPU peer-to-peer communicat...
python/mxnet/kvstore.py
def create(name='local'): """Creates a new KVStore. For single machine training, there are two commonly used types: ``local``: Copies all gradients to CPU memory and updates weights there. ``device``: Aggregates gradients and updates weights on GPUs. With this setting, the KVStore also attempts t...
def create(name='local'): """Creates a new KVStore. For single machine training, there are two commonly used types: ``local``: Copies all gradients to CPU memory and updates weights there. ``device``: Aggregates gradients and updates weights on GPUs. With this setting, the KVStore also attempts t...
[ "Creates", "a", "new", "KVStore", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L635-L677
[ "def", "create", "(", "name", "=", "'local'", ")", ":", "if", "not", "isinstance", "(", "name", ",", "string_types", ")", ":", "raise", "TypeError", "(", "'name must be a string'", ")", "handle", "=", "KVStoreHandle", "(", ")", "check_call", "(", "_LIB", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
KVStore.init
Initializes a single or a sequence of key-value pairs into the store. For each key, one must `init` it before calling `push` or `pull`. When multiple workers invoke `init` for the same key, only the value supplied by worker with rank `0` is used. This function returns after data has bee...
python/mxnet/kvstore.py
def init(self, key, value): """ Initializes a single or a sequence of key-value pairs into the store. For each key, one must `init` it before calling `push` or `pull`. When multiple workers invoke `init` for the same key, only the value supplied by worker with rank `0` is used. This fun...
def init(self, key, value): """ Initializes a single or a sequence of key-value pairs into the store. For each key, one must `init` it before calling `push` or `pull`. When multiple workers invoke `init` for the same key, only the value supplied by worker with rank `0` is used. This fun...
[ "Initializes", "a", "single", "or", "a", "sequence", "of", "key", "-", "value", "pairs", "into", "the", "store", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L116-L158
[ "def", "init", "(", "self", ",", "key", ",", "value", ")", ":", "ckeys", ",", "cvals", ",", "use_str_keys", "=", "_ctype_key_value", "(", "key", ",", "value", ")", "if", "use_str_keys", ":", "check_call", "(", "_LIB", ".", "MXKVStoreInitEx", "(", "self",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
KVStore.push
Pushes a single or a sequence of key-value pairs into the store. This function returns immediately after adding an operator to the engine. The actual operation is executed asynchronously. If there are consecutive pushes to the same key, there is no guarantee on the serialization of pushes. ...
python/mxnet/kvstore.py
def push(self, key, value, priority=0): """ Pushes a single or a sequence of key-value pairs into the store. This function returns immediately after adding an operator to the engine. The actual operation is executed asynchronously. If there are consecutive pushes to the same key, there ...
def push(self, key, value, priority=0): """ Pushes a single or a sequence of key-value pairs into the store. This function returns immediately after adding an operator to the engine. The actual operation is executed asynchronously. If there are consecutive pushes to the same key, there ...
[ "Pushes", "a", "single", "or", "a", "sequence", "of", "key", "-", "value", "pairs", "into", "the", "store", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L160-L237
[ "def", "push", "(", "self", ",", "key", ",", "value", ",", "priority", "=", "0", ")", ":", "ckeys", ",", "cvals", ",", "use_str_keys", "=", "_ctype_key_value", "(", "key", ",", "value", ")", "if", "use_str_keys", ":", "check_call", "(", "_LIB", ".", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
KVStore.pull
Pulls a single value or a sequence of values from the store. This function returns immediately after adding an operator to the engine. Subsequent attempts to read from the `out` variable will be blocked until the pull operation completes. `pull` is executed asynchronously after all pre...
python/mxnet/kvstore.py
def pull(self, key, out=None, priority=0, ignore_sparse=True): """ Pulls a single value or a sequence of values from the store. This function returns immediately after adding an operator to the engine. Subsequent attempts to read from the `out` variable will be blocked until the pull op...
def pull(self, key, out=None, priority=0, ignore_sparse=True): """ Pulls a single value or a sequence of values from the store. This function returns immediately after adding an operator to the engine. Subsequent attempts to read from the `out` variable will be blocked until the pull op...
[ "Pulls", "a", "single", "value", "or", "a", "sequence", "of", "values", "from", "the", "store", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L240-L312
[ "def", "pull", "(", "self", ",", "key", ",", "out", "=", "None", ",", "priority", "=", "0", ",", "ignore_sparse", "=", "True", ")", ":", "assert", "(", "out", "is", "not", "None", ")", "ckeys", ",", "cvals", ",", "use_str_keys", "=", "_ctype_key_valu...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
KVStore.row_sparse_pull
Pulls a single RowSparseNDArray value or a sequence of RowSparseNDArray values \ from the store with specified row_ids. When there is only one row_id, KVStoreRowSparsePull \ is invoked just once and the result is broadcast to all the rest of outputs. `row_sparse_pull` is executed asynchronously...
python/mxnet/kvstore.py
def row_sparse_pull(self, key, out=None, priority=0, row_ids=None): """ Pulls a single RowSparseNDArray value or a sequence of RowSparseNDArray values \ from the store with specified row_ids. When there is only one row_id, KVStoreRowSparsePull \ is invoked just once and the result is broadcast t...
def row_sparse_pull(self, key, out=None, priority=0, row_ids=None): """ Pulls a single RowSparseNDArray value or a sequence of RowSparseNDArray values \ from the store with specified row_ids. When there is only one row_id, KVStoreRowSparsePull \ is invoked just once and the result is broadcast t...
[ "Pulls", "a", "single", "RowSparseNDArray", "value", "or", "a", "sequence", "of", "RowSparseNDArray", "values", "\\", "from", "the", "store", "with", "specified", "row_ids", ".", "When", "there", "is", "only", "one", "row_id", "KVStoreRowSparsePull", "\\", "is",...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L314-L392
[ "def", "row_sparse_pull", "(", "self", ",", "key", ",", "out", "=", "None", ",", "priority", "=", "0", ",", "row_ids", "=", "None", ")", ":", "assert", "(", "out", "is", "not", "None", ")", "assert", "(", "row_ids", "is", "not", "None", ")", "if", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
KVStore.set_gradient_compression
Specifies type of low-bit quantization for gradient compression \ and additional arguments depending on the type of compression being used. 2bit Gradient Compression takes a positive float `threshold`. The technique works by thresholding values such that positive values in the gradient...
python/mxnet/kvstore.py
def set_gradient_compression(self, compression_params): """ Specifies type of low-bit quantization for gradient compression \ and additional arguments depending on the type of compression being used. 2bit Gradient Compression takes a positive float `threshold`. The technique works by t...
def set_gradient_compression(self, compression_params): """ Specifies type of low-bit quantization for gradient compression \ and additional arguments depending on the type of compression being used. 2bit Gradient Compression takes a positive float `threshold`. The technique works by t...
[ "Specifies", "type", "of", "low", "-", "bit", "quantization", "for", "gradient", "compression", "\\", "and", "additional", "arguments", "depending", "on", "the", "type", "of", "compression", "being", "used", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L394-L448
[ "def", "set_gradient_compression", "(", "self", ",", "compression_params", ")", ":", "if", "(", "'device'", "in", "self", ".", "type", ")", "or", "(", "'dist'", "in", "self", ".", "type", ")", ":", "# pylint: disable=unsupported-membership-test", "ckeys", ",", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
KVStore.set_optimizer
Registers an optimizer with the kvstore. When using a single machine, this function updates the local optimizer. If using multiple machines and this operation is invoked from a worker node, it will serialized the optimizer with pickle and send it to all servers. The function returns aft...
python/mxnet/kvstore.py
def set_optimizer(self, optimizer): """ Registers an optimizer with the kvstore. When using a single machine, this function updates the local optimizer. If using multiple machines and this operation is invoked from a worker node, it will serialized the optimizer with pickle and send it ...
def set_optimizer(self, optimizer): """ Registers an optimizer with the kvstore. When using a single machine, this function updates the local optimizer. If using multiple machines and this operation is invoked from a worker node, it will serialized the optimizer with pickle and send it ...
[ "Registers", "an", "optimizer", "with", "the", "kvstore", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L450-L497
[ "def", "set_optimizer", "(", "self", ",", "optimizer", ")", ":", "is_worker", "=", "ctypes", ".", "c_int", "(", ")", "check_call", "(", "_LIB", ".", "MXKVStoreIsWorkerNode", "(", "ctypes", ".", "byref", "(", "is_worker", ")", ")", ")", "# pylint: disable=inv...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
KVStore.type
Returns the type of this kvstore. Returns ------- type : str the string type
python/mxnet/kvstore.py
def type(self): """ Returns the type of this kvstore. Returns ------- type : str the string type """ kv_type = ctypes.c_char_p() check_call(_LIB.MXKVStoreGetType(self.handle, ctypes.byref(kv_type))) return py_str(kv_type.value)
def type(self): """ Returns the type of this kvstore. Returns ------- type : str the string type """ kv_type = ctypes.c_char_p() check_call(_LIB.MXKVStoreGetType(self.handle, ctypes.byref(kv_type))) return py_str(kv_type.value)
[ "Returns", "the", "type", "of", "this", "kvstore", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L500-L510
[ "def", "type", "(", "self", ")", ":", "kv_type", "=", "ctypes", ".", "c_char_p", "(", ")", "check_call", "(", "_LIB", ".", "MXKVStoreGetType", "(", "self", ".", "handle", ",", "ctypes", ".", "byref", "(", "kv_type", ")", ")", ")", "return", "py_str", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
KVStore.rank
Returns the rank of this worker node. Returns ------- rank : int The rank of this node, which is in range [0, num_workers())
python/mxnet/kvstore.py
def rank(self): """ Returns the rank of this worker node. Returns ------- rank : int The rank of this node, which is in range [0, num_workers()) """ rank = ctypes.c_int() check_call(_LIB.MXKVStoreGetRank(self.handle, ctypes.byref(rank))) retur...
def rank(self): """ Returns the rank of this worker node. Returns ------- rank : int The rank of this node, which is in range [0, num_workers()) """ rank = ctypes.c_int() check_call(_LIB.MXKVStoreGetRank(self.handle, ctypes.byref(rank))) retur...
[ "Returns", "the", "rank", "of", "this", "worker", "node", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L513-L523
[ "def", "rank", "(", "self", ")", ":", "rank", "=", "ctypes", ".", "c_int", "(", ")", "check_call", "(", "_LIB", ".", "MXKVStoreGetRank", "(", "self", ".", "handle", ",", "ctypes", ".", "byref", "(", "rank", ")", ")", ")", "return", "rank", ".", "va...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
KVStore.num_workers
Returns the number of worker nodes. Returns ------- size :int The number of worker nodes.
python/mxnet/kvstore.py
def num_workers(self): """Returns the number of worker nodes. Returns ------- size :int The number of worker nodes. """ size = ctypes.c_int() check_call(_LIB.MXKVStoreGetGroupSize(self.handle, ctypes.byref(size))) return size.value
def num_workers(self): """Returns the number of worker nodes. Returns ------- size :int The number of worker nodes. """ size = ctypes.c_int() check_call(_LIB.MXKVStoreGetGroupSize(self.handle, ctypes.byref(size))) return size.value
[ "Returns", "the", "number", "of", "worker", "nodes", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L526-L536
[ "def", "num_workers", "(", "self", ")", ":", "size", "=", "ctypes", ".", "c_int", "(", ")", "check_call", "(", "_LIB", ".", "MXKVStoreGetGroupSize", "(", "self", ".", "handle", ",", "ctypes", ".", "byref", "(", "size", ")", ")", ")", "return", "size", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
KVStore.save_optimizer_states
Saves the optimizer (updater) state to a file. This is often used when checkpointing the model during training. Parameters ---------- fname : str Path to the output states file. dump_optimizer : bool, default False Whether to also save the optimizer itsel...
python/mxnet/kvstore.py
def save_optimizer_states(self, fname, dump_optimizer=False): """Saves the optimizer (updater) state to a file. This is often used when checkpointing the model during training. Parameters ---------- fname : str Path to the output states file. dump_optimizer :...
def save_optimizer_states(self, fname, dump_optimizer=False): """Saves the optimizer (updater) state to a file. This is often used when checkpointing the model during training. Parameters ---------- fname : str Path to the output states file. dump_optimizer :...
[ "Saves", "the", "optimizer", "(", "updater", ")", "state", "to", "a", "file", ".", "This", "is", "often", "used", "when", "checkpointing", "the", "model", "during", "training", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L538-L552
[ "def", "save_optimizer_states", "(", "self", ",", "fname", ",", "dump_optimizer", "=", "False", ")", ":", "assert", "self", ".", "_updater", "is", "not", "None", ",", "\"Cannot save states for distributed training\"", "with", "open", "(", "fname", ",", "'wb'", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
KVStore.load_optimizer_states
Loads the optimizer (updater) state from the file. Parameters ---------- fname : str Path to input states file.
python/mxnet/kvstore.py
def load_optimizer_states(self, fname): """Loads the optimizer (updater) state from the file. Parameters ---------- fname : str Path to input states file. """ assert self._updater is not None, "Cannot load states for distributed training" self._update...
def load_optimizer_states(self, fname): """Loads the optimizer (updater) state from the file. Parameters ---------- fname : str Path to input states file. """ assert self._updater is not None, "Cannot load states for distributed training" self._update...
[ "Loads", "the", "optimizer", "(", "updater", ")", "state", "from", "the", "file", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L554-L563
[ "def", "load_optimizer_states", "(", "self", ",", "fname", ")", ":", "assert", "self", ".", "_updater", "is", "not", "None", ",", "\"Cannot load states for distributed training\"", "self", ".", "_updater", ".", "set_states", "(", "open", "(", "fname", ",", "'rb'...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
KVStore._set_updater
Sets a push updater into the store. This function only changes the local store. When running on multiple machines one must use `set_optimizer`. Parameters ---------- updater : function The updater function. Examples -------- >>> def update(k...
python/mxnet/kvstore.py
def _set_updater(self, updater): """Sets a push updater into the store. This function only changes the local store. When running on multiple machines one must use `set_optimizer`. Parameters ---------- updater : function The updater function. Exampl...
def _set_updater(self, updater): """Sets a push updater into the store. This function only changes the local store. When running on multiple machines one must use `set_optimizer`. Parameters ---------- updater : function The updater function. Exampl...
[ "Sets", "a", "push", "updater", "into", "the", "store", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L565-L603
[ "def", "_set_updater", "(", "self", ",", "updater", ")", ":", "self", ".", "_updater", "=", "updater", "# set updater with int keys", "_updater_proto", "=", "ctypes", ".", "CFUNCTYPE", "(", "None", ",", "ctypes", ".", "c_int", ",", "NDArrayHandle", ",", "NDArr...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
KVStore._send_command_to_servers
Sends a command to all server nodes. Sending command to a server node will cause that server node to invoke ``KVStoreServer.controller`` to execute the command. This function returns after the command has been executed on all server nodes. Parameters ---------- ...
python/mxnet/kvstore.py
def _send_command_to_servers(self, head, body): """Sends a command to all server nodes. Sending command to a server node will cause that server node to invoke ``KVStoreServer.controller`` to execute the command. This function returns after the command has been executed on all server ...
def _send_command_to_servers(self, head, body): """Sends a command to all server nodes. Sending command to a server node will cause that server node to invoke ``KVStoreServer.controller`` to execute the command. This function returns after the command has been executed on all server ...
[ "Sends", "a", "command", "to", "all", "server", "nodes", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L616-L633
[ "def", "_send_command_to_servers", "(", "self", ",", "head", ",", "body", ")", ":", "check_call", "(", "_LIB", ".", "MXKVStoreSendCommmandToServers", "(", "self", ".", "handle", ",", "mx_uint", "(", "head", ")", ",", "c_str", "(", "body", ")", ")", ")" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SequentialModule.add
Add a module to the chain. Parameters ---------- module : BaseModule The new module to add. kwargs : ``**keywords`` All the keyword arguments are saved as meta information for the added module. The currently known meta includes - `take_la...
python/mxnet/module/sequential_module.py
def add(self, module, **kwargs): """Add a module to the chain. Parameters ---------- module : BaseModule The new module to add. kwargs : ``**keywords`` All the keyword arguments are saved as meta information for the added module. The currently...
def add(self, module, **kwargs): """Add a module to the chain. Parameters ---------- module : BaseModule The new module to add. kwargs : ``**keywords`` All the keyword arguments are saved as meta information for the added module. The currently...
[ "Add", "a", "module", "to", "the", "chain", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/sequential_module.py#L52-L97
[ "def", "add", "(", "self", ",", "module", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_modules", ".", "append", "(", "module", ")", "# a sanity check to avoid typo", "for", "key", "in", "kwargs", ":", "assert", "key", "in", "self", ".", "_meta_keys"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SequentialModule.get_params
Gets current parameters. Returns ------- (arg_params, aux_params) A pair of dictionaries each mapping parameter names to NDArray values. This is a merged dictionary of all the parameters in the modules.
python/mxnet/module/sequential_module.py
def get_params(self): """Gets current parameters. Returns ------- (arg_params, aux_params) A pair of dictionaries each mapping parameter names to NDArray values. This is a merged dictionary of all the parameters in the modules. """ assert self.bin...
def get_params(self): """Gets current parameters. Returns ------- (arg_params, aux_params) A pair of dictionaries each mapping parameter names to NDArray values. This is a merged dictionary of all the parameters in the modules. """ assert self.bin...
[ "Gets", "current", "parameters", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/sequential_module.py#L153-L172
[ "def", "get_params", "(", "self", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "arg_params", "=", "dict", "(", ")", "aux_params", "=", "dict", "(", ")", "for", "module", "in", "self", ".", "_modules", ":", "arg", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SequentialModule.init_params
Initializes parameters. Parameters ---------- initializer : Initializer arg_params : dict Default ``None``. Existing parameters. This has higher priority than `initializer`. aux_params : dict Default ``None``. Existing auxiliary states. This h...
python/mxnet/module/sequential_module.py
def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None, allow_missing=False, force_init=False, allow_extra=False): """Initializes parameters. Parameters ---------- initializer : Initializer arg_params : dict Default ``No...
def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None, allow_missing=False, force_init=False, allow_extra=False): """Initializes parameters. Parameters ---------- initializer : Initializer arg_params : dict Default ``No...
[ "Initializes", "parameters", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/sequential_module.py#L174-L223
[ "def", "init_params", "(", "self", ",", "initializer", "=", "Uniform", "(", "0.01", ")", ",", "arg_params", "=", "None", ",", "aux_params", "=", "None", ",", "allow_missing", "=", "False", ",", "force_init", "=", "False", ",", "allow_extra", "=", "False", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SequentialModule.bind
Binds the symbols to construct executors. This is necessary before one can perform computation with the module. Parameters ---------- data_shapes : list of (str, tuple) Typically is `data_iter.provide_data`. label_shapes : list of (str, tuple) Typically i...
python/mxnet/module/sequential_module.py
def bind(self, data_shapes, label_shapes=None, for_training=True, inputs_need_grad=False, force_rebind=False, shared_module=None, grad_req='write'): """Binds the symbols to construct executors. This is necessary before one can perform computation with the module. Param...
def bind(self, data_shapes, label_shapes=None, for_training=True, inputs_need_grad=False, force_rebind=False, shared_module=None, grad_req='write'): """Binds the symbols to construct executors. This is necessary before one can perform computation with the module. Param...
[ "Binds", "the", "symbols", "to", "construct", "executors", ".", "This", "is", "necessary", "before", "one", "can", "perform", "computation", "with", "the", "module", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/sequential_module.py#L225-L296
[ "def", "bind", "(", "self", ",", "data_shapes", ",", "label_shapes", "=", "None", ",", "for_training", "=", "True", ",", "inputs_need_grad", "=", "False", ",", "force_rebind", "=", "False", ",", "shared_module", "=", "None", ",", "grad_req", "=", "'write'", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SequentialModule.init_optimizer
Installs and initializes optimizers. Parameters ---------- kvstore : str or KVStore Default `'local'`. optimizer : str or Optimizer Default `'sgd'` optimizer_params : dict Default ``(('learning_rate', 0.01),)``. The default value is not a dict...
python/mxnet/module/sequential_module.py
def init_optimizer(self, kvstore='local', optimizer='sgd', optimizer_params=(('learning_rate', 0.01),), force_init=False): """Installs and initializes optimizers. Parameters ---------- kvstore : str or KVStore Default `'local'`. ...
def init_optimizer(self, kvstore='local', optimizer='sgd', optimizer_params=(('learning_rate', 0.01),), force_init=False): """Installs and initializes optimizers. Parameters ---------- kvstore : str or KVStore Default `'local'`. ...
[ "Installs", "and", "initializes", "optimizers", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/sequential_module.py#L298-L325
[ "def", "init_optimizer", "(", "self", ",", "kvstore", "=", "'local'", ",", "optimizer", "=", "'sgd'", ",", "optimizer_params", "=", "(", "(", "'learning_rate'", ",", "0.01", ")", ",", ")", ",", "force_init", "=", "False", ")", ":", "assert", "self", ".",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SequentialModule.forward
Forward computation. Parameters ---------- data_batch : DataBatch is_train : bool Default is ``None``, in which case `is_train` is take as ``self.for_training``.
python/mxnet/module/sequential_module.py
def forward(self, data_batch, is_train=None): """Forward computation. Parameters ---------- data_batch : DataBatch is_train : bool Default is ``None``, in which case `is_train` is take as ``self.for_training``. """ assert self.binded and self.params_i...
def forward(self, data_batch, is_train=None): """Forward computation. Parameters ---------- data_batch : DataBatch is_train : bool Default is ``None``, in which case `is_train` is take as ``self.for_training``. """ assert self.binded and self.params_i...
[ "Forward", "computation", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/sequential_module.py#L327-L356
[ "def", "forward", "(", "self", ",", "data_batch", ",", "is_train", "=", "None", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "# make a shallow copy, just to maintain necessary properties (if any) like", "# bucket_key, pad, etc.", "d...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SequentialModule.backward
Backward computation.
python/mxnet/module/sequential_module.py
def backward(self, out_grads=None): """Backward computation.""" assert self.binded and self.params_initialized for i_layer, module in reversed(list(zip(range(len(self._modules)), self._modules))): module.backward(out_grads=out_grads) if i_layer == 0: brea...
def backward(self, out_grads=None): """Backward computation.""" assert self.binded and self.params_initialized for i_layer, module in reversed(list(zip(range(len(self._modules)), self._modules))): module.backward(out_grads=out_grads) if i_layer == 0: brea...
[ "Backward", "computation", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/sequential_module.py#L358-L367
[ "def", "backward", "(", "self", ",", "out_grads", "=", "None", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "for", "i_layer", ",", "module", "in", "reversed", "(", "list", "(", "zip", "(", "range", "(", "len", "(...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SequentialModule.update
Updates parameters according to installed optimizer and the gradient computed in the previous forward-backward cycle.
python/mxnet/module/sequential_module.py
def update(self): """Updates parameters according to installed optimizer and the gradient computed in the previous forward-backward cycle. """ assert self.binded and self.params_initialized and self.optimizer_initialized for module in self._modules: module.update()
def update(self): """Updates parameters according to installed optimizer and the gradient computed in the previous forward-backward cycle. """ assert self.binded and self.params_initialized and self.optimizer_initialized for module in self._modules: module.update()
[ "Updates", "parameters", "according", "to", "installed", "optimizer", "and", "the", "gradient", "computed", "in", "the", "previous", "forward", "-", "backward", "cycle", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/sequential_module.py#L369-L376
[ "def", "update", "(", "self", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "and", "self", ".", "optimizer_initialized", "for", "module", "in", "self", ".", "_modules", ":", "module", ".", "update", "(", ")" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7