id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
24,000
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
global_lppooling
def global_lppooling(attrs, inputs, proto_obj): """Performs global lp pooling on the input.""" p_value = attrs.get('p', 2) new_attrs = translation_utils._add_extra_attributes(attrs, {'global_pool': True, 'kernel': (1, 1), ...
python
def global_lppooling(attrs, inputs, proto_obj): """Performs global lp pooling on the input.""" p_value = attrs.get('p', 2) new_attrs = translation_utils._add_extra_attributes(attrs, {'global_pool': True, 'kernel': (1, 1), ...
[ "def", "global_lppooling", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "p_value", "=", "attrs", ".", "get", "(", "'p'", ",", "2", ")", "new_attrs", "=", "translation_utils", ".", "_add_extra_attributes", "(", "attrs", ",", "{", "'global_pool'", ...
Performs global lp pooling on the input.
[ "Performs", "global", "lp", "pooling", "on", "the", "input", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L405-L413
24,001
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
linalg_gemm
def linalg_gemm(attrs, inputs, proto_obj): """Performs general matrix multiplication and accumulation""" trans_a = 0 trans_b = 0 alpha = 1 beta = 1 if 'transA' in attrs: trans_a = attrs['transA'] if 'transB' in attrs: trans_b = attrs['transB'] if 'alpha' in attrs: ...
python
def linalg_gemm(attrs, inputs, proto_obj): """Performs general matrix multiplication and accumulation""" trans_a = 0 trans_b = 0 alpha = 1 beta = 1 if 'transA' in attrs: trans_a = attrs['transA'] if 'transB' in attrs: trans_b = attrs['transB'] if 'alpha' in attrs: ...
[ "def", "linalg_gemm", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "trans_a", "=", "0", "trans_b", "=", "0", "alpha", "=", "1", "beta", "=", "1", "if", "'transA'", "in", "attrs", ":", "trans_a", "=", "attrs", "[", "'transA'", "]", "if", ...
Performs general matrix multiplication and accumulation
[ "Performs", "general", "matrix", "multiplication", "and", "accumulation" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L415-L437
24,002
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
local_response_norm
def local_response_norm(attrs, inputs, proto_obj): """Local Response Normalization.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'bias': 'knorm', 'size' : 'nsize'}) return 'LRN', n...
python
def local_response_norm(attrs, inputs, proto_obj): """Local Response Normalization.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'bias': 'knorm', 'size' : 'nsize'}) return 'LRN', n...
[ "def", "local_response_norm", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'bias'", ":", "'knorm'", ",", "'size'", ":", "'nsize'", "}", ")", "return", "'...
Local Response Normalization.
[ "Local", "Response", "Normalization", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L439-L444
24,003
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
dropout
def dropout(attrs, inputs, proto_obj): """Dropout Regularization.""" mode = 'training' if 'is_test' in attrs and attrs['is_test'] == 0: mode = 'always' new_attrs = translation_utils._fix_attribute_names(attrs, {'ratio': 'p'}) new_attrs =...
python
def dropout(attrs, inputs, proto_obj): """Dropout Regularization.""" mode = 'training' if 'is_test' in attrs and attrs['is_test'] == 0: mode = 'always' new_attrs = translation_utils._fix_attribute_names(attrs, {'ratio': 'p'}) new_attrs =...
[ "def", "dropout", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "mode", "=", "'training'", "if", "'is_test'", "in", "attrs", "and", "attrs", "[", "'is_test'", "]", "==", "0", ":", "mode", "=", "'always'", "new_attrs", "=", "translation_utils", ...
Dropout Regularization.
[ "Dropout", "Regularization", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L446-L455
24,004
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
reshape
def reshape(attrs, inputs, proto_obj): """Reshape the given array by the shape attribute.""" if len(inputs) == 1: return 'reshape', attrs, inputs[0] reshape_shape = list(proto_obj._params[inputs[1].name].asnumpy()) reshape_shape = [int(i) for i in reshape_shape] new_attrs = {'shape': reshape...
python
def reshape(attrs, inputs, proto_obj): """Reshape the given array by the shape attribute.""" if len(inputs) == 1: return 'reshape', attrs, inputs[0] reshape_shape = list(proto_obj._params[inputs[1].name].asnumpy()) reshape_shape = [int(i) for i in reshape_shape] new_attrs = {'shape': reshape...
[ "def", "reshape", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "if", "len", "(", "inputs", ")", "==", "1", ":", "return", "'reshape'", ",", "attrs", ",", "inputs", "[", "0", "]", "reshape_shape", "=", "list", "(", "proto_obj", ".", "_para...
Reshape the given array by the shape attribute.
[ "Reshape", "the", "given", "array", "by", "the", "shape", "attribute", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L458-L465
24,005
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
cast
def cast(attrs, inputs, proto_obj): """ Cast input to a given dtype""" try: from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE except ImportError: raise ImportError("Onnx and protobuf need to be installed. " + "Instructions to install - https://github.com/onnx/onnx") ...
python
def cast(attrs, inputs, proto_obj): """ Cast input to a given dtype""" try: from onnx.mapping import TENSOR_TYPE_TO_NP_TYPE except ImportError: raise ImportError("Onnx and protobuf need to be installed. " + "Instructions to install - https://github.com/onnx/onnx") ...
[ "def", "cast", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "try", ":", "from", "onnx", ".", "mapping", "import", "TENSOR_TYPE_TO_NP_TYPE", "except", "ImportError", ":", "raise", "ImportError", "(", "\"Onnx and protobuf need to be installed. \"", "+", ...
Cast input to a given dtype
[ "Cast", "input", "to", "a", "given", "dtype" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L467-L476
24,006
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
split
def split(attrs, inputs, proto_obj): """Splits an array along a particular axis into multiple sub-arrays.""" split_list = attrs.get('split') if 'split' in attrs else [] new_attrs = translation_utils._fix_attribute_names(attrs, {'split' : 'num_outputs'})...
python
def split(attrs, inputs, proto_obj): """Splits an array along a particular axis into multiple sub-arrays.""" split_list = attrs.get('split') if 'split' in attrs else [] new_attrs = translation_utils._fix_attribute_names(attrs, {'split' : 'num_outputs'})...
[ "def", "split", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "split_list", "=", "attrs", ".", "get", "(", "'split'", ")", "if", "'split'", "in", "attrs", "else", "[", "]", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(",...
Splits an array along a particular axis into multiple sub-arrays.
[ "Splits", "an", "array", "along", "a", "particular", "axis", "into", "multiple", "sub", "-", "arrays", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L478-L498
24,007
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
_slice
def _slice(attrs, inputs, proto_obj): """Returns a slice of the input tensor along multiple axes.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes' : 'axis', 'ends' : 'end', ...
python
def _slice(attrs, inputs, proto_obj): """Returns a slice of the input tensor along multiple axes.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes' : 'axis', 'ends' : 'end', ...
[ "def", "_slice", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'axes'", ":", "'axis'", ",", "'ends'", ":", "'end'", ",", "'starts'", ":", "'begin'", "}"...
Returns a slice of the input tensor along multiple axes.
[ "Returns", "a", "slice", "of", "the", "input", "tensor", "along", "multiple", "axes", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L500-L515
24,008
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
transpose
def transpose(attrs, inputs, proto_obj): """Transpose the input array.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'perm' : 'axes'}) return 'transpose', new_attrs, inputs
python
def transpose(attrs, inputs, proto_obj): """Transpose the input array.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'perm' : 'axes'}) return 'transpose', new_attrs, inputs
[ "def", "transpose", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'perm'", ":", "'axes'", "}", ")", "return", "'transpose'", ",", "new_attrs", ",", "input...
Transpose the input array.
[ "Transpose", "the", "input", "array", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L517-L521
24,009
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
squeeze
def squeeze(attrs, inputs, proto_obj): """Remove single-dimensional entries from the shape of a tensor.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes' : 'axis'}) return 'squeeze', new_attrs, inputs
python
def squeeze(attrs, inputs, proto_obj): """Remove single-dimensional entries from the shape of a tensor.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes' : 'axis'}) return 'squeeze', new_attrs, inputs
[ "def", "squeeze", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'axes'", ":", "'axis'", "}", ")", "return", "'squeeze'", ",", "new_attrs", ",", "inputs" ]
Remove single-dimensional entries from the shape of a tensor.
[ "Remove", "single", "-", "dimensional", "entries", "from", "the", "shape", "of", "a", "tensor", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L523-L527
24,010
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
unsqueeze
def unsqueeze(attrs, inputs, cls): """Inserts a new axis of size 1 into the array shape""" # MXNet can only add one axis at a time. mxnet_op = inputs[0] for axis in attrs["axes"]: mxnet_op = symbol.expand_dims(mxnet_op, axis=axis) return mxnet_op, attrs, inputs
python
def unsqueeze(attrs, inputs, cls): """Inserts a new axis of size 1 into the array shape""" # MXNet can only add one axis at a time. mxnet_op = inputs[0] for axis in attrs["axes"]: mxnet_op = symbol.expand_dims(mxnet_op, axis=axis) return mxnet_op, attrs, inputs
[ "def", "unsqueeze", "(", "attrs", ",", "inputs", ",", "cls", ")", ":", "# MXNet can only add one axis at a time.", "mxnet_op", "=", "inputs", "[", "0", "]", "for", "axis", "in", "attrs", "[", "\"axes\"", "]", ":", "mxnet_op", "=", "symbol", ".", "expand_dims...
Inserts a new axis of size 1 into the array shape
[ "Inserts", "a", "new", "axis", "of", "size", "1", "into", "the", "array", "shape" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L529-L536
24,011
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
flatten
def flatten(attrs, inputs, proto_obj): """Flattens the input array into a 2-D array by collapsing the higher dimensions.""" #Mxnet does not have axis support. By default uses axis=1 if 'axis' in attrs and attrs['axis'] != 1: raise RuntimeError("Flatten operator only supports axis=1") new_attrs =...
python
def flatten(attrs, inputs, proto_obj): """Flattens the input array into a 2-D array by collapsing the higher dimensions.""" #Mxnet does not have axis support. By default uses axis=1 if 'axis' in attrs and attrs['axis'] != 1: raise RuntimeError("Flatten operator only supports axis=1") new_attrs =...
[ "def", "flatten", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "#Mxnet does not have axis support. By default uses axis=1", "if", "'axis'", "in", "attrs", "and", "attrs", "[", "'axis'", "]", "!=", "1", ":", "raise", "RuntimeError", "(", "\"Flatten oper...
Flattens the input array into a 2-D array by collapsing the higher dimensions.
[ "Flattens", "the", "input", "array", "into", "a", "2", "-", "D", "array", "by", "collapsing", "the", "higher", "dimensions", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L538-L544
24,012
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
reduce_max
def reduce_max(attrs, inputs, proto_obj): """Reduce the array along a given axis by maximum value""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) return 'max', new_attrs, inputs
python
def reduce_max(attrs, inputs, proto_obj): """Reduce the array along a given axis by maximum value""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) return 'max', new_attrs, inputs
[ "def", "reduce_max", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'axes'", ":", "'axis'", "}", ")", "return", "'max'", ",", "new_attrs", ",", "inputs" ]
Reduce the array along a given axis by maximum value
[ "Reduce", "the", "array", "along", "a", "given", "axis", "by", "maximum", "value" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L615-L618
24,013
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
reduce_mean
def reduce_mean(attrs, inputs, proto_obj): """Reduce the array along a given axis by mean value""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) return 'mean', new_attrs, inputs
python
def reduce_mean(attrs, inputs, proto_obj): """Reduce the array along a given axis by mean value""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) return 'mean', new_attrs, inputs
[ "def", "reduce_mean", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'axes'", ":", "'axis'", "}", ")", "return", "'mean'", ",", "new_attrs", ",", "inputs" ...
Reduce the array along a given axis by mean value
[ "Reduce", "the", "array", "along", "a", "given", "axis", "by", "mean", "value" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L620-L623
24,014
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
reduce_min
def reduce_min(attrs, inputs, proto_obj): """Reduce the array along a given axis by minimum value""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) return 'min', new_attrs, inputs
python
def reduce_min(attrs, inputs, proto_obj): """Reduce the array along a given axis by minimum value""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) return 'min', new_attrs, inputs
[ "def", "reduce_min", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'axes'", ":", "'axis'", "}", ")", "return", "'min'", ",", "new_attrs", ",", "inputs" ]
Reduce the array along a given axis by minimum value
[ "Reduce", "the", "array", "along", "a", "given", "axis", "by", "minimum", "value" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L625-L628
24,015
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
reduce_sum
def reduce_sum(attrs, inputs, proto_obj): """Reduce the array along a given axis by sum value""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) return 'sum', new_attrs, inputs
python
def reduce_sum(attrs, inputs, proto_obj): """Reduce the array along a given axis by sum value""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) return 'sum', new_attrs, inputs
[ "def", "reduce_sum", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'axes'", ":", "'axis'", "}", ")", "return", "'sum'", ",", "new_attrs", ",", "inputs" ]
Reduce the array along a given axis by sum value
[ "Reduce", "the", "array", "along", "a", "given", "axis", "by", "sum", "value" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L630-L633
24,016
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
reduce_prod
def reduce_prod(attrs, inputs, proto_obj): """Reduce the array along a given axis by product value""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) return 'prod', new_attrs, inputs
python
def reduce_prod(attrs, inputs, proto_obj): """Reduce the array along a given axis by product value""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) return 'prod', new_attrs, inputs
[ "def", "reduce_prod", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'axes'", ":", "'axis'", "}", ")", "return", "'prod'", ",", "new_attrs", ",", "inputs" ...
Reduce the array along a given axis by product value
[ "Reduce", "the", "array", "along", "a", "given", "axis", "by", "product", "value" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L635-L638
24,017
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
reduce_log_sum
def reduce_log_sum(attrs, inputs, proto_obj): """Reduce the array along a given axis by log sum value""" keep_dims = True if 'keepdims' not in attrs else attrs.get('keepdims') sum_op = symbol.sum(inputs[0], axis=attrs.get('axes'), keepdims=keep_dims) log_sym = symbol.log(sum_op) ...
python
def reduce_log_sum(attrs, inputs, proto_obj): """Reduce the array along a given axis by log sum value""" keep_dims = True if 'keepdims' not in attrs else attrs.get('keepdims') sum_op = symbol.sum(inputs[0], axis=attrs.get('axes'), keepdims=keep_dims) log_sym = symbol.log(sum_op) ...
[ "def", "reduce_log_sum", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "keep_dims", "=", "True", "if", "'keepdims'", "not", "in", "attrs", "else", "attrs", ".", "get", "(", "'keepdims'", ")", "sum_op", "=", "symbol", ".", "sum", "(", "inputs",...
Reduce the array along a given axis by log sum value
[ "Reduce", "the", "array", "along", "a", "given", "axis", "by", "log", "sum", "value" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L640-L646
24,018
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
reduce_log_sum_exp
def reduce_log_sum_exp(attrs, inputs, proto_obj): """Reduce the array along a given axis by log sum exp value""" keep_dims = True if 'keepdims' not in attrs else attrs.get('keepdims') exp_op = symbol.exp(inputs[0]) sum_op = symbol.sum(exp_op, axis=attrs.get('axes'), keepdims=keep...
python
def reduce_log_sum_exp(attrs, inputs, proto_obj): """Reduce the array along a given axis by log sum exp value""" keep_dims = True if 'keepdims' not in attrs else attrs.get('keepdims') exp_op = symbol.exp(inputs[0]) sum_op = symbol.sum(exp_op, axis=attrs.get('axes'), keepdims=keep...
[ "def", "reduce_log_sum_exp", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "keep_dims", "=", "True", "if", "'keepdims'", "not", "in", "attrs", "else", "attrs", ".", "get", "(", "'keepdims'", ")", "exp_op", "=", "symbol", ".", "exp", "(", "inpu...
Reduce the array along a given axis by log sum exp value
[ "Reduce", "the", "array", "along", "a", "given", "axis", "by", "log", "sum", "exp", "value" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L648-L655
24,019
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
reduce_sum_square
def reduce_sum_square(attrs, inputs, proto_obj): """Reduce the array along a given axis by sum square value""" square_op = symbol.square(inputs[0]) sum_op = symbol.sum(square_op, axis=attrs.get('axes'), keepdims=attrs.get('keepdims')) return sum_op, attrs, inputs
python
def reduce_sum_square(attrs, inputs, proto_obj): """Reduce the array along a given axis by sum square value""" square_op = symbol.square(inputs[0]) sum_op = symbol.sum(square_op, axis=attrs.get('axes'), keepdims=attrs.get('keepdims')) return sum_op, attrs, inputs
[ "def", "reduce_sum_square", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "square_op", "=", "symbol", ".", "square", "(", "inputs", "[", "0", "]", ")", "sum_op", "=", "symbol", ".", "sum", "(", "square_op", ",", "axis", "=", "attrs", ".", ...
Reduce the array along a given axis by sum square value
[ "Reduce", "the", "array", "along", "a", "given", "axis", "by", "sum", "square", "value" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L657-L662
24,020
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
reduce_l1
def reduce_l1(attrs, inputs, proto_obj): """Reduce input tensor by l1 normalization.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) new_attrs = translation_utils._add_extra_attributes(new_attrs, {'ord' : 1}) return 'n...
python
def reduce_l1(attrs, inputs, proto_obj): """Reduce input tensor by l1 normalization.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) new_attrs = translation_utils._add_extra_attributes(new_attrs, {'ord' : 1}) return 'n...
[ "def", "reduce_l1", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'axes'", ":", "'axis'", "}", ")", "new_attrs", "=", "translation_utils", ".", "_add_extra_...
Reduce input tensor by l1 normalization.
[ "Reduce", "input", "tensor", "by", "l1", "normalization", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L664-L669
24,021
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
reduce_l2
def reduce_l2(attrs, inputs, proto_obj): """Reduce input tensor by l2 normalization.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) return 'norm', new_attrs, inputs
python
def reduce_l2(attrs, inputs, proto_obj): """Reduce input tensor by l2 normalization.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'}) return 'norm', new_attrs, inputs
[ "def", "reduce_l2", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'axes'", ":", "'axis'", "}", ")", "return", "'norm'", ",", "new_attrs", ",", "inputs" ]
Reduce input tensor by l2 normalization.
[ "Reduce", "input", "tensor", "by", "l2", "normalization", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L679-L682
24,022
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
max_roi_pooling
def max_roi_pooling(attrs, inputs, proto_obj): """Max ROI Pooling.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'pooled_shape': 'pooled_size', 'spatial_scale': 'spatial_scale' ...
python
def max_roi_pooling(attrs, inputs, proto_obj): """Max ROI Pooling.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'pooled_shape': 'pooled_size', 'spatial_scale': 'spatial_scale' ...
[ "def", "max_roi_pooling", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'pooled_shape'", ":", "'pooled_size'", ",", "'spatial_scale'", ":", "'spatial_scale'", "...
Max ROI Pooling.
[ "Max", "ROI", "Pooling", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L729-L735
24,023
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
depthtospace
def depthtospace(attrs, inputs, proto_obj): """Rearranges data from depth into blocks of spatial data.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'blocksize':'block_size'}) return "depth_to_space", new_attrs, inputs
python
def depthtospace(attrs, inputs, proto_obj): """Rearranges data from depth into blocks of spatial data.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'blocksize':'block_size'}) return "depth_to_space", new_attrs, inputs
[ "def", "depthtospace", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'blocksize'", ":", "'block_size'", "}", ")", "return", "\"depth_to_space\"", ",", "new_at...
Rearranges data from depth into blocks of spatial data.
[ "Rearranges", "data", "from", "depth", "into", "blocks", "of", "spatial", "data", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L737-L741
24,024
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
spacetodepth
def spacetodepth(attrs, inputs, proto_obj): """Rearranges blocks of spatial data into depth.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'blocksize':'block_size'}) return "space_to_depth", new_attrs, inputs
python
def spacetodepth(attrs, inputs, proto_obj): """Rearranges blocks of spatial data into depth.""" new_attrs = translation_utils._fix_attribute_names(attrs, {'blocksize':'block_size'}) return "space_to_depth", new_attrs, inputs
[ "def", "spacetodepth", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "new_attrs", "=", "translation_utils", ".", "_fix_attribute_names", "(", "attrs", ",", "{", "'blocksize'", ":", "'block_size'", "}", ")", "return", "\"space_to_depth\"", ",", "new_at...
Rearranges blocks of spatial data into depth.
[ "Rearranges", "blocks", "of", "spatial", "data", "into", "depth", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L743-L747
24,025
apache/incubator-mxnet
python/mxnet/contrib/onnx/onnx2mx/_op_translations.py
hardmax
def hardmax(attrs, inputs, proto_obj): """Returns batched one-hot vectors.""" input_tensor_data = proto_obj.model_metadata.get('input_tensor_data')[0] input_shape = input_tensor_data[1] axis = int(attrs.get('axis', 1)) axis = axis if axis >= 0 else len(input_shape) + axis if axis == len(input_...
python
def hardmax(attrs, inputs, proto_obj): """Returns batched one-hot vectors.""" input_tensor_data = proto_obj.model_metadata.get('input_tensor_data')[0] input_shape = input_tensor_data[1] axis = int(attrs.get('axis', 1)) axis = axis if axis >= 0 else len(input_shape) + axis if axis == len(input_...
[ "def", "hardmax", "(", "attrs", ",", "inputs", ",", "proto_obj", ")", ":", "input_tensor_data", "=", "proto_obj", ".", "model_metadata", ".", "get", "(", "'input_tensor_data'", ")", "[", "0", "]", "input_shape", "=", "input_tensor_data", "[", "1", "]", "axis...
Returns batched one-hot vectors.
[ "Returns", "batched", "one", "-", "hot", "vectors", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/_op_translations.py#L749-L772
24,026
apache/incubator-mxnet
ci/docker/qemu/runtime_functions.py
run_ut_python3_qemu_internal
def run_ut_python3_qemu_internal(): """this runs inside the vm""" pkg = glob.glob('mxnet_dist/*.whl')[0] logging.info("=== NOW Running inside QEMU ===") logging.info("PIP Installing %s", pkg) check_call(['sudo', 'pip3', 'install', pkg]) logging.info("PIP Installing mxnet/test_requirements.txt") ...
python
def run_ut_python3_qemu_internal(): """this runs inside the vm""" pkg = glob.glob('mxnet_dist/*.whl')[0] logging.info("=== NOW Running inside QEMU ===") logging.info("PIP Installing %s", pkg) check_call(['sudo', 'pip3', 'install', pkg]) logging.info("PIP Installing mxnet/test_requirements.txt") ...
[ "def", "run_ut_python3_qemu_internal", "(", ")", ":", "pkg", "=", "glob", ".", "glob", "(", "'mxnet_dist/*.whl'", ")", "[", "0", "]", "logging", ".", "info", "(", "\"=== NOW Running inside QEMU ===\"", ")", "logging", ".", "info", "(", "\"PIP Installing %s\"", "...
this runs inside the vm
[ "this", "runs", "inside", "the", "vm" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/docker/qemu/runtime_functions.py#L74-L83
24,027
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
_new_empty_handle
def _new_empty_handle(): """Returns a new empty handle. Empty handle can be used to hold a result. Returns ------- handle A new empty `NDArray` handle. """ hdl = NDArrayHandle() check_call(_LIB.MXNDArrayCreateNone(ctypes.byref(hdl))) return hdl
python
def _new_empty_handle(): """Returns a new empty handle. Empty handle can be used to hold a result. Returns ------- handle A new empty `NDArray` handle. """ hdl = NDArrayHandle() check_call(_LIB.MXNDArrayCreateNone(ctypes.byref(hdl))) return hdl
[ "def", "_new_empty_handle", "(", ")", ":", "hdl", "=", "NDArrayHandle", "(", ")", "check_call", "(", "_LIB", ".", "MXNDArrayCreateNone", "(", "ctypes", ".", "byref", "(", "hdl", ")", ")", ")", "return", "hdl" ]
Returns a new empty handle. Empty handle can be used to hold a result. Returns ------- handle A new empty `NDArray` handle.
[ "Returns", "a", "new", "empty", "handle", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L107-L119
24,028
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
_new_alloc_handle
def _new_alloc_handle(shape, ctx, delay_alloc, dtype=mx_real_t): """Return a new handle with specified shape and context. Empty handle is only used to hold results. Returns ------- handle A new empty `NDArray` handle. """ hdl = NDArrayHandle() check_call(_LIB.MXNDArrayCreateEx(...
python
def _new_alloc_handle(shape, ctx, delay_alloc, dtype=mx_real_t): """Return a new handle with specified shape and context. Empty handle is only used to hold results. Returns ------- handle A new empty `NDArray` handle. """ hdl = NDArrayHandle() check_call(_LIB.MXNDArrayCreateEx(...
[ "def", "_new_alloc_handle", "(", "shape", ",", "ctx", ",", "delay_alloc", ",", "dtype", "=", "mx_real_t", ")", ":", "hdl", "=", "NDArrayHandle", "(", ")", "check_call", "(", "_LIB", ".", "MXNDArrayCreateEx", "(", "c_array_buf", "(", "mx_uint", ",", "native_a...
Return a new handle with specified shape and context. Empty handle is only used to hold results. Returns ------- handle A new empty `NDArray` handle.
[ "Return", "a", "new", "handle", "with", "specified", "shape", "and", "context", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L122-L141
24,029
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
_get_indexing_dispatch_code
def _get_indexing_dispatch_code(key): """Returns a dispatch code for calling basic or advanced indexing functions.""" if isinstance(key, (NDArray, np.ndarray)): return _NDARRAY_ADVANCED_INDEXING elif isinstance(key, list): # TODO(junwu): Add support for nested lists besides integer list ...
python
def _get_indexing_dispatch_code(key): """Returns a dispatch code for calling basic or advanced indexing functions.""" if isinstance(key, (NDArray, np.ndarray)): return _NDARRAY_ADVANCED_INDEXING elif isinstance(key, list): # TODO(junwu): Add support for nested lists besides integer list ...
[ "def", "_get_indexing_dispatch_code", "(", "key", ")", ":", "if", "isinstance", "(", "key", ",", "(", "NDArray", ",", "np", ".", "ndarray", ")", ")", ":", "return", "_NDARRAY_ADVANCED_INDEXING", "elif", "isinstance", "(", "key", ",", "list", ")", ":", "# T...
Returns a dispatch code for calling basic or advanced indexing functions.
[ "Returns", "a", "dispatch", "code", "for", "calling", "basic", "or", "advanced", "indexing", "functions", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2278-L2301
24,030
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
_get_oshape_of_gather_nd_op
def _get_oshape_of_gather_nd_op(dshape, ishape): """Given data and index shapes, get the output `NDArray` shape. This basically implements the infer shape logic of op gather_nd.""" assert len(dshape) > 0 and len(ishape) > 0 oshape = list(ishape[1:]) if ishape[0] < len(dshape): oshape.extend(...
python
def _get_oshape_of_gather_nd_op(dshape, ishape): """Given data and index shapes, get the output `NDArray` shape. This basically implements the infer shape logic of op gather_nd.""" assert len(dshape) > 0 and len(ishape) > 0 oshape = list(ishape[1:]) if ishape[0] < len(dshape): oshape.extend(...
[ "def", "_get_oshape_of_gather_nd_op", "(", "dshape", ",", "ishape", ")", ":", "assert", "len", "(", "dshape", ")", ">", "0", "and", "len", "(", "ishape", ")", ">", "0", "oshape", "=", "list", "(", "ishape", "[", "1", ":", "]", ")", "if", "ishape", ...
Given data and index shapes, get the output `NDArray` shape. This basically implements the infer shape logic of op gather_nd.
[ "Given", "data", "and", "index", "shapes", "get", "the", "output", "NDArray", "shape", ".", "This", "basically", "implements", "the", "infer", "shape", "logic", "of", "op", "gather_nd", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2347-L2354
24,031
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
_get_dim_size
def _get_dim_size(start, stop, step): """Given start, stop, and stop, calculate the number of elements of this slice.""" assert step != 0 if step > 0: assert start < stop dim_size = (stop - start - 1) // step + 1 else: assert stop < start dim_size = (start - stop - 1)...
python
def _get_dim_size(start, stop, step): """Given start, stop, and stop, calculate the number of elements of this slice.""" assert step != 0 if step > 0: assert start < stop dim_size = (stop - start - 1) // step + 1 else: assert stop < start dim_size = (start - stop - 1)...
[ "def", "_get_dim_size", "(", "start", ",", "stop", ",", "step", ")", ":", "assert", "step", "!=", "0", "if", "step", ">", "0", ":", "assert", "start", "<", "stop", "dim_size", "=", "(", "stop", "-", "start", "-", "1", ")", "//", "step", "+", "1",...
Given start, stop, and stop, calculate the number of elements of this slice.
[ "Given", "start", "stop", "and", "stop", "calculate", "the", "number", "of", "elements", "of", "this", "slice", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2357-L2367
24,032
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
_get_broadcast_shape
def _get_broadcast_shape(shape1, shape2): """Given two shapes that are not identical, find the shape that both input shapes can broadcast to.""" if shape1 == shape2: return shape1 length1 = len(shape1) length2 = len(shape2) if length1 > length2: shape = list(shape1) else: ...
python
def _get_broadcast_shape(shape1, shape2): """Given two shapes that are not identical, find the shape that both input shapes can broadcast to.""" if shape1 == shape2: return shape1 length1 = len(shape1) length2 = len(shape2) if length1 > length2: shape = list(shape1) else: ...
[ "def", "_get_broadcast_shape", "(", "shape1", ",", "shape2", ")", ":", "if", "shape1", "==", "shape2", ":", "return", "shape1", "length1", "=", "len", "(", "shape1", ")", "length2", "=", "len", "(", "shape2", ")", "if", "length1", ">", "length2", ":", ...
Given two shapes that are not identical, find the shape that both input shapes can broadcast to.
[ "Given", "two", "shapes", "that", "are", "not", "identical", "find", "the", "shape", "that", "both", "input", "shapes", "can", "broadcast", "to", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2370-L2388
24,033
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
ones
def ones(shape, ctx=None, dtype=None, **kwargs): """Returns a new array filled with all ones, with the given shape and type. Parameters ---------- shape : int or tuple of int or list of int The shape of the empty array. ctx : Context, optional An optional device context. Def...
python
def ones(shape, ctx=None, dtype=None, **kwargs): """Returns a new array filled with all ones, with the given shape and type. Parameters ---------- shape : int or tuple of int or list of int The shape of the empty array. ctx : Context, optional An optional device context. Def...
[ "def", "ones", "(", "shape", ",", "ctx", "=", "None", ",", "dtype", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable= unused-argument", "if", "ctx", "is", "None", ":", "ctx", "=", "current_context", "(", ")", "dtype", "=", "mx_real_t", ...
Returns a new array filled with all ones, with the given shape and type. Parameters ---------- shape : int or tuple of int or list of int The shape of the empty array. ctx : Context, optional An optional device context. Defaults to the current default context (``mxnet.context.cu...
[ "Returns", "a", "new", "array", "filled", "with", "all", "ones", "with", "the", "given", "shape", "and", "type", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2402-L2436
24,034
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
moveaxis
def moveaxis(tensor, source, destination): """Moves the `source` axis into the `destination` position while leaving the other axes in their original order Parameters ---------- tensor : mx.nd.array The array which axes should be reordered source : int or sequence of int Original...
python
def moveaxis(tensor, source, destination): """Moves the `source` axis into the `destination` position while leaving the other axes in their original order Parameters ---------- tensor : mx.nd.array The array which axes should be reordered source : int or sequence of int Original...
[ "def", "moveaxis", "(", "tensor", ",", "source", ",", "destination", ")", ":", "try", ":", "source", "=", "np", ".", "core", ".", "numeric", ".", "normalize_axis_tuple", "(", "source", ",", "tensor", ".", "ndim", ")", "except", "IndexError", ":", "raise"...
Moves the `source` axis into the `destination` position while leaving the other axes in their original order Parameters ---------- tensor : mx.nd.array The array which axes should be reordered source : int or sequence of int Original position of the axes to move. Can be negative but...
[ "Moves", "the", "source", "axis", "into", "the", "destination", "position", "while", "leaving", "the", "other", "axes", "in", "their", "original", "order" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2508-L2556
24,035
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
_ufunc_helper
def _ufunc_helper(lhs, rhs, fn_array, fn_scalar, lfn_scalar, rfn_scalar=None): """ Helper function for element-wise operation. The function will perform numpy-like broadcasting if needed and call different functions. Parameters -------- lhs : NDArray or numeric value Left-hand side operand....
python
def _ufunc_helper(lhs, rhs, fn_array, fn_scalar, lfn_scalar, rfn_scalar=None): """ Helper function for element-wise operation. The function will perform numpy-like broadcasting if needed and call different functions. Parameters -------- lhs : NDArray or numeric value Left-hand side operand....
[ "def", "_ufunc_helper", "(", "lhs", ",", "rhs", ",", "fn_array", ",", "fn_scalar", ",", "lfn_scalar", ",", "rfn_scalar", "=", "None", ")", ":", "if", "isinstance", "(", "lhs", ",", "numeric_types", ")", ":", "if", "isinstance", "(", "rhs", ",", "numeric_...
Helper function for element-wise operation. The function will perform numpy-like broadcasting if needed and call different functions. Parameters -------- lhs : NDArray or numeric value Left-hand side operand. rhs : NDArray or numeric value Right-hand operand, fn_array : functi...
[ "Helper", "function", "for", "element", "-", "wise", "operation", ".", "The", "function", "will", "perform", "numpy", "-", "like", "broadcasting", "if", "needed", "and", "call", "different", "functions", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2615-L2659
24,036
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
modulo
def modulo(lhs, rhs): """Returns element-wise modulo of the input arrays with broadcasting. Equivalent to ``lhs % rhs`` and ``mx.nd.broadcast_mod(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcasta...
python
def modulo(lhs, rhs): """Returns element-wise modulo of the input arrays with broadcasting. Equivalent to ``lhs % rhs`` and ``mx.nd.broadcast_mod(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcasta...
[ "def", "modulo", "(", "lhs", ",", "rhs", ")", ":", "# pylint: disable= no-member, protected-access", "return", "_ufunc_helper", "(", "lhs", ",", "rhs", ",", "op", ".", "broadcast_mod", ",", "operator", ".", "mod", ",", "_internal", ".", "_mod_scalar", ",", "_i...
Returns element-wise modulo of the input arrays with broadcasting. Equivalent to ``lhs % rhs`` and ``mx.nd.broadcast_mod(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. P...
[ "Returns", "element", "-", "wise", "modulo", "of", "the", "input", "arrays", "with", "broadcasting", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2905-L2958
24,037
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
power
def power(base, exp): """Returns result of first array elements raised to powers from second array, element-wise with broadcasting. Equivalent to ``base ** exp`` and ``mx.nd.broadcast_power(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them h...
python
def power(base, exp): """Returns result of first array elements raised to powers from second array, element-wise with broadcasting. Equivalent to ``base ** exp`` and ``mx.nd.broadcast_power(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them h...
[ "def", "power", "(", "base", ",", "exp", ")", ":", "# pylint: disable= no-member, protected-access", "return", "_ufunc_helper", "(", "base", ",", "exp", ",", "op", ".", "broadcast_power", ",", "operator", ".", "pow", ",", "_internal", ".", "_power_scalar", ",", ...
Returns result of first array elements raised to powers from second array, element-wise with broadcasting. Equivalent to ``base ** exp`` and ``mx.nd.broadcast_power(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the ar...
[ "Returns", "result", "of", "first", "array", "elements", "raised", "to", "powers", "from", "second", "array", "element", "-", "wise", "with", "broadcasting", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2962-L3020
24,038
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
maximum
def maximum(lhs, rhs): """Returns element-wise maximum of the input arrays with broadcasting. Equivalent to ``mx.nd.broadcast_maximum(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a com...
python
def maximum(lhs, rhs): """Returns element-wise maximum of the input arrays with broadcasting. Equivalent to ``mx.nd.broadcast_maximum(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a com...
[ "def", "maximum", "(", "lhs", ",", "rhs", ")", ":", "# pylint: disable= no-member, protected-access", "return", "_ufunc_helper", "(", "lhs", ",", "rhs", ",", "op", ".", "broadcast_maximum", ",", "lambda", "x", ",", "y", ":", "x", "if", "x", ">", "y", "else...
Returns element-wise maximum of the input arrays with broadcasting. Equivalent to ``mx.nd.broadcast_maximum(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ...
[ "Returns", "element", "-", "wise", "maximum", "of", "the", "input", "arrays", "with", "broadcasting", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L3024-L3077
24,039
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
minimum
def minimum(lhs, rhs): """Returns element-wise minimum of the input arrays with broadcasting. Equivalent to ``mx.nd.broadcast_minimum(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a com...
python
def minimum(lhs, rhs): """Returns element-wise minimum of the input arrays with broadcasting. Equivalent to ``mx.nd.broadcast_minimum(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a com...
[ "def", "minimum", "(", "lhs", ",", "rhs", ")", ":", "# pylint: disable= no-member, protected-access", "return", "_ufunc_helper", "(", "lhs", ",", "rhs", ",", "op", ".", "broadcast_minimum", ",", "lambda", "x", ",", "y", ":", "x", "if", "x", "<", "y", "else...
Returns element-wise minimum of the input arrays with broadcasting. Equivalent to ``mx.nd.broadcast_minimum(lhs, rhs)``. .. note:: If the corresponding dimensions of two arrays have the same size or one of them has size 1, then the arrays are broadcastable to a common shape. Parameters ...
[ "Returns", "element", "-", "wise", "minimum", "of", "the", "input", "arrays", "with", "broadcasting", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L3081-L3134
24,040
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
concatenate
def concatenate(arrays, axis=0, always_copy=True): """DEPRECATED, use ``concat`` instead Parameters ---------- arrays : list of `NDArray` Arrays to be concatenate. They must have identical shape except the first dimension. They also must have the same data type. axis : int T...
python
def concatenate(arrays, axis=0, always_copy=True): """DEPRECATED, use ``concat`` instead Parameters ---------- arrays : list of `NDArray` Arrays to be concatenate. They must have identical shape except the first dimension. They also must have the same data type. axis : int T...
[ "def", "concatenate", "(", "arrays", ",", "axis", "=", "0", ",", "always_copy", "=", "True", ")", ":", "assert", "isinstance", "(", "arrays", ",", "list", ")", "assert", "len", "(", "arrays", ")", ">", "0", "assert", "isinstance", "(", "arrays", "[", ...
DEPRECATED, use ``concat`` instead Parameters ---------- arrays : list of `NDArray` Arrays to be concatenate. They must have identical shape except the first dimension. They also must have the same data type. axis : int The axis along which to concatenate. always_copy : bool...
[ "DEPRECATED", "use", "concat", "instead" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L3705-L3759
24,041
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
imdecode
def imdecode(str_img, clip_rect=(0, 0, 0, 0), out=None, index=0, channels=3, mean=None): """DEPRECATED, use mx.img instead Parameters ---------- str_img : str Binary image data clip_rect : iterable of 4 int Clip decoded image to rectangle (x0, y0, x1, y1). out : NDArray ...
python
def imdecode(str_img, clip_rect=(0, 0, 0, 0), out=None, index=0, channels=3, mean=None): """DEPRECATED, use mx.img instead Parameters ---------- str_img : str Binary image data clip_rect : iterable of 4 int Clip decoded image to rectangle (x0, y0, x1, y1). out : NDArray ...
[ "def", "imdecode", "(", "str_img", ",", "clip_rect", "=", "(", "0", ",", "0", ",", "0", ",", "0", ")", ",", "out", "=", "None", ",", "index", "=", "0", ",", "channels", "=", "3", ",", "mean", "=", "None", ")", ":", "# pylint: disable= no-member, pr...
DEPRECATED, use mx.img instead Parameters ---------- str_img : str Binary image data clip_rect : iterable of 4 int Clip decoded image to rectangle (x0, y0, x1, y1). out : NDArray Output buffer. Can be 3 dimensional (c, h, w) or 4 dimensional (n, c, h, w). index : int ...
[ "DEPRECATED", "use", "mx", ".", "img", "instead" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L3763-L3802
24,042
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
zeros
def zeros(shape, ctx=None, dtype=None, **kwargs): """Returns a new array filled with all zeros, with the given shape and type. Parameters ---------- shape : int or tuple of int The shape of the empty array. ctx : Context, optional An optional device context (default is the current d...
python
def zeros(shape, ctx=None, dtype=None, **kwargs): """Returns a new array filled with all zeros, with the given shape and type. Parameters ---------- shape : int or tuple of int The shape of the empty array. ctx : Context, optional An optional device context (default is the current d...
[ "def", "zeros", "(", "shape", ",", "ctx", "=", "None", ",", "dtype", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable= unused-argument", "if", "ctx", "is", "None", ":", "ctx", "=", "current_context", "(", ")", "dtype", "=", "mx_real_t",...
Returns a new array filled with all zeros, with the given shape and type. Parameters ---------- shape : int or tuple of int The shape of the empty array. ctx : Context, optional An optional device context (default is the current default context). dtype : str or numpy.dtype, optional...
[ "Returns", "a", "new", "array", "filled", "with", "all", "zeros", "with", "the", "given", "shape", "and", "type", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L3805-L3838
24,043
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
eye
def eye(N, M=0, k=0, ctx=None, dtype=None, **kwargs): """Return a 2-D array with ones on the diagonal and zeros elsewhere. Parameters ---------- N: int Number of rows in the output. M: int, optional Number of columns in the output. If 0, defaults to N. k: int, optional I...
python
def eye(N, M=0, k=0, ctx=None, dtype=None, **kwargs): """Return a 2-D array with ones on the diagonal and zeros elsewhere. Parameters ---------- N: int Number of rows in the output. M: int, optional Number of columns in the output. If 0, defaults to N. k: int, optional I...
[ "def", "eye", "(", "N", ",", "M", "=", "0", ",", "k", "=", "0", ",", "ctx", "=", "None", ",", "dtype", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# pylint: disable= unused-argument", "if", "ctx", "is", "None", ":", "ctx", "=", "current_contex...
Return a 2-D array with ones on the diagonal and zeros elsewhere. Parameters ---------- N: int Number of rows in the output. M: int, optional Number of columns in the output. If 0, defaults to N. k: int, optional Index of the diagonal: 0 (the default) refers to the main diag...
[ "Return", "a", "2", "-", "D", "array", "with", "ones", "on", "the", "diagonal", "and", "zeros", "elsewhere", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L3841-L3880
24,044
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
to_dlpack_for_read
def to_dlpack_for_read(data): """Returns a reference view of NDArray that represents as DLManagedTensor until all previous write operations on the current array are finished. Parameters ---------- data: NDArray input data. Returns ------- PyCapsule (the pointer of DLManagedT...
python
def to_dlpack_for_read(data): """Returns a reference view of NDArray that represents as DLManagedTensor until all previous write operations on the current array are finished. Parameters ---------- data: NDArray input data. Returns ------- PyCapsule (the pointer of DLManagedT...
[ "def", "to_dlpack_for_read", "(", "data", ")", ":", "data", ".", "wait_to_read", "(", ")", "dlpack", "=", "DLPackHandle", "(", ")", "check_call", "(", "_LIB", ".", "MXNDArrayToDLPack", "(", "data", ".", "handle", ",", "ctypes", ".", "byref", "(", "dlpack",...
Returns a reference view of NDArray that represents as DLManagedTensor until all previous write operations on the current array are finished. Parameters ---------- data: NDArray input data. Returns ------- PyCapsule (the pointer of DLManagedTensor) a reference view of ND...
[ "Returns", "a", "reference", "view", "of", "NDArray", "that", "represents", "as", "DLManagedTensor", "until", "all", "previous", "write", "operations", "on", "the", "current", "array", "are", "finished", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L4007-L4036
24,045
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
from_dlpack
def from_dlpack(dlpack): """Returns a NDArray backed by a dlpack tensor. Parameters ---------- dlpack: PyCapsule (the pointer of DLManagedTensor) input data Returns ------- NDArray a NDArray backed by a dlpack tensor Examples -------- >>> x = mx.nd.ones((2,3)) ...
python
def from_dlpack(dlpack): """Returns a NDArray backed by a dlpack tensor. Parameters ---------- dlpack: PyCapsule (the pointer of DLManagedTensor) input data Returns ------- NDArray a NDArray backed by a dlpack tensor Examples -------- >>> x = mx.nd.ones((2,3)) ...
[ "def", "from_dlpack", "(", "dlpack", ")", ":", "handle", "=", "NDArrayHandle", "(", ")", "dlpack", "=", "ctypes", ".", "py_object", "(", "dlpack", ")", "assert", "ctypes", ".", "pythonapi", ".", "PyCapsule_IsValid", "(", "dlpack", ",", "_c_str_dltensor", ")"...
Returns a NDArray backed by a dlpack tensor. Parameters ---------- dlpack: PyCapsule (the pointer of DLManagedTensor) input data Returns ------- NDArray a NDArray backed by a dlpack tensor Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = mx.nd.to_dlpack_for_...
[ "Returns", "a", "NDArray", "backed", "by", "a", "dlpack", "tensor", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L4070-L4117
24,046
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
from_numpy
def from_numpy(ndarray, zero_copy=True): """Returns an MXNet's NDArray backed by Numpy's ndarray. Parameters ---------- ndarray: numpy.ndarray input data zero_copy: bool Whether we use DLPack's zero-copy conversion to convert to MXNet's NDArray. This is only available for c...
python
def from_numpy(ndarray, zero_copy=True): """Returns an MXNet's NDArray backed by Numpy's ndarray. Parameters ---------- ndarray: numpy.ndarray input data zero_copy: bool Whether we use DLPack's zero-copy conversion to convert to MXNet's NDArray. This is only available for c...
[ "def", "from_numpy", "(", "ndarray", ",", "zero_copy", "=", "True", ")", ":", "def", "_make_manager_ctx", "(", "obj", ")", ":", "pyobj", "=", "ctypes", ".", "py_object", "(", "obj", ")", "void_p", "=", "ctypes", ".", "c_void_p", ".", "from_buffer", "(", ...
Returns an MXNet's NDArray backed by Numpy's ndarray. Parameters ---------- ndarray: numpy.ndarray input data zero_copy: bool Whether we use DLPack's zero-copy conversion to convert to MXNet's NDArray. This is only available for c-contiguous arrays, i.e. array.flags[C_CONTIGUOU...
[ "Returns", "an", "MXNet", "s", "NDArray", "backed", "by", "Numpy", "s", "ndarray", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L4167-L4222
24,047
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
NDArray._prepare_value_nd
def _prepare_value_nd(self, value, vshape): """Given value and vshape, create an `NDArray` from value with the same context and dtype as the current one and broadcast it to vshape.""" if isinstance(value, numeric_types): value_nd = full(shape=vshape, val=value, ctx=self.context, dtyp...
python
def _prepare_value_nd(self, value, vshape): """Given value and vshape, create an `NDArray` from value with the same context and dtype as the current one and broadcast it to vshape.""" if isinstance(value, numeric_types): value_nd = full(shape=vshape, val=value, ctx=self.context, dtyp...
[ "def", "_prepare_value_nd", "(", "self", ",", "value", ",", "vshape", ")", ":", "if", "isinstance", "(", "value", ",", "numeric_types", ")", ":", "value_nd", "=", "full", "(", "shape", "=", "vshape", ",", "val", "=", "value", ",", "ctx", "=", "self", ...
Given value and vshape, create an `NDArray` from value with the same context and dtype as the current one and broadcast it to vshape.
[ "Given", "value", "and", "vshape", "create", "an", "NDArray", "from", "value", "with", "the", "same", "context", "and", "dtype", "as", "the", "current", "one", "and", "broadcast", "it", "to", "vshape", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L664-L681
24,048
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
NDArray.broadcast_to
def broadcast_to(self, shape): """Broadcasts the input array to a new shape. Broadcasting is only allowed on axes with size 1. The new shape cannot change the number of dimensions. For example, you could broadcast from shape (2, 1) to (2, 3), but not from shape (2, 3) to (2, 3, ...
python
def broadcast_to(self, shape): """Broadcasts the input array to a new shape. Broadcasting is only allowed on axes with size 1. The new shape cannot change the number of dimensions. For example, you could broadcast from shape (2, 1) to (2, 3), but not from shape (2, 3) to (2, 3, ...
[ "def", "broadcast_to", "(", "self", ",", "shape", ")", ":", "cur_shape", "=", "self", ".", "shape", "err_str", "=", "'operands could not be broadcast together with remapped shapes'", "'[original->remapped]: {} and requested shape {}'", ".", "format", "(", "cur_shape", ",", ...
Broadcasts the input array to a new shape. Broadcasting is only allowed on axes with size 1. The new shape cannot change the number of dimensions. For example, you could broadcast from shape (2, 1) to (2, 3), but not from shape (2, 3) to (2, 3, 3). Parameters ----------...
[ "Broadcasts", "the", "input", "array", "to", "a", "new", "shape", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L1710-L1759
24,049
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
NDArray.shape
def shape(self): """Tuple of array dimensions. Examples -------- >>> x = mx.nd.array([1, 2, 3, 4]) >>> x.shape (4L,) >>> y = mx.nd.zeros((2, 3, 4)) >>> y.shape (2L, 3L, 4L) """ ndim = mx_int() pdata = ctypes.POINTER(mx_int)...
python
def shape(self): """Tuple of array dimensions. Examples -------- >>> x = mx.nd.array([1, 2, 3, 4]) >>> x.shape (4L,) >>> y = mx.nd.zeros((2, 3, 4)) >>> y.shape (2L, 3L, 4L) """ ndim = mx_int() pdata = ctypes.POINTER(mx_int)...
[ "def", "shape", "(", "self", ")", ":", "ndim", "=", "mx_int", "(", ")", "pdata", "=", "ctypes", ".", "POINTER", "(", "mx_int", ")", "(", ")", "check_call", "(", "_LIB", ".", "MXNDArrayGetShapeEx", "(", "self", ".", "handle", ",", "ctypes", ".", "byre...
Tuple of array dimensions. Examples -------- >>> x = mx.nd.array([1, 2, 3, 4]) >>> x.shape (4L,) >>> y = mx.nd.zeros((2, 3, 4)) >>> y.shape (2L, 3L, 4L)
[ "Tuple", "of", "array", "dimensions", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L1836-L1855
24,050
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
NDArray.context
def context(self): """Device context of the array. Examples -------- >>> x = mx.nd.array([1, 2, 3, 4]) >>> x.context cpu(0) >>> type(x.context) <class 'mxnet.context.Context'> >>> y = mx.nd.zeros((2,3), mx.gpu(0)) >>> y.context gpu...
python
def context(self): """Device context of the array. Examples -------- >>> x = mx.nd.array([1, 2, 3, 4]) >>> x.context cpu(0) >>> type(x.context) <class 'mxnet.context.Context'> >>> y = mx.nd.zeros((2,3), mx.gpu(0)) >>> y.context gpu...
[ "def", "context", "(", "self", ")", ":", "dev_typeid", "=", "ctypes", ".", "c_int", "(", ")", "dev_id", "=", "ctypes", ".", "c_int", "(", ")", "check_call", "(", "_LIB", ".", "MXNDArrayGetContext", "(", "self", ".", "handle", ",", "ctypes", ".", "byref...
Device context of the array. Examples -------- >>> x = mx.nd.array([1, 2, 3, 4]) >>> x.context cpu(0) >>> type(x.context) <class 'mxnet.context.Context'> >>> y = mx.nd.zeros((2,3), mx.gpu(0)) >>> y.context gpu(0)
[ "Device", "context", "of", "the", "array", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L1879-L1897
24,051
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
NDArray.dtype
def dtype(self): """Data-type of the array's elements. Returns ------- numpy.dtype This NDArray's data type. Examples -------- >>> x = mx.nd.zeros((2,3)) >>> x.dtype <type 'numpy.float32'> >>> y = mx.nd.zeros((2,3), dtype='int...
python
def dtype(self): """Data-type of the array's elements. Returns ------- numpy.dtype This NDArray's data type. Examples -------- >>> x = mx.nd.zeros((2,3)) >>> x.dtype <type 'numpy.float32'> >>> y = mx.nd.zeros((2,3), dtype='int...
[ "def", "dtype", "(", "self", ")", ":", "mx_dtype", "=", "ctypes", ".", "c_int", "(", ")", "check_call", "(", "_LIB", ".", "MXNDArrayGetDType", "(", "self", ".", "handle", ",", "ctypes", ".", "byref", "(", "mx_dtype", ")", ")", ")", "return", "_DTYPE_MX...
Data-type of the array's elements. Returns ------- numpy.dtype This NDArray's data type. Examples -------- >>> x = mx.nd.zeros((2,3)) >>> x.dtype <type 'numpy.float32'> >>> y = mx.nd.zeros((2,3), dtype='int32') >>> y.dtype ...
[ "Data", "-", "type", "of", "the", "array", "s", "elements", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L1900-L1920
24,052
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
NDArray.asnumpy
def asnumpy(self): """Returns a ``numpy.ndarray`` object with value copied from this array. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = x.asnumpy() >>> type(y) <type 'numpy.ndarray'> >>> y array([[ 1., 1., 1.], [ 1., 1., ...
python
def asnumpy(self): """Returns a ``numpy.ndarray`` object with value copied from this array. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = x.asnumpy() >>> type(y) <type 'numpy.ndarray'> >>> y array([[ 1., 1., 1.], [ 1., 1., ...
[ "def", "asnumpy", "(", "self", ")", ":", "data", "=", "np", ".", "empty", "(", "self", ".", "shape", ",", "dtype", "=", "self", ".", "dtype", ")", "check_call", "(", "_LIB", ".", "MXNDArraySyncCopyToCPU", "(", "self", ".", "handle", ",", "data", ".",...
Returns a ``numpy.ndarray`` object with value copied from this array. Examples -------- >>> x = mx.nd.ones((2,3)) >>> y = x.asnumpy() >>> type(y) <type 'numpy.ndarray'> >>> y array([[ 1., 1., 1.], [ 1., 1., 1.]], dtype=float32) ...
[ "Returns", "a", "numpy", ".", "ndarray", "object", "with", "value", "copied", "from", "this", "array", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L1974-L1996
24,053
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
NDArray.astype
def astype(self, dtype, copy=True): """Returns a copy of the array after casting to a specified type. Parameters ---------- dtype : numpy.dtype or str The type of the returned array. copy : bool Default `True`. By default, astype always returns a newly ...
python
def astype(self, dtype, copy=True): """Returns a copy of the array after casting to a specified type. Parameters ---------- dtype : numpy.dtype or str The type of the returned array. copy : bool Default `True`. By default, astype always returns a newly ...
[ "def", "astype", "(", "self", ",", "dtype", ",", "copy", "=", "True", ")", ":", "if", "not", "copy", "and", "np", ".", "dtype", "(", "dtype", ")", "==", "self", ".", "dtype", ":", "return", "self", "res", "=", "empty", "(", "self", ".", "shape", ...
Returns a copy of the array after casting to a specified type. Parameters ---------- dtype : numpy.dtype or str The type of the returned array. copy : bool Default `True`. By default, astype always returns a newly allocated ndarray on the same context...
[ "Returns", "a", "copy", "of", "the", "array", "after", "casting", "to", "a", "specified", "type", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2015-L2048
24,054
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
NDArray.as_in_context
def as_in_context(self, context): """Returns an array on the target device with the same value as this array. If the target context is the same as ``self.context``, then ``self`` is returned. Otherwise, a copy is made. Parameters ---------- context : Context ...
python
def as_in_context(self, context): """Returns an array on the target device with the same value as this array. If the target context is the same as ``self.context``, then ``self`` is returned. Otherwise, a copy is made. Parameters ---------- context : Context ...
[ "def", "as_in_context", "(", "self", ",", "context", ")", ":", "if", "self", ".", "context", "==", "context", ":", "return", "self", "return", "self", ".", "copyto", "(", "context", ")" ]
Returns an array on the target device with the same value as this array. If the target context is the same as ``self.context``, then ``self`` is returned. Otherwise, a copy is made. Parameters ---------- context : Context The target context. Returns ...
[ "Returns", "an", "array", "on", "the", "target", "device", "with", "the", "same", "value", "as", "this", "array", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2114-L2143
24,055
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
NDArray.attach_grad
def attach_grad(self, grad_req='write', stype=None): """Attach a gradient buffer to this NDArray, so that `backward` can compute gradient with respect to it. Parameters ---------- grad_req : {'write', 'add', 'null'} How gradient will be accumulated. - 'wr...
python
def attach_grad(self, grad_req='write', stype=None): """Attach a gradient buffer to this NDArray, so that `backward` can compute gradient with respect to it. Parameters ---------- grad_req : {'write', 'add', 'null'} How gradient will be accumulated. - 'wr...
[ "def", "attach_grad", "(", "self", ",", "grad_req", "=", "'write'", ",", "stype", "=", "None", ")", ":", "from", ".", "import", "zeros", "as", "_zeros", "if", "stype", "is", "not", "None", ":", "grad", "=", "_zeros", "(", "self", ".", "shape", ",", ...
Attach a gradient buffer to this NDArray, so that `backward` can compute gradient with respect to it. Parameters ---------- grad_req : {'write', 'add', 'null'} How gradient will be accumulated. - 'write': gradient will be overwritten on every backward. ...
[ "Attach", "a", "gradient", "buffer", "to", "this", "NDArray", "so", "that", "backward", "can", "compute", "gradient", "with", "respect", "to", "it", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2145-L2168
24,056
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
NDArray.grad
def grad(self): """Returns gradient buffer attached to this NDArray.""" from . import _ndarray_cls hdl = NDArrayHandle() check_call(_LIB.MXNDArrayGetGrad(self.handle, ctypes.byref(hdl))) if hdl.value is None: return None return _ndarray_cls(hdl)
python
def grad(self): """Returns gradient buffer attached to this NDArray.""" from . import _ndarray_cls hdl = NDArrayHandle() check_call(_LIB.MXNDArrayGetGrad(self.handle, ctypes.byref(hdl))) if hdl.value is None: return None return _ndarray_cls(hdl)
[ "def", "grad", "(", "self", ")", ":", "from", ".", "import", "_ndarray_cls", "hdl", "=", "NDArrayHandle", "(", ")", "check_call", "(", "_LIB", ".", "MXNDArrayGetGrad", "(", "self", ".", "handle", ",", "ctypes", ".", "byref", "(", "hdl", ")", ")", ")", ...
Returns gradient buffer attached to this NDArray.
[ "Returns", "gradient", "buffer", "attached", "to", "this", "NDArray", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2171-L2178
24,057
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
NDArray.detach
def detach(self): """Returns a new NDArray, detached from the current graph.""" from . import _ndarray_cls hdl = NDArrayHandle() check_call(_LIB.MXNDArrayDetach(self.handle, ctypes.byref(hdl))) return _ndarray_cls(hdl)
python
def detach(self): """Returns a new NDArray, detached from the current graph.""" from . import _ndarray_cls hdl = NDArrayHandle() check_call(_LIB.MXNDArrayDetach(self.handle, ctypes.byref(hdl))) return _ndarray_cls(hdl)
[ "def", "detach", "(", "self", ")", ":", "from", ".", "import", "_ndarray_cls", "hdl", "=", "NDArrayHandle", "(", ")", "check_call", "(", "_LIB", ".", "MXNDArrayDetach", "(", "self", ".", "handle", ",", "ctypes", ".", "byref", "(", "hdl", ")", ")", ")",...
Returns a new NDArray, detached from the current graph.
[ "Returns", "a", "new", "NDArray", "detached", "from", "the", "current", "graph", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2180-L2185
24,058
apache/incubator-mxnet
python/mxnet/ndarray/ndarray.py
NDArray.backward
def backward(self, out_grad=None, retain_graph=False, train_mode=True): """Compute the gradients of this NDArray w.r.t variables. Parameters ---------- out_grad : NDArray, optional Gradient with respect to head. retain_graph : bool, optional Whether to re...
python
def backward(self, out_grad=None, retain_graph=False, train_mode=True): """Compute the gradients of this NDArray w.r.t variables. Parameters ---------- out_grad : NDArray, optional Gradient with respect to head. retain_graph : bool, optional Whether to re...
[ "def", "backward", "(", "self", ",", "out_grad", "=", "None", ",", "retain_graph", "=", "False", ",", "train_mode", "=", "True", ")", ":", "if", "out_grad", "is", "None", ":", "ograd_handles", "=", "[", "NDArrayHandle", "(", "0", ")", "]", "else", ":",...
Compute the gradients of this NDArray w.r.t variables. Parameters ---------- out_grad : NDArray, optional Gradient with respect to head. retain_graph : bool, optional Whether to retain the computaion graph for another backward pass on the same graph. ...
[ "Compute", "the", "gradients", "of", "this", "NDArray", "w", ".", "r", ".", "t", "variables", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2187-L2215
24,059
apache/incubator-mxnet
example/gluon/lipnet/utils/align.py
Align.build
def build(self, align_path): """ Build the align array """ file = open(align_path, 'r') lines = file.readlines() file.close() # words: list([op, ed, word]) words = [] for line in lines: _op, _ed, word = line.strip().split(' ') ...
python
def build(self, align_path): """ Build the align array """ file = open(align_path, 'r') lines = file.readlines() file.close() # words: list([op, ed, word]) words = [] for line in lines: _op, _ed, word = line.strip().split(' ') ...
[ "def", "build", "(", "self", ",", "align_path", ")", ":", "file", "=", "open", "(", "align_path", ",", "'r'", ")", "lines", "=", "file", ".", "readlines", "(", ")", "file", ".", "close", "(", ")", "# words: list([op, ed, word])", "words", "=", "[", "]"...
Build the align array
[ "Build", "the", "align", "array" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/utils/align.py#L36-L52
24,060
apache/incubator-mxnet
example/gluon/lipnet/utils/align.py
Align.word_frame_pos
def word_frame_pos(self, _id): """ Get the position of words """ left = int(self.words[_id][0]/1000) right = max(left+1, int(self.words[_id][1]/1000)) return (left, right)
python
def word_frame_pos(self, _id): """ Get the position of words """ left = int(self.words[_id][0]/1000) right = max(left+1, int(self.words[_id][1]/1000)) return (left, right)
[ "def", "word_frame_pos", "(", "self", ",", "_id", ")", ":", "left", "=", "int", "(", "self", ".", "words", "[", "_id", "]", "[", "0", "]", "/", "1000", ")", "right", "=", "max", "(", "left", "+", "1", ",", "int", "(", "self", ".", "words", "[...
Get the position of words
[ "Get", "the", "position", "of", "words" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/utils/align.py#L77-L83
24,061
apache/incubator-mxnet
example/rnn/large_word_lm/custom_module.py
CustomModule.prepare_sparse_params
def prepare_sparse_params(self, param_rowids): '''Prepares the module for processing a data batch by pulling row_sparse parameters from kvstore to all devices based on rowids. Parameters ---------- param_rowids : dict of str to NDArray of list of NDArrays ''' if ...
python
def prepare_sparse_params(self, param_rowids): '''Prepares the module for processing a data batch by pulling row_sparse parameters from kvstore to all devices based on rowids. Parameters ---------- param_rowids : dict of str to NDArray of list of NDArrays ''' if ...
[ "def", "prepare_sparse_params", "(", "self", ",", "param_rowids", ")", ":", "if", "not", "self", ".", "_kvstore", ":", "return", "assert", "(", "isinstance", "(", "param_rowids", ",", "dict", ")", ")", "for", "param_name", ",", "rowids", "in", "param_rowids"...
Prepares the module for processing a data batch by pulling row_sparse parameters from kvstore to all devices based on rowids. Parameters ---------- param_rowids : dict of str to NDArray of list of NDArrays
[ "Prepares", "the", "module", "for", "processing", "a", "data", "batch", "by", "pulling", "row_sparse", "parameters", "from", "kvstore", "to", "all", "devices", "based", "on", "rowids", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/large_word_lm/custom_module.py#L38-L60
24,062
apache/incubator-mxnet
example/rnn/large_word_lm/custom_module.py
CustomModule.rescale_grad
def rescale_grad(self, scale=None, param_name=None): """ Rescale the gradient of provided parameters by a certain scale """ if scale is None or param_name is None: return param_idx = self._exec_group.param_names.index(param_name) grad_vals = self._exec_group.grad_arrays[param...
python
def rescale_grad(self, scale=None, param_name=None): """ Rescale the gradient of provided parameters by a certain scale """ if scale is None or param_name is None: return param_idx = self._exec_group.param_names.index(param_name) grad_vals = self._exec_group.grad_arrays[param...
[ "def", "rescale_grad", "(", "self", ",", "scale", "=", "None", ",", "param_name", "=", "None", ")", ":", "if", "scale", "is", "None", "or", "param_name", "is", "None", ":", "return", "param_idx", "=", "self", ".", "_exec_group", ".", "param_names", ".", ...
Rescale the gradient of provided parameters by a certain scale
[ "Rescale", "the", "gradient", "of", "provided", "parameters", "by", "a", "certain", "scale" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/large_word_lm/custom_module.py#L176-L183
24,063
apache/incubator-mxnet
python/mxnet/symbol_doc.py
_build_doc
def _build_doc(func_name, desc, arg_names, arg_types, arg_desc, key_var_num_args=None, ret_type=None): """Build docstring for symbolic functions.""" param_str = _build_param_doc(arg_names, arg_types, arg_desc) if key_v...
python
def _build_doc(func_name, desc, arg_names, arg_types, arg_desc, key_var_num_args=None, ret_type=None): """Build docstring for symbolic functions.""" param_str = _build_param_doc(arg_names, arg_types, arg_desc) if key_v...
[ "def", "_build_doc", "(", "func_name", ",", "desc", ",", "arg_names", ",", "arg_types", ",", "arg_desc", ",", "key_var_num_args", "=", "None", ",", "ret_type", "=", "None", ")", ":", "param_str", "=", "_build_param_doc", "(", "arg_names", ",", "arg_types", "...
Build docstring for symbolic functions.
[ "Build", "docstring", "for", "symbolic", "functions", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol_doc.py#L212-L236
24,064
apache/incubator-mxnet
python/mxnet/symbol_doc.py
SymbolDoc.get_output_shape
def get_output_shape(sym, **input_shapes): """Get user friendly information of the output shapes.""" _, s_outputs, _ = sym.infer_shape(**input_shapes) return dict(zip(sym.list_outputs(), s_outputs))
python
def get_output_shape(sym, **input_shapes): """Get user friendly information of the output shapes.""" _, s_outputs, _ = sym.infer_shape(**input_shapes) return dict(zip(sym.list_outputs(), s_outputs))
[ "def", "get_output_shape", "(", "sym", ",", "*", "*", "input_shapes", ")", ":", "_", ",", "s_outputs", ",", "_", "=", "sym", ".", "infer_shape", "(", "*", "*", "input_shapes", ")", "return", "dict", "(", "zip", "(", "sym", ".", "list_outputs", "(", "...
Get user friendly information of the output shapes.
[ "Get", "user", "friendly", "information", "of", "the", "output", "shapes", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol_doc.py#L56-L59
24,065
apache/incubator-mxnet
python/mxnet/context.py
num_gpus
def num_gpus(): """Query CUDA for the number of GPUs present. Raises ------ Will raise an exception on any CUDA error. Returns ------- count : int The number of GPUs. """ count = ctypes.c_int() check_call(_LIB.MXGetGPUCount(ctypes.byref(count))) return count.value
python
def num_gpus(): """Query CUDA for the number of GPUs present. Raises ------ Will raise an exception on any CUDA error. Returns ------- count : int The number of GPUs. """ count = ctypes.c_int() check_call(_LIB.MXGetGPUCount(ctypes.byref(count))) return count.value
[ "def", "num_gpus", "(", ")", ":", "count", "=", "ctypes", ".", "c_int", "(", ")", "check_call", "(", "_LIB", ".", "MXGetGPUCount", "(", "ctypes", ".", "byref", "(", "count", ")", ")", ")", "return", "count", ".", "value" ]
Query CUDA for the number of GPUs present. Raises ------ Will raise an exception on any CUDA error. Returns ------- count : int The number of GPUs.
[ "Query", "CUDA", "for", "the", "number", "of", "GPUs", "present", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/context.py#L244-L259
24,066
apache/incubator-mxnet
python/mxnet/context.py
gpu_memory_info
def gpu_memory_info(device_id=0): """Query CUDA for the free and total bytes of GPU global memory. Parameters ---------- device_id : int, optional The device id of the GPU device. Raises ------ Will raise an exception on any CUDA error. Returns ------- (free, total) : ...
python
def gpu_memory_info(device_id=0): """Query CUDA for the free and total bytes of GPU global memory. Parameters ---------- device_id : int, optional The device id of the GPU device. Raises ------ Will raise an exception on any CUDA error. Returns ------- (free, total) : ...
[ "def", "gpu_memory_info", "(", "device_id", "=", "0", ")", ":", "free", "=", "ctypes", ".", "c_uint64", "(", ")", "total", "=", "ctypes", ".", "c_uint64", "(", ")", "dev_id", "=", "ctypes", ".", "c_int", "(", "device_id", ")", "check_call", "(", "_LIB"...
Query CUDA for the free and total bytes of GPU global memory. Parameters ---------- device_id : int, optional The device id of the GPU device. Raises ------ Will raise an exception on any CUDA error. Returns ------- (free, total) : (int, int) The number of GPUs.
[ "Query", "CUDA", "for", "the", "free", "and", "total", "bytes", "of", "GPU", "global", "memory", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/context.py#L261-L283
24,067
apache/incubator-mxnet
python/mxnet/context.py
current_context
def current_context(): """Returns the current context. By default, `mx.cpu()` is used for all the computations and it can be overridden by using `with mx.Context(x)` statement where x can be cpu(device_id) or gpu(device_id). Examples ------- >>> mx.current_context() cpu(0) >>> with...
python
def current_context(): """Returns the current context. By default, `mx.cpu()` is used for all the computations and it can be overridden by using `with mx.Context(x)` statement where x can be cpu(device_id) or gpu(device_id). Examples ------- >>> mx.current_context() cpu(0) >>> with...
[ "def", "current_context", "(", ")", ":", "if", "not", "hasattr", "(", "Context", ".", "_default_ctx", ",", "\"value\"", ")", ":", "Context", ".", "_default_ctx", ".", "value", "=", "Context", "(", "'cpu'", ",", "0", ")", "return", "Context", ".", "_defau...
Returns the current context. By default, `mx.cpu()` is used for all the computations and it can be overridden by using `with mx.Context(x)` statement where x can be cpu(device_id) or gpu(device_id). Examples ------- >>> mx.current_context() cpu(0) >>> with mx.Context('gpu', 1): # Cont...
[ "Returns", "the", "current", "context", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/context.py#L285-L309
24,068
apache/incubator-mxnet
python/setup.py
config_cython
def config_cython(): """Try to configure cython and return cython configuration""" if not with_cython: return [] # pylint: disable=unreachable if os.name == 'nt': print("WARNING: Cython is not supported on Windows, will compile without cython module") return [] try: ...
python
def config_cython(): """Try to configure cython and return cython configuration""" if not with_cython: return [] # pylint: disable=unreachable if os.name == 'nt': print("WARNING: Cython is not supported on Windows, will compile without cython module") return [] try: ...
[ "def", "config_cython", "(", ")", ":", "if", "not", "with_cython", ":", "return", "[", "]", "# pylint: disable=unreachable", "if", "os", ".", "name", "==", "'nt'", ":", "print", "(", "\"WARNING: Cython is not supported on Windows, will compile without cython module\"", ...
Try to configure cython and return cython configuration
[ "Try", "to", "configure", "cython", "and", "return", "cython", "configuration" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/setup.py#L62-L100
24,069
apache/incubator-mxnet
python/mxnet/_ctypes/symbol.py
SymbolBase._compose
def _compose(self, *args, **kwargs): """Compose symbol on inputs. This call mutates the current symbol. Parameters ---------- args: provide positional arguments kwargs: provide keyword arguments Returns ------- the resul...
python
def _compose(self, *args, **kwargs): """Compose symbol on inputs. This call mutates the current symbol. Parameters ---------- args: provide positional arguments kwargs: provide keyword arguments Returns ------- the resul...
[ "def", "_compose", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "name", "=", "kwargs", ".", "pop", "(", "'name'", ",", "None", ")", "if", "name", ":", "name", "=", "c_str", "(", "name", ")", "if", "len", "(", "args", ")", ...
Compose symbol on inputs. This call mutates the current symbol. Parameters ---------- args: provide positional arguments kwargs: provide keyword arguments Returns ------- the resulting symbol
[ "Compose", "symbol", "on", "inputs", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/_ctypes/symbol.py#L48-L88
24,070
apache/incubator-mxnet
python/mxnet/_ctypes/symbol.py
SymbolBase._set_attr
def _set_attr(self, **kwargs): """Set the attribute of the symbol. Parameters ---------- **kwargs The attributes to set """ keys = c_str_array(kwargs.keys()) vals = c_str_array([str(s) for s in kwargs.values()]) num_args = mx_uint(len(kwargs))...
python
def _set_attr(self, **kwargs): """Set the attribute of the symbol. Parameters ---------- **kwargs The attributes to set """ keys = c_str_array(kwargs.keys()) vals = c_str_array([str(s) for s in kwargs.values()]) num_args = mx_uint(len(kwargs))...
[ "def", "_set_attr", "(", "self", ",", "*", "*", "kwargs", ")", ":", "keys", "=", "c_str_array", "(", "kwargs", ".", "keys", "(", ")", ")", "vals", "=", "c_str_array", "(", "[", "str", "(", "s", ")", "for", "s", "in", "kwargs", ".", "values", "(",...
Set the attribute of the symbol. Parameters ---------- **kwargs The attributes to set
[ "Set", "the", "attribute", "of", "the", "symbol", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/_ctypes/symbol.py#L90-L102
24,071
apache/incubator-mxnet
example/ssd/symbol/symbol_factory.py
get_symbol_train
def get_symbol_train(network, data_shape, **kwargs): """Wrapper for get symbol for train Parameters ---------- network : str name for the base network symbol data_shape : int input shape kwargs : dict see symbol_builder.get_symbol_train for more details """ if ne...
python
def get_symbol_train(network, data_shape, **kwargs): """Wrapper for get symbol for train Parameters ---------- network : str name for the base network symbol data_shape : int input shape kwargs : dict see symbol_builder.get_symbol_train for more details """ if ne...
[ "def", "get_symbol_train", "(", "network", ",", "data_shape", ",", "*", "*", "kwargs", ")", ":", "if", "network", ".", "startswith", "(", "'legacy'", ")", ":", "logging", ".", "warn", "(", "'Using legacy model.'", ")", "return", "symbol_builder", ".", "impor...
Wrapper for get symbol for train Parameters ---------- network : str name for the base network symbol data_shape : int input shape kwargs : dict see symbol_builder.get_symbol_train for more details
[ "Wrapper", "for", "get", "symbol", "for", "train" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/symbol/symbol_factory.py#L103-L120
24,072
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter._set_trainer
def _set_trainer(self, trainer): """ Set the trainer this parameter is associated with. """ # trainer cannot be replaced for sparse params if self._stype != 'default' and self._trainer and trainer and self._trainer is not trainer: raise RuntimeError( "Failed to set th...
python
def _set_trainer(self, trainer): """ Set the trainer this parameter is associated with. """ # trainer cannot be replaced for sparse params if self._stype != 'default' and self._trainer and trainer and self._trainer is not trainer: raise RuntimeError( "Failed to set th...
[ "def", "_set_trainer", "(", "self", ",", "trainer", ")", ":", "# trainer cannot be replaced for sparse params", "if", "self", ".", "_stype", "!=", "'default'", "and", "self", ".", "_trainer", "and", "trainer", "and", "self", ".", "_trainer", "is", "not", "traine...
Set the trainer this parameter is associated with.
[ "Set", "the", "trainer", "this", "parameter", "is", "associated", "with", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L174-L182
24,073
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter._get_row_sparse
def _get_row_sparse(self, arr_list, ctx, row_id): """ Get row_sparse data from row_sparse parameters based on row_id. """ # get row sparse params based on row ids if not isinstance(row_id, ndarray.NDArray): raise TypeError("row_id must have NDArray type, but %s is given"%(type(row_id...
python
def _get_row_sparse(self, arr_list, ctx, row_id): """ Get row_sparse data from row_sparse parameters based on row_id. """ # get row sparse params based on row ids if not isinstance(row_id, ndarray.NDArray): raise TypeError("row_id must have NDArray type, but %s is given"%(type(row_id...
[ "def", "_get_row_sparse", "(", "self", ",", "arr_list", ",", "ctx", ",", "row_id", ")", ":", "# get row sparse params based on row ids", "if", "not", "isinstance", "(", "row_id", ",", "ndarray", ".", "NDArray", ")", ":", "raise", "TypeError", "(", "\"row_id must...
Get row_sparse data from row_sparse parameters based on row_id.
[ "Get", "row_sparse", "data", "from", "row_sparse", "parameters", "based", "on", "row_id", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L216-L228
24,074
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter._finish_deferred_init
def _finish_deferred_init(self): """Finishes deferred initialization.""" if not self._deferred_init: return init, ctx, default_init, data = self._deferred_init self._deferred_init = () assert self.shape is not None and np.prod(self.shape) > 0, \ "Cannot in...
python
def _finish_deferred_init(self): """Finishes deferred initialization.""" if not self._deferred_init: return init, ctx, default_init, data = self._deferred_init self._deferred_init = () assert self.shape is not None and np.prod(self.shape) > 0, \ "Cannot in...
[ "def", "_finish_deferred_init", "(", "self", ")", ":", "if", "not", "self", ".", "_deferred_init", ":", "return", "init", ",", "ctx", ",", "default_init", ",", "data", "=", "self", ".", "_deferred_init", "self", ".", "_deferred_init", "=", "(", ")", "asser...
Finishes deferred initialization.
[ "Finishes", "deferred", "initialization", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L266-L285
24,075
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter._init_impl
def _init_impl(self, data, ctx_list): """Sets data and grad.""" self._ctx_list = list(ctx_list) self._ctx_map = [[], []] for i, ctx in enumerate(self._ctx_list): dev_list = self._ctx_map[ctx.device_typeid&1] while len(dev_list) <= ctx.device_id: de...
python
def _init_impl(self, data, ctx_list): """Sets data and grad.""" self._ctx_list = list(ctx_list) self._ctx_map = [[], []] for i, ctx in enumerate(self._ctx_list): dev_list = self._ctx_map[ctx.device_typeid&1] while len(dev_list) <= ctx.device_id: de...
[ "def", "_init_impl", "(", "self", ",", "data", ",", "ctx_list", ")", ":", "self", ".", "_ctx_list", "=", "list", "(", "ctx_list", ")", "self", ".", "_ctx_map", "=", "[", "[", "]", ",", "[", "]", "]", "for", "i", ",", "ctx", "in", "enumerate", "("...
Sets data and grad.
[ "Sets", "data", "and", "grad", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L287-L298
24,076
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter._init_grad
def _init_grad(self): """Initialize grad buffers.""" if self.grad_req == 'null': self._grad = None return self._grad = [ndarray.zeros(shape=i.shape, dtype=i.dtype, ctx=i.context, stype=self._grad_stype) for i in self._data] au...
python
def _init_grad(self): """Initialize grad buffers.""" if self.grad_req == 'null': self._grad = None return self._grad = [ndarray.zeros(shape=i.shape, dtype=i.dtype, ctx=i.context, stype=self._grad_stype) for i in self._data] au...
[ "def", "_init_grad", "(", "self", ")", ":", "if", "self", ".", "grad_req", "==", "'null'", ":", "self", ".", "_grad", "=", "None", "return", "self", ".", "_grad", "=", "[", "ndarray", ".", "zeros", "(", "shape", "=", "i", ".", "shape", ",", "dtype"...
Initialize grad buffers.
[ "Initialize", "grad", "buffers", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L300-L310
24,077
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter._reduce
def _reduce(self): """Reduce data from multiple context to cpu.""" ctx = context.cpu() if self._stype == 'default': block = self.list_data() data = ndarray.add_n(*(w.copyto(ctx) for w in block)) / len(block) else: # fetch all rows for 'row_sparse' para...
python
def _reduce(self): """Reduce data from multiple context to cpu.""" ctx = context.cpu() if self._stype == 'default': block = self.list_data() data = ndarray.add_n(*(w.copyto(ctx) for w in block)) / len(block) else: # fetch all rows for 'row_sparse' para...
[ "def", "_reduce", "(", "self", ")", ":", "ctx", "=", "context", ".", "cpu", "(", ")", "if", "self", ".", "_stype", "==", "'default'", ":", "block", "=", "self", ".", "list_data", "(", ")", "data", "=", "ndarray", ".", "add_n", "(", "*", "(", "w",...
Reduce data from multiple context to cpu.
[ "Reduce", "data", "from", "multiple", "context", "to", "cpu", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L312-L323
24,078
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter.reset_ctx
def reset_ctx(self, ctx): """Re-assign Parameter to other contexts. Parameters ---------- ctx : Context or list of Context, default ``context.current_context()``. Assign Parameter to given context. If ctx is a list of Context, a copy will be made for each context...
python
def reset_ctx(self, ctx): """Re-assign Parameter to other contexts. Parameters ---------- ctx : Context or list of Context, default ``context.current_context()``. Assign Parameter to given context. If ctx is a list of Context, a copy will be made for each context...
[ "def", "reset_ctx", "(", "self", ",", "ctx", ")", ":", "if", "ctx", "is", "None", ":", "ctx", "=", "[", "context", ".", "current_context", "(", ")", "]", "if", "isinstance", "(", "ctx", ",", "Context", ")", ":", "ctx", "=", "[", "ctx", "]", "if",...
Re-assign Parameter to other contexts. Parameters ---------- ctx : Context or list of Context, default ``context.current_context()``. Assign Parameter to given context. If ctx is a list of Context, a copy will be made for each context.
[ "Re", "-", "assign", "Parameter", "to", "other", "contexts", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L393-L415
24,079
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter.set_data
def set_data(self, data): """Sets this parameter's value on all contexts.""" self.shape = data.shape if self._data is None: assert self._deferred_init, \ "Parameter '%s' has not been initialized"%self.name self._deferred_init = self._deferred_init[:3] + (...
python
def set_data(self, data): """Sets this parameter's value on all contexts.""" self.shape = data.shape if self._data is None: assert self._deferred_init, \ "Parameter '%s' has not been initialized"%self.name self._deferred_init = self._deferred_init[:3] + (...
[ "def", "set_data", "(", "self", ",", "data", ")", ":", "self", ".", "shape", "=", "data", ".", "shape", "if", "self", ".", "_data", "is", "None", ":", "assert", "self", ".", "_deferred_init", ",", "\"Parameter '%s' has not been initialized\"", "%", "self", ...
Sets this parameter's value on all contexts.
[ "Sets", "this", "parameter", "s", "value", "on", "all", "contexts", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L418-L434
24,080
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter.row_sparse_data
def row_sparse_data(self, row_id): """Returns a copy of the 'row_sparse' parameter on the same context as row_id's. The copy only retains rows whose ids occur in provided row ids. The parameter must have been initialized on this context before. Parameters ---------- row_...
python
def row_sparse_data(self, row_id): """Returns a copy of the 'row_sparse' parameter on the same context as row_id's. The copy only retains rows whose ids occur in provided row ids. The parameter must have been initialized on this context before. Parameters ---------- row_...
[ "def", "row_sparse_data", "(", "self", ",", "row_id", ")", ":", "if", "self", ".", "_stype", "!=", "'row_sparse'", ":", "raise", "RuntimeError", "(", "\"Cannot return a copy of Parameter %s via row_sparse_data() \"", "\"because its storage type is %s. Please use data() instead....
Returns a copy of the 'row_sparse' parameter on the same context as row_id's. The copy only retains rows whose ids occur in provided row ids. The parameter must have been initialized on this context before. Parameters ---------- row_id: NDArray Row ids to retain for ...
[ "Returns", "a", "copy", "of", "the", "row_sparse", "parameter", "on", "the", "same", "context", "as", "row_id", "s", ".", "The", "copy", "only", "retains", "rows", "whose", "ids", "occur", "in", "provided", "row", "ids", ".", "The", "parameter", "must", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L436-L454
24,081
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter.list_row_sparse_data
def list_row_sparse_data(self, row_id): """Returns copies of the 'row_sparse' parameter on all contexts, in the same order as creation. The copy only retains rows whose ids occur in provided row ids. The parameter must have been initialized before. Parameters ---------- ...
python
def list_row_sparse_data(self, row_id): """Returns copies of the 'row_sparse' parameter on all contexts, in the same order as creation. The copy only retains rows whose ids occur in provided row ids. The parameter must have been initialized before. Parameters ---------- ...
[ "def", "list_row_sparse_data", "(", "self", ",", "row_id", ")", ":", "if", "self", ".", "_stype", "!=", "'row_sparse'", ":", "raise", "RuntimeError", "(", "\"Cannot return copies of Parameter '%s' on all contexts via \"", "\"list_row_sparse_data() because its storage type is %s...
Returns copies of the 'row_sparse' parameter on all contexts, in the same order as creation. The copy only retains rows whose ids occur in provided row ids. The parameter must have been initialized before. Parameters ---------- row_id: NDArray Row ids to retain for t...
[ "Returns", "copies", "of", "the", "row_sparse", "parameter", "on", "all", "contexts", "in", "the", "same", "order", "as", "creation", ".", "The", "copy", "only", "retains", "rows", "whose", "ids", "occur", "in", "provided", "row", "ids", ".", "The", "param...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L456-L474
24,082
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter.grad
def grad(self, ctx=None): """Returns a gradient buffer for this parameter on one context. Parameters ---------- ctx : Context Desired context. """ if self._data is not None and self._grad is None: raise RuntimeError( "Cannot get gr...
python
def grad(self, ctx=None): """Returns a gradient buffer for this parameter on one context. Parameters ---------- ctx : Context Desired context. """ if self._data is not None and self._grad is None: raise RuntimeError( "Cannot get gr...
[ "def", "grad", "(", "self", ",", "ctx", "=", "None", ")", ":", "if", "self", ".", "_data", "is", "not", "None", "and", "self", ".", "_grad", "is", "None", ":", "raise", "RuntimeError", "(", "\"Cannot get gradient array for Parameter '%s' \"", "\"because grad_r...
Returns a gradient buffer for this parameter on one context. Parameters ---------- ctx : Context Desired context.
[ "Returns", "a", "gradient", "buffer", "for", "this", "parameter", "on", "one", "context", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L511-L523
24,083
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter.list_ctx
def list_ctx(self): """Returns a list of contexts this parameter is initialized on.""" if self._data is None: if self._deferred_init: return self._deferred_init[1] raise RuntimeError("Parameter '%s' has not been initialized"%self.name) return self._ctx_lis...
python
def list_ctx(self): """Returns a list of contexts this parameter is initialized on.""" if self._data is None: if self._deferred_init: return self._deferred_init[1] raise RuntimeError("Parameter '%s' has not been initialized"%self.name) return self._ctx_lis...
[ "def", "list_ctx", "(", "self", ")", ":", "if", "self", ".", "_data", "is", "None", ":", "if", "self", ".", "_deferred_init", ":", "return", "self", ".", "_deferred_init", "[", "1", "]", "raise", "RuntimeError", "(", "\"Parameter '%s' has not been initialized\...
Returns a list of contexts this parameter is initialized on.
[ "Returns", "a", "list", "of", "contexts", "this", "parameter", "is", "initialized", "on", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L534-L540
24,084
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter.zero_grad
def zero_grad(self): """Sets gradient buffer on all contexts to 0. No action is taken if parameter is uninitialized or doesn't require gradient.""" if self._grad is None: return for i in self._grad: ndarray.zeros_like(i, out=i)
python
def zero_grad(self): """Sets gradient buffer on all contexts to 0. No action is taken if parameter is uninitialized or doesn't require gradient.""" if self._grad is None: return for i in self._grad: ndarray.zeros_like(i, out=i)
[ "def", "zero_grad", "(", "self", ")", ":", "if", "self", ".", "_grad", "is", "None", ":", "return", "for", "i", "in", "self", ".", "_grad", ":", "ndarray", ".", "zeros_like", "(", "i", ",", "out", "=", "i", ")" ]
Sets gradient buffer on all contexts to 0. No action is taken if parameter is uninitialized or doesn't require gradient.
[ "Sets", "gradient", "buffer", "on", "all", "contexts", "to", "0", ".", "No", "action", "is", "taken", "if", "parameter", "is", "uninitialized", "or", "doesn", "t", "require", "gradient", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L542-L548
24,085
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter.var
def var(self): """Returns a symbol representing this parameter.""" if self._var is None: self._var = symbol.var(self.name, shape=self.shape, dtype=self.dtype, lr_mult=self.lr_mult, wd_mult=self.wd_mult, init=self.init, sty...
python
def var(self): """Returns a symbol representing this parameter.""" if self._var is None: self._var = symbol.var(self.name, shape=self.shape, dtype=self.dtype, lr_mult=self.lr_mult, wd_mult=self.wd_mult, init=self.init, sty...
[ "def", "var", "(", "self", ")", ":", "if", "self", ".", "_var", "is", "None", ":", "self", ".", "_var", "=", "symbol", ".", "var", "(", "self", ".", "name", ",", "shape", "=", "self", ".", "shape", ",", "dtype", "=", "self", ".", "dtype", ",", ...
Returns a symbol representing this parameter.
[ "Returns", "a", "symbol", "representing", "this", "parameter", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L550-L556
24,086
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
Parameter.cast
def cast(self, dtype): """Cast data and gradient of this Parameter to a new data type. Parameters ---------- dtype : str or numpy.dtype The new data type. """ self.dtype = dtype if self._data is None: return with autograd.pause(): ...
python
def cast(self, dtype): """Cast data and gradient of this Parameter to a new data type. Parameters ---------- dtype : str or numpy.dtype The new data type. """ self.dtype = dtype if self._data is None: return with autograd.pause(): ...
[ "def", "cast", "(", "self", ",", "dtype", ")", ":", "self", ".", "dtype", "=", "dtype", "if", "self", ".", "_data", "is", "None", ":", "return", "with", "autograd", ".", "pause", "(", ")", ":", "self", ".", "_data", "=", "[", "i", ".", "astype", ...
Cast data and gradient of this Parameter to a new data type. Parameters ---------- dtype : str or numpy.dtype The new data type.
[ "Cast", "data", "and", "gradient", "of", "this", "Parameter", "to", "a", "new", "data", "type", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L558-L574
24,087
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
ParameterDict.update
def update(self, other): """Copies all Parameters in ``other`` to self.""" for k, v in other.items(): if k in self._params: assert self._params[k] is v, \ "Cannot update self with other because they have different " \ "Parameters with t...
python
def update(self, other): """Copies all Parameters in ``other`` to self.""" for k, v in other.items(): if k in self._params: assert self._params[k] is v, \ "Cannot update self with other because they have different " \ "Parameters with t...
[ "def", "update", "(", "self", ",", "other", ")", ":", "for", "k", ",", "v", "in", "other", ".", "items", "(", ")", ":", "if", "k", "in", "self", ".", "_params", ":", "assert", "self", ".", "_params", "[", "k", "]", "is", "v", ",", "\"Cannot upd...
Copies all Parameters in ``other`` to self.
[ "Copies", "all", "Parameters", "in", "other", "to", "self", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L782-L791
24,088
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
ParameterDict.setattr
def setattr(self, name, value): """Set an attribute to a new value for all Parameters. For example, set grad_req to null if you don't need gradient w.r.t a model's Parameters:: model.collect_params().setattr('grad_req', 'null') or change the learning rate multiplier:: ...
python
def setattr(self, name, value): """Set an attribute to a new value for all Parameters. For example, set grad_req to null if you don't need gradient w.r.t a model's Parameters:: model.collect_params().setattr('grad_req', 'null') or change the learning rate multiplier:: ...
[ "def", "setattr", "(", "self", ",", "name", ",", "value", ")", ":", "for", "i", "in", "self", ".", "values", "(", ")", ":", "setattr", "(", "i", ",", "name", ",", "value", ")" ]
Set an attribute to a new value for all Parameters. For example, set grad_req to null if you don't need gradient w.r.t a model's Parameters:: model.collect_params().setattr('grad_req', 'null') or change the learning rate multiplier:: model.collect_params().setattr('lr...
[ "Set", "an", "attribute", "to", "a", "new", "value", "for", "all", "Parameters", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L832-L852
24,089
apache/incubator-mxnet
python/mxnet/gluon/parameter.py
ParameterDict.save
def save(self, filename, strip_prefix=''): """Save parameters to file. Parameters ---------- filename : str Path to parameter file. strip_prefix : str, default '' Strip prefix from parameter names before saving. """ arg_dict = {} f...
python
def save(self, filename, strip_prefix=''): """Save parameters to file. Parameters ---------- filename : str Path to parameter file. strip_prefix : str, default '' Strip prefix from parameter names before saving. """ arg_dict = {} f...
[ "def", "save", "(", "self", ",", "filename", ",", "strip_prefix", "=", "''", ")", ":", "arg_dict", "=", "{", "}", "for", "param", "in", "self", ".", "values", "(", ")", ":", "weight", "=", "param", ".", "_reduce", "(", ")", "if", "not", "param", ...
Save parameters to file. Parameters ---------- filename : str Path to parameter file. strip_prefix : str, default '' Strip prefix from parameter names before saving.
[ "Save", "parameters", "to", "file", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/parameter.py#L854-L877
24,090
apache/incubator-mxnet
python/mxnet/torch.py
_init_torch_module
def _init_torch_module(): """List and add all the torch backed ndarray functions to current module.""" plist = ctypes.POINTER(FunctionHandle)() size = ctypes.c_uint() check_call(_LIB.MXListFunctions(ctypes.byref(size), ctypes.byref(plist))) module_obj = sys.modul...
python
def _init_torch_module(): """List and add all the torch backed ndarray functions to current module.""" plist = ctypes.POINTER(FunctionHandle)() size = ctypes.c_uint() check_call(_LIB.MXListFunctions(ctypes.byref(size), ctypes.byref(plist))) module_obj = sys.modul...
[ "def", "_init_torch_module", "(", ")", ":", "plist", "=", "ctypes", ".", "POINTER", "(", "FunctionHandle", ")", "(", ")", "size", "=", "ctypes", ".", "c_uint", "(", ")", "check_call", "(", "_LIB", ".", "MXListFunctions", "(", "ctypes", ".", "byref", "(",...
List and add all the torch backed ndarray functions to current module.
[ "List", "and", "add", "all", "the", "torch", "backed", "ndarray", "functions", "to", "current", "module", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/torch.py#L167-L180
24,091
apache/incubator-mxnet
python/mxnet/recordio.py
pack
def pack(header, s): """Pack a string into MXImageRecord. Parameters ---------- header : IRHeader Header of the image record. ``header.label`` can be a number or an array. See more detail in ``IRHeader``. s : str Raw image string to be packed. Returns ------- s ...
python
def pack(header, s): """Pack a string into MXImageRecord. Parameters ---------- header : IRHeader Header of the image record. ``header.label`` can be a number or an array. See more detail in ``IRHeader``. s : str Raw image string to be packed. Returns ------- s ...
[ "def", "pack", "(", "header", ",", "s", ")", ":", "header", "=", "IRHeader", "(", "*", "header", ")", "if", "isinstance", "(", "header", ".", "label", ",", "numbers", ".", "Number", ")", ":", "header", "=", "header", ".", "_replace", "(", "flag", "...
Pack a string into MXImageRecord. Parameters ---------- header : IRHeader Header of the image record. ``header.label`` can be a number or an array. See more detail in ``IRHeader``. s : str Raw image string to be packed. Returns ------- s : str The packed str...
[ "Pack", "a", "string", "into", "MXImageRecord", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L358-L391
24,092
apache/incubator-mxnet
python/mxnet/recordio.py
unpack
def unpack(s): """Unpack a MXImageRecord to string. Parameters ---------- s : str String buffer from ``MXRecordIO.read``. Returns ------- header : IRHeader Header of the image record. s : str Unpacked string. Examples -------- >>> record = mx.record...
python
def unpack(s): """Unpack a MXImageRecord to string. Parameters ---------- s : str String buffer from ``MXRecordIO.read``. Returns ------- header : IRHeader Header of the image record. s : str Unpacked string. Examples -------- >>> record = mx.record...
[ "def", "unpack", "(", "s", ")", ":", "header", "=", "IRHeader", "(", "*", "struct", ".", "unpack", "(", "_IR_FORMAT", ",", "s", "[", ":", "_IR_SIZE", "]", ")", ")", "s", "=", "s", "[", "_IR_SIZE", ":", "]", "if", "header", ".", "flag", ">", "0"...
Unpack a MXImageRecord to string. Parameters ---------- s : str String buffer from ``MXRecordIO.read``. Returns ------- header : IRHeader Header of the image record. s : str Unpacked string. Examples -------- >>> record = mx.recordio.MXRecordIO('test.re...
[ "Unpack", "a", "MXImageRecord", "to", "string", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L393-L421
24,093
apache/incubator-mxnet
python/mxnet/recordio.py
unpack_img
def unpack_img(s, iscolor=-1): """Unpack a MXImageRecord to image. Parameters ---------- s : str String buffer from ``MXRecordIO.read``. iscolor : int Image format option for ``cv2.imdecode``. Returns ------- header : IRHeader Header of the image record. img...
python
def unpack_img(s, iscolor=-1): """Unpack a MXImageRecord to image. Parameters ---------- s : str String buffer from ``MXRecordIO.read``. iscolor : int Image format option for ``cv2.imdecode``. Returns ------- header : IRHeader Header of the image record. img...
[ "def", "unpack_img", "(", "s", ",", "iscolor", "=", "-", "1", ")", ":", "header", ",", "s", "=", "unpack", "(", "s", ")", "img", "=", "np", ".", "frombuffer", "(", "s", ",", "dtype", "=", "np", ".", "uint8", ")", "assert", "cv2", "is", "not", ...
Unpack a MXImageRecord to image. Parameters ---------- s : str String buffer from ``MXRecordIO.read``. iscolor : int Image format option for ``cv2.imdecode``. Returns ------- header : IRHeader Header of the image record. img : numpy.ndarray Unpacked imag...
[ "Unpack", "a", "MXImageRecord", "to", "image", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L423-L464
24,094
apache/incubator-mxnet
python/mxnet/recordio.py
pack_img
def pack_img(header, img, quality=95, img_fmt='.jpg'): """Pack an image into ``MXImageRecord``. Parameters ---------- header : IRHeader Header of the image record. ``header.label`` can be a number or an array. See more detail in ``IRHeader``. img : numpy.ndarray Image to be ...
python
def pack_img(header, img, quality=95, img_fmt='.jpg'): """Pack an image into ``MXImageRecord``. Parameters ---------- header : IRHeader Header of the image record. ``header.label`` can be a number or an array. See more detail in ``IRHeader``. img : numpy.ndarray Image to be ...
[ "def", "pack_img", "(", "header", ",", "img", ",", "quality", "=", "95", ",", "img_fmt", "=", "'.jpg'", ")", ":", "assert", "cv2", "is", "not", "None", "jpg_formats", "=", "[", "'.JPG'", ",", "'.JPEG'", "]", "png_formats", "=", "[", "'.PNG'", "]", "e...
Pack an image into ``MXImageRecord``. Parameters ---------- header : IRHeader Header of the image record. ``header.label`` can be a number or an array. See more detail in ``IRHeader``. img : numpy.ndarray Image to be packed. quality : int Quality for JPEG encoding in...
[ "Pack", "an", "image", "into", "MXImageRecord", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L466-L505
24,095
apache/incubator-mxnet
python/mxnet/recordio.py
MXRecordIO.open
def open(self): """Opens the record file.""" if self.flag == "w": check_call(_LIB.MXRecordIOWriterCreate(self.uri, ctypes.byref(self.handle))) self.writable = True elif self.flag == "r": check_call(_LIB.MXRecordIOReaderCreate(self.uri, ctypes.byref(self.handle...
python
def open(self): """Opens the record file.""" if self.flag == "w": check_call(_LIB.MXRecordIOWriterCreate(self.uri, ctypes.byref(self.handle))) self.writable = True elif self.flag == "r": check_call(_LIB.MXRecordIOReaderCreate(self.uri, ctypes.byref(self.handle...
[ "def", "open", "(", "self", ")", ":", "if", "self", ".", "flag", "==", "\"w\"", ":", "check_call", "(", "_LIB", ".", "MXRecordIOWriterCreate", "(", "self", ".", "uri", ",", "ctypes", ".", "byref", "(", "self", ".", "handle", ")", ")", ")", "self", ...
Opens the record file.
[ "Opens", "the", "record", "file", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L73-L84
24,096
apache/incubator-mxnet
python/mxnet/recordio.py
MXRecordIO._check_pid
def _check_pid(self, allow_reset=False): """Check process id to ensure integrity, reset if in new process.""" if not self.pid == current_process().pid: if allow_reset: self.reset() else: raise RuntimeError("Forbidden operation in multiple processes...
python
def _check_pid(self, allow_reset=False): """Check process id to ensure integrity, reset if in new process.""" if not self.pid == current_process().pid: if allow_reset: self.reset() else: raise RuntimeError("Forbidden operation in multiple processes...
[ "def", "_check_pid", "(", "self", ",", "allow_reset", "=", "False", ")", ":", "if", "not", "self", ".", "pid", "==", "current_process", "(", ")", ".", "pid", ":", "if", "allow_reset", ":", "self", ".", "reset", "(", ")", "else", ":", "raise", "Runtim...
Check process id to ensure integrity, reset if in new process.
[ "Check", "process", "id", "to", "ensure", "integrity", "reset", "if", "in", "new", "process", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L115-L121
24,097
apache/incubator-mxnet
python/mxnet/recordio.py
MXRecordIO.write
def write(self, buf): """Inserts a string buffer as a record. Examples --------- >>> record = mx.recordio.MXRecordIO('tmp.rec', 'w') >>> for i in range(5): ... record.write('record_%d'%i) >>> record.close() Parameters ---------- buf : ...
python
def write(self, buf): """Inserts a string buffer as a record. Examples --------- >>> record = mx.recordio.MXRecordIO('tmp.rec', 'w') >>> for i in range(5): ... record.write('record_%d'%i) >>> record.close() Parameters ---------- buf : ...
[ "def", "write", "(", "self", ",", "buf", ")", ":", "assert", "self", ".", "writable", "self", ".", "_check_pid", "(", "allow_reset", "=", "False", ")", "check_call", "(", "_LIB", ".", "MXRecordIOWriterWriteRecord", "(", "self", ".", "handle", ",", "ctypes"...
Inserts a string buffer as a record. Examples --------- >>> record = mx.recordio.MXRecordIO('tmp.rec', 'w') >>> for i in range(5): ... record.write('record_%d'%i) >>> record.close() Parameters ---------- buf : string (python2), bytes (python3)...
[ "Inserts", "a", "string", "buffer", "as", "a", "record", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L155-L174
24,098
apache/incubator-mxnet
python/mxnet/recordio.py
MXRecordIO.read
def read(self): """Returns record as a string. Examples --------- >>> record = mx.recordio.MXRecordIO('tmp.rec', 'r') >>> for i in range(5): ... item = record.read() ... print(item) record_0 record_1 record_2 record_3 ...
python
def read(self): """Returns record as a string. Examples --------- >>> record = mx.recordio.MXRecordIO('tmp.rec', 'r') >>> for i in range(5): ... item = record.read() ... print(item) record_0 record_1 record_2 record_3 ...
[ "def", "read", "(", "self", ")", ":", "assert", "not", "self", ".", "writable", "# trying to implicitly read from multiple processes is forbidden,", "# there's no elegant way to handle unless lock is introduced", "self", ".", "_check_pid", "(", "allow_reset", "=", "False", ")...
Returns record as a string. Examples --------- >>> record = mx.recordio.MXRecordIO('tmp.rec', 'r') >>> for i in range(5): ... item = record.read() ... print(item) record_0 record_1 record_2 record_3 record_4 >>> recor...
[ "Returns", "record", "as", "a", "string", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L176-L210
24,099
apache/incubator-mxnet
python/mxnet/recordio.py
MXIndexedRecordIO.seek
def seek(self, idx): """Sets the current read pointer position. This function is internally called by `read_idx(idx)` to find the current reader pointer position. It doesn't return anything.""" assert not self.writable self._check_pid(allow_reset=True) pos = ctypes.c_siz...
python
def seek(self, idx): """Sets the current read pointer position. This function is internally called by `read_idx(idx)` to find the current reader pointer position. It doesn't return anything.""" assert not self.writable self._check_pid(allow_reset=True) pos = ctypes.c_siz...
[ "def", "seek", "(", "self", ",", "idx", ")", ":", "assert", "not", "self", ".", "writable", "self", ".", "_check_pid", "(", "allow_reset", "=", "True", ")", "pos", "=", "ctypes", ".", "c_size_t", "(", "self", ".", "idx", "[", "idx", "]", ")", "chec...
Sets the current read pointer position. This function is internally called by `read_idx(idx)` to find the current reader pointer position. It doesn't return anything.
[ "Sets", "the", "current", "read", "pointer", "position", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/recordio.py#L268-L276