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
23,700
apache/incubator-mxnet
example/bayesian-methods/bdk_demo.py
get_mnist_sym
def get_mnist_sym(output_op=None, num_hidden=400): """Get symbol of mnist""" net = mx.symbol.Variable('data') net = mx.symbol.FullyConnected(data=net, name='mnist_fc1', num_hidden=num_hidden) net = mx.symbol.Activation(data=net, name='mnist_relu1', act_type="relu") net = mx.symbol.FullyConnected(dat...
python
def get_mnist_sym(output_op=None, num_hidden=400): """Get symbol of mnist""" net = mx.symbol.Variable('data') net = mx.symbol.FullyConnected(data=net, name='mnist_fc1', num_hidden=num_hidden) net = mx.symbol.Activation(data=net, name='mnist_relu1', act_type="relu") net = mx.symbol.FullyConnected(dat...
[ "def", "get_mnist_sym", "(", "output_op", "=", "None", ",", "num_hidden", "=", "400", ")", ":", "net", "=", "mx", ".", "symbol", ".", "Variable", "(", "'data'", ")", "net", "=", "mx", ".", "symbol", ".", "FullyConnected", "(", "data", "=", "net", ","...
Get symbol of mnist
[ "Get", "symbol", "of", "mnist" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L106-L118
23,701
apache/incubator-mxnet
example/bayesian-methods/bdk_demo.py
synthetic_grad
def synthetic_grad(X, theta, sigma1, sigma2, sigmax, rescale_grad=1.0, grad=None): """Get synthetic gradient value""" if grad is None: grad = nd.empty(theta.shape, theta.context) theta1 = theta.asnumpy()[0] theta2 = theta.asnumpy()[1] v1 = sigma1 ** 2 v2 = sigma2 ** 2 vx = sigmax ** ...
python
def synthetic_grad(X, theta, sigma1, sigma2, sigmax, rescale_grad=1.0, grad=None): """Get synthetic gradient value""" if grad is None: grad = nd.empty(theta.shape, theta.context) theta1 = theta.asnumpy()[0] theta2 = theta.asnumpy()[1] v1 = sigma1 ** 2 v2 = sigma2 ** 2 vx = sigmax ** ...
[ "def", "synthetic_grad", "(", "X", ",", "theta", ",", "sigma1", ",", "sigma2", ",", "sigmax", ",", "rescale_grad", "=", "1.0", ",", "grad", "=", "None", ")", ":", "if", "grad", "is", "None", ":", "grad", "=", "nd", ".", "empty", "(", "theta", ".", ...
Get synthetic gradient value
[ "Get", "synthetic", "gradient", "value" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L121-L139
23,702
apache/incubator-mxnet
example/bayesian-methods/bdk_demo.py
get_toy_sym
def get_toy_sym(teacher=True, teacher_noise_precision=None): """Get toy symbol""" if teacher: net = mx.symbol.Variable('data') net = mx.symbol.FullyConnected(data=net, name='teacher_fc1', num_hidden=100) net = mx.symbol.Activation(data=net, name='teacher_relu1', act_type="relu") ...
python
def get_toy_sym(teacher=True, teacher_noise_precision=None): """Get toy symbol""" if teacher: net = mx.symbol.Variable('data') net = mx.symbol.FullyConnected(data=net, name='teacher_fc1', num_hidden=100) net = mx.symbol.Activation(data=net, name='teacher_relu1', act_type="relu") ...
[ "def", "get_toy_sym", "(", "teacher", "=", "True", ",", "teacher_noise_precision", "=", "None", ")", ":", "if", "teacher", ":", "net", "=", "mx", ".", "symbol", ".", "Variable", "(", "'data'", ")", "net", "=", "mx", ".", "symbol", ".", "FullyConnected", ...
Get toy symbol
[ "Get", "toy", "symbol" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L142-L158
23,703
apache/incubator-mxnet
example/bayesian-methods/bdk_demo.py
run_mnist_DistilledSGLD
def run_mnist_DistilledSGLD(num_training=50000, gpu_id=None): """Run DistilledSGLD on mnist dataset""" X, Y, X_test, Y_test = load_mnist(num_training) minibatch_size = 100 if num_training >= 10000: num_hidden = 800 total_iter_num = 1000000 teacher_learning_rate = 1E-6 stu...
python
def run_mnist_DistilledSGLD(num_training=50000, gpu_id=None): """Run DistilledSGLD on mnist dataset""" X, Y, X_test, Y_test = load_mnist(num_training) minibatch_size = 100 if num_training >= 10000: num_hidden = 800 total_iter_num = 1000000 teacher_learning_rate = 1E-6 stu...
[ "def", "run_mnist_DistilledSGLD", "(", "num_training", "=", "50000", ",", "gpu_id", "=", "None", ")", ":", "X", ",", "Y", ",", "X_test", ",", "Y_test", "=", "load_mnist", "(", "num_training", ")", "minibatch_size", "=", "100", "if", "num_training", ">=", "...
Run DistilledSGLD on mnist dataset
[ "Run", "DistilledSGLD", "on", "mnist", "dataset" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L196-L237
23,704
apache/incubator-mxnet
example/bayesian-methods/bdk_demo.py
run_toy_SGLD
def run_toy_SGLD(gpu_id=None): """Run SGLD on toy dataset""" X, Y, X_test, Y_test = load_toy() minibatch_size = 1 teacher_noise_precision = 1.0 / 9.0 net = get_toy_sym(True, teacher_noise_precision) data_shape = (minibatch_size,) + X.shape[1::] data_inputs = {'data': nd.zeros(data_shape, ctx...
python
def run_toy_SGLD(gpu_id=None): """Run SGLD on toy dataset""" X, Y, X_test, Y_test = load_toy() minibatch_size = 1 teacher_noise_precision = 1.0 / 9.0 net = get_toy_sym(True, teacher_noise_precision) data_shape = (minibatch_size,) + X.shape[1::] data_inputs = {'data': nd.zeros(data_shape, ctx...
[ "def", "run_toy_SGLD", "(", "gpu_id", "=", "None", ")", ":", "X", ",", "Y", ",", "X_test", ",", "Y_test", "=", "load_toy", "(", ")", "minibatch_size", "=", "1", "teacher_noise_precision", "=", "1.0", "/", "9.0", "net", "=", "get_toy_sym", "(", "True", ...
Run SGLD on toy dataset
[ "Run", "SGLD", "on", "toy", "dataset" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L240-L265
23,705
apache/incubator-mxnet
example/bayesian-methods/bdk_demo.py
run_toy_DistilledSGLD
def run_toy_DistilledSGLD(gpu_id): """Run DistilledSGLD on toy dataset""" X, Y, X_test, Y_test = load_toy() minibatch_size = 1 teacher_noise_precision = 1.0 teacher_net = get_toy_sym(True, teacher_noise_precision) student_net = get_toy_sym(False) data_shape = (minibatch_size,) + X.shape[1::]...
python
def run_toy_DistilledSGLD(gpu_id): """Run DistilledSGLD on toy dataset""" X, Y, X_test, Y_test = load_toy() minibatch_size = 1 teacher_noise_precision = 1.0 teacher_net = get_toy_sym(True, teacher_noise_precision) student_net = get_toy_sym(False) data_shape = (minibatch_size,) + X.shape[1::]...
[ "def", "run_toy_DistilledSGLD", "(", "gpu_id", ")", ":", "X", ",", "Y", ",", "X_test", ",", "Y_test", "=", "load_toy", "(", ")", "minibatch_size", "=", "1", "teacher_noise_precision", "=", "1.0", "teacher_net", "=", "get_toy_sym", "(", "True", ",", "teacher_...
Run DistilledSGLD on toy dataset
[ "Run", "DistilledSGLD", "on", "toy", "dataset" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L268-L297
23,706
apache/incubator-mxnet
example/bayesian-methods/bdk_demo.py
run_toy_HMC
def run_toy_HMC(gpu_id=None): """Run HMC on toy dataset""" X, Y, X_test, Y_test = load_toy() minibatch_size = Y.shape[0] noise_precision = 1 / 9.0 net = get_toy_sym(True, noise_precision) data_shape = (minibatch_size,) + X.shape[1::] data_inputs = {'data': nd.zeros(data_shape, ctx=dev(gpu_id...
python
def run_toy_HMC(gpu_id=None): """Run HMC on toy dataset""" X, Y, X_test, Y_test = load_toy() minibatch_size = Y.shape[0] noise_precision = 1 / 9.0 net = get_toy_sym(True, noise_precision) data_shape = (minibatch_size,) + X.shape[1::] data_inputs = {'data': nd.zeros(data_shape, ctx=dev(gpu_id...
[ "def", "run_toy_HMC", "(", "gpu_id", "=", "None", ")", ":", "X", ",", "Y", ",", "X_test", ",", "Y_test", "=", "load_toy", "(", ")", "minibatch_size", "=", "Y", ".", "shape", "[", "0", "]", "noise_precision", "=", "1", "/", "9.0", "net", "=", "get_t...
Run HMC on toy dataset
[ "Run", "HMC", "on", "toy", "dataset" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L300-L312
23,707
apache/incubator-mxnet
example/bayesian-methods/bdk_demo.py
run_synthetic_SGLD
def run_synthetic_SGLD(): """Run synthetic SGLD""" theta1 = 0 theta2 = 1 sigma1 = numpy.sqrt(10) sigma2 = 1 sigmax = numpy.sqrt(2) X = load_synthetic(theta1=theta1, theta2=theta2, sigmax=sigmax, num=100) minibatch_size = 1 total_iter_num = 1000000 lr_scheduler = SGLDScheduler(beg...
python
def run_synthetic_SGLD(): """Run synthetic SGLD""" theta1 = 0 theta2 = 1 sigma1 = numpy.sqrt(10) sigma2 = 1 sigmax = numpy.sqrt(2) X = load_synthetic(theta1=theta1, theta2=theta2, sigmax=sigmax, num=100) minibatch_size = 1 total_iter_num = 1000000 lr_scheduler = SGLDScheduler(beg...
[ "def", "run_synthetic_SGLD", "(", ")", ":", "theta1", "=", "0", "theta2", "=", "1", "sigma1", "=", "numpy", ".", "sqrt", "(", "10", ")", "sigma2", "=", "1", "sigmax", "=", "numpy", ".", "sqrt", "(", "2", ")", "X", "=", "load_synthetic", "(", "theta...
Run synthetic SGLD
[ "Run", "synthetic", "SGLD" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/bdk_demo.py#L315-L349
23,708
apache/incubator-mxnet
example/ssd/tools/prepare_dataset.py
load_pascal
def load_pascal(image_set, year, devkit_path, shuffle=False): """ wrapper function for loading pascal voc dataset Parameters: ---------- image_set : str train, trainval... year : str 2007, 2012 or combinations splitted by comma devkit_path : str root directory of dat...
python
def load_pascal(image_set, year, devkit_path, shuffle=False): """ wrapper function for loading pascal voc dataset Parameters: ---------- image_set : str train, trainval... year : str 2007, 2012 or combinations splitted by comma devkit_path : str root directory of dat...
[ "def", "load_pascal", "(", "image_set", ",", "year", ",", "devkit_path", ",", "shuffle", "=", "False", ")", ":", "image_set", "=", "[", "y", ".", "strip", "(", ")", "for", "y", "in", "image_set", ".", "split", "(", "','", ")", "]", "assert", "image_s...
wrapper function for loading pascal voc dataset Parameters: ---------- image_set : str train, trainval... year : str 2007, 2012 or combinations splitted by comma devkit_path : str root directory of dataset shuffle : bool whether to shuffle initial list Retur...
[ "wrapper", "function", "for", "loading", "pascal", "voc", "dataset" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/tools/prepare_dataset.py#L31-L68
23,709
apache/incubator-mxnet
example/ssd/tools/prepare_dataset.py
load_coco
def load_coco(image_set, dirname, shuffle=False): """ wrapper function for loading ms coco dataset Parameters: ---------- image_set : str train2014, val2014, valminusminival2014, minival2014 dirname: str root dir for coco shuffle: boolean initial shuffle """ ...
python
def load_coco(image_set, dirname, shuffle=False): """ wrapper function for loading ms coco dataset Parameters: ---------- image_set : str train2014, val2014, valminusminival2014, minival2014 dirname: str root dir for coco shuffle: boolean initial shuffle """ ...
[ "def", "load_coco", "(", "image_set", ",", "dirname", ",", "shuffle", "=", "False", ")", ":", "anno_files", "=", "[", "'instances_'", "+", "y", ".", "strip", "(", ")", "+", "'.json'", "for", "y", "in", "image_set", ".", "split", "(", "','", ")", "]",...
wrapper function for loading ms coco dataset Parameters: ---------- image_set : str train2014, val2014, valminusminival2014, minival2014 dirname: str root dir for coco shuffle: boolean initial shuffle
[ "wrapper", "function", "for", "loading", "ms", "coco", "dataset" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/tools/prepare_dataset.py#L70-L92
23,710
apache/incubator-mxnet
tools/coreml/converter/_layers.py
convert_transpose
def convert_transpose(net, node, module, builder): """Convert a transpose layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A...
python
def convert_transpose(net, node, module, builder): """Convert a transpose layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A...
[ "def", "convert_transpose", "(", "net", ",", "node", ",", "module", ",", "builder", ")", ":", "input_name", ",", "output_name", "=", "_get_input_output_name", "(", "net", ",", "node", ")", "name", "=", "node", "[", "'name'", "]", "param", "=", "_get_attrs"...
Convert a transpose layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neural network builder object.
[ "Convert", "a", "transpose", "layer", "from", "mxnet", "to", "coreml", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L116-L138
23,711
apache/incubator-mxnet
tools/coreml/converter/_layers.py
convert_flatten
def convert_flatten(net, node, module, builder): """Convert a flatten layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neu...
python
def convert_flatten(net, node, module, builder): """Convert a flatten layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neu...
[ "def", "convert_flatten", "(", "net", ",", "node", ",", "module", ",", "builder", ")", ":", "input_name", ",", "output_name", "=", "_get_input_output_name", "(", "net", ",", "node", ")", "name", "=", "node", "[", "'name'", "]", "mode", "=", "0", "# CHANN...
Convert a flatten layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neural network builder object.
[ "Convert", "a", "flatten", "layer", "from", "mxnet", "to", "coreml", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L141-L161
23,712
apache/incubator-mxnet
tools/coreml/converter/_layers.py
convert_activation
def convert_activation(net, node, module, builder): """Convert an activation layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder ...
python
def convert_activation(net, node, module, builder): """Convert an activation layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder ...
[ "def", "convert_activation", "(", "net", ",", "node", ",", "module", ",", "builder", ")", ":", "input_name", ",", "output_name", "=", "_get_input_output_name", "(", "net", ",", "node", ")", "name", "=", "node", "[", "'name'", "]", "mx_non_linearity", "=", ...
Convert an activation layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neural network builder object.
[ "Convert", "an", "activation", "layer", "from", "mxnet", "to", "coreml", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L188-L220
23,713
apache/incubator-mxnet
tools/coreml/converter/_layers.py
convert_leakyrelu
def convert_leakyrelu(net, node, module, builder): """Convert a leakyrelu layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A...
python
def convert_leakyrelu(net, node, module, builder): """Convert a leakyrelu layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A...
[ "def", "convert_leakyrelu", "(", "net", ",", "node", ",", "module", ",", "builder", ")", ":", "input_name", ",", "output_name", "=", "_get_input_output_name", "(", "net", ",", "node", ")", "name", "=", "node", "[", "'name'", "]", "inputs", "=", "node", "...
Convert a leakyrelu layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neural network builder object.
[ "Convert", "a", "leakyrelu", "layer", "from", "mxnet", "to", "coreml", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L223-L263
23,714
apache/incubator-mxnet
tools/coreml/converter/_layers.py
convert_elementwise_add
def convert_elementwise_add(net, node, module, builder): """Convert an elementwise add layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuil...
python
def convert_elementwise_add(net, node, module, builder): """Convert an elementwise add layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuil...
[ "def", "convert_elementwise_add", "(", "net", ",", "node", ",", "module", ",", "builder", ")", ":", "input_names", ",", "output_name", "=", "_get_input_output_name", "(", "net", ",", "node", ",", "[", "0", ",", "1", "]", ")", "name", "=", "node", "[", ...
Convert an elementwise add layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neural network builder object.
[ "Convert", "an", "elementwise", "add", "layer", "from", "mxnet", "to", "coreml", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L266-L287
23,715
apache/incubator-mxnet
tools/coreml/converter/_layers.py
convert_convolution
def convert_convolution(net, node, module, builder): """Convert a convolution layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder ...
python
def convert_convolution(net, node, module, builder): """Convert a convolution layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder ...
[ "def", "convert_convolution", "(", "net", ",", "node", ",", "module", ",", "builder", ")", ":", "input_name", ",", "output_name", "=", "_get_input_output_name", "(", "net", ",", "node", ")", "name", "=", "node", "[", "'name'", "]", "param", "=", "_get_attr...
Convert a convolution layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neural network builder object.
[ "Convert", "a", "convolution", "layer", "from", "mxnet", "to", "coreml", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L337-L415
23,716
apache/incubator-mxnet
tools/coreml/converter/_layers.py
convert_pooling
def convert_pooling(net, node, module, builder): """Convert a pooling layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neu...
python
def convert_pooling(net, node, module, builder): """Convert a pooling layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neu...
[ "def", "convert_pooling", "(", "net", ",", "node", ",", "module", ",", "builder", ")", ":", "input_name", ",", "output_name", "=", "_get_input_output_name", "(", "net", ",", "node", ")", "name", "=", "node", "[", "'name'", "]", "param", "=", "_get_attrs", ...
Convert a pooling layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neural network builder object.
[ "Convert", "a", "pooling", "layer", "from", "mxnet", "to", "coreml", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L418-L494
23,717
apache/incubator-mxnet
tools/coreml/converter/_layers.py
convert_batchnorm
def convert_batchnorm(net, node, module, builder): """Convert a batchnorm layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A...
python
def convert_batchnorm(net, node, module, builder): """Convert a batchnorm layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A...
[ "def", "convert_batchnorm", "(", "net", ",", "node", ",", "module", ",", "builder", ")", ":", "input_name", ",", "output_name", "=", "_get_input_output_name", "(", "net", ",", "node", ")", "name", "=", "node", "[", "'name'", "]", "inputs", "=", "node", "...
Convert a batchnorm layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neural network builder object.
[ "Convert", "a", "batchnorm", "layer", "from", "mxnet", "to", "coreml", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L497-L545
23,718
apache/incubator-mxnet
tools/coreml/converter/_layers.py
convert_concat
def convert_concat(net, node, module, builder): """Convert concat layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neural ...
python
def convert_concat(net, node, module, builder): """Convert concat layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neural ...
[ "def", "convert_concat", "(", "net", ",", "node", ",", "module", ",", "builder", ")", ":", "# Get input and output names", "input_names", ",", "output_name", "=", "_get_input_output_name", "(", "net", ",", "node", ",", "'all'", ")", "name", "=", "node", "[", ...
Convert concat layer from mxnet to coreml. Parameters ---------- network: net A mxnet network object. layer: node Node to convert. module: module An module for MXNet builder: NeuralNetworkBuilder A neural network builder object.
[ "Convert", "concat", "layer", "from", "mxnet", "to", "coreml", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_layers.py#L548-L570
23,719
apache/incubator-mxnet
tools/launch.py
dmlc_opts
def dmlc_opts(opts): """convert from mxnet's opts to dmlc's opts """ args = ['--num-workers', str(opts.num_workers), '--num-servers', str(opts.num_servers), '--cluster', opts.launcher, '--host-file', opts.hostfile, '--sync-dst-dir', opts.sync_dst_dir] # c...
python
def dmlc_opts(opts): """convert from mxnet's opts to dmlc's opts """ args = ['--num-workers', str(opts.num_workers), '--num-servers', str(opts.num_servers), '--cluster', opts.launcher, '--host-file', opts.hostfile, '--sync-dst-dir', opts.sync_dst_dir] # c...
[ "def", "dmlc_opts", "(", "opts", ")", ":", "args", "=", "[", "'--num-workers'", ",", "str", "(", "opts", ".", "num_workers", ")", ",", "'--num-servers'", ",", "str", "(", "opts", ".", "num_servers", ")", ",", "'--cluster'", ",", "opts", ".", "launcher", ...
convert from mxnet's opts to dmlc's opts
[ "convert", "from", "mxnet", "s", "opts", "to", "dmlc", "s", "opts" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/launch.py#L31-L54
23,720
apache/incubator-mxnet
python/mxnet/gluon/rnn/rnn_layer.py
_RNNLayer._unfuse
def _unfuse(self): """Unfuses the fused RNN in to a stack of rnn cells.""" assert not self._projection_size, "_unfuse does not support projection layer yet!" assert not self._lstm_state_clip_min and not self._lstm_state_clip_max, \ "_unfuse does not support state clipping yet!" ...
python
def _unfuse(self): """Unfuses the fused RNN in to a stack of rnn cells.""" assert not self._projection_size, "_unfuse does not support projection layer yet!" assert not self._lstm_state_clip_min and not self._lstm_state_clip_max, \ "_unfuse does not support state clipping yet!" ...
[ "def", "_unfuse", "(", "self", ")", ":", "assert", "not", "self", ".", "_projection_size", ",", "\"_unfuse does not support projection layer yet!\"", "assert", "not", "self", ".", "_lstm_state_clip_min", "and", "not", "self", ".", "_lstm_state_clip_max", ",", "\"_unfu...
Unfuses the fused RNN in to a stack of rnn cells.
[ "Unfuses", "the", "fused", "RNN", "in", "to", "a", "stack", "of", "rnn", "cells", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/rnn/rnn_layer.py#L144-L181
23,721
apache/incubator-mxnet
python/mxnet/gluon/rnn/rnn_layer.py
_RNNLayer._forward_kernel
def _forward_kernel(self, F, inputs, states, **kwargs): """ forward using CUDNN or CPU kenrel""" if self._layout == 'NTC': inputs = F.swapaxes(inputs, dim1=0, dim2=1) if self._projection_size is None: params = (kwargs['{}{}_{}_{}'.format(d, l, g, t)].reshape(-1) ...
python
def _forward_kernel(self, F, inputs, states, **kwargs): """ forward using CUDNN or CPU kenrel""" if self._layout == 'NTC': inputs = F.swapaxes(inputs, dim1=0, dim2=1) if self._projection_size is None: params = (kwargs['{}{}_{}_{}'.format(d, l, g, t)].reshape(-1) ...
[ "def", "_forward_kernel", "(", "self", ",", "F", ",", "inputs", ",", "states", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_layout", "==", "'NTC'", ":", "inputs", "=", "F", ".", "swapaxes", "(", "inputs", ",", "dim1", "=", "0", ",", "d...
forward using CUDNN or CPU kenrel
[ "forward", "using", "CUDNN", "or", "CPU", "kenrel" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/rnn/rnn_layer.py#L244-L280
23,722
apache/incubator-mxnet
example/distributed_training/cifar10_dist.py
evaluate_accuracy
def evaluate_accuracy(data_iterator, network): """ Measure the accuracy of ResNet Parameters ---------- data_iterator: Iter examples of dataset network: ResNet Returns ---------- tuple of array element """ acc = mx.metric.Accuracy() # Iterate through data and l...
python
def evaluate_accuracy(data_iterator, network): """ Measure the accuracy of ResNet Parameters ---------- data_iterator: Iter examples of dataset network: ResNet Returns ---------- tuple of array element """ acc = mx.metric.Accuracy() # Iterate through data and l...
[ "def", "evaluate_accuracy", "(", "data_iterator", ",", "network", ")", ":", "acc", "=", "mx", ".", "metric", ".", "Accuracy", "(", ")", "# Iterate through data and label", "for", "i", ",", "(", "data", ",", "label", ")", "in", "enumerate", "(", "data_iterato...
Measure the accuracy of ResNet Parameters ---------- data_iterator: Iter examples of dataset network: ResNet Returns ---------- tuple of array element
[ "Measure", "the", "accuracy", "of", "ResNet" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/distributed_training/cifar10_dist.py#L110-L142
23,723
apache/incubator-mxnet
example/distributed_training/cifar10_dist.py
train_batch
def train_batch(batch_list, context, network, gluon_trainer): """ Training with multiple GPUs Parameters ---------- batch_list: List list of dataset context: List a list of all GPUs to be used for training network: ResNet gluon_trainer: rain module of gluon """ ...
python
def train_batch(batch_list, context, network, gluon_trainer): """ Training with multiple GPUs Parameters ---------- batch_list: List list of dataset context: List a list of all GPUs to be used for training network: ResNet gluon_trainer: rain module of gluon """ ...
[ "def", "train_batch", "(", "batch_list", ",", "context", ",", "network", ",", "gluon_trainer", ")", ":", "# Split and load data into multiple GPUs", "data", "=", "batch_list", "[", "0", "]", "data", "=", "gluon", ".", "utils", ".", "split_and_load", "(", "data",...
Training with multiple GPUs Parameters ---------- batch_list: List list of dataset context: List a list of all GPUs to be used for training network: ResNet gluon_trainer: rain module of gluon
[ "Training", "with", "multiple", "GPUs" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/distributed_training/cifar10_dist.py#L163-L190
23,724
apache/incubator-mxnet
python/mxnet/contrib/tensorrt.py
get_optimized_symbol
def get_optimized_symbol(executor): """ Take an executor's underlying symbol graph and return its generated optimized version. Parameters ---------- executor : An executor for which you want to see an optimized symbol. Getting an optimized symbol is useful to compare and verify the ...
python
def get_optimized_symbol(executor): """ Take an executor's underlying symbol graph and return its generated optimized version. Parameters ---------- executor : An executor for which you want to see an optimized symbol. Getting an optimized symbol is useful to compare and verify the ...
[ "def", "get_optimized_symbol", "(", "executor", ")", ":", "handle", "=", "SymbolHandle", "(", ")", "try", ":", "check_call", "(", "_LIB", ".", "MXExecutorGetOptimizedSymbol", "(", "executor", ".", "handle", ",", "ctypes", ".", "byref", "(", "handle", ")", ")...
Take an executor's underlying symbol graph and return its generated optimized version. Parameters ---------- executor : An executor for which you want to see an optimized symbol. Getting an optimized symbol is useful to compare and verify the work TensorRT has done against a legacy behaviou...
[ "Take", "an", "executor", "s", "underlying", "symbol", "graph", "and", "return", "its", "generated", "optimized", "version", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/tensorrt.py#L50-L73
23,725
apache/incubator-mxnet
python/mxnet/contrib/tensorrt.py
tensorrt_bind
def tensorrt_bind(symbol, ctx, all_params, type_dict=None, stype_dict=None, group2ctx=None, **kwargs): """Bind current symbol to get an optimized trt executor. Parameters ---------- symbol : Symbol The symbol you wish to bind, and optimize with TensorRT. ctx : Context ...
python
def tensorrt_bind(symbol, ctx, all_params, type_dict=None, stype_dict=None, group2ctx=None, **kwargs): """Bind current symbol to get an optimized trt executor. Parameters ---------- symbol : Symbol The symbol you wish to bind, and optimize with TensorRT. ctx : Context ...
[ "def", "tensorrt_bind", "(", "symbol", ",", "ctx", ",", "all_params", ",", "type_dict", "=", "None", ",", "stype_dict", "=", "None", ",", "group2ctx", "=", "None", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'shared_buffer'", "]", "=", "all_params...
Bind current symbol to get an optimized trt executor. Parameters ---------- symbol : Symbol The symbol you wish to bind, and optimize with TensorRT. ctx : Context The device context the generated executor to run on. all_params : Dict of str->ndarray A dictionary of mapping...
[ "Bind", "current", "symbol", "to", "get", "an", "optimized", "trt", "executor", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/tensorrt.py#L76-L110
23,726
apache/incubator-mxnet
example/ssd/detect/detector.py
Detector.detect_iter
def detect_iter(self, det_iter, show_timer=False): """ detect all images in iterator Parameters: ---------- det_iter : DetIter iterator for all testing images show_timer : Boolean whether to print out detection exec time Returns: ...
python
def detect_iter(self, det_iter, show_timer=False): """ detect all images in iterator Parameters: ---------- det_iter : DetIter iterator for all testing images show_timer : Boolean whether to print out detection exec time Returns: ...
[ "def", "detect_iter", "(", "self", ",", "det_iter", ",", "show_timer", "=", "False", ")", ":", "num_images", "=", "det_iter", ".", "_size", "if", "not", "isinstance", "(", "det_iter", ",", "mx", ".", "io", ".", "PrefetchingIter", ")", ":", "det_iter", "=...
detect all images in iterator Parameters: ---------- det_iter : DetIter iterator for all testing images show_timer : Boolean whether to print out detection exec time Returns: ---------- list of detection results
[ "detect", "all", "images", "in", "iterator" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/detect/detector.py#L82-L107
23,727
apache/incubator-mxnet
example/ssd/detect/detector.py
Detector.im_detect
def im_detect(self, im_list, root_dir=None, extension=None, show_timer=False): """ wrapper for detecting multiple images Parameters: ---------- im_list : list of str image path or list of image paths root_dir : str directory of input images, optio...
python
def im_detect(self, im_list, root_dir=None, extension=None, show_timer=False): """ wrapper for detecting multiple images Parameters: ---------- im_list : list of str image path or list of image paths root_dir : str directory of input images, optio...
[ "def", "im_detect", "(", "self", ",", "im_list", ",", "root_dir", "=", "None", ",", "extension", "=", "None", ",", "show_timer", "=", "False", ")", ":", "test_db", "=", "TestDB", "(", "im_list", ",", "root_dir", "=", "root_dir", ",", "extension", "=", ...
wrapper for detecting multiple images Parameters: ---------- im_list : list of str image path or list of image paths root_dir : str directory of input images, optional if image path already has full directory information extension : str ...
[ "wrapper", "for", "detecting", "multiple", "images" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/detect/detector.py#L120-L142
23,728
apache/incubator-mxnet
example/ssd/detect/detector.py
Detector.visualize_detection
def visualize_detection(self, img, dets, classes=[], thresh=0.6): """ visualize detections in one image Parameters: ---------- img : numpy.array image, in bgr format dets : numpy.array ssd detections, numpy.array([[id, score, x1, y1, x2, y2]...]) ...
python
def visualize_detection(self, img, dets, classes=[], thresh=0.6): """ visualize detections in one image Parameters: ---------- img : numpy.array image, in bgr format dets : numpy.array ssd detections, numpy.array([[id, score, x1, y1, x2, y2]...]) ...
[ "def", "visualize_detection", "(", "self", ",", "img", ",", "dets", ",", "classes", "=", "[", "]", ",", "thresh", "=", "0.6", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt", "import", "random", "plt", ".", "imshow", "(", "img", ")", "he...
visualize detections in one image Parameters: ---------- img : numpy.array image, in bgr format dets : numpy.array ssd detections, numpy.array([[id, score, x1, y1, x2, y2]...]) each row is one object classes : tuple or list of str ...
[ "visualize", "detections", "in", "one", "image" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/detect/detector.py#L144-L189
23,729
apache/incubator-mxnet
example/ssd/detect/detector.py
Detector.detect_and_visualize
def detect_and_visualize(self, im_list, root_dir=None, extension=None, classes=[], thresh=0.6, show_timer=False): """ wrapper for im_detect and visualize_detection Parameters: ---------- im_list : list of str or str image path or list of ...
python
def detect_and_visualize(self, im_list, root_dir=None, extension=None, classes=[], thresh=0.6, show_timer=False): """ wrapper for im_detect and visualize_detection Parameters: ---------- im_list : list of str or str image path or list of ...
[ "def", "detect_and_visualize", "(", "self", ",", "im_list", ",", "root_dir", "=", "None", ",", "extension", "=", "None", ",", "classes", "=", "[", "]", ",", "thresh", "=", "0.6", ",", "show_timer", "=", "False", ")", ":", "dets", "=", "self", ".", "i...
wrapper for im_detect and visualize_detection Parameters: ---------- im_list : list of str or str image path or list of image paths root_dir : str or None directory of input images, optional if image path already has full directory information ...
[ "wrapper", "for", "im_detect", "and", "visualize_detection" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/detect/detector.py#L212-L238
23,730
apache/incubator-mxnet
tools/caffe_converter/caffe_proto_utils.py
process_network_proto
def process_network_proto(caffe_root, deploy_proto): """ Runs the caffe upgrade tool on the prototxt to create a prototxt in the latest format. This enable us to work just with latest structures, instead of supporting all the variants :param caffe_root: link to caffe root folder, where the upgrade tool...
python
def process_network_proto(caffe_root, deploy_proto): """ Runs the caffe upgrade tool on the prototxt to create a prototxt in the latest format. This enable us to work just with latest structures, instead of supporting all the variants :param caffe_root: link to caffe root folder, where the upgrade tool...
[ "def", "process_network_proto", "(", "caffe_root", ",", "deploy_proto", ")", ":", "processed_deploy_proto", "=", "deploy_proto", "+", "\".processed\"", "from", "shutil", "import", "copyfile", "copyfile", "(", "deploy_proto", ",", "processed_deploy_proto", ")", "# run up...
Runs the caffe upgrade tool on the prototxt to create a prototxt in the latest format. This enable us to work just with latest structures, instead of supporting all the variants :param caffe_root: link to caffe root folder, where the upgrade tool is located :param deploy_proto: name of the original prototx...
[ "Runs", "the", "caffe", "upgrade", "tool", "on", "the", "prototxt", "to", "create", "a", "prototxt", "in", "the", "latest", "format", ".", "This", "enable", "us", "to", "work", "just", "with", "latest", "structures", "instead", "of", "supporting", "all", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/caffe_proto_utils.py#L22-L42
23,731
apache/incubator-mxnet
example/gluon/embedding_learning/model.py
get_distance
def get_distance(F, x): """Helper function for margin-based loss. Return a distance matrix given a matrix.""" n = x.shape[0] square = F.sum(x ** 2.0, axis=1, keepdims=True) distance_square = square + square.transpose() - (2.0 * F.dot(x, x.transpose())) # Adding identity to make sqrt work. retu...
python
def get_distance(F, x): """Helper function for margin-based loss. Return a distance matrix given a matrix.""" n = x.shape[0] square = F.sum(x ** 2.0, axis=1, keepdims=True) distance_square = square + square.transpose() - (2.0 * F.dot(x, x.transpose())) # Adding identity to make sqrt work. retu...
[ "def", "get_distance", "(", "F", ",", "x", ")", ":", "n", "=", "x", ".", "shape", "[", "0", "]", "square", "=", "F", ".", "sum", "(", "x", "**", "2.0", ",", "axis", "=", "1", ",", "keepdims", "=", "True", ")", "distance_square", "=", "square", ...
Helper function for margin-based loss. Return a distance matrix given a matrix.
[ "Helper", "function", "for", "margin", "-", "based", "loss", ".", "Return", "a", "distance", "matrix", "given", "a", "matrix", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/embedding_learning/model.py#L51-L59
23,732
apache/incubator-mxnet
example/rnn/large_word_lm/model.py
cross_entropy_loss
def cross_entropy_loss(inputs, labels, rescale_loss=1): """ cross entropy loss with a mask """ criterion = mx.gluon.loss.SoftmaxCrossEntropyLoss(weight=rescale_loss) loss = criterion(inputs, labels) mask = S.var('mask') loss = loss * S.reshape(mask, shape=(-1,)) return S.make_loss(loss.mean())
python
def cross_entropy_loss(inputs, labels, rescale_loss=1): """ cross entropy loss with a mask """ criterion = mx.gluon.loss.SoftmaxCrossEntropyLoss(weight=rescale_loss) loss = criterion(inputs, labels) mask = S.var('mask') loss = loss * S.reshape(mask, shape=(-1,)) return S.make_loss(loss.mean())
[ "def", "cross_entropy_loss", "(", "inputs", ",", "labels", ",", "rescale_loss", "=", "1", ")", ":", "criterion", "=", "mx", ".", "gluon", ".", "loss", ".", "SoftmaxCrossEntropyLoss", "(", "weight", "=", "rescale_loss", ")", "loss", "=", "criterion", "(", "...
cross entropy loss with a mask
[ "cross", "entropy", "loss", "with", "a", "mask" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/large_word_lm/model.py#L39-L45
23,733
apache/incubator-mxnet
example/rnn/large_word_lm/model.py
rnn
def rnn(bptt, vocab_size, num_embed, nhid, num_layers, dropout, num_proj, batch_size): """ word embedding + LSTM Projected """ state_names = [] data = S.var('data') weight = S.var("encoder_weight", stype='row_sparse') embed = S.sparse.Embedding(data=data, weight=weight, input_dim=vocab_size, ...
python
def rnn(bptt, vocab_size, num_embed, nhid, num_layers, dropout, num_proj, batch_size): """ word embedding + LSTM Projected """ state_names = [] data = S.var('data') weight = S.var("encoder_weight", stype='row_sparse') embed = S.sparse.Embedding(data=data, weight=weight, input_dim=vocab_size, ...
[ "def", "rnn", "(", "bptt", ",", "vocab_size", ",", "num_embed", ",", "nhid", ",", "num_layers", ",", "dropout", ",", "num_proj", ",", "batch_size", ")", ":", "state_names", "=", "[", "]", "data", "=", "S", ".", "var", "(", "'data'", ")", "weight", "=...
word embedding + LSTM Projected
[ "word", "embedding", "+", "LSTM", "Projected" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/large_word_lm/model.py#L47-L72
23,734
apache/incubator-mxnet
example/rnn/large_word_lm/model.py
sampled_softmax
def sampled_softmax(num_classes, num_samples, in_dim, inputs, weight, bias, sampled_values, remove_accidental_hits=True): """ Sampled softmax via importance sampling. This under-estimates the full softmax and is only used for training. """ # inputs = (n, in_dim) ...
python
def sampled_softmax(num_classes, num_samples, in_dim, inputs, weight, bias, sampled_values, remove_accidental_hits=True): """ Sampled softmax via importance sampling. This under-estimates the full softmax and is only used for training. """ # inputs = (n, in_dim) ...
[ "def", "sampled_softmax", "(", "num_classes", ",", "num_samples", ",", "in_dim", ",", "inputs", ",", "weight", ",", "bias", ",", "sampled_values", ",", "remove_accidental_hits", "=", "True", ")", ":", "# inputs = (n, in_dim)", "sample", ",", "prob_sample", ",", ...
Sampled softmax via importance sampling. This under-estimates the full softmax and is only used for training.
[ "Sampled", "softmax", "via", "importance", "sampling", ".", "This", "under", "-", "estimates", "the", "full", "softmax", "and", "is", "only", "used", "for", "training", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/large_word_lm/model.py#L74-L128
23,735
apache/incubator-mxnet
example/rnn/large_word_lm/model.py
generate_samples
def generate_samples(label, num_splits, sampler): """ Split labels into `num_splits` and generate candidates based on log-uniform distribution. """ def listify(x): return x if isinstance(x, list) else [x] label_splits = listify(label.split(num_splits, axis=0)) prob_samples = [] p...
python
def generate_samples(label, num_splits, sampler): """ Split labels into `num_splits` and generate candidates based on log-uniform distribution. """ def listify(x): return x if isinstance(x, list) else [x] label_splits = listify(label.split(num_splits, axis=0)) prob_samples = [] p...
[ "def", "generate_samples", "(", "label", ",", "num_splits", ",", "sampler", ")", ":", "def", "listify", "(", "x", ")", ":", "return", "x", "if", "isinstance", "(", "x", ",", "list", ")", "else", "[", "x", "]", "label_splits", "=", "listify", "(", "la...
Split labels into `num_splits` and generate candidates based on log-uniform distribution.
[ "Split", "labels", "into", "num_splits", "and", "generate", "candidates", "based", "on", "log", "-", "uniform", "distribution", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/large_word_lm/model.py#L130-L147
23,736
apache/incubator-mxnet
python/mxnet/gluon/model_zoo/vision/__init__.py
get_model
def get_model(name, **kwargs): """Returns a pre-defined model by name Parameters ---------- name : str Name of the model. pretrained : bool Whether to load the pretrained weights for model. classes : int Number of classes for the output layer. ctx : Context, default ...
python
def get_model(name, **kwargs): """Returns a pre-defined model by name Parameters ---------- name : str Name of the model. pretrained : bool Whether to load the pretrained weights for model. classes : int Number of classes for the output layer. ctx : Context, default ...
[ "def", "get_model", "(", "name", ",", "*", "*", "kwargs", ")", ":", "models", "=", "{", "'resnet18_v1'", ":", "resnet18_v1", ",", "'resnet34_v1'", ":", "resnet34_v1", ",", "'resnet50_v1'", ":", "resnet50_v1", ",", "'resnet101_v1'", ":", "resnet101_v1", ",", ...
Returns a pre-defined model by name Parameters ---------- name : str Name of the model. pretrained : bool Whether to load the pretrained weights for model. classes : int Number of classes for the output layer. ctx : Context, default CPU The context in which to lo...
[ "Returns", "a", "pre", "-", "defined", "model", "by", "name" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/model_zoo/vision/__init__.py#L91-L152
23,737
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
_new_alloc_handle
def _new_alloc_handle(stype, shape, ctx, delay_alloc, dtype, aux_types, aux_shapes=None): """Return a new handle with specified storage type, shape, dtype and context. Empty handle is only used to hold results Returns ------- handle A new empty ndarray handle """ hdl = NDArrayHandl...
python
def _new_alloc_handle(stype, shape, ctx, delay_alloc, dtype, aux_types, aux_shapes=None): """Return a new handle with specified storage type, shape, dtype and context. Empty handle is only used to hold results Returns ------- handle A new empty ndarray handle """ hdl = NDArrayHandl...
[ "def", "_new_alloc_handle", "(", "stype", ",", "shape", ",", "ctx", ",", "delay_alloc", ",", "dtype", ",", "aux_types", ",", "aux_shapes", "=", "None", ")", ":", "hdl", "=", "NDArrayHandle", "(", ")", "for", "aux_t", "in", "aux_types", ":", "if", "np", ...
Return a new handle with specified storage type, shape, dtype and context. Empty handle is only used to hold results Returns ------- handle A new empty ndarray handle
[ "Return", "a", "new", "handle", "with", "specified", "storage", "type", "shape", "dtype", "and", "context", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L72-L104
23,738
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
_prepare_src_array
def _prepare_src_array(source_array, dtype): """Prepare `source_array` so that it can be used to construct NDArray. `source_array` is converted to a `np.ndarray` if it's neither an `NDArray` \ nor an `np.ndarray`. """ if not isinstance(source_array, NDArray) and not isinstance(source_array, np.ndarr...
python
def _prepare_src_array(source_array, dtype): """Prepare `source_array` so that it can be used to construct NDArray. `source_array` is converted to a `np.ndarray` if it's neither an `NDArray` \ nor an `np.ndarray`. """ if not isinstance(source_array, NDArray) and not isinstance(source_array, np.ndarr...
[ "def", "_prepare_src_array", "(", "source_array", ",", "dtype", ")", ":", "if", "not", "isinstance", "(", "source_array", ",", "NDArray", ")", "and", "not", "isinstance", "(", "source_array", ",", "np", ".", "ndarray", ")", ":", "try", ":", "source_array", ...
Prepare `source_array` so that it can be used to construct NDArray. `source_array` is converted to a `np.ndarray` if it's neither an `NDArray` \ nor an `np.ndarray`.
[ "Prepare", "source_array", "so", "that", "it", "can", "be", "used", "to", "construct", "NDArray", ".", "source_array", "is", "converted", "to", "a", "np", ".", "ndarray", "if", "it", "s", "neither", "an", "NDArray", "\\", "nor", "an", "np", ".", "ndarray...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L796-L806
23,739
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
_prepare_default_dtype
def _prepare_default_dtype(src_array, dtype): """Prepare the value of dtype if `dtype` is None. If `src_array` is an NDArray, numpy.ndarray or scipy.sparse.csr.csr_matrix, return src_array.dtype. float32 is returned otherwise.""" if dtype is None: if isinstance(src_array, (NDArray, np.ndarray)): ...
python
def _prepare_default_dtype(src_array, dtype): """Prepare the value of dtype if `dtype` is None. If `src_array` is an NDArray, numpy.ndarray or scipy.sparse.csr.csr_matrix, return src_array.dtype. float32 is returned otherwise.""" if dtype is None: if isinstance(src_array, (NDArray, np.ndarray)): ...
[ "def", "_prepare_default_dtype", "(", "src_array", ",", "dtype", ")", ":", "if", "dtype", "is", "None", ":", "if", "isinstance", "(", "src_array", ",", "(", "NDArray", ",", "np", ".", "ndarray", ")", ")", ":", "dtype", "=", "src_array", ".", "dtype", "...
Prepare the value of dtype if `dtype` is None. If `src_array` is an NDArray, numpy.ndarray or scipy.sparse.csr.csr_matrix, return src_array.dtype. float32 is returned otherwise.
[ "Prepare", "the", "value", "of", "dtype", "if", "dtype", "is", "None", ".", "If", "src_array", "is", "an", "NDArray", "numpy", ".", "ndarray", "or", "scipy", ".", "sparse", ".", "csr", ".", "csr_matrix", "return", "src_array", ".", "dtype", ".", "float32...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L808-L818
23,740
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
_check_shape
def _check_shape(s1, s2): """check s1 == s2 if both are not None""" if s1 and s2 and s1 != s2: raise ValueError("Shape mismatch detected. " + str(s1) + " v.s. " + str(s2))
python
def _check_shape(s1, s2): """check s1 == s2 if both are not None""" if s1 and s2 and s1 != s2: raise ValueError("Shape mismatch detected. " + str(s1) + " v.s. " + str(s2))
[ "def", "_check_shape", "(", "s1", ",", "s2", ")", ":", "if", "s1", "and", "s2", "and", "s1", "!=", "s2", ":", "raise", "ValueError", "(", "\"Shape mismatch detected. \"", "+", "str", "(", "s1", ")", "+", "\" v.s. \"", "+", "str", "(", "s2", ")", ")" ...
check s1 == s2 if both are not None
[ "check", "s1", "==", "s2", "if", "both", "are", "not", "None" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L820-L823
23,741
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
_csr_matrix_from_definition
def _csr_matrix_from_definition(data, indices, indptr, shape=None, ctx=None, dtype=None, indices_type=None, indptr_type=None): """Create a `CSRNDArray` based on data, indices and indptr""" # pylint: disable= no-member, protected-access storage_type = 'csr' # context c...
python
def _csr_matrix_from_definition(data, indices, indptr, shape=None, ctx=None, dtype=None, indices_type=None, indptr_type=None): """Create a `CSRNDArray` based on data, indices and indptr""" # pylint: disable= no-member, protected-access storage_type = 'csr' # context c...
[ "def", "_csr_matrix_from_definition", "(", "data", ",", "indices", ",", "indptr", ",", "shape", "=", "None", ",", "ctx", "=", "None", ",", "dtype", "=", "None", ",", "indices_type", "=", "None", ",", "indptr_type", "=", "None", ")", ":", "# pylint: disable...
Create a `CSRNDArray` based on data, indices and indptr
[ "Create", "a", "CSRNDArray", "based", "on", "data", "indices", "and", "indptr" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L978-L1017
23,742
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
row_sparse_array
def row_sparse_array(arg1, shape=None, ctx=None, dtype=None): """Creates a `RowSparseNDArray`, a multidimensional row sparse array with a set of \ tensor slices at given indices. The RowSparseNDArray can be instantiated in several ways: - row_sparse_array(D): to construct a RowSparseNDArray wi...
python
def row_sparse_array(arg1, shape=None, ctx=None, dtype=None): """Creates a `RowSparseNDArray`, a multidimensional row sparse array with a set of \ tensor slices at given indices. The RowSparseNDArray can be instantiated in several ways: - row_sparse_array(D): to construct a RowSparseNDArray wi...
[ "def", "row_sparse_array", "(", "arg1", ",", "shape", "=", "None", ",", "ctx", "=", "None", ",", "dtype", "=", "None", ")", ":", "# construct a row sparse array from (D0, D1 ..) or (data, indices)", "if", "isinstance", "(", "arg1", ",", "tuple", ")", ":", "arg_l...
Creates a `RowSparseNDArray`, a multidimensional row sparse array with a set of \ tensor slices at given indices. The RowSparseNDArray can be instantiated in several ways: - row_sparse_array(D): to construct a RowSparseNDArray with a dense ndarray ``D`` - **D** (*array_like*) - An object ...
[ "Creates", "a", "RowSparseNDArray", "a", "multidimensional", "row", "sparse", "array", "with", "a", "set", "of", "\\", "tensor", "slices", "at", "given", "indices", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L1020-L1140
23,743
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
_row_sparse_ndarray_from_definition
def _row_sparse_ndarray_from_definition(data, indices, shape=None, ctx=None, dtype=None, indices_type=None): """Create a `RowSparseNDArray` based on data and indices""" storage_type = 'row_sparse' # context ctx = current_context() if ctx is None else ctx # typ...
python
def _row_sparse_ndarray_from_definition(data, indices, shape=None, ctx=None, dtype=None, indices_type=None): """Create a `RowSparseNDArray` based on data and indices""" storage_type = 'row_sparse' # context ctx = current_context() if ctx is None else ctx # typ...
[ "def", "_row_sparse_ndarray_from_definition", "(", "data", ",", "indices", ",", "shape", "=", "None", ",", "ctx", "=", "None", ",", "dtype", "=", "None", ",", "indices_type", "=", "None", ")", ":", "storage_type", "=", "'row_sparse'", "# context", "ctx", "="...
Create a `RowSparseNDArray` based on data and indices
[ "Create", "a", "RowSparseNDArray", "based", "on", "data", "and", "indices" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L1142-L1175
23,744
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
array
def array(source_array, ctx=None, dtype=None): """Creates a sparse array from any object exposing the array interface. Parameters ---------- source_array : RowSparseNDArray, CSRNDArray or scipy.sparse.csr.csr_matrix The source sparse array ctx : Context, optional The default context...
python
def array(source_array, ctx=None, dtype=None): """Creates a sparse array from any object exposing the array interface. Parameters ---------- source_array : RowSparseNDArray, CSRNDArray or scipy.sparse.csr.csr_matrix The source sparse array ctx : Context, optional The default context...
[ "def", "array", "(", "source_array", ",", "ctx", "=", "None", ",", "dtype", "=", "None", ")", ":", "ctx", "=", "current_context", "(", ")", "if", "ctx", "is", "None", "else", "ctx", "if", "isinstance", "(", "source_array", ",", "NDArray", ")", ":", "...
Creates a sparse array from any object exposing the array interface. Parameters ---------- source_array : RowSparseNDArray, CSRNDArray or scipy.sparse.csr.csr_matrix The source sparse array ctx : Context, optional The default context is ``source_array.context`` if ``source_array`` is an...
[ "Creates", "a", "sparse", "array", "from", "any", "object", "exposing", "the", "array", "interface", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L1579-L1637
23,745
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
BaseSparseNDArray._aux_type
def _aux_type(self, i): """Data-type of the array's ith aux data. Returns ------- numpy.dtype This BaseSparseNDArray's aux data type. """ aux_type = ctypes.c_int() check_call(_LIB.MXNDArrayGetAuxType(self.handle, i, ctypes.byref(aux_type))) re...
python
def _aux_type(self, i): """Data-type of the array's ith aux data. Returns ------- numpy.dtype This BaseSparseNDArray's aux data type. """ aux_type = ctypes.c_int() check_call(_LIB.MXNDArrayGetAuxType(self.handle, i, ctypes.byref(aux_type))) re...
[ "def", "_aux_type", "(", "self", ",", "i", ")", ":", "aux_type", "=", "ctypes", ".", "c_int", "(", ")", "check_call", "(", "_LIB", ".", "MXNDArrayGetAuxType", "(", "self", ".", "handle", ",", "i", ",", "ctypes", ".", "byref", "(", "aux_type", ")", ")...
Data-type of the array's ith aux data. Returns ------- numpy.dtype This BaseSparseNDArray's aux data type.
[ "Data", "-", "type", "of", "the", "array", "s", "ith", "aux", "data", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L164-L174
23,746
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
BaseSparseNDArray._aux_types
def _aux_types(self): """The data types of the aux data for the BaseSparseNDArray. """ aux_types = [] num_aux = self._num_aux for i in range(num_aux): aux_types.append(self._aux_type(i)) return aux_types
python
def _aux_types(self): """The data types of the aux data for the BaseSparseNDArray. """ aux_types = [] num_aux = self._num_aux for i in range(num_aux): aux_types.append(self._aux_type(i)) return aux_types
[ "def", "_aux_types", "(", "self", ")", ":", "aux_types", "=", "[", "]", "num_aux", "=", "self", ".", "_num_aux", "for", "i", "in", "range", "(", "num_aux", ")", ":", "aux_types", ".", "append", "(", "self", ".", "_aux_type", "(", "i", ")", ")", "re...
The data types of the aux data for the BaseSparseNDArray.
[ "The", "data", "types", "of", "the", "aux", "data", "for", "the", "BaseSparseNDArray", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L183-L190
23,747
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
BaseSparseNDArray.astype
def astype(self, dtype, copy=True): """Return 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): """Return 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", "=", "zeros", "(", "shape", "=", "self", ...
Return 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....
[ "Return", "a", "copy", "of", "the", "array", "after", "casting", "to", "a", "specified", "type", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L197-L223
23,748
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
BaseSparseNDArray.check_format
def check_format(self, full_check=True): """Check whether the NDArray format is valid. Parameters ---------- full_check : bool, optional If `True`, rigorous check, O(N) operations. Otherwise basic check, O(1) operations (default True). """ check_c...
python
def check_format(self, full_check=True): """Check whether the NDArray format is valid. Parameters ---------- full_check : bool, optional If `True`, rigorous check, O(N) operations. Otherwise basic check, O(1) operations (default True). """ check_c...
[ "def", "check_format", "(", "self", ",", "full_check", "=", "True", ")", ":", "check_call", "(", "_LIB", ".", "MXNDArraySyncCheckFormat", "(", "self", ".", "handle", ",", "ctypes", ".", "c_bool", "(", "full_check", ")", ")", ")" ]
Check whether the NDArray format is valid. Parameters ---------- full_check : bool, optional If `True`, rigorous check, O(N) operations. Otherwise basic check, O(1) operations (default True).
[ "Check", "whether", "the", "NDArray", "format", "is", "valid", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L252-L261
23,749
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
BaseSparseNDArray._data
def _data(self): """A deep copy NDArray of the data array associated with the BaseSparseNDArray. This function blocks. Do not use it in performance critical code. """ self.wait_to_read() hdl = NDArrayHandle() check_call(_LIB.MXNDArrayGetDataNDArray(self.handle, ctypes.by...
python
def _data(self): """A deep copy NDArray of the data array associated with the BaseSparseNDArray. This function blocks. Do not use it in performance critical code. """ self.wait_to_read() hdl = NDArrayHandle() check_call(_LIB.MXNDArrayGetDataNDArray(self.handle, ctypes.by...
[ "def", "_data", "(", "self", ")", ":", "self", ".", "wait_to_read", "(", ")", "hdl", "=", "NDArrayHandle", "(", ")", "check_call", "(", "_LIB", ".", "MXNDArrayGetDataNDArray", "(", "self", ".", "handle", ",", "ctypes", ".", "byref", "(", "hdl", ")", ")...
A deep copy NDArray of the data array associated with the BaseSparseNDArray. This function blocks. Do not use it in performance critical code.
[ "A", "deep", "copy", "NDArray", "of", "the", "data", "array", "associated", "with", "the", "BaseSparseNDArray", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L263-L271
23,750
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
BaseSparseNDArray._aux_data
def _aux_data(self, i): """ Get a deep copy NDArray of the i-th aux data array associated with the BaseSparseNDArray. This function blocks. Do not use it in performance critical code. """ self.wait_to_read() hdl = NDArrayHandle() check_call(_LIB.MXNDArrayGetAuxND...
python
def _aux_data(self, i): """ Get a deep copy NDArray of the i-th aux data array associated with the BaseSparseNDArray. This function blocks. Do not use it in performance critical code. """ self.wait_to_read() hdl = NDArrayHandle() check_call(_LIB.MXNDArrayGetAuxND...
[ "def", "_aux_data", "(", "self", ",", "i", ")", ":", "self", ".", "wait_to_read", "(", ")", "hdl", "=", "NDArrayHandle", "(", ")", "check_call", "(", "_LIB", ".", "MXNDArrayGetAuxNDArray", "(", "self", ".", "handle", ",", "i", ",", "ctypes", ".", "byre...
Get a deep copy NDArray of the i-th aux data array associated with the BaseSparseNDArray. This function blocks. Do not use it in performance critical code.
[ "Get", "a", "deep", "copy", "NDArray", "of", "the", "i", "-", "th", "aux", "data", "array", "associated", "with", "the", "BaseSparseNDArray", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L274-L283
23,751
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
CSRNDArray.asscipy
def asscipy(self): """Returns a ``scipy.sparse.csr.csr_matrix`` object with value copied from this array Examples -------- >>> x = mx.nd.sparse.zeros('csr', (2,3)) >>> y = x.asscipy() >>> type(y) <type 'scipy.sparse.csr.csr_matrix'> >>> y <2x3 spa...
python
def asscipy(self): """Returns a ``scipy.sparse.csr.csr_matrix`` object with value copied from this array Examples -------- >>> x = mx.nd.sparse.zeros('csr', (2,3)) >>> y = x.asscipy() >>> type(y) <type 'scipy.sparse.csr.csr_matrix'> >>> y <2x3 spa...
[ "def", "asscipy", "(", "self", ")", ":", "data", "=", "self", ".", "data", ".", "asnumpy", "(", ")", "indices", "=", "self", ".", "indices", ".", "asnumpy", "(", ")", "indptr", "=", "self", ".", "indptr", ".", "asnumpy", "(", ")", "if", "not", "s...
Returns a ``scipy.sparse.csr.csr_matrix`` object with value copied from this array Examples -------- >>> x = mx.nd.sparse.zeros('csr', (2,3)) >>> y = x.asscipy() >>> type(y) <type 'scipy.sparse.csr.csr_matrix'> >>> y <2x3 sparse matrix of type '<type 'num...
[ "Returns", "a", "scipy", ".", "sparse", ".", "csr", ".", "csr_matrix", "object", "with", "value", "copied", "from", "this", "array" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L539-L558
23,752
apache/incubator-mxnet
python/mxnet/ndarray/sparse.py
RowSparseNDArray.tostype
def tostype(self, stype): """Return a copy of the array with chosen storage type. Returns ------- NDArray or RowSparseNDArray A copy of the array with the chosen storage stype """ # pylint: disable= no-member, protected-access if stype == 'csr': ...
python
def tostype(self, stype): """Return a copy of the array with chosen storage type. Returns ------- NDArray or RowSparseNDArray A copy of the array with the chosen storage stype """ # pylint: disable= no-member, protected-access if stype == 'csr': ...
[ "def", "tostype", "(", "self", ",", "stype", ")", ":", "# pylint: disable= no-member, protected-access", "if", "stype", "==", "'csr'", ":", "raise", "ValueError", "(", "\"cast_storage from row_sparse to csr is not supported\"", ")", "return", "op", ".", "cast_storage", ...
Return a copy of the array with chosen storage type. Returns ------- NDArray or RowSparseNDArray A copy of the array with the chosen storage stype
[ "Return", "a", "copy", "of", "the", "array", "with", "chosen", "storage", "type", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/sparse.py#L740-L751
23,753
apache/incubator-mxnet
benchmark/python/sparse/memory_benchmark.py
bench_dot
def bench_dot(lhs_row_dim, lhs_col_dim, rhs_col_dim, density, rhs_density, dot_func, trans_lhs, lhs_stype, rhs_stype, only_storage, distribution="uniform"): """ Benchmarking both storage and dot """ lhs_nd = rand_ndarray((lhs_row_dim, lhs_col_dim), lhs_stype, density, distributio...
python
def bench_dot(lhs_row_dim, lhs_col_dim, rhs_col_dim, density, rhs_density, dot_func, trans_lhs, lhs_stype, rhs_stype, only_storage, distribution="uniform"): """ Benchmarking both storage and dot """ lhs_nd = rand_ndarray((lhs_row_dim, lhs_col_dim), lhs_stype, density, distributio...
[ "def", "bench_dot", "(", "lhs_row_dim", ",", "lhs_col_dim", ",", "rhs_col_dim", ",", "density", ",", "rhs_density", ",", "dot_func", ",", "trans_lhs", ",", "lhs_stype", ",", "rhs_stype", ",", "only_storage", ",", "distribution", "=", "\"uniform\"", ")", ":", "...
Benchmarking both storage and dot
[ "Benchmarking", "both", "storage", "and", "dot" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/benchmark/python/sparse/memory_benchmark.py#L79-L89
23,754
apache/incubator-mxnet
tools/caffe_converter/convert_mean.py
convert_mean
def convert_mean(binaryproto_fname, output=None): """Convert caffe mean Parameters ---------- binaryproto_fname : str Filename of the mean output : str, optional Save the mean into mxnet's format Returns ------- NDArray Mean in ndarray """ mean_blob = ca...
python
def convert_mean(binaryproto_fname, output=None): """Convert caffe mean Parameters ---------- binaryproto_fname : str Filename of the mean output : str, optional Save the mean into mxnet's format Returns ------- NDArray Mean in ndarray """ mean_blob = ca...
[ "def", "convert_mean", "(", "binaryproto_fname", ",", "output", "=", "None", ")", ":", "mean_blob", "=", "caffe_parser", ".", "caffe_pb2", ".", "BlobProto", "(", ")", "with", "open", "(", "binaryproto_fname", ",", "'rb'", ")", "as", "f", ":", "mean_blob", ...
Convert caffe mean Parameters ---------- binaryproto_fname : str Filename of the mean output : str, optional Save the mean into mxnet's format Returns ------- NDArray Mean in ndarray
[ "Convert", "caffe", "mean" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/convert_mean.py#L25-L53
23,755
apache/incubator-mxnet
example/ssd/symbol/symbol_builder.py
import_module
def import_module(module_name): """Helper function to import module""" import sys, os import importlib sys.path.append(os.path.dirname(__file__)) return importlib.import_module(module_name)
python
def import_module(module_name): """Helper function to import module""" import sys, os import importlib sys.path.append(os.path.dirname(__file__)) return importlib.import_module(module_name)
[ "def", "import_module", "(", "module_name", ")", ":", "import", "sys", ",", "os", "import", "importlib", "sys", ".", "path", ".", "append", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "return", "importlib", ".", "import_module", "(...
Helper function to import module
[ "Helper", "function", "to", "import", "module" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/symbol/symbol_builder.py#L22-L27
23,756
apache/incubator-mxnet
example/ssd/symbol/symbol_builder.py
get_symbol_train
def get_symbol_train(network, num_classes, from_layers, num_filters, strides, pads, sizes, ratios, normalizations=-1, steps=[], min_filter=128, nms_thresh=0.5, force_suppress=False, nms_topk=400, **kwargs): """Build network symbol for training SSD Parameters ------...
python
def get_symbol_train(network, num_classes, from_layers, num_filters, strides, pads, sizes, ratios, normalizations=-1, steps=[], min_filter=128, nms_thresh=0.5, force_suppress=False, nms_topk=400, **kwargs): """Build network symbol for training SSD Parameters ------...
[ "def", "get_symbol_train", "(", "network", ",", "num_classes", ",", "from_layers", ",", "num_filters", ",", "strides", ",", "pads", ",", "sizes", ",", "ratios", ",", "normalizations", "=", "-", "1", ",", "steps", "=", "[", "]", ",", "min_filter", "=", "1...
Build network symbol for training SSD Parameters ---------- network : str base network symbol name num_classes : int number of object classes not including background from_layers : list of str feature extraction layers, use '' for add extra layers For example: ...
[ "Build", "network", "symbol", "for", "training", "SSD" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/symbol/symbol_builder.py#L29-L116
23,757
apache/incubator-mxnet
example/ssd/symbol/symbol_builder.py
get_symbol
def get_symbol(network, num_classes, from_layers, num_filters, sizes, ratios, strides, pads, normalizations=-1, steps=[], min_filter=128, nms_thresh=0.5, force_suppress=False, nms_topk=400, **kwargs): """Build network for testing SSD Parameters ---------- network : str ...
python
def get_symbol(network, num_classes, from_layers, num_filters, sizes, ratios, strides, pads, normalizations=-1, steps=[], min_filter=128, nms_thresh=0.5, force_suppress=False, nms_topk=400, **kwargs): """Build network for testing SSD Parameters ---------- network : str ...
[ "def", "get_symbol", "(", "network", ",", "num_classes", ",", "from_layers", ",", "num_filters", ",", "sizes", ",", "ratios", ",", "strides", ",", "pads", ",", "normalizations", "=", "-", "1", ",", "steps", "=", "[", "]", ",", "min_filter", "=", "128", ...
Build network for testing SSD Parameters ---------- network : str base network symbol name num_classes : int number of object classes not including background from_layers : list of str feature extraction layers, use '' for add extra layers For example: from_l...
[ "Build", "network", "for", "testing", "SSD" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/symbol/symbol_builder.py#L118-L182
23,758
apache/incubator-mxnet
docs/tutorial_utils/vision/cnn_visualization/gradcam.py
get_conv_out_grad
def get_conv_out_grad(net, image, class_id=None, conv_layer_name=None): """Get the output and gradients of output of a convolutional layer. Parameters: ---------- net: Block Network to use for visualization. image: NDArray Preprocessed image to use for visualization. class_id: i...
python
def get_conv_out_grad(net, image, class_id=None, conv_layer_name=None): """Get the output and gradients of output of a convolutional layer. Parameters: ---------- net: Block Network to use for visualization. image: NDArray Preprocessed image to use for visualization. class_id: i...
[ "def", "get_conv_out_grad", "(", "net", ",", "image", ",", "class_id", "=", "None", ",", "conv_layer_name", "=", "None", ")", ":", "return", "_get_grad", "(", "net", ",", "image", ",", "class_id", ",", "conv_layer_name", ",", "image_grad", "=", "False", ")...
Get the output and gradients of output of a convolutional layer. Parameters: ---------- net: Block Network to use for visualization. image: NDArray Preprocessed image to use for visualization. class_id: int Category ID this image belongs to. If not provided, network'...
[ "Get", "the", "output", "and", "gradients", "of", "output", "of", "a", "convolutional", "layer", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/docs/tutorial_utils/vision/cnn_visualization/gradcam.py#L169-L183
23,759
apache/incubator-mxnet
docs/tutorial_utils/vision/cnn_visualization/gradcam.py
get_image_grad
def get_image_grad(net, image, class_id=None): """Get the gradients of the image. Parameters: ---------- net: Block Network to use for visualization. image: NDArray Preprocessed image to use for visualization. class_id: int Category ID this image belongs to. If not provi...
python
def get_image_grad(net, image, class_id=None): """Get the gradients of the image. Parameters: ---------- net: Block Network to use for visualization. image: NDArray Preprocessed image to use for visualization. class_id: int Category ID this image belongs to. If not provi...
[ "def", "get_image_grad", "(", "net", ",", "image", ",", "class_id", "=", "None", ")", ":", "return", "_get_grad", "(", "net", ",", "image", ",", "class_id", ",", "image_grad", "=", "True", ")" ]
Get the gradients of the image. Parameters: ---------- net: Block Network to use for visualization. image: NDArray Preprocessed image to use for visualization. class_id: int Category ID this image belongs to. If not provided, network's prediction will be used.
[ "Get", "the", "gradients", "of", "the", "image", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/docs/tutorial_utils/vision/cnn_visualization/gradcam.py#L185-L197
23,760
apache/incubator-mxnet
docs/tutorial_utils/vision/cnn_visualization/gradcam.py
grad_to_image
def grad_to_image(gradient): """Convert gradients of image obtained using `get_image_grad` into image. This shows parts of the image that is most strongly activating the output neurons.""" gradient = gradient - gradient.min() gradient /= gradient.max() gradient = np.uint8(gradient * 255).transpo...
python
def grad_to_image(gradient): """Convert gradients of image obtained using `get_image_grad` into image. This shows parts of the image that is most strongly activating the output neurons.""" gradient = gradient - gradient.min() gradient /= gradient.max() gradient = np.uint8(gradient * 255).transpo...
[ "def", "grad_to_image", "(", "gradient", ")", ":", "gradient", "=", "gradient", "-", "gradient", ".", "min", "(", ")", "gradient", "/=", "gradient", ".", "max", "(", ")", "gradient", "=", "np", ".", "uint8", "(", "gradient", "*", "255", ")", ".", "tr...
Convert gradients of image obtained using `get_image_grad` into image. This shows parts of the image that is most strongly activating the output neurons.
[ "Convert", "gradients", "of", "image", "obtained", "using", "get_image_grad", "into", "image", ".", "This", "shows", "parts", "of", "the", "image", "that", "is", "most", "strongly", "activating", "the", "output", "neurons", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/docs/tutorial_utils/vision/cnn_visualization/gradcam.py#L199-L207
23,761
apache/incubator-mxnet
docs/tutorial_utils/vision/cnn_visualization/gradcam.py
get_img_heatmap
def get_img_heatmap(orig_img, activation_map): """Draw a heatmap on top of the original image using intensities from activation_map""" heatmap = cv2.applyColorMap(activation_map, cv2.COLORMAP_COOL) heatmap = cv2.cvtColor(heatmap, cv2.COLOR_BGR2RGB) img_heatmap = np.float32(heatmap) + np.float32(orig_img...
python
def get_img_heatmap(orig_img, activation_map): """Draw a heatmap on top of the original image using intensities from activation_map""" heatmap = cv2.applyColorMap(activation_map, cv2.COLORMAP_COOL) heatmap = cv2.cvtColor(heatmap, cv2.COLOR_BGR2RGB) img_heatmap = np.float32(heatmap) + np.float32(orig_img...
[ "def", "get_img_heatmap", "(", "orig_img", ",", "activation_map", ")", ":", "heatmap", "=", "cv2", ".", "applyColorMap", "(", "activation_map", ",", "cv2", ".", "COLORMAP_COOL", ")", "heatmap", "=", "cv2", ".", "cvtColor", "(", "heatmap", ",", "cv2", ".", ...
Draw a heatmap on top of the original image using intensities from activation_map
[ "Draw", "a", "heatmap", "on", "top", "of", "the", "original", "image", "using", "intensities", "from", "activation_map" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/docs/tutorial_utils/vision/cnn_visualization/gradcam.py#L225-L232
23,762
apache/incubator-mxnet
docs/tutorial_utils/vision/cnn_visualization/gradcam.py
to_grayscale
def to_grayscale(cv2im): """Convert gradients to grayscale. This gives a saliency map.""" # How strongly does each position activate the output grayscale_im = np.sum(np.abs(cv2im), axis=0) # Normalize between min and 99th percentile im_max = np.percentile(grayscale_im, 99) im_min = np.min(grays...
python
def to_grayscale(cv2im): """Convert gradients to grayscale. This gives a saliency map.""" # How strongly does each position activate the output grayscale_im = np.sum(np.abs(cv2im), axis=0) # Normalize between min and 99th percentile im_max = np.percentile(grayscale_im, 99) im_min = np.min(grays...
[ "def", "to_grayscale", "(", "cv2im", ")", ":", "# How strongly does each position activate the output", "grayscale_im", "=", "np", ".", "sum", "(", "np", ".", "abs", "(", "cv2im", ")", ",", "axis", "=", "0", ")", "# Normalize between min and 99th percentile", "im_ma...
Convert gradients to grayscale. This gives a saliency map.
[ "Convert", "gradients", "to", "grayscale", ".", "This", "gives", "a", "saliency", "map", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/docs/tutorial_utils/vision/cnn_visualization/gradcam.py#L234-L245
23,763
apache/incubator-mxnet
python/mxnet/metric.py
check_label_shapes
def check_label_shapes(labels, preds, wrap=False, shape=False): """Helper function for checking shape of label and prediction Parameters ---------- labels : list of `NDArray` The labels of the data. preds : list of `NDArray` Predicted values. wrap : boolean If True, wr...
python
def check_label_shapes(labels, preds, wrap=False, shape=False): """Helper function for checking shape of label and prediction Parameters ---------- labels : list of `NDArray` The labels of the data. preds : list of `NDArray` Predicted values. wrap : boolean If True, wr...
[ "def", "check_label_shapes", "(", "labels", ",", "preds", ",", "wrap", "=", "False", ",", "shape", "=", "False", ")", ":", "if", "not", "shape", ":", "label_shape", ",", "pred_shape", "=", "len", "(", "labels", ")", ",", "len", "(", "preds", ")", "el...
Helper function for checking shape of label and prediction Parameters ---------- labels : list of `NDArray` The labels of the data. preds : list of `NDArray` Predicted values. wrap : boolean If True, wrap labels/preds in a list if they are single NDArray shape : boole...
[ "Helper", "function", "for", "checking", "shape", "of", "label", "and", "prediction" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/metric.py#L33-L66
23,764
apache/incubator-mxnet
python/mxnet/metric.py
create
def create(metric, *args, **kwargs): """Creates evaluation metric from metric names or instances of EvalMetric or a custom metric function. Parameters ---------- metric : str or callable Specifies the metric to create. This argument must be one of the below: - Name of a met...
python
def create(metric, *args, **kwargs): """Creates evaluation metric from metric names or instances of EvalMetric or a custom metric function. Parameters ---------- metric : str or callable Specifies the metric to create. This argument must be one of the below: - Name of a met...
[ "def", "create", "(", "metric", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "callable", "(", "metric", ")", ":", "return", "CustomMetric", "(", "metric", ",", "*", "args", ",", "*", "*", "kwargs", ")", "elif", "isinstance", "(", "met...
Creates evaluation metric from metric names or instances of EvalMetric or a custom metric function. Parameters ---------- metric : str or callable Specifies the metric to create. This argument must be one of the below: - Name of a metric. - An instance of `EvalMetric`. ...
[ "Creates", "evaluation", "metric", "from", "metric", "names", "or", "instances", "of", "EvalMetric", "or", "a", "custom", "metric", "function", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/metric.py#L234-L273
23,765
apache/incubator-mxnet
python/mxnet/metric.py
np
def np(numpy_feval, name=None, allow_extra_outputs=False): """Creates a custom evaluation metric that receives its inputs as numpy arrays. Parameters ---------- numpy_feval : callable(label, pred) Custom evaluation function that receives labels and predictions for a minibatch as numpy a...
python
def np(numpy_feval, name=None, allow_extra_outputs=False): """Creates a custom evaluation metric that receives its inputs as numpy arrays. Parameters ---------- numpy_feval : callable(label, pred) Custom evaluation function that receives labels and predictions for a minibatch as numpy a...
[ "def", "np", "(", "numpy_feval", ",", "name", "=", "None", ",", "allow_extra_outputs", "=", "False", ")", ":", "def", "feval", "(", "label", ",", "pred", ")", ":", "\"\"\"Internal eval function.\"\"\"", "return", "numpy_feval", "(", "label", ",", "pred", ")"...
Creates a custom evaluation metric that receives its inputs as numpy arrays. Parameters ---------- numpy_feval : callable(label, pred) Custom evaluation function that receives labels and predictions for a minibatch as numpy arrays and returns the corresponding custom metric as a floating po...
[ "Creates", "a", "custom", "evaluation", "metric", "that", "receives", "its", "inputs", "as", "numpy", "arrays", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/metric.py#L1747-L1778
23,766
apache/incubator-mxnet
python/mxnet/metric.py
EvalMetric.update_dict
def update_dict(self, label, pred): """Update the internal evaluation with named label and pred Parameters ---------- labels : OrderedDict of str -> NDArray name to array mapping for labels. preds : OrderedDict of str -> NDArray name to array mapping of ...
python
def update_dict(self, label, pred): """Update the internal evaluation with named label and pred Parameters ---------- labels : OrderedDict of str -> NDArray name to array mapping for labels. preds : OrderedDict of str -> NDArray name to array mapping of ...
[ "def", "update_dict", "(", "self", ",", "label", ",", "pred", ")", ":", "if", "self", ".", "output_names", "is", "not", "None", ":", "pred", "=", "[", "pred", "[", "name", "]", "for", "name", "in", "self", ".", "output_names", "]", "else", ":", "pr...
Update the internal evaluation with named label and pred Parameters ---------- labels : OrderedDict of str -> NDArray name to array mapping for labels. preds : OrderedDict of str -> NDArray name to array mapping of predicted outputs.
[ "Update", "the", "internal", "evaluation", "with", "named", "label", "and", "pred" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/metric.py#L112-L133
23,767
apache/incubator-mxnet
python/mxnet/metric.py
EvalMetric.reset
def reset(self): """Resets the internal evaluation result to initial state.""" self.num_inst = 0 self.sum_metric = 0.0 self.global_num_inst = 0 self.global_sum_metric = 0.0
python
def reset(self): """Resets the internal evaluation result to initial state.""" self.num_inst = 0 self.sum_metric = 0.0 self.global_num_inst = 0 self.global_sum_metric = 0.0
[ "def", "reset", "(", "self", ")", ":", "self", ".", "num_inst", "=", "0", "self", ".", "sum_metric", "=", "0.0", "self", ".", "global_num_inst", "=", "0", "self", ".", "global_sum_metric", "=", "0.0" ]
Resets the internal evaluation result to initial state.
[ "Resets", "the", "internal", "evaluation", "result", "to", "initial", "state", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/metric.py#L148-L153
23,768
apache/incubator-mxnet
python/mxnet/metric.py
EvalMetric.get
def get(self): """Gets the current evaluation result. Returns ------- names : list of str Name of the metrics. values : list of float Value of the evaluations. """ if self.num_inst == 0: return (self.name, float('nan')) e...
python
def get(self): """Gets the current evaluation result. Returns ------- names : list of str Name of the metrics. values : list of float Value of the evaluations. """ if self.num_inst == 0: return (self.name, float('nan')) e...
[ "def", "get", "(", "self", ")", ":", "if", "self", ".", "num_inst", "==", "0", ":", "return", "(", "self", ".", "name", ",", "float", "(", "'nan'", ")", ")", "else", ":", "return", "(", "self", ".", "name", ",", "self", ".", "sum_metric", "/", ...
Gets the current evaluation result. Returns ------- names : list of str Name of the metrics. values : list of float Value of the evaluations.
[ "Gets", "the", "current", "evaluation", "result", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/metric.py#L161-L174
23,769
apache/incubator-mxnet
python/mxnet/metric.py
EvalMetric.get_global
def get_global(self): """Gets the current global evaluation result. Returns ------- names : list of str Name of the metrics. values : list of float Value of the evaluations. """ if self._has_global_stats: if self.global_num_inst ...
python
def get_global(self): """Gets the current global evaluation result. Returns ------- names : list of str Name of the metrics. values : list of float Value of the evaluations. """ if self._has_global_stats: if self.global_num_inst ...
[ "def", "get_global", "(", "self", ")", ":", "if", "self", ".", "_has_global_stats", ":", "if", "self", ".", "global_num_inst", "==", "0", ":", "return", "(", "self", ".", "name", ",", "float", "(", "'nan'", ")", ")", "else", ":", "return", "(", "self...
Gets the current global evaluation result. Returns ------- names : list of str Name of the metrics. values : list of float Value of the evaluations.
[ "Gets", "the", "current", "global", "evaluation", "result", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/metric.py#L176-L192
23,770
apache/incubator-mxnet
python/mxnet/metric.py
EvalMetric.get_name_value
def get_name_value(self): """Returns zipped name and value pairs. Returns ------- list of tuples A (name, value) tuple list. """ name, value = self.get() if not isinstance(name, list): name = [name] if not isinstance(value, list): ...
python
def get_name_value(self): """Returns zipped name and value pairs. Returns ------- list of tuples A (name, value) tuple list. """ name, value = self.get() if not isinstance(name, list): name = [name] if not isinstance(value, list): ...
[ "def", "get_name_value", "(", "self", ")", ":", "name", ",", "value", "=", "self", ".", "get", "(", ")", "if", "not", "isinstance", "(", "name", ",", "list", ")", ":", "name", "=", "[", "name", "]", "if", "not", "isinstance", "(", "value", ",", "...
Returns zipped name and value pairs. Returns ------- list of tuples A (name, value) tuple list.
[ "Returns", "zipped", "name", "and", "value", "pairs", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/metric.py#L194-L207
23,771
apache/incubator-mxnet
python/mxnet/metric.py
EvalMetric.get_global_name_value
def get_global_name_value(self): """Returns zipped name and value pairs for global results. Returns ------- list of tuples A (name, value) tuple list. """ if self._has_global_stats: name, value = self.get_global() if not isinstance(nam...
python
def get_global_name_value(self): """Returns zipped name and value pairs for global results. Returns ------- list of tuples A (name, value) tuple list. """ if self._has_global_stats: name, value = self.get_global() if not isinstance(nam...
[ "def", "get_global_name_value", "(", "self", ")", ":", "if", "self", ".", "_has_global_stats", ":", "name", ",", "value", "=", "self", ".", "get_global", "(", ")", "if", "not", "isinstance", "(", "name", ",", "list", ")", ":", "name", "=", "[", "name",...
Returns zipped name and value pairs for global results. Returns ------- list of tuples A (name, value) tuple list.
[ "Returns", "zipped", "name", "and", "value", "pairs", "for", "global", "results", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/metric.py#L209-L225
23,772
apache/incubator-mxnet
python/mxnet/metric.py
_BinaryClassificationMetrics.matthewscc
def matthewscc(self, use_global=False): """ Calculate the Matthew's Correlation Coefficent """ if use_global: if not self.global_total_examples: return 0. true_pos = float(self.global_true_positives) false_pos = float(self.global_false...
python
def matthewscc(self, use_global=False): """ Calculate the Matthew's Correlation Coefficent """ if use_global: if not self.global_total_examples: return 0. true_pos = float(self.global_true_positives) false_pos = float(self.global_false...
[ "def", "matthewscc", "(", "self", ",", "use_global", "=", "False", ")", ":", "if", "use_global", ":", "if", "not", "self", ".", "global_total_examples", ":", "return", "0.", "true_pos", "=", "float", "(", "self", ".", "global_true_positives", ")", "false_pos...
Calculate the Matthew's Correlation Coefficent
[ "Calculate", "the", "Matthew", "s", "Correlation", "Coefficent" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/metric.py#L693-L721
23,773
apache/incubator-mxnet
python/mxnet/gluon/data/dataset.py
Dataset.transform
def transform(self, fn, lazy=True): """Returns a new dataset with each sample transformed by the transformer function `fn`. Parameters ---------- fn : callable A transformer function that takes a sample as input and returns the transformed sample. ...
python
def transform(self, fn, lazy=True): """Returns a new dataset with each sample transformed by the transformer function `fn`. Parameters ---------- fn : callable A transformer function that takes a sample as input and returns the transformed sample. ...
[ "def", "transform", "(", "self", ",", "fn", ",", "lazy", "=", "True", ")", ":", "trans", "=", "_LazyTransformDataset", "(", "self", ",", "fn", ")", "if", "lazy", ":", "return", "trans", "return", "SimpleDataset", "(", "[", "i", "for", "i", "in", "tra...
Returns a new dataset with each sample transformed by the transformer function `fn`. Parameters ---------- fn : callable A transformer function that takes a sample as input and returns the transformed sample. lazy : bool, default True If False...
[ "Returns", "a", "new", "dataset", "with", "each", "sample", "transformed", "by", "the", "transformer", "function", "fn", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataset.py#L43-L66
23,774
apache/incubator-mxnet
example/ctc/ocr_predict.py
lstm_ocr_model.forward_ocr
def forward_ocr(self, img_): """Forward the image through the LSTM network model Parameters ---------- img_: int of array Returns ---------- label_list: string of list """ img_ = cv2.resize(img_, (80, 30)) img_ = img_.transpose(1, 0) ...
python
def forward_ocr(self, img_): """Forward the image through the LSTM network model Parameters ---------- img_: int of array Returns ---------- label_list: string of list """ img_ = cv2.resize(img_, (80, 30)) img_ = img_.transpose(1, 0) ...
[ "def", "forward_ocr", "(", "self", ",", "img_", ")", ":", "img_", "=", "cv2", ".", "resize", "(", "img_", ",", "(", "80", ",", "30", ")", ")", "img_", "=", "img_", ".", "transpose", "(", "1", ",", "0", ")", "print", "(", "img_", ".", "shape", ...
Forward the image through the LSTM network model Parameters ---------- img_: int of array Returns ---------- label_list: string of list
[ "Forward", "the", "image", "through", "the", "LSTM", "network", "model" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/ocr_predict.py#L63-L88
23,775
apache/incubator-mxnet
tools/caffe_converter/caffe_parser.py
read_prototxt
def read_prototxt(fname): """Return a caffe_pb2.NetParameter object that defined in a prototxt file """ proto = caffe_pb2.NetParameter() with open(fname, 'r') as f: text_format.Merge(str(f.read()), proto) return proto
python
def read_prototxt(fname): """Return a caffe_pb2.NetParameter object that defined in a prototxt file """ proto = caffe_pb2.NetParameter() with open(fname, 'r') as f: text_format.Merge(str(f.read()), proto) return proto
[ "def", "read_prototxt", "(", "fname", ")", ":", "proto", "=", "caffe_pb2", ".", "NetParameter", "(", ")", "with", "open", "(", "fname", ",", "'r'", ")", "as", "f", ":", "text_format", ".", "Merge", "(", "str", "(", "f", ".", "read", "(", ")", ")", ...
Return a caffe_pb2.NetParameter object that defined in a prototxt file
[ "Return", "a", "caffe_pb2", ".", "NetParameter", "object", "that", "defined", "in", "a", "prototxt", "file" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/caffe_parser.py#L34-L40
23,776
apache/incubator-mxnet
tools/caffe_converter/caffe_parser.py
get_layers
def get_layers(proto): """Returns layers in a caffe_pb2.NetParameter object """ if len(proto.layer): return proto.layer elif len(proto.layers): return proto.layers else: raise ValueError('Invalid proto file.')
python
def get_layers(proto): """Returns layers in a caffe_pb2.NetParameter object """ if len(proto.layer): return proto.layer elif len(proto.layers): return proto.layers else: raise ValueError('Invalid proto file.')
[ "def", "get_layers", "(", "proto", ")", ":", "if", "len", "(", "proto", ".", "layer", ")", ":", "return", "proto", ".", "layer", "elif", "len", "(", "proto", ".", "layers", ")", ":", "return", "proto", ".", "layers", "else", ":", "raise", "ValueError...
Returns layers in a caffe_pb2.NetParameter object
[ "Returns", "layers", "in", "a", "caffe_pb2", ".", "NetParameter", "object" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/caffe_parser.py#L42-L50
23,777
apache/incubator-mxnet
tools/caffe_converter/caffe_parser.py
read_caffemodel
def read_caffemodel(prototxt_fname, caffemodel_fname): """Return a caffe_pb2.NetParameter object that defined in a binary caffemodel file """ if use_caffe: caffe.set_mode_cpu() net = caffe.Net(prototxt_fname, caffemodel_fname, caffe.TEST) layer_names = net._layer_names la...
python
def read_caffemodel(prototxt_fname, caffemodel_fname): """Return a caffe_pb2.NetParameter object that defined in a binary caffemodel file """ if use_caffe: caffe.set_mode_cpu() net = caffe.Net(prototxt_fname, caffemodel_fname, caffe.TEST) layer_names = net._layer_names la...
[ "def", "read_caffemodel", "(", "prototxt_fname", ",", "caffemodel_fname", ")", ":", "if", "use_caffe", ":", "caffe", ".", "set_mode_cpu", "(", ")", "net", "=", "caffe", ".", "Net", "(", "prototxt_fname", ",", "caffemodel_fname", ",", "caffe", ".", "TEST", ")...
Return a caffe_pb2.NetParameter object that defined in a binary caffemodel file
[ "Return", "a", "caffe_pb2", ".", "NetParameter", "object", "that", "defined", "in", "a", "binary", "caffemodel", "file" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/caffe_parser.py#L52-L66
23,778
apache/incubator-mxnet
tools/caffe_converter/caffe_parser.py
layer_iter
def layer_iter(layers, layer_names): """Iterate over all layers""" if use_caffe: for layer_idx, layer in enumerate(layers): layer_name = re.sub('[-/]', '_', layer_names[layer_idx]) layer_type = layer.type layer_blobs = layer.blobs yield (layer_name, layer_...
python
def layer_iter(layers, layer_names): """Iterate over all layers""" if use_caffe: for layer_idx, layer in enumerate(layers): layer_name = re.sub('[-/]', '_', layer_names[layer_idx]) layer_type = layer.type layer_blobs = layer.blobs yield (layer_name, layer_...
[ "def", "layer_iter", "(", "layers", ",", "layer_names", ")", ":", "if", "use_caffe", ":", "for", "layer_idx", ",", "layer", "in", "enumerate", "(", "layers", ")", ":", "layer_name", "=", "re", ".", "sub", "(", "'[-/]'", ",", "'_'", ",", "layer_names", ...
Iterate over all layers
[ "Iterate", "over", "all", "layers" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/caffe_parser.py#L68-L81
23,779
apache/incubator-mxnet
python/mxnet/profiler.py
set_state
def set_state(state='stop', profile_process='worker'): """Set up the profiler state to 'run' or 'stop'. Parameters ---------- state : string, optional Indicates whether to run the profiler, can be 'stop' or 'run'. Default is `stop`. profile_process : string whether to profil...
python
def set_state(state='stop', profile_process='worker'): """Set up the profiler state to 'run' or 'stop'. Parameters ---------- state : string, optional Indicates whether to run the profiler, can be 'stop' or 'run'. Default is `stop`. profile_process : string whether to profil...
[ "def", "set_state", "(", "state", "=", "'stop'", ",", "profile_process", "=", "'worker'", ")", ":", "state2int", "=", "{", "'stop'", ":", "0", ",", "'run'", ":", "1", "}", "profile_process2int", "=", "{", "'worker'", ":", "0", ",", "'server'", ":", "1"...
Set up the profiler state to 'run' or 'stop'. Parameters ---------- state : string, optional Indicates whether to run the profiler, can be 'stop' or 'run'. Default is `stop`. profile_process : string whether to profile kvstore `server` or `worker`. server can only be pro...
[ "Set", "up", "the", "profiler", "state", "to", "run", "or", "stop", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/profiler.py#L89-L106
23,780
apache/incubator-mxnet
python/mxnet/profiler.py
dump
def dump(finished=True, profile_process='worker'): """Dump profile and stop profiler. Use this to save profile in advance in case your program cannot exit normally. Parameters ---------- finished : boolean Indicates whether to stop statistic output (dumping) after this dump. Default...
python
def dump(finished=True, profile_process='worker'): """Dump profile and stop profiler. Use this to save profile in advance in case your program cannot exit normally. Parameters ---------- finished : boolean Indicates whether to stop statistic output (dumping) after this dump. Default...
[ "def", "dump", "(", "finished", "=", "True", ",", "profile_process", "=", "'worker'", ")", ":", "fin", "=", "1", "if", "finished", "is", "True", "else", "0", "profile_process2int", "=", "{", "'worker'", ":", "0", ",", "'server'", ":", "1", "}", "check_...
Dump profile and stop profiler. Use this to save profile in advance in case your program cannot exit normally. Parameters ---------- finished : boolean Indicates whether to stop statistic output (dumping) after this dump. Default is True profile_process : string whether to p...
[ "Dump", "profile", "and", "stop", "profiler", ".", "Use", "this", "to", "save", "profile", "in", "advance", "in", "case", "your", "program", "cannot", "exit", "normally", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/profiler.py#L122-L140
23,781
apache/incubator-mxnet
python/mxnet/profiler.py
dumps
def dumps(reset=False): """Return a printable string of aggregate profile stats. Parameters ---------- reset: boolean Indicates whether to clean aggeregate statistical data collected up to this point """ debug_str = ctypes.c_char_p() do_reset = 1 if reset is True else 0 check_ca...
python
def dumps(reset=False): """Return a printable string of aggregate profile stats. Parameters ---------- reset: boolean Indicates whether to clean aggeregate statistical data collected up to this point """ debug_str = ctypes.c_char_p() do_reset = 1 if reset is True else 0 check_ca...
[ "def", "dumps", "(", "reset", "=", "False", ")", ":", "debug_str", "=", "ctypes", ".", "c_char_p", "(", ")", "do_reset", "=", "1", "if", "reset", "is", "True", "else", "0", "check_call", "(", "_LIB", ".", "MXAggregateProfileStatsPrint", "(", "ctypes", "....
Return a printable string of aggregate profile stats. Parameters ---------- reset: boolean Indicates whether to clean aggeregate statistical data collected up to this point
[ "Return", "a", "printable", "string", "of", "aggregate", "profile", "stats", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/profiler.py#L151-L162
23,782
apache/incubator-mxnet
python/mxnet/profiler.py
pause
def pause(profile_process='worker'): """Pause profiling. Parameters ---------- profile_process : string whether to profile kvstore `server` or `worker`. server can only be profiled when kvstore is of type dist. if this is not passed, defaults to `worker` """ profile_proc...
python
def pause(profile_process='worker'): """Pause profiling. Parameters ---------- profile_process : string whether to profile kvstore `server` or `worker`. server can only be profiled when kvstore is of type dist. if this is not passed, defaults to `worker` """ profile_proc...
[ "def", "pause", "(", "profile_process", "=", "'worker'", ")", ":", "profile_process2int", "=", "{", "'worker'", ":", "0", ",", "'server'", ":", "1", "}", "check_call", "(", "_LIB", ".", "MXProcessProfilePause", "(", "int", "(", "1", ")", ",", "profile_proc...
Pause profiling. Parameters ---------- profile_process : string whether to profile kvstore `server` or `worker`. server can only be profiled when kvstore is of type dist. if this is not passed, defaults to `worker`
[ "Pause", "profiling", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/profiler.py#L165-L178
23,783
apache/incubator-mxnet
python/mxnet/profiler.py
resume
def resume(profile_process='worker'): """ Resume paused profiling. Parameters ---------- profile_process : string whether to profile kvstore `server` or `worker`. server can only be profiled when kvstore is of type dist. if this is not passed, defaults to `worker` """ ...
python
def resume(profile_process='worker'): """ Resume paused profiling. Parameters ---------- profile_process : string whether to profile kvstore `server` or `worker`. server can only be profiled when kvstore is of type dist. if this is not passed, defaults to `worker` """ ...
[ "def", "resume", "(", "profile_process", "=", "'worker'", ")", ":", "profile_process2int", "=", "{", "'worker'", ":", "0", ",", "'server'", ":", "1", "}", "check_call", "(", "_LIB", ".", "MXProcessProfilePause", "(", "int", "(", "0", ")", ",", "profile_pro...
Resume paused profiling. Parameters ---------- profile_process : string whether to profile kvstore `server` or `worker`. server can only be profiled when kvstore is of type dist. if this is not passed, defaults to `worker`
[ "Resume", "paused", "profiling", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/profiler.py#L181-L195
23,784
apache/incubator-mxnet
python/mxnet/profiler.py
Counter.set_value
def set_value(self, value): """Set counter value. Parameters ---------- value : int Value for the counter """ check_call(_LIB.MXProfileSetCounter(self.handle, int(value)))
python
def set_value(self, value): """Set counter value. Parameters ---------- value : int Value for the counter """ check_call(_LIB.MXProfileSetCounter(self.handle, int(value)))
[ "def", "set_value", "(", "self", ",", "value", ")", ":", "check_call", "(", "_LIB", ".", "MXProfileSetCounter", "(", "self", ".", "handle", ",", "int", "(", "value", ")", ")", ")" ]
Set counter value. Parameters ---------- value : int Value for the counter
[ "Set", "counter", "value", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/profiler.py#L405-L413
23,785
apache/incubator-mxnet
python/mxnet/profiler.py
Counter.decrement
def decrement(self, delta=1): """Decrement counter value. Parameters ---------- value_change : int Amount by which to subtract from the counter """ check_call(_LIB.MXProfileAdjustCounter(self.handle, -int(delta)))
python
def decrement(self, delta=1): """Decrement counter value. Parameters ---------- value_change : int Amount by which to subtract from the counter """ check_call(_LIB.MXProfileAdjustCounter(self.handle, -int(delta)))
[ "def", "decrement", "(", "self", ",", "delta", "=", "1", ")", ":", "check_call", "(", "_LIB", ".", "MXProfileAdjustCounter", "(", "self", ".", "handle", ",", "-", "int", "(", "delta", ")", ")", ")" ]
Decrement counter value. Parameters ---------- value_change : int Amount by which to subtract from the counter
[ "Decrement", "counter", "value", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/profiler.py#L425-L433
23,786
apache/incubator-mxnet
python/mxnet/profiler.py
Marker.mark
def mark(self, scope='process'): """Set up the profiler state to record operator. Parameters ---------- scope : string, optional Indicates what scope the marker should refer to. Can be 'global', 'process', thread', task', and 'marker' Default is `proc...
python
def mark(self, scope='process'): """Set up the profiler state to record operator. Parameters ---------- scope : string, optional Indicates what scope the marker should refer to. Can be 'global', 'process', thread', task', and 'marker' Default is `proc...
[ "def", "mark", "(", "self", ",", "scope", "=", "'process'", ")", ":", "check_call", "(", "_LIB", ".", "MXProfileSetMarker", "(", "self", ".", "domain", ".", "handle", ",", "c_str", "(", "self", ".", "name", ")", ",", "c_str", "(", "scope", ")", ")", ...
Set up the profiler state to record operator. Parameters ---------- scope : string, optional Indicates what scope the marker should refer to. Can be 'global', 'process', thread', task', and 'marker' Default is `process`.
[ "Set", "up", "the", "profiler", "state", "to", "record", "operator", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/profiler.py#L463-L473
23,787
apache/incubator-mxnet
python/mxnet/rtc.py
CudaModule.get_kernel
def get_kernel(self, name, signature): r"""Get CUDA kernel from compiled module. Parameters ---------- name : str String name of the kernel. signature : str Function signature for the kernel. For example, if a kernel is declared as:: ...
python
def get_kernel(self, name, signature): r"""Get CUDA kernel from compiled module. Parameters ---------- name : str String name of the kernel. signature : str Function signature for the kernel. For example, if a kernel is declared as:: ...
[ "def", "get_kernel", "(", "self", ",", "name", ",", "signature", ")", ":", "hdl", "=", "CudaKernelHandle", "(", ")", "is_ndarray", "=", "[", "]", "is_const", "=", "[", "]", "dtypes", "=", "[", "]", "pattern", "=", "re", ".", "compile", "(", "r\"\"\"^...
r"""Get CUDA kernel from compiled module. Parameters ---------- name : str String name of the kernel. signature : str Function signature for the kernel. For example, if a kernel is declared as:: extern "C" __global__ void axpy(const f...
[ "r", "Get", "CUDA", "kernel", "from", "compiled", "module", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rtc.py#L112-L171
23,788
apache/incubator-mxnet
python/mxnet/rtc.py
CudaKernel.launch
def launch(self, args, ctx, grid_dims, block_dims, shared_mem=0): """Launch cuda kernel. Parameters ---------- args : tuple of NDArray or numbers List of arguments for kernel. NDArrays are expected for pointer types (e.g. `float*`, `double*`) while numbers are ex...
python
def launch(self, args, ctx, grid_dims, block_dims, shared_mem=0): """Launch cuda kernel. Parameters ---------- args : tuple of NDArray or numbers List of arguments for kernel. NDArrays are expected for pointer types (e.g. `float*`, `double*`) while numbers are ex...
[ "def", "launch", "(", "self", ",", "args", ",", "ctx", ",", "grid_dims", ",", "block_dims", ",", "shared_mem", "=", "0", ")", ":", "assert", "ctx", ".", "device_type", "==", "'gpu'", ",", "\"Cuda kernel can only be launched on GPU\"", "assert", "len", "(", "...
Launch cuda kernel. Parameters ---------- args : tuple of NDArray or numbers List of arguments for kernel. NDArrays are expected for pointer types (e.g. `float*`, `double*`) while numbers are expected for non-pointer types (e.g. `int`, `float`). ctx :...
[ "Launch", "cuda", "kernel", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rtc.py#L185-L230
23,789
apache/incubator-mxnet
example/ssd/evaluate/eval_metric.py
MApMetric.reset
def reset(self): """Clear the internal statistics to initial state.""" if getattr(self, 'num', None) is None: self.num_inst = 0 self.sum_metric = 0.0 else: self.num_inst = [0] * self.num self.sum_metric = [0.0] * self.num self.records = dic...
python
def reset(self): """Clear the internal statistics to initial state.""" if getattr(self, 'num', None) is None: self.num_inst = 0 self.sum_metric = 0.0 else: self.num_inst = [0] * self.num self.sum_metric = [0.0] * self.num self.records = dic...
[ "def", "reset", "(", "self", ")", ":", "if", "getattr", "(", "self", ",", "'num'", ",", "None", ")", "is", "None", ":", "self", ".", "num_inst", "=", "0", "self", ".", "sum_metric", "=", "0.0", "else", ":", "self", ".", "num_inst", "=", "[", "0",...
Clear the internal statistics to initial state.
[ "Clear", "the", "internal", "statistics", "to", "initial", "state", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/evaluate/eval_metric.py#L53-L62
23,790
apache/incubator-mxnet
example/ssd/evaluate/eval_metric.py
MApMetric._update
def _update(self): """ update num_inst and sum_metric """ aps = [] for k, v in self.records.items(): recall, prec = self._recall_prec(v, self.counts[k]) ap = self._average_precision(recall, prec) aps.append(ap) if self.num is not None and k < (self...
python
def _update(self): """ update num_inst and sum_metric """ aps = [] for k, v in self.records.items(): recall, prec = self._recall_prec(v, self.counts[k]) ap = self._average_precision(recall, prec) aps.append(ap) if self.num is not None and k < (self...
[ "def", "_update", "(", "self", ")", ":", "aps", "=", "[", "]", "for", "k", ",", "v", "in", "self", ".", "records", ".", "items", "(", ")", ":", "recall", ",", "prec", "=", "self", ".", "_recall_prec", "(", "v", ",", "self", ".", "counts", "[", ...
update num_inst and sum_metric
[ "update", "num_inst", "and", "sum_metric" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/evaluate/eval_metric.py#L197-L212
23,791
apache/incubator-mxnet
example/ssd/evaluate/eval_metric.py
MApMetric._recall_prec
def _recall_prec(self, record, count): """ get recall and precision from internal records """ record = np.delete(record, np.where(record[:, 1].astype(int) == 0)[0], axis=0) sorted_records = record[record[:,0].argsort()[::-1]] tp = np.cumsum(sorted_records[:, 1].astype(int) == 1) ...
python
def _recall_prec(self, record, count): """ get recall and precision from internal records """ record = np.delete(record, np.where(record[:, 1].astype(int) == 0)[0], axis=0) sorted_records = record[record[:,0].argsort()[::-1]] tp = np.cumsum(sorted_records[:, 1].astype(int) == 1) ...
[ "def", "_recall_prec", "(", "self", ",", "record", ",", "count", ")", ":", "record", "=", "np", ".", "delete", "(", "record", ",", "np", ".", "where", "(", "record", "[", ":", ",", "1", "]", ".", "astype", "(", "int", ")", "==", "0", ")", "[", ...
get recall and precision from internal records
[ "get", "recall", "and", "precision", "from", "internal", "records" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/evaluate/eval_metric.py#L214-L225
23,792
apache/incubator-mxnet
example/ssd/evaluate/eval_metric.py
MApMetric._average_precision
def _average_precision(self, rec, prec): """ calculate average precision Params: ---------- rec : numpy.array cumulated recall prec : numpy.array cumulated precision Returns: ---------- ap as float """ # app...
python
def _average_precision(self, rec, prec): """ calculate average precision Params: ---------- rec : numpy.array cumulated recall prec : numpy.array cumulated precision Returns: ---------- ap as float """ # app...
[ "def", "_average_precision", "(", "self", ",", "rec", ",", "prec", ")", ":", "# append sentinel values at both ends", "mrec", "=", "np", ".", "concatenate", "(", "(", "[", "0.", "]", ",", "rec", ",", "[", "1.", "]", ")", ")", "mpre", "=", "np", ".", ...
calculate average precision Params: ---------- rec : numpy.array cumulated recall prec : numpy.array cumulated precision Returns: ---------- ap as float
[ "calculate", "average", "precision" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/evaluate/eval_metric.py#L227-L254
23,793
apache/incubator-mxnet
example/ssd/evaluate/eval_metric.py
MApMetric._insert
def _insert(self, key, records, count): """ Insert records according to key """ if key not in self.records: assert key not in self.counts self.records[key] = records self.counts[key] = count else: self.records[key] = np.vstack((self.records[key], r...
python
def _insert(self, key, records, count): """ Insert records according to key """ if key not in self.records: assert key not in self.counts self.records[key] = records self.counts[key] = count else: self.records[key] = np.vstack((self.records[key], r...
[ "def", "_insert", "(", "self", ",", "key", ",", "records", ",", "count", ")", ":", "if", "key", "not", "in", "self", ".", "records", ":", "assert", "key", "not", "in", "self", ".", "counts", "self", ".", "records", "[", "key", "]", "=", "records", ...
Insert records according to key
[ "Insert", "records", "according", "to", "key" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/evaluate/eval_metric.py#L256-L265
23,794
apache/incubator-mxnet
example/ssd/evaluate/eval_metric.py
VOC07MApMetric._average_precision
def _average_precision(self, rec, prec): """ calculate average precision, override the default one, special 11-point metric Params: ---------- rec : numpy.array cumulated recall prec : numpy.array cumulated precision Returns: ...
python
def _average_precision(self, rec, prec): """ calculate average precision, override the default one, special 11-point metric Params: ---------- rec : numpy.array cumulated recall prec : numpy.array cumulated precision Returns: ...
[ "def", "_average_precision", "(", "self", ",", "rec", ",", "prec", ")", ":", "ap", "=", "0.", "for", "t", "in", "np", ".", "arange", "(", "0.", ",", "1.1", ",", "0.1", ")", ":", "if", "np", ".", "sum", "(", "rec", ">=", "t", ")", "==", "0", ...
calculate average precision, override the default one, special 11-point metric Params: ---------- rec : numpy.array cumulated recall prec : numpy.array cumulated precision Returns: ---------- ap as float
[ "calculate", "average", "precision", "override", "the", "default", "one", "special", "11", "-", "point", "metric" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/evaluate/eval_metric.py#L273-L295
23,795
apache/incubator-mxnet
python/mxnet/initializer.py
Initializer._verbose_print
def _verbose_print(self, desc, init, arr): """Internal verbose print function Parameters ---------- desc : InitDesc or str name of the array init : str initializer pattern arr : NDArray initialized array """ if self._ve...
python
def _verbose_print(self, desc, init, arr): """Internal verbose print function Parameters ---------- desc : InitDesc or str name of the array init : str initializer pattern arr : NDArray initialized array """ if self._ve...
[ "def", "_verbose_print", "(", "self", ",", "desc", ",", "init", ",", "arr", ")", ":", "if", "self", ".", "_verbose", "and", "self", ".", "_print_func", ":", "logging", ".", "info", "(", "'Initialized %s as %s: %s'", ",", "desc", ",", "init", ",", "self",...
Internal verbose print function Parameters ---------- desc : InitDesc or str name of the array init : str initializer pattern arr : NDArray initialized array
[ "Internal", "verbose", "print", "function" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/initializer.py#L82-L95
23,796
apache/incubator-mxnet
python/mxnet/initializer.py
Initializer._legacy_init
def _legacy_init(self, name, arr): """Legacy initialization method. Parameters ---------- name : str Name of corresponding NDArray. arr : NDArray NDArray to be initialized. """ warnings.warn( "\033[91mCalling initializer with ...
python
def _legacy_init(self, name, arr): """Legacy initialization method. Parameters ---------- name : str Name of corresponding NDArray. arr : NDArray NDArray to be initialized. """ warnings.warn( "\033[91mCalling initializer with ...
[ "def", "_legacy_init", "(", "self", ",", "name", ",", "arr", ")", ":", "warnings", ".", "warn", "(", "\"\\033[91mCalling initializer with init(str, NDArray) has been deprecated.\"", "\"please use init(mx.init.InitDesc(...), NDArray) instead.\\033[0m\"", ",", "DeprecationWarning", ...
Legacy initialization method. Parameters ---------- name : str Name of corresponding NDArray. arr : NDArray NDArray to be initialized.
[ "Legacy", "initialization", "method", "." ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/initializer.py#L171-L217
23,797
apache/incubator-mxnet
example/ssd/dataset/imdb.py
Imdb.save_imglist
def save_imglist(self, fname=None, root=None, shuffle=False): """ save imglist to disk Parameters: ---------- fname : str saved filename """ def progress_bar(count, total, suffix=''): import sys bar_len = 24 filled_...
python
def save_imglist(self, fname=None, root=None, shuffle=False): """ save imglist to disk Parameters: ---------- fname : str saved filename """ def progress_bar(count, total, suffix=''): import sys bar_len = 24 filled_...
[ "def", "save_imglist", "(", "self", ",", "fname", "=", "None", ",", "root", "=", "None", ",", "shuffle", "=", "False", ")", ":", "def", "progress_bar", "(", "count", ",", "total", ",", "suffix", "=", "''", ")", ":", "import", "sys", "bar_len", "=", ...
save imglist to disk Parameters: ---------- fname : str saved filename
[ "save", "imglist", "to", "disk" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/imdb.py#L70-L110
23,798
apache/incubator-mxnet
example/ssd/dataset/imdb.py
Imdb._load_class_names
def _load_class_names(self, filename, dirname): """ load class names from text file Parameters: ---------- filename: str file stores class names dirname: str file directory """ full_path = osp.join(dirname, filename) classe...
python
def _load_class_names(self, filename, dirname): """ load class names from text file Parameters: ---------- filename: str file stores class names dirname: str file directory """ full_path = osp.join(dirname, filename) classe...
[ "def", "_load_class_names", "(", "self", ",", "filename", ",", "dirname", ")", ":", "full_path", "=", "osp", ".", "join", "(", "dirname", ",", "filename", ")", "classes", "=", "[", "]", "with", "open", "(", "full_path", ",", "'r'", ")", "as", "f", ":...
load class names from text file Parameters: ---------- filename: str file stores class names dirname: str file directory
[ "load", "class", "names", "from", "text", "file" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/imdb.py#L112-L127
23,799
apache/incubator-mxnet
example/image-classification/train_mnist.py
read_data
def read_data(label, image): """ download and read data into numpy """ base_url = 'http://yann.lecun.com/exdb/mnist/' with gzip.open(download_file(base_url+label, os.path.join('data',label))) as flbl: magic, num = struct.unpack(">II", flbl.read(8)) label = np.fromstring(flbl.read(), ...
python
def read_data(label, image): """ download and read data into numpy """ base_url = 'http://yann.lecun.com/exdb/mnist/' with gzip.open(download_file(base_url+label, os.path.join('data',label))) as flbl: magic, num = struct.unpack(">II", flbl.read(8)) label = np.fromstring(flbl.read(), ...
[ "def", "read_data", "(", "label", ",", "image", ")", ":", "base_url", "=", "'http://yann.lecun.com/exdb/mnist/'", "with", "gzip", ".", "open", "(", "download_file", "(", "base_url", "+", "label", ",", "os", ".", "path", ".", "join", "(", "'data'", ",", "la...
download and read data into numpy
[ "download", "and", "read", "data", "into", "numpy" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/image-classification/train_mnist.py#L31-L42