repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
apache/incubator-mxnet
python/mxnet/io/io.py
NDArrayIter.hard_reset
def hard_reset(self): """Ignore roll over data and set to start.""" if self.shuffle: self._shuffle_data() self.cursor = -self.batch_size self._cache_data = None self._cache_label = None
python
def hard_reset(self): """Ignore roll over data and set to start.""" if self.shuffle: self._shuffle_data() self.cursor = -self.batch_size self._cache_data = None self._cache_label = None
[ "def", "hard_reset", "(", "self", ")", ":", "if", "self", ".", "shuffle", ":", "self", ".", "_shuffle_data", "(", ")", "self", ".", "cursor", "=", "-", "self", ".", "batch_size", "self", ".", "_cache_data", "=", "None", "self", ".", "_cache_label", "="...
Ignore roll over data and set to start.
[ "Ignore", "roll", "over", "data", "and", "set", "to", "start", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L650-L656
train
apache/incubator-mxnet
python/mxnet/io/io.py
NDArrayIter.reset
def reset(self): """Resets the iterator to the beginning of the data.""" if self.shuffle: self._shuffle_data() # the range below indicate the last batch if self.last_batch_handle == 'roll_over' and \ self.num_data - self.batch_size < self.cursor < self.num_data: ...
python
def reset(self): """Resets the iterator to the beginning of the data.""" if self.shuffle: self._shuffle_data() # the range below indicate the last batch if self.last_batch_handle == 'roll_over' and \ self.num_data - self.batch_size < self.cursor < self.num_data: ...
[ "def", "reset", "(", "self", ")", ":", "if", "self", ".", "shuffle", ":", "self", ".", "_shuffle_data", "(", ")", "# the range below indicate the last batch", "if", "self", ".", "last_batch_handle", "==", "'roll_over'", "and", "self", ".", "num_data", "-", "se...
Resets the iterator to the beginning of the data.
[ "Resets", "the", "iterator", "to", "the", "beginning", "of", "the", "data", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L658-L668
train
apache/incubator-mxnet
python/mxnet/io/io.py
NDArrayIter.iter_next
def iter_next(self): """Increments the coursor by batch_size for next batch and check current cursor if it exceed the number of data points.""" self.cursor += self.batch_size return self.cursor < self.num_data
python
def iter_next(self): """Increments the coursor by batch_size for next batch and check current cursor if it exceed the number of data points.""" self.cursor += self.batch_size return self.cursor < self.num_data
[ "def", "iter_next", "(", "self", ")", ":", "self", ".", "cursor", "+=", "self", ".", "batch_size", "return", "self", ".", "cursor", "<", "self", ".", "num_data" ]
Increments the coursor by batch_size for next batch and check current cursor if it exceed the number of data points.
[ "Increments", "the", "coursor", "by", "batch_size", "for", "next", "batch", "and", "check", "current", "cursor", "if", "it", "exceed", "the", "number", "of", "data", "points", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L670-L674
train
apache/incubator-mxnet
python/mxnet/io/io.py
NDArrayIter.next
def next(self): """Returns the next batch of data.""" if not self.iter_next(): raise StopIteration data = self.getdata() label = self.getlabel() # iter should stop when last batch is not complete if data[0].shape[0] != self.batch_size: # in this case, ...
python
def next(self): """Returns the next batch of data.""" if not self.iter_next(): raise StopIteration data = self.getdata() label = self.getlabel() # iter should stop when last batch is not complete if data[0].shape[0] != self.batch_size: # in this case, ...
[ "def", "next", "(", "self", ")", ":", "if", "not", "self", ".", "iter_next", "(", ")", ":", "raise", "StopIteration", "data", "=", "self", ".", "getdata", "(", ")", "label", "=", "self", ".", "getlabel", "(", ")", "# iter should stop when last batch is not...
Returns the next batch of data.
[ "Returns", "the", "next", "batch", "of", "data", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L676-L689
train
apache/incubator-mxnet
python/mxnet/io/io.py
NDArrayIter._getdata
def _getdata(self, data_source, start=None, end=None): """Load data from underlying arrays.""" assert start is not None or end is not None, 'should at least specify start or end' start = start if start is not None else 0 if end is None: end = data_source[0][1].shape[0] if dat...
python
def _getdata(self, data_source, start=None, end=None): """Load data from underlying arrays.""" assert start is not None or end is not None, 'should at least specify start or end' start = start if start is not None else 0 if end is None: end = data_source[0][1].shape[0] if dat...
[ "def", "_getdata", "(", "self", ",", "data_source", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "assert", "start", "is", "not", "None", "or", "end", "is", "not", "None", ",", "'should at least specify start or end'", "start", "=", "start"...
Load data from underlying arrays.
[ "Load", "data", "from", "underlying", "arrays", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L691-L706
train
apache/incubator-mxnet
python/mxnet/io/io.py
NDArrayIter._concat
def _concat(self, first_data, second_data): """Helper function to concat two NDArrays.""" assert len(first_data) == len( second_data), 'data source should contain the same size' if first_data and second_data: return [ concat( first_data...
python
def _concat(self, first_data, second_data): """Helper function to concat two NDArrays.""" assert len(first_data) == len( second_data), 'data source should contain the same size' if first_data and second_data: return [ concat( first_data...
[ "def", "_concat", "(", "self", ",", "first_data", ",", "second_data", ")", ":", "assert", "len", "(", "first_data", ")", "==", "len", "(", "second_data", ")", ",", "'data source should contain the same size'", "if", "first_data", "and", "second_data", ":", "retu...
Helper function to concat two NDArrays.
[ "Helper", "function", "to", "concat", "two", "NDArrays", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L708-L726
train
apache/incubator-mxnet
python/mxnet/io/io.py
NDArrayIter._batchify
def _batchify(self, data_source): """Load data from underlying arrays, internal use only.""" assert self.cursor < self.num_data, 'DataIter needs reset.' # first batch of next epoch with 'roll_over' if self.last_batch_handle == 'roll_over' and \ -self.batch_size < self.cursor ...
python
def _batchify(self, data_source): """Load data from underlying arrays, internal use only.""" assert self.cursor < self.num_data, 'DataIter needs reset.' # first batch of next epoch with 'roll_over' if self.last_batch_handle == 'roll_over' and \ -self.batch_size < self.cursor ...
[ "def", "_batchify", "(", "self", ",", "data_source", ")", ":", "assert", "self", ".", "cursor", "<", "self", ".", "num_data", ",", "'DataIter needs reset.'", "# first batch of next epoch with 'roll_over'", "if", "self", ".", "last_batch_handle", "==", "'roll_over'", ...
Load data from underlying arrays, internal use only.
[ "Load", "data", "from", "underlying", "arrays", "internal", "use", "only", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L728-L758
train
apache/incubator-mxnet
python/mxnet/io/io.py
NDArrayIter.getpad
def getpad(self): """Get pad value of DataBatch.""" if self.last_batch_handle == 'pad' and \ self.cursor + self.batch_size > self.num_data: return self.cursor + self.batch_size - self.num_data # check the first batch elif self.last_batch_handle == 'roll_over' and \...
python
def getpad(self): """Get pad value of DataBatch.""" if self.last_batch_handle == 'pad' and \ self.cursor + self.batch_size > self.num_data: return self.cursor + self.batch_size - self.num_data # check the first batch elif self.last_batch_handle == 'roll_over' and \...
[ "def", "getpad", "(", "self", ")", ":", "if", "self", ".", "last_batch_handle", "==", "'pad'", "and", "self", ".", "cursor", "+", "self", ".", "batch_size", ">", "self", ".", "num_data", ":", "return", "self", ".", "cursor", "+", "self", ".", "batch_si...
Get pad value of DataBatch.
[ "Get", "pad", "value", "of", "DataBatch", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L768-L778
train
apache/incubator-mxnet
python/mxnet/io/io.py
NDArrayIter._shuffle_data
def _shuffle_data(self): """Shuffle the data.""" # shuffle index np.random.shuffle(self.idx) # get the data by corresponding index self.data = _getdata_by_idx(self.data, self.idx) self.label = _getdata_by_idx(self.label, self.idx)
python
def _shuffle_data(self): """Shuffle the data.""" # shuffle index np.random.shuffle(self.idx) # get the data by corresponding index self.data = _getdata_by_idx(self.data, self.idx) self.label = _getdata_by_idx(self.label, self.idx)
[ "def", "_shuffle_data", "(", "self", ")", ":", "# shuffle index", "np", ".", "random", ".", "shuffle", "(", "self", ".", "idx", ")", "# get the data by corresponding index", "self", ".", "data", "=", "_getdata_by_idx", "(", "self", ".", "data", ",", "self", ...
Shuffle the data.
[ "Shuffle", "the", "data", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/io.py#L780-L786
train
apache/incubator-mxnet
python/mxnet/contrib/quantization.py
_quantize_params
def _quantize_params(qsym, params, th_dict): """Given a quantized symbol and a dict of params that have not been quantized, generate quantized params. Currently only supports quantizing the arg_params with names of `weight` or `bias`, not aux_params. If `qsym` contains symbols that are excluded from bei...
python
def _quantize_params(qsym, params, th_dict): """Given a quantized symbol and a dict of params that have not been quantized, generate quantized params. Currently only supports quantizing the arg_params with names of `weight` or `bias`, not aux_params. If `qsym` contains symbols that are excluded from bei...
[ "def", "_quantize_params", "(", "qsym", ",", "params", ",", "th_dict", ")", ":", "inputs_name", "=", "qsym", ".", "list_arguments", "(", ")", "quantized_params", "=", "{", "}", "for", "name", "in", "inputs_name", ":", "if", "name", ".", "endswith", "(", ...
Given a quantized symbol and a dict of params that have not been quantized, generate quantized params. Currently only supports quantizing the arg_params with names of `weight` or `bias`, not aux_params. If `qsym` contains symbols that are excluded from being quantized, their corresponding params will no...
[ "Given", "a", "quantized", "symbol", "and", "a", "dict", "of", "params", "that", "have", "not", "been", "quantized", "generate", "quantized", "params", ".", "Currently", "only", "supports", "quantizing", "the", "arg_params", "with", "names", "of", "weight", "o...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L43-L81
train
apache/incubator-mxnet
python/mxnet/contrib/quantization.py
_quantize_symbol
def _quantize_symbol(sym, excluded_symbols=None, offline_params=None, quantized_dtype='int8'): """Given a symbol object representing a neural network of data type FP32, quantize it into a INT8 network. Parameters ---------- sym : Symbol FP32 neural network symbol. excluded_sym_names : l...
python
def _quantize_symbol(sym, excluded_symbols=None, offline_params=None, quantized_dtype='int8'): """Given a symbol object representing a neural network of data type FP32, quantize it into a INT8 network. Parameters ---------- sym : Symbol FP32 neural network symbol. excluded_sym_names : l...
[ "def", "_quantize_symbol", "(", "sym", ",", "excluded_symbols", "=", "None", ",", "offline_params", "=", "None", ",", "quantized_dtype", "=", "'int8'", ")", ":", "num_excluded_symbols", "=", "0", "if", "excluded_symbols", "is", "not", "None", ":", "assert", "i...
Given a symbol object representing a neural network of data type FP32, quantize it into a INT8 network. Parameters ---------- sym : Symbol FP32 neural network symbol. excluded_sym_names : list of strings A list of strings representing the names of the symbols that users want to excl...
[ "Given", "a", "symbol", "object", "representing", "a", "neural", "network", "of", "data", "type", "FP32", "quantize", "it", "into", "a", "INT8", "network", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L83-L124
train
apache/incubator-mxnet
python/mxnet/contrib/quantization.py
_calibrate_quantized_sym
def _calibrate_quantized_sym(qsym, th_dict): """Given a dictionary containing the thresholds for quantizing the layers, set the thresholds into the quantized symbol as the params of requantize operators. """ if th_dict is None or len(th_dict) == 0: return qsym num_layer_outputs = len(th_dict...
python
def _calibrate_quantized_sym(qsym, th_dict): """Given a dictionary containing the thresholds for quantizing the layers, set the thresholds into the quantized symbol as the params of requantize operators. """ if th_dict is None or len(th_dict) == 0: return qsym num_layer_outputs = len(th_dict...
[ "def", "_calibrate_quantized_sym", "(", "qsym", ",", "th_dict", ")", ":", "if", "th_dict", "is", "None", "or", "len", "(", "th_dict", ")", "==", "0", ":", "return", "qsym", "num_layer_outputs", "=", "len", "(", "th_dict", ")", "layer_output_names", "=", "[...
Given a dictionary containing the thresholds for quantizing the layers, set the thresholds into the quantized symbol as the params of requantize operators.
[ "Given", "a", "dictionary", "containing", "the", "thresholds", "for", "quantizing", "the", "layers", "set", "the", "thresholds", "into", "the", "quantized", "symbol", "as", "the", "params", "of", "requantize", "operators", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L179-L201
train
apache/incubator-mxnet
python/mxnet/contrib/quantization.py
_collect_layer_output_min_max
def _collect_layer_output_min_max(mod, data, include_layer=None, max_num_examples=None, logger=None): """Collect min and max values from layer outputs and save them in a dictionary mapped by layer names. """ collector = _LayerOutputMinMaxCollector(include_layer=include_...
python
def _collect_layer_output_min_max(mod, data, include_layer=None, max_num_examples=None, logger=None): """Collect min and max values from layer outputs and save them in a dictionary mapped by layer names. """ collector = _LayerOutputMinMaxCollector(include_layer=include_...
[ "def", "_collect_layer_output_min_max", "(", "mod", ",", "data", ",", "include_layer", "=", "None", ",", "max_num_examples", "=", "None", ",", "logger", "=", "None", ")", ":", "collector", "=", "_LayerOutputMinMaxCollector", "(", "include_layer", "=", "include_lay...
Collect min and max values from layer outputs and save them in a dictionary mapped by layer names.
[ "Collect", "min", "and", "max", "values", "from", "layer", "outputs", "and", "save", "them", "in", "a", "dictionary", "mapped", "by", "layer", "names", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L223-L230
train
apache/incubator-mxnet
python/mxnet/contrib/quantization.py
_collect_layer_outputs
def _collect_layer_outputs(mod, data, include_layer=None, max_num_examples=None, logger=None): """Collect layer outputs and save them in a dictionary mapped by layer names.""" collector = _LayerOutputCollector(include_layer=include_layer, logger=logger) num_examples = _collect_layer_statistics(mod, data, co...
python
def _collect_layer_outputs(mod, data, include_layer=None, max_num_examples=None, logger=None): """Collect layer outputs and save them in a dictionary mapped by layer names.""" collector = _LayerOutputCollector(include_layer=include_layer, logger=logger) num_examples = _collect_layer_statistics(mod, data, co...
[ "def", "_collect_layer_outputs", "(", "mod", ",", "data", ",", "include_layer", "=", "None", ",", "max_num_examples", "=", "None", ",", "logger", "=", "None", ")", ":", "collector", "=", "_LayerOutputCollector", "(", "include_layer", "=", "include_layer", ",", ...
Collect layer outputs and save them in a dictionary mapped by layer names.
[ "Collect", "layer", "outputs", "and", "save", "them", "in", "a", "dictionary", "mapped", "by", "layer", "names", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L233-L237
train
apache/incubator-mxnet
python/mxnet/contrib/quantization.py
_smooth_distribution
def _smooth_distribution(p, eps=0.0001): """Given a discrete distribution (may have not been normalized to 1), smooth it by replacing zeros with eps multiplied by a scaling factor and taking the corresponding amount off the non-zero values. Ref: http://web.engr.illinois.edu/~hanj/cs412/bk3/KL-divergence...
python
def _smooth_distribution(p, eps=0.0001): """Given a discrete distribution (may have not been normalized to 1), smooth it by replacing zeros with eps multiplied by a scaling factor and taking the corresponding amount off the non-zero values. Ref: http://web.engr.illinois.edu/~hanj/cs412/bk3/KL-divergence...
[ "def", "_smooth_distribution", "(", "p", ",", "eps", "=", "0.0001", ")", ":", "is_zeros", "=", "(", "p", "==", "0", ")", ".", "astype", "(", "np", ".", "float32", ")", "is_nonzeros", "=", "(", "p", "!=", "0", ")", ".", "astype", "(", "np", ".", ...
Given a discrete distribution (may have not been normalized to 1), smooth it by replacing zeros with eps multiplied by a scaling factor and taking the corresponding amount off the non-zero values. Ref: http://web.engr.illinois.edu/~hanj/cs412/bk3/KL-divergence.pdf
[ "Given", "a", "discrete", "distribution", "(", "may", "have", "not", "been", "normalized", "to", "1", ")", "smooth", "it", "by", "replacing", "zeros", "with", "eps", "multiplied", "by", "a", "scaling", "factor", "and", "taking", "the", "corresponding", "amou...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L240-L257
train
apache/incubator-mxnet
python/mxnet/contrib/quantization.py
_get_optimal_threshold
def _get_optimal_threshold(arr, quantized_dtype, num_bins=8001, num_quantized_bins=255): """Given a dataset, find the optimal threshold for quantizing it. The reference distribution is `q`, and the candidate distribution is `p`. `q` is a truncated version of the original distribution. Ref: http://on-de...
python
def _get_optimal_threshold(arr, quantized_dtype, num_bins=8001, num_quantized_bins=255): """Given a dataset, find the optimal threshold for quantizing it. The reference distribution is `q`, and the candidate distribution is `p`. `q` is a truncated version of the original distribution. Ref: http://on-de...
[ "def", "_get_optimal_threshold", "(", "arr", ",", "quantized_dtype", ",", "num_bins", "=", "8001", ",", "num_quantized_bins", "=", "255", ")", ":", "if", "isinstance", "(", "arr", ",", "NDArray", ")", ":", "arr", "=", "arr", ".", "asnumpy", "(", ")", "el...
Given a dataset, find the optimal threshold for quantizing it. The reference distribution is `q`, and the candidate distribution is `p`. `q` is a truncated version of the original distribution. Ref: http://on-demand.gputechconf.com/gtc/2017/presentation/s7310-8-bit-inference-with-tensorrt.pdf
[ "Given", "a", "dataset", "find", "the", "optimal", "threshold", "for", "quantizing", "it", ".", "The", "reference", "distribution", "is", "q", "and", "the", "candidate", "distribution", "is", "p", ".", "q", "is", "a", "truncated", "version", "of", "the", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L261-L351
train
apache/incubator-mxnet
python/mxnet/contrib/quantization.py
_get_optimal_thresholds
def _get_optimal_thresholds(nd_dict, quantized_dtype, num_bins=8001, num_quantized_bins=255, logger=None): """Given a ndarray dict, find the optimal threshold for quantizing each value of the key.""" if stats is None: raise ImportError('scipy.stats is required for running entropy mode of calculating' ...
python
def _get_optimal_thresholds(nd_dict, quantized_dtype, num_bins=8001, num_quantized_bins=255, logger=None): """Given a ndarray dict, find the optimal threshold for quantizing each value of the key.""" if stats is None: raise ImportError('scipy.stats is required for running entropy mode of calculating' ...
[ "def", "_get_optimal_thresholds", "(", "nd_dict", ",", "quantized_dtype", ",", "num_bins", "=", "8001", ",", "num_quantized_bins", "=", "255", ",", "logger", "=", "None", ")", ":", "if", "stats", "is", "None", ":", "raise", "ImportError", "(", "'scipy.stats is...
Given a ndarray dict, find the optimal threshold for quantizing each value of the key.
[ "Given", "a", "ndarray", "dict", "find", "the", "optimal", "threshold", "for", "quantizing", "each", "value", "of", "the", "key", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L355-L381
train
apache/incubator-mxnet
python/mxnet/contrib/quantization.py
_load_sym
def _load_sym(sym, logger=logging): """Given a str as a path the symbol .json file or a symbol, returns a Symbol object.""" if isinstance(sym, str): # sym is a symbol file path cur_path = os.path.dirname(os.path.realpath(__file__)) symbol_file_path = os.path.join(cur_path, sym) logger.i...
python
def _load_sym(sym, logger=logging): """Given a str as a path the symbol .json file or a symbol, returns a Symbol object.""" if isinstance(sym, str): # sym is a symbol file path cur_path = os.path.dirname(os.path.realpath(__file__)) symbol_file_path = os.path.join(cur_path, sym) logger.i...
[ "def", "_load_sym", "(", "sym", ",", "logger", "=", "logging", ")", ":", "if", "isinstance", "(", "sym", ",", "str", ")", ":", "# sym is a symbol file path", "cur_path", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpath", "...
Given a str as a path the symbol .json file or a symbol, returns a Symbol object.
[ "Given", "a", "str", "as", "a", "path", "the", "symbol", ".", "json", "file", "or", "a", "symbol", "returns", "a", "Symbol", "object", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L384-L395
train
apache/incubator-mxnet
python/mxnet/contrib/quantization.py
_load_params
def _load_params(params, logger=logging): """Given a str as a path to the .params file or a pair of params, returns two dictionaries representing arg_params and aux_params. """ if isinstance(params, str): cur_path = os.path.dirname(os.path.realpath(__file__)) param_file_path = os.path.jo...
python
def _load_params(params, logger=logging): """Given a str as a path to the .params file or a pair of params, returns two dictionaries representing arg_params and aux_params. """ if isinstance(params, str): cur_path = os.path.dirname(os.path.realpath(__file__)) param_file_path = os.path.jo...
[ "def", "_load_params", "(", "params", ",", "logger", "=", "logging", ")", ":", "if", "isinstance", "(", "params", ",", "str", ")", ":", "cur_path", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "realpath", "(", "__file__", ")",...
Given a str as a path to the .params file or a pair of params, returns two dictionaries representing arg_params and aux_params.
[ "Given", "a", "str", "as", "a", "path", "to", "the", ".", "params", "file", "or", "a", "pair", "of", "params", "returns", "two", "dictionaries", "representing", "arg_params", "and", "aux_params", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L398-L420
train
apache/incubator-mxnet
python/mxnet/contrib/quantization.py
quantize_model
def quantize_model(sym, arg_params, aux_params, data_names=('data',), label_names=('softmax_label',), ctx=cpu(), excluded_sym_names=None, calib_mode='entropy', calib_data=None, num_calib_examples=None, calib_layer=None, quantized_dtype='int8', ...
python
def quantize_model(sym, arg_params, aux_params, data_names=('data',), label_names=('softmax_label',), ctx=cpu(), excluded_sym_names=None, calib_mode='entropy', calib_data=None, num_calib_examples=None, calib_layer=None, quantized_dtype='int8', ...
[ "def", "quantize_model", "(", "sym", ",", "arg_params", ",", "aux_params", ",", "data_names", "=", "(", "'data'", ",", ")", ",", "label_names", "=", "(", "'softmax_label'", ",", ")", ",", "ctx", "=", "cpu", "(", ")", ",", "excluded_sym_names", "=", "None...
User-level API for generating a quantized model from a FP32 model w/ or w/o calibration. The backend quantized operators are only enabled for Linux systems. Please do not run inference using the quantized models on Windows for now. The quantization implementation adopts the TensorFlow's approach: https:...
[ "User", "-", "level", "API", "for", "generating", "a", "quantized", "model", "from", "a", "FP32", "model", "w", "/", "or", "w", "/", "o", "calibration", ".", "The", "backend", "quantized", "operators", "are", "only", "enabled", "for", "Linux", "systems", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L422-L544
train
apache/incubator-mxnet
python/mxnet/contrib/quantization.py
_LayerOutputCollector.collect
def collect(self, name, arr): """Callback function for collecting layer output NDArrays.""" name = py_str(name) if self.include_layer is not None and not self.include_layer(name): return handle = ctypes.cast(arr, NDArrayHandle) arr = NDArray(handle, writable=False).co...
python
def collect(self, name, arr): """Callback function for collecting layer output NDArrays.""" name = py_str(name) if self.include_layer is not None and not self.include_layer(name): return handle = ctypes.cast(arr, NDArrayHandle) arr = NDArray(handle, writable=False).co...
[ "def", "collect", "(", "self", ",", "name", ",", "arr", ")", ":", "name", "=", "py_str", "(", "name", ")", "if", "self", ".", "include_layer", "is", "not", "None", "and", "not", "self", ".", "include_layer", "(", "name", ")", ":", "return", "handle",...
Callback function for collecting layer output NDArrays.
[ "Callback", "function", "for", "collecting", "layer", "output", "NDArrays", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L137-L149
train
apache/incubator-mxnet
python/mxnet/contrib/quantization.py
_LayerOutputMinMaxCollector.collect
def collect(self, name, arr): """Callback function for collecting min and max values from an NDArray.""" name = py_str(name) if self.include_layer is not None and not self.include_layer(name): return handle = ctypes.cast(arr, NDArrayHandle) arr = NDArray(handle, writa...
python
def collect(self, name, arr): """Callback function for collecting min and max values from an NDArray.""" name = py_str(name) if self.include_layer is not None and not self.include_layer(name): return handle = ctypes.cast(arr, NDArrayHandle) arr = NDArray(handle, writa...
[ "def", "collect", "(", "self", ",", "name", ",", "arr", ")", ":", "name", "=", "py_str", "(", "name", ")", "if", "self", ".", "include_layer", "is", "not", "None", "and", "not", "self", ".", "include_layer", "(", "name", ")", ":", "return", "handle",...
Callback function for collecting min and max values from an NDArray.
[ "Callback", "function", "for", "collecting", "min", "and", "max", "values", "from", "an", "NDArray", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/quantization.py#L160-L177
train
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
encoder
def encoder(nef, z_dim, batch_size, no_bias=True, fix_gamma=True, eps=1e-5 + 1e-12): '''The encoder is a CNN which takes 32x32 image as input generates the 100 dimensional shape embedding as a sample from normal distribution using predicted meand and variance ''' BatchNorm = mx.sym.BatchNorm da...
python
def encoder(nef, z_dim, batch_size, no_bias=True, fix_gamma=True, eps=1e-5 + 1e-12): '''The encoder is a CNN which takes 32x32 image as input generates the 100 dimensional shape embedding as a sample from normal distribution using predicted meand and variance ''' BatchNorm = mx.sym.BatchNorm da...
[ "def", "encoder", "(", "nef", ",", "z_dim", ",", "batch_size", ",", "no_bias", "=", "True", ",", "fix_gamma", "=", "True", ",", "eps", "=", "1e-5", "+", "1e-12", ")", ":", "BatchNorm", "=", "mx", ".", "sym", ".", "BatchNorm", "data", "=", "mx", "."...
The encoder is a CNN which takes 32x32 image as input generates the 100 dimensional shape embedding as a sample from normal distribution using predicted meand and variance
[ "The", "encoder", "is", "a", "CNN", "which", "takes", "32x32", "image", "as", "input", "generates", "the", "100", "dimensional", "shape", "embedding", "as", "a", "sample", "from", "normal", "distribution", "using", "predicted", "meand", "and", "variance" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L54-L86
train
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
generator
def generator(ngf, nc, no_bias=True, fix_gamma=True, eps=1e-5 + 1e-12, z_dim=100, activation='sigmoid'): '''The genrator is a CNN which takes 100 dimensional embedding as input and reconstructs the input image given to the encoder ''' BatchNorm = mx.sym.BatchNorm rand = mx.sym.Variable('rand') ...
python
def generator(ngf, nc, no_bias=True, fix_gamma=True, eps=1e-5 + 1e-12, z_dim=100, activation='sigmoid'): '''The genrator is a CNN which takes 100 dimensional embedding as input and reconstructs the input image given to the encoder ''' BatchNorm = mx.sym.BatchNorm rand = mx.sym.Variable('rand') ...
[ "def", "generator", "(", "ngf", ",", "nc", ",", "no_bias", "=", "True", ",", "fix_gamma", "=", "True", ",", "eps", "=", "1e-5", "+", "1e-12", ",", "z_dim", "=", "100", ",", "activation", "=", "'sigmoid'", ")", ":", "BatchNorm", "=", "mx", ".", "sym...
The genrator is a CNN which takes 100 dimensional embedding as input and reconstructs the input image given to the encoder
[ "The", "genrator", "is", "a", "CNN", "which", "takes", "100", "dimensional", "embedding", "as", "input", "and", "reconstructs", "the", "input", "image", "given", "to", "the", "encoder" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L88-L116
train
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
discriminator1
def discriminator1(ndf, no_bias=True, fix_gamma=True, eps=1e-5 + 1e-12): '''First part of the discriminator which takes a 32x32 image as input and output a convolutional feature map, this is required to calculate the layer loss''' BatchNorm = mx.sym.BatchNorm data = mx.sym.Variable('data') d1 ...
python
def discriminator1(ndf, no_bias=True, fix_gamma=True, eps=1e-5 + 1e-12): '''First part of the discriminator which takes a 32x32 image as input and output a convolutional feature map, this is required to calculate the layer loss''' BatchNorm = mx.sym.BatchNorm data = mx.sym.Variable('data') d1 ...
[ "def", "discriminator1", "(", "ndf", ",", "no_bias", "=", "True", ",", "fix_gamma", "=", "True", ",", "eps", "=", "1e-5", "+", "1e-12", ")", ":", "BatchNorm", "=", "mx", ".", "sym", ".", "BatchNorm", "data", "=", "mx", ".", "sym", ".", "Variable", ...
First part of the discriminator which takes a 32x32 image as input and output a convolutional feature map, this is required to calculate the layer loss
[ "First", "part", "of", "the", "discriminator", "which", "takes", "a", "32x32", "image", "as", "input", "and", "output", "a", "convolutional", "feature", "map", "this", "is", "required", "to", "calculate", "the", "layer", "loss" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L118-L137
train
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
discriminator2
def discriminator2(ndf, no_bias=True, fix_gamma=True, eps=1e-5 + 1e-12): '''Second part of the discriminator which takes a 256x8x8 feature map as input and generates the loss based on whether the input image was a real one or fake one''' BatchNorm = mx.sym.BatchNorm data = mx.sym.Variable('data') ...
python
def discriminator2(ndf, no_bias=True, fix_gamma=True, eps=1e-5 + 1e-12): '''Second part of the discriminator which takes a 256x8x8 feature map as input and generates the loss based on whether the input image was a real one or fake one''' BatchNorm = mx.sym.BatchNorm data = mx.sym.Variable('data') ...
[ "def", "discriminator2", "(", "ndf", ",", "no_bias", "=", "True", ",", "fix_gamma", "=", "True", ",", "eps", "=", "1e-5", "+", "1e-12", ")", ":", "BatchNorm", "=", "mx", ".", "sym", ".", "BatchNorm", "data", "=", "mx", ".", "sym", ".", "Variable", ...
Second part of the discriminator which takes a 256x8x8 feature map as input and generates the loss based on whether the input image was a real one or fake one
[ "Second", "part", "of", "the", "discriminator", "which", "takes", "a", "256x8x8", "feature", "map", "as", "input", "and", "generates", "the", "loss", "based", "on", "whether", "the", "input", "image", "was", "a", "real", "one", "or", "fake", "one" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L139-L159
train
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
GaussianLogDensity
def GaussianLogDensity(x, mu, log_var, name='GaussianLogDensity', EPSILON = 1e-6): '''GaussianLogDensity loss calculation for layer wise loss ''' c = mx.sym.ones_like(log_var)*2.0 * 3.1416 c = mx.symbol.log(c) var = mx.sym.exp(log_var) x_mu2 = mx.symbol.square(x - mu) # [Issue] not sure the di...
python
def GaussianLogDensity(x, mu, log_var, name='GaussianLogDensity', EPSILON = 1e-6): '''GaussianLogDensity loss calculation for layer wise loss ''' c = mx.sym.ones_like(log_var)*2.0 * 3.1416 c = mx.symbol.log(c) var = mx.sym.exp(log_var) x_mu2 = mx.symbol.square(x - mu) # [Issue] not sure the di...
[ "def", "GaussianLogDensity", "(", "x", ",", "mu", ",", "log_var", ",", "name", "=", "'GaussianLogDensity'", ",", "EPSILON", "=", "1e-6", ")", ":", "c", "=", "mx", ".", "sym", ".", "ones_like", "(", "log_var", ")", "*", "2.0", "*", "3.1416", "c", "=",...
GaussianLogDensity loss calculation for layer wise loss
[ "GaussianLogDensity", "loss", "calculation", "for", "layer", "wise", "loss" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L161-L171
train
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
DiscriminatorLayerLoss
def DiscriminatorLayerLoss(): '''Calculate the discriminator layer loss ''' data = mx.sym.Variable('data') label = mx.sym.Variable('label') data = mx.sym.Flatten(data) label = mx.sym.Flatten(label) label = mx.sym.BlockGrad(label) zeros = mx.sym.zeros_like(data) output = -Gaussi...
python
def DiscriminatorLayerLoss(): '''Calculate the discriminator layer loss ''' data = mx.sym.Variable('data') label = mx.sym.Variable('label') data = mx.sym.Flatten(data) label = mx.sym.Flatten(label) label = mx.sym.BlockGrad(label) zeros = mx.sym.zeros_like(data) output = -Gaussi...
[ "def", "DiscriminatorLayerLoss", "(", ")", ":", "data", "=", "mx", ".", "sym", ".", "Variable", "(", "'data'", ")", "label", "=", "mx", ".", "sym", ".", "Variable", "(", "'label'", ")", "data", "=", "mx", ".", "sym", ".", "Flatten", "(", "data", ")...
Calculate the discriminator layer loss
[ "Calculate", "the", "discriminator", "layer", "loss" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L173-L192
train
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
KLDivergenceLoss
def KLDivergenceLoss(): '''KLDivergenceLoss loss ''' data = mx.sym.Variable('data') mu1, lv1 = mx.sym.split(data, num_outputs=2, axis=0) mu2 = mx.sym.zeros_like(mu1) lv2 = mx.sym.zeros_like(lv1) v1 = mx.sym.exp(lv1) v2 = mx.sym.exp(lv2) mu_diff_sq = mx.sym.square(mu1 - mu2) di...
python
def KLDivergenceLoss(): '''KLDivergenceLoss loss ''' data = mx.sym.Variable('data') mu1, lv1 = mx.sym.split(data, num_outputs=2, axis=0) mu2 = mx.sym.zeros_like(mu1) lv2 = mx.sym.zeros_like(lv1) v1 = mx.sym.exp(lv1) v2 = mx.sym.exp(lv2) mu_diff_sq = mx.sym.square(mu1 - mu2) di...
[ "def", "KLDivergenceLoss", "(", ")", ":", "data", "=", "mx", ".", "sym", ".", "Variable", "(", "'data'", ")", "mu1", ",", "lv1", "=", "mx", ".", "sym", ".", "split", "(", "data", ",", "num_outputs", "=", "2", ",", "axis", "=", "0", ")", "mu2", ...
KLDivergenceLoss loss
[ "KLDivergenceLoss", "loss" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L194-L211
train
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
get_data
def get_data(path, activation): '''Get the dataset ''' data = [] image_names = [] for filename in os.listdir(path): img = cv2.imread(os.path.join(path,filename), cv2.IMREAD_GRAYSCALE) image_names.append(filename) if img is not None: data.append(img) data = np...
python
def get_data(path, activation): '''Get the dataset ''' data = [] image_names = [] for filename in os.listdir(path): img = cv2.imread(os.path.join(path,filename), cv2.IMREAD_GRAYSCALE) image_names.append(filename) if img is not None: data.append(img) data = np...
[ "def", "get_data", "(", "path", ",", "activation", ")", ":", "data", "=", "[", "]", "image_names", "=", "[", "]", "for", "filename", "in", "os", ".", "listdir", "(", "path", ")", ":", "img", "=", "cv2", ".", "imread", "(", "os", ".", "path", ".",...
Get the dataset
[ "Get", "the", "dataset" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L213-L237
train
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
fill_buf
def fill_buf(buf, i, img, shape): '''fill the ith grid of the buffer matrix with the values from the img buf : buffer matrix i : serial of the image in the 2D grid img : image data shape : ( height width depth ) of image''' # grid height is a multiple of individual image height m = buf.shap...
python
def fill_buf(buf, i, img, shape): '''fill the ith grid of the buffer matrix with the values from the img buf : buffer matrix i : serial of the image in the 2D grid img : image data shape : ( height width depth ) of image''' # grid height is a multiple of individual image height m = buf.shap...
[ "def", "fill_buf", "(", "buf", ",", "i", ",", "img", ",", "shape", ")", ":", "# grid height is a multiple of individual image height", "m", "=", "buf", ".", "shape", "[", "0", "]", "/", "shape", "[", "0", "]", "sx", "=", "(", "i", "%", "m", ")", "*",...
fill the ith grid of the buffer matrix with the values from the img buf : buffer matrix i : serial of the image in the 2D grid img : image data shape : ( height width depth ) of image
[ "fill", "the", "ith", "grid", "of", "the", "buffer", "matrix", "with", "the", "values", "from", "the", "img", "buf", ":", "buffer", "matrix", "i", ":", "serial", "of", "the", "image", "in", "the", "2D", "grid", "img", ":", "image", "data", "shape", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L254-L268
train
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
visual
def visual(title, X, activation): '''create a grid of images and save it as a final image title : grid image name X : array of images ''' assert len(X.shape) == 4 X = X.transpose((0, 2, 3, 1)) if activation == 'sigmoid': X = np.clip((X)*(255.0), 0, 255).astype(np.uint8) elif act...
python
def visual(title, X, activation): '''create a grid of images and save it as a final image title : grid image name X : array of images ''' assert len(X.shape) == 4 X = X.transpose((0, 2, 3, 1)) if activation == 'sigmoid': X = np.clip((X)*(255.0), 0, 255).astype(np.uint8) elif act...
[ "def", "visual", "(", "title", ",", "X", ",", "activation", ")", ":", "assert", "len", "(", "X", ".", "shape", ")", "==", "4", "X", "=", "X", ".", "transpose", "(", "(", "0", ",", "2", ",", "3", ",", "1", ")", ")", "if", "activation", "==", ...
create a grid of images and save it as a final image title : grid image name X : array of images
[ "create", "a", "grid", "of", "images", "and", "save", "it", "as", "a", "final", "image", "title", ":", "grid", "image", "name", "X", ":", "array", "of", "images" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L270-L286
train
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
train
def train(dataset, nef, ndf, ngf, nc, batch_size, Z, lr, beta1, epsilon, ctx, check_point, g_dl_weight, output_path, checkpoint_path, data_path, activation,num_epoch, save_after_every, visualize_after_every, show_after_every): '''adversarial training of the VAE ''' #encoder z_mu, z_lv, z = encoder(nef,...
python
def train(dataset, nef, ndf, ngf, nc, batch_size, Z, lr, beta1, epsilon, ctx, check_point, g_dl_weight, output_path, checkpoint_path, data_path, activation,num_epoch, save_after_every, visualize_after_every, show_after_every): '''adversarial training of the VAE ''' #encoder z_mu, z_lv, z = encoder(nef,...
[ "def", "train", "(", "dataset", ",", "nef", ",", "ndf", ",", "ngf", ",", "nc", ",", "batch_size", ",", "Z", ",", "lr", ",", "beta1", ",", "epsilon", ",", "ctx", ",", "check_point", ",", "g_dl_weight", ",", "output_path", ",", "checkpoint_path", ",", ...
adversarial training of the VAE
[ "adversarial", "training", "of", "the", "VAE" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L288-L613
train
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
create_and_validate_dir
def create_and_validate_dir(data_dir): '''Creates/Validates dir ''' if data_dir != "": if not os.path.exists(data_dir): try: logging.info('create directory %s', data_dir) os.makedirs(data_dir) except OSError as exc: if exc.errno...
python
def create_and_validate_dir(data_dir): '''Creates/Validates dir ''' if data_dir != "": if not os.path.exists(data_dir): try: logging.info('create directory %s', data_dir) os.makedirs(data_dir) except OSError as exc: if exc.errno...
[ "def", "create_and_validate_dir", "(", "data_dir", ")", ":", "if", "data_dir", "!=", "\"\"", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "data_dir", ")", ":", "try", ":", "logging", ".", "info", "(", "'create directory %s'", ",", "data_dir", ...
Creates/Validates dir
[ "Creates", "/", "Validates", "dir" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L660-L670
train
apache/incubator-mxnet
example/vae-gan/vaegan_mxnet.py
parse_args
def parse_args(): '''Parse args ''' parser = argparse.ArgumentParser(description='Train and Test an Adversarial Variatiional Encoder') parser.add_argument('--train', help='train the network', action='store_true') parser.add_argument('--test', help='test the network', action='store_true') parser...
python
def parse_args(): '''Parse args ''' parser = argparse.ArgumentParser(description='Train and Test an Adversarial Variatiional Encoder') parser.add_argument('--train', help='train the network', action='store_true') parser.add_argument('--test', help='test the network', action='store_true') parser...
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Train and Test an Adversarial Variatiional Encoder'", ")", "parser", ".", "add_argument", "(", "'--train'", ",", "help", "=", "'train the network'", ",", ...
Parse args
[ "Parse", "args" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/vae-gan/vaegan_mxnet.py#L673-L708
train
apache/incubator-mxnet
example/gluon/house_prices/kaggle_k_fold_cross_validation.py
get_rmse_log
def get_rmse_log(net, X_train, y_train): """Gets root mse between the logarithms of the prediction and the truth.""" num_train = X_train.shape[0] clipped_preds = nd.clip(net(X_train), 1, float('inf')) return np.sqrt(2 * nd.sum(square_loss( nd.log(clipped_preds), nd.log(y_train))).asscalar() / nu...
python
def get_rmse_log(net, X_train, y_train): """Gets root mse between the logarithms of the prediction and the truth.""" num_train = X_train.shape[0] clipped_preds = nd.clip(net(X_train), 1, float('inf')) return np.sqrt(2 * nd.sum(square_loss( nd.log(clipped_preds), nd.log(y_train))).asscalar() / nu...
[ "def", "get_rmse_log", "(", "net", ",", "X_train", ",", "y_train", ")", ":", "num_train", "=", "X_train", ".", "shape", "[", "0", "]", "clipped_preds", "=", "nd", ".", "clip", "(", "net", "(", "X_train", ")", ",", "1", ",", "float", "(", "'inf'", "...
Gets root mse between the logarithms of the prediction and the truth.
[ "Gets", "root", "mse", "between", "the", "logarithms", "of", "the", "prediction", "and", "the", "truth", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/house_prices/kaggle_k_fold_cross_validation.py#L66-L71
train
apache/incubator-mxnet
example/gluon/house_prices/kaggle_k_fold_cross_validation.py
get_net
def get_net(): """Gets a neural network. Better results are obtained with modifications.""" net = gluon.nn.Sequential() with net.name_scope(): net.add(gluon.nn.Dense(50, activation="relu")) net.add(gluon.nn.Dense(1)) net.initialize() return net
python
def get_net(): """Gets a neural network. Better results are obtained with modifications.""" net = gluon.nn.Sequential() with net.name_scope(): net.add(gluon.nn.Dense(50, activation="relu")) net.add(gluon.nn.Dense(1)) net.initialize() return net
[ "def", "get_net", "(", ")", ":", "net", "=", "gluon", ".", "nn", ".", "Sequential", "(", ")", "with", "net", ".", "name_scope", "(", ")", ":", "net", ".", "add", "(", "gluon", ".", "nn", ".", "Dense", "(", "50", ",", "activation", "=", "\"relu\""...
Gets a neural network. Better results are obtained with modifications.
[ "Gets", "a", "neural", "network", ".", "Better", "results", "are", "obtained", "with", "modifications", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/house_prices/kaggle_k_fold_cross_validation.py#L73-L80
train
apache/incubator-mxnet
example/gluon/house_prices/kaggle_k_fold_cross_validation.py
train
def train(net, X_train, y_train, epochs, verbose_epoch, learning_rate, weight_decay, batch_size): """Trains the model.""" dataset_train = gluon.data.ArrayDataset(X_train, y_train) data_iter_train = gluon.data.DataLoader(dataset_train, batch_size, shuffle...
python
def train(net, X_train, y_train, epochs, verbose_epoch, learning_rate, weight_decay, batch_size): """Trains the model.""" dataset_train = gluon.data.ArrayDataset(X_train, y_train) data_iter_train = gluon.data.DataLoader(dataset_train, batch_size, shuffle...
[ "def", "train", "(", "net", ",", "X_train", ",", "y_train", ",", "epochs", ",", "verbose_epoch", ",", "learning_rate", ",", "weight_decay", ",", "batch_size", ")", ":", "dataset_train", "=", "gluon", ".", "data", ".", "ArrayDataset", "(", "X_train", ",", "...
Trains the model.
[ "Trains", "the", "model", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/house_prices/kaggle_k_fold_cross_validation.py#L82-L102
train
apache/incubator-mxnet
example/gluon/house_prices/kaggle_k_fold_cross_validation.py
k_fold_cross_valid
def k_fold_cross_valid(k, epochs, verbose_epoch, X_train, y_train, learning_rate, weight_decay, batch_size): """Conducts k-fold cross validation for the model.""" assert k > 1 fold_size = X_train.shape[0] // k train_loss_sum = 0.0 test_loss_sum = 0.0 for test_idx in range...
python
def k_fold_cross_valid(k, epochs, verbose_epoch, X_train, y_train, learning_rate, weight_decay, batch_size): """Conducts k-fold cross validation for the model.""" assert k > 1 fold_size = X_train.shape[0] // k train_loss_sum = 0.0 test_loss_sum = 0.0 for test_idx in range...
[ "def", "k_fold_cross_valid", "(", "k", ",", "epochs", ",", "verbose_epoch", ",", "X_train", ",", "y_train", ",", "learning_rate", ",", "weight_decay", ",", "batch_size", ")", ":", "assert", "k", ">", "1", "fold_size", "=", "X_train", ".", "shape", "[", "0"...
Conducts k-fold cross validation for the model.
[ "Conducts", "k", "-", "fold", "cross", "validation", "for", "the", "model", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/house_prices/kaggle_k_fold_cross_validation.py#L104-L135
train
apache/incubator-mxnet
example/gluon/house_prices/kaggle_k_fold_cross_validation.py
learn
def learn(epochs, verbose_epoch, X_train, y_train, test, learning_rate, weight_decay, batch_size): """Trains the model and predicts on the test data set.""" net = get_net() _ = train(net, X_train, y_train, epochs, verbose_epoch, learning_rate, weight_decay, batch_size) preds =...
python
def learn(epochs, verbose_epoch, X_train, y_train, test, learning_rate, weight_decay, batch_size): """Trains the model and predicts on the test data set.""" net = get_net() _ = train(net, X_train, y_train, epochs, verbose_epoch, learning_rate, weight_decay, batch_size) preds =...
[ "def", "learn", "(", "epochs", ",", "verbose_epoch", ",", "X_train", ",", "y_train", ",", "test", ",", "learning_rate", ",", "weight_decay", ",", "batch_size", ")", ":", "net", "=", "get_net", "(", ")", "_", "=", "train", "(", "net", ",", "X_train", ",...
Trains the model and predicts on the test data set.
[ "Trains", "the", "model", "and", "predicts", "on", "the", "test", "data", "set", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/house_prices/kaggle_k_fold_cross_validation.py#L152-L161
train
apache/incubator-mxnet
example/capsnet/capsulenet.py
capsnet
def capsnet(batch_size, n_class, num_routing, recon_loss_weight): """Create CapsNet""" # data.shape = [batch_size, 1, 28, 28] data = mx.sym.Variable('data') input_shape = (1, 28, 28) # Conv2D layer # net.shape = [batch_size, 256, 20, 20] conv1 = mx.sym.Convolution(data=data, ...
python
def capsnet(batch_size, n_class, num_routing, recon_loss_weight): """Create CapsNet""" # data.shape = [batch_size, 1, 28, 28] data = mx.sym.Variable('data') input_shape = (1, 28, 28) # Conv2D layer # net.shape = [batch_size, 256, 20, 20] conv1 = mx.sym.Convolution(data=data, ...
[ "def", "capsnet", "(", "batch_size", ",", "n_class", ",", "num_routing", ",", "recon_loss_weight", ")", ":", "# data.shape = [batch_size, 1, 28, 28]", "data", "=", "mx", ".", "sym", ".", "Variable", "(", "'data'", ")", "input_shape", "=", "(", "1", ",", "28", ...
Create CapsNet
[ "Create", "CapsNet" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/capsnet/capsulenet.py#L39-L100
train
apache/incubator-mxnet
example/capsnet/capsulenet.py
do_training
def do_training(num_epoch, optimizer, kvstore, learning_rate, model_prefix, decay): """Perform CapsNet training""" summary_writer = SummaryWriter(args.tblog_dir) lr_scheduler = SimpleLRScheduler(learning_rate) optimizer_params = {'lr_scheduler': lr_scheduler} module.init_params() module.init_opt...
python
def do_training(num_epoch, optimizer, kvstore, learning_rate, model_prefix, decay): """Perform CapsNet training""" summary_writer = SummaryWriter(args.tblog_dir) lr_scheduler = SimpleLRScheduler(learning_rate) optimizer_params = {'lr_scheduler': lr_scheduler} module.init_params() module.init_opt...
[ "def", "do_training", "(", "num_epoch", ",", "optimizer", ",", "kvstore", ",", "learning_rate", ",", "model_prefix", ",", "decay", ")", ":", "summary_writer", "=", "SummaryWriter", "(", "args", ".", "tblog_dir", ")", "lr_scheduler", "=", "SimpleLRScheduler", "("...
Perform CapsNet training
[ "Perform", "CapsNet", "training" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/capsnet/capsulenet.py#L195-L238
train
apache/incubator-mxnet
example/capsnet/capsulenet.py
_shuffle
def _shuffle(data, idx): """Shuffle the data.""" shuffle_data = [] for idx_k, idx_v in data: shuffle_data.append((idx_k, mx.ndarray.array(idx_v.asnumpy()[idx], idx_v.context))) return shuffle_data
python
def _shuffle(data, idx): """Shuffle the data.""" shuffle_data = [] for idx_k, idx_v in data: shuffle_data.append((idx_k, mx.ndarray.array(idx_v.asnumpy()[idx], idx_v.context))) return shuffle_data
[ "def", "_shuffle", "(", "data", ",", "idx", ")", ":", "shuffle_data", "=", "[", "]", "for", "idx_k", ",", "idx_v", "in", "data", ":", "shuffle_data", ".", "append", "(", "(", "idx_k", ",", "mx", ".", "ndarray", ".", "array", "(", "idx_v", ".", "asn...
Shuffle the data.
[ "Shuffle", "the", "data", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/capsnet/capsulenet.py#L268-L275
train
apache/incubator-mxnet
example/capsnet/capsulenet.py
LossMetric.update
def update(self, labels, preds): """Update the hyper-parameters and loss of CapsNet""" batch_sum_metric = 0 batch_num_inst = 0 for label, pred_outcaps in zip(labels[0], preds[0]): label_np = int(label.asnumpy()) pred_label = int(np.argmax(pred_outcaps.asnumpy())) ...
python
def update(self, labels, preds): """Update the hyper-parameters and loss of CapsNet""" batch_sum_metric = 0 batch_num_inst = 0 for label, pred_outcaps in zip(labels[0], preds[0]): label_np = int(label.asnumpy()) pred_label = int(np.argmax(pred_outcaps.asnumpy())) ...
[ "def", "update", "(", "self", ",", "labels", ",", "preds", ")", ":", "batch_sum_metric", "=", "0", "batch_num_inst", "=", "0", "for", "label", ",", "pred_outcaps", "in", "zip", "(", "labels", "[", "0", "]", ",", "preds", "[", "0", "]", ")", ":", "l...
Update the hyper-parameters and loss of CapsNet
[ "Update", "the", "hyper", "-", "parameters", "and", "loss", "of", "CapsNet" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/capsnet/capsulenet.py#L140-L158
train
apache/incubator-mxnet
example/capsnet/capsulenet.py
MNISTCustomIter.reset
def reset(self): """Reset class MNISTCustomIter(mx.io.NDArrayIter):""" # shuffle data if self.is_train: np.random.shuffle(self.idx) self.data = _shuffle(self.data, self.idx) self.label = _shuffle(self.label, self.idx) if self.last_batch_handle == 'rol...
python
def reset(self): """Reset class MNISTCustomIter(mx.io.NDArrayIter):""" # shuffle data if self.is_train: np.random.shuffle(self.idx) self.data = _shuffle(self.data, self.idx) self.label = _shuffle(self.label, self.idx) if self.last_batch_handle == 'rol...
[ "def", "reset", "(", "self", ")", ":", "# shuffle data", "if", "self", ".", "is_train", ":", "np", ".", "random", ".", "shuffle", "(", "self", ".", "idx", ")", "self", ".", "data", "=", "_shuffle", "(", "self", ".", "data", ",", "self", ".", "idx",...
Reset class MNISTCustomIter(mx.io.NDArrayIter):
[ "Reset", "class", "MNISTCustomIter", "(", "mx", ".", "io", ".", "NDArrayIter", ")", ":" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/capsnet/capsulenet.py#L287-L298
train
apache/incubator-mxnet
example/capsnet/capsulenet.py
MNISTCustomIter.next
def next(self): """Generate next of iterator""" if self.iter_next(): if self.is_train: data_raw_list = self.getdata() data_shifted = [] for data_raw in data_raw_list[0]: data_shifted.append(random_shift(data_raw.asnumpy(), 0...
python
def next(self): """Generate next of iterator""" if self.iter_next(): if self.is_train: data_raw_list = self.getdata() data_shifted = [] for data_raw in data_raw_list[0]: data_shifted.append(random_shift(data_raw.asnumpy(), 0...
[ "def", "next", "(", "self", ")", ":", "if", "self", ".", "iter_next", "(", ")", ":", "if", "self", ".", "is_train", ":", "data_raw_list", "=", "self", ".", "getdata", "(", ")", "data_shifted", "=", "[", "]", "for", "data_raw", "in", "data_raw_list", ...
Generate next of iterator
[ "Generate", "next", "of", "iterator" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/capsnet/capsulenet.py#L304-L318
train
apache/incubator-mxnet
python/mxnet/attribute.py
AttrScope.get
def get(self, attr): """ Get the attribute dict given the attribute set by the symbol. Parameters ---------- attr : dict of string to string The attribute passed in by user during symbol creation. Returns ------- attr : dict of string to stri...
python
def get(self, attr): """ Get the attribute dict given the attribute set by the symbol. Parameters ---------- attr : dict of string to string The attribute passed in by user during symbol creation. Returns ------- attr : dict of string to stri...
[ "def", "get", "(", "self", ",", "attr", ")", ":", "if", "self", ".", "_attr", ":", "ret", "=", "self", ".", "_attr", ".", "copy", "(", ")", "if", "attr", ":", "ret", ".", "update", "(", "attr", ")", "return", "ret", "else", ":", "return", "attr...
Get the attribute dict given the attribute set by the symbol. Parameters ---------- attr : dict of string to string The attribute passed in by user during symbol creation. Returns ------- attr : dict of string to string Updated attributes to add ...
[ "Get", "the", "attribute", "dict", "given", "the", "attribute", "set", "by", "the", "symbol", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/attribute.py#L47-L67
train
apache/incubator-mxnet
python/mxnet/model.py
_create_sparse_kvstore
def _create_sparse_kvstore(kvstore): """Create kvstore assuming some parameters' storage types are row_sparse. Parameters ---------- kvstore : KVStore or str The kvstore. Returns ------- kvstore : KVStore update_on_kvstore : bool. Always True. """ # always update on kvs...
python
def _create_sparse_kvstore(kvstore): """Create kvstore assuming some parameters' storage types are row_sparse. Parameters ---------- kvstore : KVStore or str The kvstore. Returns ------- kvstore : KVStore update_on_kvstore : bool. Always True. """ # always update on kvs...
[ "def", "_create_sparse_kvstore", "(", "kvstore", ")", ":", "# always update on kvstore", "update_on_kvstore", "=", "True", "if", "isinstance", "(", "kvstore", ",", "kvs", ".", "KVStore", ")", ":", "kv", "=", "kvstore", "elif", "isinstance", "(", "kvstore", ",", ...
Create kvstore assuming some parameters' storage types are row_sparse. Parameters ---------- kvstore : KVStore or str The kvstore. Returns ------- kvstore : KVStore update_on_kvstore : bool. Always True.
[ "Create", "kvstore", "assuming", "some", "parameters", "storage", "types", "are", "row_sparse", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L58-L80
train
apache/incubator-mxnet
python/mxnet/model.py
_create_kvstore
def _create_kvstore(kvstore, num_device, arg_params): """Create kvstore This function select and create a proper kvstore if given the kvstore type. Parameters ---------- kvstore : KVStore or str The kvstore. num_device : int The number of devices arg_params : dict of str to ...
python
def _create_kvstore(kvstore, num_device, arg_params): """Create kvstore This function select and create a proper kvstore if given the kvstore type. Parameters ---------- kvstore : KVStore or str The kvstore. num_device : int The number of devices arg_params : dict of str to ...
[ "def", "_create_kvstore", "(", "kvstore", ",", "num_device", ",", "arg_params", ")", ":", "update_on_kvstore", "=", "bool", "(", "int", "(", "os", ".", "getenv", "(", "'MXNET_UPDATE_ON_KVSTORE'", ",", "\"1\"", ")", ")", ")", "if", "kvstore", "is", "None", ...
Create kvstore This function select and create a proper kvstore if given the kvstore type. Parameters ---------- kvstore : KVStore or str The kvstore. num_device : int The number of devices arg_params : dict of str to `NDArray`. Model parameter, dict of name to `NDArray`...
[ "Create", "kvstore", "This", "function", "select", "and", "create", "a", "proper", "kvstore", "if", "given", "the", "kvstore", "type", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L82-L119
train
apache/incubator-mxnet
python/mxnet/model.py
_initialize_kvstore
def _initialize_kvstore(kvstore, param_arrays, arg_params, param_names, update_on_kvstore): """Initialize kvstore""" for idx, param_on_devs in enumerate(param_arrays): name = param_names[idx] kvstore.init(name, arg_params[name]) if update_on_kvstore: kvstore.pull(name, param...
python
def _initialize_kvstore(kvstore, param_arrays, arg_params, param_names, update_on_kvstore): """Initialize kvstore""" for idx, param_on_devs in enumerate(param_arrays): name = param_names[idx] kvstore.init(name, arg_params[name]) if update_on_kvstore: kvstore.pull(name, param...
[ "def", "_initialize_kvstore", "(", "kvstore", ",", "param_arrays", ",", "arg_params", ",", "param_names", ",", "update_on_kvstore", ")", ":", "for", "idx", ",", "param_on_devs", "in", "enumerate", "(", "param_arrays", ")", ":", "name", "=", "param_names", "[", ...
Initialize kvstore
[ "Initialize", "kvstore" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L121-L128
train
apache/incubator-mxnet
python/mxnet/model.py
_update_params_on_kvstore_nccl
def _update_params_on_kvstore_nccl(param_arrays, grad_arrays, kvstore, param_names): """Perform update of param_arrays from grad_arrays on NCCL kvstore.""" valid_indices = [index for index, grad_list in enumerate(grad_arrays) if grad_list[0] is not None] valid_grad_arrays = [grad_arrays...
python
def _update_params_on_kvstore_nccl(param_arrays, grad_arrays, kvstore, param_names): """Perform update of param_arrays from grad_arrays on NCCL kvstore.""" valid_indices = [index for index, grad_list in enumerate(grad_arrays) if grad_list[0] is not None] valid_grad_arrays = [grad_arrays...
[ "def", "_update_params_on_kvstore_nccl", "(", "param_arrays", ",", "grad_arrays", ",", "kvstore", ",", "param_names", ")", ":", "valid_indices", "=", "[", "index", "for", "index", ",", "grad_list", "in", "enumerate", "(", "grad_arrays", ")", "if", "grad_list", "...
Perform update of param_arrays from grad_arrays on NCCL kvstore.
[ "Perform", "update", "of", "param_arrays", "from", "grad_arrays", "on", "NCCL", "kvstore", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L130-L148
train
apache/incubator-mxnet
python/mxnet/model.py
_update_params_on_kvstore
def _update_params_on_kvstore(param_arrays, grad_arrays, kvstore, param_names): """Perform update of param_arrays from grad_arrays on kvstore.""" for index, pair in enumerate(zip(param_arrays, grad_arrays)): arg_list, grad_list = pair if grad_list[0] is None: continue name = ...
python
def _update_params_on_kvstore(param_arrays, grad_arrays, kvstore, param_names): """Perform update of param_arrays from grad_arrays on kvstore.""" for index, pair in enumerate(zip(param_arrays, grad_arrays)): arg_list, grad_list = pair if grad_list[0] is None: continue name = ...
[ "def", "_update_params_on_kvstore", "(", "param_arrays", ",", "grad_arrays", ",", "kvstore", ",", "param_names", ")", ":", "for", "index", ",", "pair", "in", "enumerate", "(", "zip", "(", "param_arrays", ",", "grad_arrays", ")", ")", ":", "arg_list", ",", "g...
Perform update of param_arrays from grad_arrays on kvstore.
[ "Perform", "update", "of", "param_arrays", "from", "grad_arrays", "on", "kvstore", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L150-L160
train
apache/incubator-mxnet
python/mxnet/model.py
_update_params
def _update_params(param_arrays, grad_arrays, updater, num_device, kvstore=None, param_names=None): """Perform update of param_arrays from grad_arrays not on kvstore.""" updates = [[] for _ in range(num_device)] for i, pair in enumerate(zip(param_arrays, grad_arrays)): arg_list, g...
python
def _update_params(param_arrays, grad_arrays, updater, num_device, kvstore=None, param_names=None): """Perform update of param_arrays from grad_arrays not on kvstore.""" updates = [[] for _ in range(num_device)] for i, pair in enumerate(zip(param_arrays, grad_arrays)): arg_list, g...
[ "def", "_update_params", "(", "param_arrays", ",", "grad_arrays", ",", "updater", ",", "num_device", ",", "kvstore", "=", "None", ",", "param_names", "=", "None", ")", ":", "updates", "=", "[", "[", "]", "for", "_", "in", "range", "(", "num_device", ")",...
Perform update of param_arrays from grad_arrays not on kvstore.
[ "Perform", "update", "of", "param_arrays", "from", "grad_arrays", "not", "on", "kvstore", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L162-L187
train
apache/incubator-mxnet
python/mxnet/model.py
_multiple_callbacks
def _multiple_callbacks(callbacks, *args, **kwargs): """Sends args and kwargs to any configured callbacks. This handles the cases where the 'callbacks' variable is ``None``, a single function, or a list. """ if isinstance(callbacks, list): for cb in callbacks: cb(*args, **kwargs)...
python
def _multiple_callbacks(callbacks, *args, **kwargs): """Sends args and kwargs to any configured callbacks. This handles the cases where the 'callbacks' variable is ``None``, a single function, or a list. """ if isinstance(callbacks, list): for cb in callbacks: cb(*args, **kwargs)...
[ "def", "_multiple_callbacks", "(", "callbacks", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "callbacks", ",", "list", ")", ":", "for", "cb", "in", "callbacks", ":", "cb", "(", "*", "args", ",", "*", "*", "kwargs", ...
Sends args and kwargs to any configured callbacks. This handles the cases where the 'callbacks' variable is ``None``, a single function, or a list.
[ "Sends", "args", "and", "kwargs", "to", "any", "configured", "callbacks", ".", "This", "handles", "the", "cases", "where", "the", "callbacks", "variable", "is", "None", "a", "single", "function", "or", "a", "list", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L190-L200
train
apache/incubator-mxnet
python/mxnet/model.py
_train_multi_device
def _train_multi_device(symbol, ctx, arg_names, param_names, aux_names, arg_params, aux_params, begin_epoch, end_epoch, epoch_size, optimizer, kvstore, update_on_kvstore, train_data, eval_data=None, eval_metric=None, ...
python
def _train_multi_device(symbol, ctx, arg_names, param_names, aux_names, arg_params, aux_params, begin_epoch, end_epoch, epoch_size, optimizer, kvstore, update_on_kvstore, train_data, eval_data=None, eval_metric=None, ...
[ "def", "_train_multi_device", "(", "symbol", ",", "ctx", ",", "arg_names", ",", "param_names", ",", "aux_names", ",", "arg_params", ",", "aux_params", ",", "begin_epoch", ",", "end_epoch", ",", "epoch_size", ",", "optimizer", ",", "kvstore", ",", "update_on_kvst...
Internal training function on multiple devices. This function will also work for single device as well. Parameters ---------- symbol : Symbol The network configuration. ctx : list of Context The training devices. arg_names: list of str Name of all arguments of the networ...
[ "Internal", "training", "function", "on", "multiple", "devices", ".", "This", "function", "will", "also", "work", "for", "single", "device", "as", "well", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L203-L390
train
apache/incubator-mxnet
python/mxnet/model.py
save_checkpoint
def save_checkpoint(prefix, epoch, symbol, arg_params, aux_params): """Checkpoint the model data into file. Parameters ---------- prefix : str Prefix of model name. epoch : int The epoch number of the model. symbol : Symbol The input Symbol. arg_params : dict of str ...
python
def save_checkpoint(prefix, epoch, symbol, arg_params, aux_params): """Checkpoint the model data into file. Parameters ---------- prefix : str Prefix of model name. epoch : int The epoch number of the model. symbol : Symbol The input Symbol. arg_params : dict of str ...
[ "def", "save_checkpoint", "(", "prefix", ",", "epoch", ",", "symbol", ",", "arg_params", ",", "aux_params", ")", ":", "if", "symbol", "is", "not", "None", ":", "symbol", ".", "save", "(", "'%s-symbol.json'", "%", "prefix", ")", "save_dict", "=", "{", "("...
Checkpoint the model data into file. Parameters ---------- prefix : str Prefix of model name. epoch : int The epoch number of the model. symbol : Symbol The input Symbol. arg_params : dict of str to NDArray Model parameter, dict of name to NDArray of net's weight...
[ "Checkpoint", "the", "model", "data", "into", "file", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L394-L421
train
apache/incubator-mxnet
python/mxnet/model.py
load_checkpoint
def load_checkpoint(prefix, epoch): """Load model checkpoint from file. Parameters ---------- prefix : str Prefix of model name. epoch : int Epoch number of model we would like to load. Returns ------- symbol : Symbol The symbol configuration of computation netw...
python
def load_checkpoint(prefix, epoch): """Load model checkpoint from file. Parameters ---------- prefix : str Prefix of model name. epoch : int Epoch number of model we would like to load. Returns ------- symbol : Symbol The symbol configuration of computation netw...
[ "def", "load_checkpoint", "(", "prefix", ",", "epoch", ")", ":", "symbol", "=", "sym", ".", "load", "(", "'%s-symbol.json'", "%", "prefix", ")", "save_dict", "=", "nd", ".", "load", "(", "'%s-%04d.params'", "%", "(", "prefix", ",", "epoch", ")", ")", "...
Load model checkpoint from file. Parameters ---------- prefix : str Prefix of model name. epoch : int Epoch number of model we would like to load. Returns ------- symbol : Symbol The symbol configuration of computation network. arg_params : dict of str to NDArra...
[ "Load", "model", "checkpoint", "from", "file", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L424-L458
train
apache/incubator-mxnet
python/mxnet/model.py
FeedForward._check_arguments
def _check_arguments(self): """verify the argument of the default symbol and user provided parameters""" if self.argument_checked: return assert(self.symbol is not None) self.argument_checked = True # check if symbol contain duplicated names. _check_argument...
python
def _check_arguments(self): """verify the argument of the default symbol and user provided parameters""" if self.argument_checked: return assert(self.symbol is not None) self.argument_checked = True # check if symbol contain duplicated names. _check_argument...
[ "def", "_check_arguments", "(", "self", ")", ":", "if", "self", ".", "argument_checked", ":", "return", "assert", "(", "self", ".", "symbol", "is", "not", "None", ")", "self", ".", "argument_checked", "=", "True", "# check if symbol contain duplicated names.", "...
verify the argument of the default symbol and user provided parameters
[ "verify", "the", "argument", "of", "the", "default", "symbol", "and", "user", "provided", "parameters" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L546-L565
train
apache/incubator-mxnet
python/mxnet/model.py
FeedForward._init_params
def _init_params(self, inputs, overwrite=False): """Initialize weight parameters and auxiliary states.""" inputs = [x if isinstance(x, DataDesc) else DataDesc(*x) for x in inputs] input_shapes = {item.name: item.shape for item in inputs} arg_shapes, _, aux_shapes = self.symbol.infer_shap...
python
def _init_params(self, inputs, overwrite=False): """Initialize weight parameters and auxiliary states.""" inputs = [x if isinstance(x, DataDesc) else DataDesc(*x) for x in inputs] input_shapes = {item.name: item.shape for item in inputs} arg_shapes, _, aux_shapes = self.symbol.infer_shap...
[ "def", "_init_params", "(", "self", ",", "inputs", ",", "overwrite", "=", "False", ")", ":", "inputs", "=", "[", "x", "if", "isinstance", "(", "x", ",", "DataDesc", ")", "else", "DataDesc", "(", "*", "x", ")", "for", "x", "in", "inputs", "]", "inpu...
Initialize weight parameters and auxiliary states.
[ "Initialize", "weight", "parameters", "and", "auxiliary", "states", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L573-L611
train
apache/incubator-mxnet
python/mxnet/model.py
FeedForward._init_predictor
def _init_predictor(self, input_shapes, type_dict=None): """Initialize the predictor module for running prediction.""" shapes = {name: self.arg_params[name].shape for name in self.arg_params} shapes.update(dict(input_shapes)) if self._pred_exec is not None: arg_shapes, _, _ =...
python
def _init_predictor(self, input_shapes, type_dict=None): """Initialize the predictor module for running prediction.""" shapes = {name: self.arg_params[name].shape for name in self.arg_params} shapes.update(dict(input_shapes)) if self._pred_exec is not None: arg_shapes, _, _ =...
[ "def", "_init_predictor", "(", "self", ",", "input_shapes", ",", "type_dict", "=", "None", ")", ":", "shapes", "=", "{", "name", ":", "self", ".", "arg_params", "[", "name", "]", ".", "shape", "for", "name", "in", "self", ".", "arg_params", "}", "shape...
Initialize the predictor module for running prediction.
[ "Initialize", "the", "predictor", "module", "for", "running", "prediction", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L621-L637
train
apache/incubator-mxnet
python/mxnet/model.py
FeedForward._init_iter
def _init_iter(self, X, y, is_train): """Initialize the iterator given input.""" if isinstance(X, (np.ndarray, nd.NDArray)): if y is None: if is_train: raise ValueError('y must be specified when X is numpy.ndarray') else: ...
python
def _init_iter(self, X, y, is_train): """Initialize the iterator given input.""" if isinstance(X, (np.ndarray, nd.NDArray)): if y is None: if is_train: raise ValueError('y must be specified when X is numpy.ndarray') else: ...
[ "def", "_init_iter", "(", "self", ",", "X", ",", "y", ",", "is_train", ")", ":", "if", "isinstance", "(", "X", ",", "(", "np", ".", "ndarray", ",", "nd", ".", "NDArray", ")", ")", ":", "if", "y", "is", "None", ":", "if", "is_train", ":", "raise...
Initialize the iterator given input.
[ "Initialize", "the", "iterator", "given", "input", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L639-L662
train
apache/incubator-mxnet
python/mxnet/model.py
FeedForward._init_eval_iter
def _init_eval_iter(self, eval_data): """Initialize the iterator given eval_data.""" if eval_data is None: return eval_data if isinstance(eval_data, (tuple, list)) and len(eval_data) == 2: if eval_data[0] is not None: if eval_data[1] is None and isinstance...
python
def _init_eval_iter(self, eval_data): """Initialize the iterator given eval_data.""" if eval_data is None: return eval_data if isinstance(eval_data, (tuple, list)) and len(eval_data) == 2: if eval_data[0] is not None: if eval_data[1] is None and isinstance...
[ "def", "_init_eval_iter", "(", "self", ",", "eval_data", ")", ":", "if", "eval_data", "is", "None", ":", "return", "eval_data", "if", "isinstance", "(", "eval_data", ",", "(", "tuple", ",", "list", ")", ")", "and", "len", "(", "eval_data", ")", "==", "...
Initialize the iterator given eval_data.
[ "Initialize", "the", "iterator", "given", "eval_data", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L664-L682
train
apache/incubator-mxnet
python/mxnet/model.py
FeedForward.predict
def predict(self, X, num_batch=None, return_data=False, reset=True): """Run the prediction, always only use one device. Parameters ---------- X : mxnet.DataIter num_batch : int or None The number of batch to run. Go though all batches if ``None``. Returns ...
python
def predict(self, X, num_batch=None, return_data=False, reset=True): """Run the prediction, always only use one device. Parameters ---------- X : mxnet.DataIter num_batch : int or None The number of batch to run. Go though all batches if ``None``. Returns ...
[ "def", "predict", "(", "self", ",", "X", ",", "num_batch", "=", "None", ",", "return_data", "=", "False", ",", "reset", "=", "True", ")", ":", "X", "=", "self", ".", "_init_iter", "(", "X", ",", "None", ",", "is_train", "=", "False", ")", "if", "...
Run the prediction, always only use one device. Parameters ---------- X : mxnet.DataIter num_batch : int or None The number of batch to run. Go though all batches if ``None``. Returns ------- y : numpy.ndarray or a list of numpy.ndarray if the network...
[ "Run", "the", "prediction", "always", "only", "use", "one", "device", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L684-L751
train
apache/incubator-mxnet
python/mxnet/model.py
FeedForward.score
def score(self, X, eval_metric='acc', num_batch=None, batch_end_callback=None, reset=True): """Run the model given an input and calculate the score as assessed by an evaluation metric. Parameters ---------- X : mxnet.DataIter eval_metric : metric.metric The m...
python
def score(self, X, eval_metric='acc', num_batch=None, batch_end_callback=None, reset=True): """Run the model given an input and calculate the score as assessed by an evaluation metric. Parameters ---------- X : mxnet.DataIter eval_metric : metric.metric The m...
[ "def", "score", "(", "self", ",", "X", ",", "eval_metric", "=", "'acc'", ",", "num_batch", "=", "None", ",", "batch_end_callback", "=", "None", ",", "reset", "=", "True", ")", ":", "# setup metric", "if", "not", "isinstance", "(", "eval_metric", ",", "me...
Run the model given an input and calculate the score as assessed by an evaluation metric. Parameters ---------- X : mxnet.DataIter eval_metric : metric.metric The metric for calculating score. num_batch : int or None The number of batches to run. ...
[ "Run", "the", "model", "given", "an", "input", "and", "calculate", "the", "score", "as", "assessed", "by", "an", "evaluation", "metric", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L753-L802
train
apache/incubator-mxnet
python/mxnet/model.py
FeedForward.fit
def fit(self, X, y=None, eval_data=None, eval_metric='acc', epoch_end_callback=None, batch_end_callback=None, kvstore='local', logger=None, work_load_list=None, monitor=None, eval_end_callback=LogValidationMetricsCallback(), eval_batch_end_callback=None): """Fit the model. ...
python
def fit(self, X, y=None, eval_data=None, eval_metric='acc', epoch_end_callback=None, batch_end_callback=None, kvstore='local', logger=None, work_load_list=None, monitor=None, eval_end_callback=LogValidationMetricsCallback(), eval_batch_end_callback=None): """Fit the model. ...
[ "def", "fit", "(", "self", ",", "X", ",", "y", "=", "None", ",", "eval_data", "=", "None", ",", "eval_metric", "=", "'acc'", ",", "epoch_end_callback", "=", "None", ",", "batch_end_callback", "=", "None", ",", "kvstore", "=", "'local'", ",", "logger", ...
Fit the model. Parameters ---------- X : DataIter, or numpy.ndarray/NDArray Training data. If `X` is a `DataIter`, the name or (if name not available) the position of its outputs should match the corresponding variable names defined in the symbolic graph. ...
[ "Fit", "the", "model", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L804-L905
train
apache/incubator-mxnet
python/mxnet/model.py
FeedForward.save
def save(self, prefix, epoch=None): """Checkpoint the model checkpoint into file. You can also use `pickle` to do the job if you only work on Python. The advantage of `load` and `save` (as compared to `pickle`) is that the resulting file can be loaded from other MXNet language bindings. ...
python
def save(self, prefix, epoch=None): """Checkpoint the model checkpoint into file. You can also use `pickle` to do the job if you only work on Python. The advantage of `load` and `save` (as compared to `pickle`) is that the resulting file can be loaded from other MXNet language bindings. ...
[ "def", "save", "(", "self", ",", "prefix", ",", "epoch", "=", "None", ")", ":", "if", "epoch", "is", "None", ":", "epoch", "=", "self", ".", "num_epoch", "assert", "epoch", "is", "not", "None", "save_checkpoint", "(", "prefix", ",", "epoch", ",", "se...
Checkpoint the model checkpoint into file. You can also use `pickle` to do the job if you only work on Python. The advantage of `load` and `save` (as compared to `pickle`) is that the resulting file can be loaded from other MXNet language bindings. One can also directly `load`/`save` fro...
[ "Checkpoint", "the", "model", "checkpoint", "into", "file", ".", "You", "can", "also", "use", "pickle", "to", "do", "the", "job", "if", "you", "only", "work", "on", "Python", ".", "The", "advantage", "of", "load", "and", "save", "(", "as", "compared", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L908-L928
train
apache/incubator-mxnet
python/mxnet/model.py
FeedForward.load
def load(prefix, epoch, ctx=None, **kwargs): """Load model checkpoint from file. Parameters ---------- prefix : str Prefix of model name. epoch : int epoch number of model we would like to load. ctx : Context or list of Context, optional ...
python
def load(prefix, epoch, ctx=None, **kwargs): """Load model checkpoint from file. Parameters ---------- prefix : str Prefix of model name. epoch : int epoch number of model we would like to load. ctx : Context or list of Context, optional ...
[ "def", "load", "(", "prefix", ",", "epoch", ",", "ctx", "=", "None", ",", "*", "*", "kwargs", ")", ":", "symbol", ",", "arg_params", ",", "aux_params", "=", "load_checkpoint", "(", "prefix", ",", "epoch", ")", "return", "FeedForward", "(", "symbol", ",...
Load model checkpoint from file. Parameters ---------- prefix : str Prefix of model name. epoch : int epoch number of model we would like to load. ctx : Context or list of Context, optional The device context of training and prediction. ...
[ "Load", "model", "checkpoint", "from", "file", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L931-L959
train
apache/incubator-mxnet
python/mxnet/model.py
FeedForward.create
def create(symbol, X, y=None, ctx=None, num_epoch=None, epoch_size=None, optimizer='sgd', initializer=Uniform(0.01), eval_data=None, eval_metric='acc', epoch_end_callback=None, batch_end_callback=None, kvstore='local', logger=None, work_load_list=None, ...
python
def create(symbol, X, y=None, ctx=None, num_epoch=None, epoch_size=None, optimizer='sgd', initializer=Uniform(0.01), eval_data=None, eval_metric='acc', epoch_end_callback=None, batch_end_callback=None, kvstore='local', logger=None, work_load_list=None, ...
[ "def", "create", "(", "symbol", ",", "X", ",", "y", "=", "None", ",", "ctx", "=", "None", ",", "num_epoch", "=", "None", ",", "epoch_size", "=", "None", ",", "optimizer", "=", "'sgd'", ",", "initializer", "=", "Uniform", "(", "0.01", ")", ",", "eva...
Functional style to create a model. This function is more consistent with functional languages such as R, where mutation is not allowed. Parameters ---------- symbol : Symbol The symbol configuration of a computation network. X : DataIter Training...
[ "Functional", "style", "to", "create", "a", "model", ".", "This", "function", "is", "more", "consistent", "with", "functional", "languages", "such", "as", "R", "where", "mutation", "is", "not", "allowed", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/model.py#L962-L1025
train
apache/incubator-mxnet
ci/docker_cache.py
build_save_containers
def build_save_containers(platforms, registry, load_cache) -> int: """ Entry point to build and upload all built dockerimages in parallel :param platforms: List of platforms :param registry: Docker registry name :param load_cache: Load cache before building :return: 1 if error occurred, 0 otherw...
python
def build_save_containers(platforms, registry, load_cache) -> int: """ Entry point to build and upload all built dockerimages in parallel :param platforms: List of platforms :param registry: Docker registry name :param load_cache: Load cache before building :return: 1 if error occurred, 0 otherw...
[ "def", "build_save_containers", "(", "platforms", ",", "registry", ",", "load_cache", ")", "->", "int", ":", "from", "joblib", "import", "Parallel", ",", "delayed", "if", "len", "(", "platforms", ")", "==", "0", ":", "return", "0", "platform_results", "=", ...
Entry point to build and upload all built dockerimages in parallel :param platforms: List of platforms :param registry: Docker registry name :param load_cache: Load cache before building :return: 1 if error occurred, 0 otherwise
[ "Entry", "point", "to", "build", "and", "upload", "all", "built", "dockerimages", "in", "parallel", ":", "param", "platforms", ":", "List", "of", "platforms", ":", "param", "registry", ":", "Docker", "registry", "name", ":", "param", "load_cache", ":", "Load...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/docker_cache.py#L44-L66
train
apache/incubator-mxnet
ci/docker_cache.py
_build_save_container
def _build_save_container(platform, registry, load_cache) -> Optional[str]: """ Build image for passed platform and upload the cache to the specified S3 bucket :param platform: Platform :param registry: Docker registry name :param load_cache: Load cache before building :return: Platform if faile...
python
def _build_save_container(platform, registry, load_cache) -> Optional[str]: """ Build image for passed platform and upload the cache to the specified S3 bucket :param platform: Platform :param registry: Docker registry name :param load_cache: Load cache before building :return: Platform if faile...
[ "def", "_build_save_container", "(", "platform", ",", "registry", ",", "load_cache", ")", "->", "Optional", "[", "str", "]", ":", "docker_tag", "=", "build_util", ".", "get_docker_tag", "(", "platform", "=", "platform", ",", "registry", "=", "registry", ")", ...
Build image for passed platform and upload the cache to the specified S3 bucket :param platform: Platform :param registry: Docker registry name :param load_cache: Load cache before building :return: Platform if failed, None otherwise
[ "Build", "image", "for", "passed", "platform", "and", "upload", "the", "cache", "to", "the", "specified", "S3", "bucket", ":", "param", "platform", ":", "Platform", ":", "param", "registry", ":", "Docker", "registry", "name", ":", "param", "load_cache", ":",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/docker_cache.py#L69-L95
train
apache/incubator-mxnet
ci/docker_cache.py
_upload_image
def _upload_image(registry, docker_tag, image_id) -> None: """ Upload the passed image by id, tag it with docker tag and upload to S3 bucket :param registry: Docker registry name :param docker_tag: Docker tag :param image_id: Image id :return: None """ # We don't have to retag the image ...
python
def _upload_image(registry, docker_tag, image_id) -> None: """ Upload the passed image by id, tag it with docker tag and upload to S3 bucket :param registry: Docker registry name :param docker_tag: Docker tag :param image_id: Image id :return: None """ # We don't have to retag the image ...
[ "def", "_upload_image", "(", "registry", ",", "docker_tag", ",", "image_id", ")", "->", "None", ":", "# We don't have to retag the image since it is already in the right format", "logging", ".", "info", "(", "'Uploading %s (%s) to %s'", ",", "docker_tag", ",", "image_id", ...
Upload the passed image by id, tag it with docker tag and upload to S3 bucket :param registry: Docker registry name :param docker_tag: Docker tag :param image_id: Image id :return: None
[ "Upload", "the", "passed", "image", "by", "id", "tag", "it", "with", "docker", "tag", "and", "upload", "to", "S3", "bucket", ":", "param", "registry", ":", "Docker", "registry", "name", ":", "param", "docker_tag", ":", "Docker", "tag", ":", "param", "ima...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/docker_cache.py#L100-L111
train
apache/incubator-mxnet
ci/docker_cache.py
_login_dockerhub
def _login_dockerhub(): """ Login to the Docker Hub account :return: None """ dockerhub_credentials = _get_dockerhub_credentials() logging.info('Logging in to DockerHub') # We use password-stdin instead of --password to avoid leaking passwords in case of an error. # This method will pro...
python
def _login_dockerhub(): """ Login to the Docker Hub account :return: None """ dockerhub_credentials = _get_dockerhub_credentials() logging.info('Logging in to DockerHub') # We use password-stdin instead of --password to avoid leaking passwords in case of an error. # This method will pro...
[ "def", "_login_dockerhub", "(", ")", ":", "dockerhub_credentials", "=", "_get_dockerhub_credentials", "(", ")", "logging", ".", "info", "(", "'Logging in to DockerHub'", ")", "# We use password-stdin instead of --password to avoid leaking passwords in case of an error.", "# This me...
Login to the Docker Hub account :return: None
[ "Login", "to", "the", "Docker", "Hub", "account", ":", "return", ":", "None" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/docker_cache.py#L116-L134
train
apache/incubator-mxnet
ci/docker_cache.py
load_docker_cache
def load_docker_cache(registry, docker_tag) -> None: """ Load the precompiled docker cache from the registry :param registry: Docker registry name :param docker_tag: Docker tag to load :return: None """ # We don't have to retag the image since it's already in the right format if not regi...
python
def load_docker_cache(registry, docker_tag) -> None: """ Load the precompiled docker cache from the registry :param registry: Docker registry name :param docker_tag: Docker tag to load :return: None """ # We don't have to retag the image since it's already in the right format if not regi...
[ "def", "load_docker_cache", "(", "registry", ",", "docker_tag", ")", "->", "None", ":", "# We don't have to retag the image since it's already in the right format", "if", "not", "registry", ":", "return", "assert", "docker_tag", "logging", ".", "info", "(", "'Loading Dock...
Load the precompiled docker cache from the registry :param registry: Docker registry name :param docker_tag: Docker tag to load :return: None
[ "Load", "the", "precompiled", "docker", "cache", "from", "the", "registry", ":", "param", "registry", ":", "Docker", "registry", "name", ":", "param", "docker_tag", ":", "Docker", "tag", "to", "load", ":", "return", ":", "None" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/docker_cache.py#L149-L166
train
apache/incubator-mxnet
ci/docker_cache.py
delete_local_docker_cache
def delete_local_docker_cache(docker_tag): """ Delete the local docker cache for the entire docker image chain :param docker_tag: Docker tag :return: None """ history_cmd = ['docker', 'history', '-q', docker_tag] try: image_ids_b = subprocess.check_output(history_cmd) image_...
python
def delete_local_docker_cache(docker_tag): """ Delete the local docker cache for the entire docker image chain :param docker_tag: Docker tag :return: None """ history_cmd = ['docker', 'history', '-q', docker_tag] try: image_ids_b = subprocess.check_output(history_cmd) image_...
[ "def", "delete_local_docker_cache", "(", "docker_tag", ")", ":", "history_cmd", "=", "[", "'docker'", ",", "'history'", ",", "'-q'", ",", "docker_tag", "]", "try", ":", "image_ids_b", "=", "subprocess", ".", "check_output", "(", "history_cmd", ")", "image_ids_st...
Delete the local docker cache for the entire docker image chain :param docker_tag: Docker tag :return: None
[ "Delete", "the", "local", "docker", "cache", "for", "the", "entire", "docker", "image", "chain", ":", "param", "docker_tag", ":", "Docker", "tag", ":", "return", ":", "None" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/docker_cache.py#L169-L187
train
apache/incubator-mxnet
ci/docker_cache.py
main
def main() -> int: """ Utility to create and publish the Docker cache to Docker Hub :return: """ # We need to be in the same directory than the script so the commands in the dockerfiles work as # expected. But the script can be invoked from a different path base = os.path.split(os.path.realp...
python
def main() -> int: """ Utility to create and publish the Docker cache to Docker Hub :return: """ # We need to be in the same directory than the script so the commands in the dockerfiles work as # expected. But the script can be invoked from a different path base = os.path.split(os.path.realp...
[ "def", "main", "(", ")", "->", "int", ":", "# We need to be in the same directory than the script so the commands in the dockerfiles work as", "# expected. But the script can be invoked from a different path", "base", "=", "os", ".", "path", ".", "split", "(", "os", ".", "path"...
Utility to create and publish the Docker cache to Docker Hub :return:
[ "Utility", "to", "create", "and", "publish", "the", "Docker", "cache", "to", "Docker", "Hub", ":", "return", ":" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/docker_cache.py#L221-L255
train
apache/incubator-mxnet
example/cnn_chinese_text_classification/data_helpers.py
get_chinese_text
def get_chinese_text(): """Download the chinese_text dataset and unzip it""" if not os.path.isdir("data/"): os.system("mkdir data/") if (not os.path.exists('data/pos.txt')) or \ (not os.path.exists('data/neg')): os.system("wget -q https://raw.githubusercontent.com/dmlc/web-data/master...
python
def get_chinese_text(): """Download the chinese_text dataset and unzip it""" if not os.path.isdir("data/"): os.system("mkdir data/") if (not os.path.exists('data/pos.txt')) or \ (not os.path.exists('data/neg')): os.system("wget -q https://raw.githubusercontent.com/dmlc/web-data/master...
[ "def", "get_chinese_text", "(", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "\"data/\"", ")", ":", "os", ".", "system", "(", "\"mkdir data/\"", ")", "if", "(", "not", "os", ".", "path", ".", "exists", "(", "'data/pos.txt'", ")", ")",...
Download the chinese_text dataset and unzip it
[ "Download", "the", "chinese_text", "dataset", "and", "unzip", "it" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_chinese_text_classification/data_helpers.py#L51-L61
train
apache/incubator-mxnet
example/cnn_chinese_text_classification/data_helpers.py
load_data_and_labels
def load_data_and_labels(): """Loads MR polarity data from files, splits the data into words and generates labels. Returns split sentences and labels. """ # download dataset get_chinese_text() # Load data from files positive_examples = list(codecs.open("./data/pos.txt", "r", "utf-8").readli...
python
def load_data_and_labels(): """Loads MR polarity data from files, splits the data into words and generates labels. Returns split sentences and labels. """ # download dataset get_chinese_text() # Load data from files positive_examples = list(codecs.open("./data/pos.txt", "r", "utf-8").readli...
[ "def", "load_data_and_labels", "(", ")", ":", "# download dataset", "get_chinese_text", "(", ")", "# Load data from files", "positive_examples", "=", "list", "(", "codecs", ".", "open", "(", "\"./data/pos.txt\"", ",", "\"r\"", ",", "\"utf-8\"", ")", ".", "readlines"...
Loads MR polarity data from files, splits the data into words and generates labels. Returns split sentences and labels.
[ "Loads", "MR", "polarity", "data", "from", "files", "splits", "the", "data", "into", "words", "and", "generates", "labels", ".", "Returns", "split", "sentences", "and", "labels", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_chinese_text_classification/data_helpers.py#L64-L87
train
apache/incubator-mxnet
example/ssd/train/metric.py
MultiBoxMetric.reset
def reset(self): """ override reset behavior """ if getattr(self, 'num', None) is None: self.num_inst = 0 self.sum_metric = 0.0 else: self.num_inst = [0] * self.num self.sum_metric = [0.0] * self.num
python
def reset(self): """ override reset behavior """ if getattr(self, 'num', None) is None: self.num_inst = 0 self.sum_metric = 0.0 else: self.num_inst = [0] * self.num self.sum_metric = [0.0] * self.num
[ "def", "reset", "(", "self", ")", ":", "if", "getattr", "(", "self", ",", "'num'", ",", "None", ")", "is", "None", ":", "self", ".", "num_inst", "=", "0", "self", ".", "sum_metric", "=", "0.0", "else", ":", "self", ".", "num_inst", "=", "[", "0",...
override reset behavior
[ "override", "reset", "behavior" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/train/metric.py#L31-L40
train
apache/incubator-mxnet
example/ssd/train/metric.py
MultiBoxMetric.reset_local
def reset_local(self): """ override reset behavior """ if getattr(self, 'num', None) is None: self.num_inst = 0 self.sum_metric = 0.0 else: self.num_inst = [0] * self.num self.sum_metric = [0.0] * self.num
python
def reset_local(self): """ override reset behavior """ if getattr(self, 'num', None) is None: self.num_inst = 0 self.sum_metric = 0.0 else: self.num_inst = [0] * self.num self.sum_metric = [0.0] * self.num
[ "def", "reset_local", "(", "self", ")", ":", "if", "getattr", "(", "self", ",", "'num'", ",", "None", ")", "is", "None", ":", "self", ".", "num_inst", "=", "0", "self", ".", "sum_metric", "=", "0.0", "else", ":", "self", ".", "num_inst", "=", "[", ...
override reset behavior
[ "override", "reset", "behavior" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/train/metric.py#L42-L51
train
apache/incubator-mxnet
example/ssd/train/metric.py
MultiBoxMetric.update
def update(self, labels, preds): """ Implementation of updating metrics """ # get generated multi label from network cls_prob = preds[0].asnumpy() loc_loss = preds[1].asnumpy() cls_label = preds[2].asnumpy() valid_count = np.sum(cls_label >= 0) # o...
python
def update(self, labels, preds): """ Implementation of updating metrics """ # get generated multi label from network cls_prob = preds[0].asnumpy() loc_loss = preds[1].asnumpy() cls_label = preds[2].asnumpy() valid_count = np.sum(cls_label >= 0) # o...
[ "def", "update", "(", "self", ",", "labels", ",", "preds", ")", ":", "# get generated multi label from network", "cls_prob", "=", "preds", "[", "0", "]", ".", "asnumpy", "(", ")", "loc_loss", "=", "preds", "[", "1", "]", ".", "asnumpy", "(", ")", "cls_la...
Implementation of updating metrics
[ "Implementation", "of", "updating", "metrics" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/train/metric.py#L53-L72
train
apache/incubator-mxnet
example/ssd/train/metric.py
MultiBoxMetric.get
def get(self): """Get the current evaluation result. Override the default behavior Returns ------- name : str Name of the metric. value : float Value of the evaluation. """ if self.num is None: if self.num_inst == 0: ...
python
def get(self): """Get the current evaluation result. Override the default behavior Returns ------- name : str Name of the metric. value : float Value of the evaluation. """ if self.num is None: if self.num_inst == 0: ...
[ "def", "get", "(", "self", ")", ":", "if", "self", ".", "num", "is", "None", ":", "if", "self", ".", "num_inst", "==", "0", ":", "return", "(", "self", ".", "name", ",", "float", "(", "'nan'", ")", ")", "else", ":", "return", "(", "self", ".", ...
Get the current evaluation result. Override the default behavior Returns ------- name : str Name of the metric. value : float Value of the evaluation.
[ "Get", "the", "current", "evaluation", "result", ".", "Override", "the", "default", "behavior" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/train/metric.py#L74-L94
train
apache/incubator-mxnet
example/reinforcement-learning/dqn/operators.py
dqn_sym_nips
def dqn_sym_nips(action_num, data=None, name='dqn'): """Structure of the Deep Q Network in the NIPS 2013 workshop paper: Playing Atari with Deep Reinforcement Learning (https://www.cs.toronto.edu/~vmnih/docs/dqn.pdf) Parameters ---------- action_num : int data : mxnet.sym.Symbol, optional n...
python
def dqn_sym_nips(action_num, data=None, name='dqn'): """Structure of the Deep Q Network in the NIPS 2013 workshop paper: Playing Atari with Deep Reinforcement Learning (https://www.cs.toronto.edu/~vmnih/docs/dqn.pdf) Parameters ---------- action_num : int data : mxnet.sym.Symbol, optional n...
[ "def", "dqn_sym_nips", "(", "action_num", ",", "data", "=", "None", ",", "name", "=", "'dqn'", ")", ":", "if", "data", "is", "None", ":", "net", "=", "mx", ".", "symbol", ".", "Variable", "(", "'data'", ")", "else", ":", "net", "=", "data", "net", ...
Structure of the Deep Q Network in the NIPS 2013 workshop paper: Playing Atari with Deep Reinforcement Learning (https://www.cs.toronto.edu/~vmnih/docs/dqn.pdf) Parameters ---------- action_num : int data : mxnet.sym.Symbol, optional name : str, optional
[ "Structure", "of", "the", "Deep", "Q", "Network", "in", "the", "NIPS", "2013", "workshop", "paper", ":", "Playing", "Atari", "with", "Deep", "Reinforcement", "Learning", "(", "https", ":", "//", "www", ".", "cs", ".", "toronto", ".", "edu", "/", "~vmnih"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/reinforcement-learning/dqn/operators.py#L98-L121
train
apache/incubator-mxnet
python/mxnet/executor.py
_monitor_callback_wrapper
def _monitor_callback_wrapper(callback): """A wrapper for the user-defined handle.""" def callback_handle(name, array, _): """ ctypes function """ callback(name, array) return callback_handle
python
def _monitor_callback_wrapper(callback): """A wrapper for the user-defined handle.""" def callback_handle(name, array, _): """ ctypes function """ callback(name, array) return callback_handle
[ "def", "_monitor_callback_wrapper", "(", "callback", ")", ":", "def", "callback_handle", "(", "name", ",", "array", ",", "_", ")", ":", "\"\"\" ctypes function \"\"\"", "callback", "(", "name", ",", "array", ")", "return", "callback_handle" ]
A wrapper for the user-defined handle.
[ "A", "wrapper", "for", "the", "user", "-", "defined", "handle", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/executor.py#L38-L43
train
apache/incubator-mxnet
python/mxnet/executor.py
Executor._get_dict
def _get_dict(names, ndarrays): """Get the dictionary given name and ndarray pairs.""" nset = set() for nm in names: if nm in nset: raise ValueError('Duplicate names detected, %s' % str(names)) nset.add(nm) return dict(zip(names, ndarrays))
python
def _get_dict(names, ndarrays): """Get the dictionary given name and ndarray pairs.""" nset = set() for nm in names: if nm in nset: raise ValueError('Duplicate names detected, %s' % str(names)) nset.add(nm) return dict(zip(names, ndarrays))
[ "def", "_get_dict", "(", "names", ",", "ndarrays", ")", ":", "nset", "=", "set", "(", ")", "for", "nm", "in", "names", ":", "if", "nm", "in", "nset", ":", "raise", "ValueError", "(", "'Duplicate names detected, %s'", "%", "str", "(", "names", ")", ")",...
Get the dictionary given name and ndarray pairs.
[ "Get", "the", "dictionary", "given", "name", "and", "ndarray", "pairs", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/executor.py#L90-L97
train
apache/incubator-mxnet
python/mxnet/executor.py
Executor._get_outputs
def _get_outputs(self): """List all the output NDArray. Returns ------- A list of ndarray bound to the heads of executor. """ out_size = mx_uint() handles = ctypes.POINTER(NDArrayHandle)() check_call(_LIB.MXExecutorOutputs(self.handle, ...
python
def _get_outputs(self): """List all the output NDArray. Returns ------- A list of ndarray bound to the heads of executor. """ out_size = mx_uint() handles = ctypes.POINTER(NDArrayHandle)() check_call(_LIB.MXExecutorOutputs(self.handle, ...
[ "def", "_get_outputs", "(", "self", ")", ":", "out_size", "=", "mx_uint", "(", ")", "handles", "=", "ctypes", ".", "POINTER", "(", "NDArrayHandle", ")", "(", ")", "check_call", "(", "_LIB", ".", "MXExecutorOutputs", "(", "self", ".", "handle", ",", "ctyp...
List all the output NDArray. Returns ------- A list of ndarray bound to the heads of executor.
[ "List", "all", "the", "output", "NDArray", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/executor.py#L99-L112
train
apache/incubator-mxnet
python/mxnet/executor.py
Executor.forward
def forward(self, is_train=False, **kwargs): """Calculate the outputs specified by the bound symbol. Parameters ---------- is_train: bool, optional Whether this forward is for evaluation purpose. If True, a backward call is expected to follow. **kwargs ...
python
def forward(self, is_train=False, **kwargs): """Calculate the outputs specified by the bound symbol. Parameters ---------- is_train: bool, optional Whether this forward is for evaluation purpose. If True, a backward call is expected to follow. **kwargs ...
[ "def", "forward", "(", "self", ",", "is_train", "=", "False", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "kwargs", ")", "!=", "0", ":", "arg_dict", "=", "self", ".", "arg_dict", "for", "name", ",", "array", "in", "kwargs", ".", "items", ...
Calculate the outputs specified by the bound symbol. Parameters ---------- is_train: bool, optional Whether this forward is for evaluation purpose. If True, a backward call is expected to follow. **kwargs Additional specification of input arguments. ...
[ "Calculate", "the", "outputs", "specified", "by", "the", "bound", "symbol", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/executor.py#L114-L153
train
apache/incubator-mxnet
python/mxnet/executor.py
Executor.backward
def backward(self, out_grads=None, is_train=True): """Do backward pass to get the gradient of arguments. Parameters ---------- out_grads : NDArray or list of NDArray or dict of str to NDArray, optional Gradient on the outputs to be propagated back. This parameter...
python
def backward(self, out_grads=None, is_train=True): """Do backward pass to get the gradient of arguments. Parameters ---------- out_grads : NDArray or list of NDArray or dict of str to NDArray, optional Gradient on the outputs to be propagated back. This parameter...
[ "def", "backward", "(", "self", ",", "out_grads", "=", "None", ",", "is_train", "=", "True", ")", ":", "if", "out_grads", "is", "None", ":", "out_grads", "=", "[", "]", "elif", "isinstance", "(", "out_grads", ",", "NDArray", ")", ":", "out_grads", "=",...
Do backward pass to get the gradient of arguments. Parameters ---------- out_grads : NDArray or list of NDArray or dict of str to NDArray, optional Gradient on the outputs to be propagated back. This parameter is only needed when bind is called on outputs tha...
[ "Do", "backward", "pass", "to", "get", "the", "gradient", "of", "arguments", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/executor.py#L155-L235
train
apache/incubator-mxnet
python/mxnet/executor.py
Executor.set_monitor_callback
def set_monitor_callback(self, callback, monitor_all=False): """Install callback for monitor. Parameters ---------- callback : function Takes a string and an NDArrayHandle. monitor_all : bool, default False If true, monitor both input and output, otherwis...
python
def set_monitor_callback(self, callback, monitor_all=False): """Install callback for monitor. Parameters ---------- callback : function Takes a string and an NDArrayHandle. monitor_all : bool, default False If true, monitor both input and output, otherwis...
[ "def", "set_monitor_callback", "(", "self", ",", "callback", ",", "monitor_all", "=", "False", ")", ":", "cb_type", "=", "ctypes", ".", "CFUNCTYPE", "(", "None", ",", "ctypes", ".", "c_char_p", ",", "NDArrayHandle", ",", "ctypes", ".", "c_void_p", ")", "se...
Install callback for monitor. Parameters ---------- callback : function Takes a string and an NDArrayHandle. monitor_all : bool, default False If true, monitor both input and output, otherwise monitor output only. Examples -------- >>> de...
[ "Install", "callback", "for", "monitor", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/executor.py#L237-L260
train
apache/incubator-mxnet
python/mxnet/executor.py
Executor.arg_dict
def arg_dict(self): """Get dictionary representation of argument arrrays. Returns ------- arg_dict : dict of str to NDArray The dictionary that maps the names of arguments to NDArrays. Raises ------ ValueError : if there are duplicated names in the a...
python
def arg_dict(self): """Get dictionary representation of argument arrrays. Returns ------- arg_dict : dict of str to NDArray The dictionary that maps the names of arguments to NDArrays. Raises ------ ValueError : if there are duplicated names in the a...
[ "def", "arg_dict", "(", "self", ")", ":", "if", "self", ".", "_arg_dict", "is", "None", ":", "self", ".", "_arg_dict", "=", "Executor", ".", "_get_dict", "(", "self", ".", "_symbol", ".", "list_arguments", "(", ")", ",", "self", ".", "arg_arrays", ")",...
Get dictionary representation of argument arrrays. Returns ------- arg_dict : dict of str to NDArray The dictionary that maps the names of arguments to NDArrays. Raises ------ ValueError : if there are duplicated names in the arguments.
[ "Get", "dictionary", "representation", "of", "argument", "arrrays", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/executor.py#L263-L278
train
apache/incubator-mxnet
python/mxnet/executor.py
Executor.grad_dict
def grad_dict(self): """Get dictionary representation of gradient arrays. Returns ------- grad_dict : dict of str to NDArray The dictionary that maps name of arguments to gradient arrays. """ if self._grad_dict is None: self._grad_dict = Executor....
python
def grad_dict(self): """Get dictionary representation of gradient arrays. Returns ------- grad_dict : dict of str to NDArray The dictionary that maps name of arguments to gradient arrays. """ if self._grad_dict is None: self._grad_dict = Executor....
[ "def", "grad_dict", "(", "self", ")", ":", "if", "self", ".", "_grad_dict", "is", "None", ":", "self", ".", "_grad_dict", "=", "Executor", ".", "_get_dict", "(", "self", ".", "_symbol", ".", "list_arguments", "(", ")", ",", "self", ".", "grad_arrays", ...
Get dictionary representation of gradient arrays. Returns ------- grad_dict : dict of str to NDArray The dictionary that maps name of arguments to gradient arrays.
[ "Get", "dictionary", "representation", "of", "gradient", "arrays", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/executor.py#L281-L292
train
apache/incubator-mxnet
python/mxnet/executor.py
Executor.aux_dict
def aux_dict(self): """Get dictionary representation of auxiliary states arrays. Returns ------- aux_dict : dict of str to NDArray The dictionary that maps name of auxiliary states to NDArrays. Raises ------ ValueError : if there are duplicated names...
python
def aux_dict(self): """Get dictionary representation of auxiliary states arrays. Returns ------- aux_dict : dict of str to NDArray The dictionary that maps name of auxiliary states to NDArrays. Raises ------ ValueError : if there are duplicated names...
[ "def", "aux_dict", "(", "self", ")", ":", "if", "self", ".", "_aux_dict", "is", "None", ":", "self", ".", "_aux_dict", "=", "Executor", ".", "_get_dict", "(", "self", ".", "_symbol", ".", "list_auxiliary_states", "(", ")", ",", "self", ".", "aux_arrays",...
Get dictionary representation of auxiliary states arrays. Returns ------- aux_dict : dict of str to NDArray The dictionary that maps name of auxiliary states to NDArrays. Raises ------ ValueError : if there are duplicated names in the auxiliary states.
[ "Get", "dictionary", "representation", "of", "auxiliary", "states", "arrays", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/executor.py#L295-L310
train
apache/incubator-mxnet
python/mxnet/executor.py
Executor.output_dict
def output_dict(self): """Get dictionary representation of output arrays. Returns ------- output_dict : dict of str to NDArray The dictionary that maps name of output names to NDArrays. Raises ------ ValueError : if there are duplicated names in the ...
python
def output_dict(self): """Get dictionary representation of output arrays. Returns ------- output_dict : dict of str to NDArray The dictionary that maps name of output names to NDArrays. Raises ------ ValueError : if there are duplicated names in the ...
[ "def", "output_dict", "(", "self", ")", ":", "if", "self", ".", "_output_dict", "is", "None", ":", "self", ".", "_output_dict", "=", "Executor", ".", "_get_dict", "(", "self", ".", "_symbol", ".", "list_outputs", "(", ")", ",", "self", ".", "outputs", ...
Get dictionary representation of output arrays. Returns ------- output_dict : dict of str to NDArray The dictionary that maps name of output names to NDArrays. Raises ------ ValueError : if there are duplicated names in the outputs.
[ "Get", "dictionary", "representation", "of", "output", "arrays", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/executor.py#L313-L328
train
apache/incubator-mxnet
python/mxnet/executor.py
Executor.copy_params_from
def copy_params_from(self, arg_params, aux_params=None, allow_extra_params=False): """Copy parameters from arg_params, aux_params into executor's internal array. Parameters ---------- arg_params : dict of str to NDArray Parameters, dict of name to NDArray of arguments. ...
python
def copy_params_from(self, arg_params, aux_params=None, allow_extra_params=False): """Copy parameters from arg_params, aux_params into executor's internal array. Parameters ---------- arg_params : dict of str to NDArray Parameters, dict of name to NDArray of arguments. ...
[ "def", "copy_params_from", "(", "self", ",", "arg_params", ",", "aux_params", "=", "None", ",", "allow_extra_params", "=", "False", ")", ":", "for", "name", ",", "array", "in", "arg_params", ".", "items", "(", ")", ":", "if", "name", "in", "self", ".", ...
Copy parameters from arg_params, aux_params into executor's internal array. Parameters ---------- arg_params : dict of str to NDArray Parameters, dict of name to NDArray of arguments. aux_params : dict of str to NDArray, optional Parameters, dict of name to NDAr...
[ "Copy", "parameters", "from", "arg_params", "aux_params", "into", "executor", "s", "internal", "array", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/executor.py#L330-L373
train
apache/incubator-mxnet
python/mxnet/executor.py
Executor.reshape
def reshape(self, partial_shaping=False, allow_up_sizing=False, **kwargs): """Return a new executor with the same symbol and shared memory, but different input/output shapes. For runtime reshaping, variable length sequences, etc. The returned executor shares state with the current one, ...
python
def reshape(self, partial_shaping=False, allow_up_sizing=False, **kwargs): """Return a new executor with the same symbol and shared memory, but different input/output shapes. For runtime reshaping, variable length sequences, etc. The returned executor shares state with the current one, ...
[ "def", "reshape", "(", "self", ",", "partial_shaping", "=", "False", ",", "allow_up_sizing", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable=too-many-branches", "provided_arg_shape_data", "=", "[", "]", "# shape data", "# argument shape index in sd...
Return a new executor with the same symbol and shared memory, but different input/output shapes. For runtime reshaping, variable length sequences, etc. The returned executor shares state with the current one, and cannot be used in parallel with it. Parameters ---------- ...
[ "Return", "a", "new", "executor", "with", "the", "same", "symbol", "and", "shared", "memory", "but", "different", "input", "/", "output", "shapes", ".", "For", "runtime", "reshaping", "variable", "length", "sequences", "etc", ".", "The", "returned", "executor"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/executor.py#L375-L472
train
apache/incubator-mxnet
python/mxnet/executor.py
Executor.debug_str
def debug_str(self): """Get a debug string about internal execution plan. Returns ------- debug_str : string Debug string of the executor. Examples -------- >>> a = mx.sym.Variable('a') >>> b = mx.sym.sin(a) >>> c = 2 * a + b ...
python
def debug_str(self): """Get a debug string about internal execution plan. Returns ------- debug_str : string Debug string of the executor. Examples -------- >>> a = mx.sym.Variable('a') >>> b = mx.sym.sin(a) >>> c = 2 * a + b ...
[ "def", "debug_str", "(", "self", ")", ":", "debug_str", "=", "ctypes", ".", "c_char_p", "(", ")", "check_call", "(", "_LIB", ".", "MXExecutorPrint", "(", "self", ".", "handle", ",", "ctypes", ".", "byref", "(", "debug_str", ")", ")", ")", "return", "py...
Get a debug string about internal execution plan. Returns ------- debug_str : string Debug string of the executor. Examples -------- >>> a = mx.sym.Variable('a') >>> b = mx.sym.sin(a) >>> c = 2 * a + b >>> texec = c.bind(mx.cpu(), {'a...
[ "Get", "a", "debug", "string", "about", "internal", "execution", "plan", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/executor.py#L474-L513
train
apache/incubator-mxnet
example/ssd/evaluate/eval_voc.py
parse_voc_rec
def parse_voc_rec(filename): """ parse pascal voc record into a dictionary :param filename: xml file path :return: list of dict """ import xml.etree.ElementTree as ET tree = ET.parse(filename) objects = [] for obj in tree.findall('object'): obj_dict = dict() obj_dict[...
python
def parse_voc_rec(filename): """ parse pascal voc record into a dictionary :param filename: xml file path :return: list of dict """ import xml.etree.ElementTree as ET tree = ET.parse(filename) objects = [] for obj in tree.findall('object'): obj_dict = dict() obj_dict[...
[ "def", "parse_voc_rec", "(", "filename", ")", ":", "import", "xml", ".", "etree", ".", "ElementTree", "as", "ET", "tree", "=", "ET", ".", "parse", "(", "filename", ")", "objects", "=", "[", "]", "for", "obj", "in", "tree", ".", "findall", "(", "'obje...
parse pascal voc record into a dictionary :param filename: xml file path :return: list of dict
[ "parse", "pascal", "voc", "record", "into", "a", "dictionary", ":", "param", "filename", ":", "xml", "file", "path", ":", "return", ":", "list", "of", "dict" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/evaluate/eval_voc.py#L30-L49
train
apache/incubator-mxnet
example/ssd/evaluate/eval_voc.py
voc_eval
def voc_eval(detpath, annopath, imageset_file, classname, cache_dir, ovthresh=0.5, use_07_metric=False): """ pascal voc evaluation :param detpath: detection results detpath.format(classname) :param annopath: annotations annopath.format(classname) :param imageset_file: text file containing list of im...
python
def voc_eval(detpath, annopath, imageset_file, classname, cache_dir, ovthresh=0.5, use_07_metric=False): """ pascal voc evaluation :param detpath: detection results detpath.format(classname) :param annopath: annotations annopath.format(classname) :param imageset_file: text file containing list of im...
[ "def", "voc_eval", "(", "detpath", ",", "annopath", ",", "imageset_file", ",", "classname", ",", "cache_dir", ",", "ovthresh", "=", "0.5", ",", "use_07_metric", "=", "False", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "cache_dir", ")", ...
pascal voc evaluation :param detpath: detection results detpath.format(classname) :param annopath: annotations annopath.format(classname) :param imageset_file: text file containing list of images :param classname: category name :param cache_dir: caching annotations :param ovthresh: overlap thres...
[ "pascal", "voc", "evaluation", ":", "param", "detpath", ":", "detection", "results", "detpath", ".", "format", "(", "classname", ")", ":", "param", "annopath", ":", "annotations", "annopath", ".", "format", "(", "classname", ")", ":", "param", "imageset_file",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/evaluate/eval_voc.py#L86-L196
train
apache/incubator-mxnet
python/mxnet/contrib/onnx/mx2onnx/export_onnx.py
MXNetGraph.register
def register(op_name): """Register operators""" def wrapper(func): """Helper function to map functions""" try: import onnx as _ MXNetGraph.registry_[op_name] = func except ImportError: pass return func ...
python
def register(op_name): """Register operators""" def wrapper(func): """Helper function to map functions""" try: import onnx as _ MXNetGraph.registry_[op_name] = func except ImportError: pass return func ...
[ "def", "register", "(", "op_name", ")", ":", "def", "wrapper", "(", "func", ")", ":", "\"\"\"Helper function to map functions\"\"\"", "try", ":", "import", "onnx", "as", "_", "MXNetGraph", ".", "registry_", "[", "op_name", "]", "=", "func", "except", "ImportEr...
Register operators
[ "Register", "operators" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/export_onnx.py#L72-L83
train
apache/incubator-mxnet
python/mxnet/contrib/onnx/mx2onnx/export_onnx.py
MXNetGraph.convert_layer
def convert_layer(node, **kwargs): """Convert MXNet layer to ONNX""" op = str(node["op"]) if op not in MXNetGraph.registry_: raise AttributeError("No conversion function registered for op type %s yet." % op) convert_func = MXNetGraph.registry_[op] return convert_func(...
python
def convert_layer(node, **kwargs): """Convert MXNet layer to ONNX""" op = str(node["op"]) if op not in MXNetGraph.registry_: raise AttributeError("No conversion function registered for op type %s yet." % op) convert_func = MXNetGraph.registry_[op] return convert_func(...
[ "def", "convert_layer", "(", "node", ",", "*", "*", "kwargs", ")", ":", "op", "=", "str", "(", "node", "[", "\"op\"", "]", ")", "if", "op", "not", "in", "MXNetGraph", ".", "registry_", ":", "raise", "AttributeError", "(", "\"No conversion function register...
Convert MXNet layer to ONNX
[ "Convert", "MXNet", "layer", "to", "ONNX" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/export_onnx.py#L86-L92
train
apache/incubator-mxnet
python/mxnet/contrib/onnx/mx2onnx/export_onnx.py
MXNetGraph.split_params
def split_params(sym, params): """Helper function to split params dictionary into args and aux params Parameters ---------- sym : :class:`~mxnet.symbol.Symbol` MXNet symbol object params : dict of ``str`` to :class:`~mxnet.ndarray.NDArray` Dict of convert...
python
def split_params(sym, params): """Helper function to split params dictionary into args and aux params Parameters ---------- sym : :class:`~mxnet.symbol.Symbol` MXNet symbol object params : dict of ``str`` to :class:`~mxnet.ndarray.NDArray` Dict of convert...
[ "def", "split_params", "(", "sym", ",", "params", ")", ":", "arg_params", "=", "{", "}", "aux_params", "=", "{", "}", "for", "args", "in", "sym", ".", "list_arguments", "(", ")", ":", "if", "args", "in", "params", ":", "arg_params", ".", "update", "(...
Helper function to split params dictionary into args and aux params Parameters ---------- sym : :class:`~mxnet.symbol.Symbol` MXNet symbol object params : dict of ``str`` to :class:`~mxnet.ndarray.NDArray` Dict of converted parameters stored in ``mxnet.ndarray.ND...
[ "Helper", "function", "to", "split", "params", "dictionary", "into", "args", "and", "aux", "params" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/export_onnx.py#L95-L120
train