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,600 | apache/incubator-mxnet | example/svrg_module/linear_regression/common.py | calc_expectation | def calc_expectation(grad_dict, num_batches):
"""Calculates the expectation of the gradients per epoch for each parameter w.r.t number of batches
Parameters
----------
grad_dict: dict
dictionary that maps parameter name to gradients in the mod executor group
num_batches: int
number ... | python | def calc_expectation(grad_dict, num_batches):
"""Calculates the expectation of the gradients per epoch for each parameter w.r.t number of batches
Parameters
----------
grad_dict: dict
dictionary that maps parameter name to gradients in the mod executor group
num_batches: int
number ... | [
"def",
"calc_expectation",
"(",
"grad_dict",
",",
"num_batches",
")",
":",
"for",
"key",
"in",
"grad_dict",
".",
"keys",
"(",
")",
":",
"grad_dict",
"[",
"str",
".",
"format",
"(",
"key",
"+",
"\"_expectation\"",
")",
"]",
"=",
"mx",
".",
"ndarray",
".... | Calculates the expectation of the gradients per epoch for each parameter w.r.t number of batches
Parameters
----------
grad_dict: dict
dictionary that maps parameter name to gradients in the mod executor group
num_batches: int
number of batches
Returns
----------
grad_dict:... | [
"Calculates",
"the",
"expectation",
"of",
"the",
"gradients",
"per",
"epoch",
"for",
"each",
"parameter",
"w",
".",
"r",
".",
"t",
"number",
"of",
"batches"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/svrg_module/linear_regression/common.py#L74-L93 |
23,601 | apache/incubator-mxnet | example/svrg_module/linear_regression/common.py | calc_variance | def calc_variance(grad_dict, num_batches, param_names):
"""Calculates the variance of the gradients per epoch for each parameter w.r.t number of batches
Parameters
----------
grad_dict: dict
dictionary that maps parameter name to gradients in the mod executor group
num_batches: int
... | python | def calc_variance(grad_dict, num_batches, param_names):
"""Calculates the variance of the gradients per epoch for each parameter w.r.t number of batches
Parameters
----------
grad_dict: dict
dictionary that maps parameter name to gradients in the mod executor group
num_batches: int
... | [
"def",
"calc_variance",
"(",
"grad_dict",
",",
"num_batches",
",",
"param_names",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"param_names",
")",
")",
":",
"diff_sqr",
"=",
"mx",
".",
"ndarray",
".",
"square",
"(",
"mx",
".",
"nd",
".",
"su... | Calculates the variance of the gradients per epoch for each parameter w.r.t number of batches
Parameters
----------
grad_dict: dict
dictionary that maps parameter name to gradients in the mod executor group
num_batches: int
number of batches
param_names: str
parameter name i... | [
"Calculates",
"the",
"variance",
"of",
"the",
"gradients",
"per",
"epoch",
"for",
"each",
"parameter",
"w",
".",
"r",
".",
"t",
"number",
"of",
"batches"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/svrg_module/linear_regression/common.py#L96-L117 |
23,602 | apache/incubator-mxnet | example/named_entity_recognition/src/metrics.py | classifer_metrics | def classifer_metrics(label, pred):
"""
computes f1, precision and recall on the entity class
"""
prediction = np.argmax(pred, axis=1)
label = label.astype(int)
pred_is_entity = prediction != not_entity_index
label_is_entity = label != not_entity_index
corr_pred = (prediction == label)... | python | def classifer_metrics(label, pred):
"""
computes f1, precision and recall on the entity class
"""
prediction = np.argmax(pred, axis=1)
label = label.astype(int)
pred_is_entity = prediction != not_entity_index
label_is_entity = label != not_entity_index
corr_pred = (prediction == label)... | [
"def",
"classifer_metrics",
"(",
"label",
",",
"pred",
")",
":",
"prediction",
"=",
"np",
".",
"argmax",
"(",
"pred",
",",
"axis",
"=",
"1",
")",
"label",
"=",
"label",
".",
"astype",
"(",
"int",
")",
"pred_is_entity",
"=",
"prediction",
"!=",
"not_ent... | computes f1, precision and recall on the entity class | [
"computes",
"f1",
"precision",
"and",
"recall",
"on",
"the",
"entity",
"class"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/named_entity_recognition/src/metrics.py#L33-L62 |
23,603 | apache/incubator-mxnet | example/cnn_text_classification/text_cnn.py | data_iter | def data_iter(batch_size, num_embed, pre_trained_word2vec=False):
"""Construct data iter
Parameters
----------
batch_size: int
num_embed: int
pre_trained_word2vec: boolean
identify the pre-trained layers or not
Returns
----------
train_set: DataIter
... | python | def data_iter(batch_size, num_embed, pre_trained_word2vec=False):
"""Construct data iter
Parameters
----------
batch_size: int
num_embed: int
pre_trained_word2vec: boolean
identify the pre-trained layers or not
Returns
----------
train_set: DataIter
... | [
"def",
"data_iter",
"(",
"batch_size",
",",
"num_embed",
",",
"pre_trained_word2vec",
"=",
"False",
")",
":",
"print",
"(",
"'Loading data...'",
")",
"if",
"pre_trained_word2vec",
":",
"word2vec",
"=",
"data_helpers",
".",
"load_pretrained_word2vec",
"(",
"'data/rt.... | Construct data iter
Parameters
----------
batch_size: int
num_embed: int
pre_trained_word2vec: boolean
identify the pre-trained layers or not
Returns
----------
train_set: DataIter
Train DataIter
valid: DataIter
Valid DataIter
... | [
"Construct",
"data",
"iter"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_text_classification/text_cnn.py#L71-L129 |
23,604 | apache/incubator-mxnet | example/cnn_text_classification/text_cnn.py | sym_gen | def sym_gen(batch_size, sentences_size, num_embed, vocabulary_size,
num_label=2, filter_list=None, num_filter=100,
dropout=0.0, pre_trained_word2vec=False):
"""Generate network symbol
Parameters
----------
batch_size: int
sentences_size: int
num_embed: int
vocabulary... | python | def sym_gen(batch_size, sentences_size, num_embed, vocabulary_size,
num_label=2, filter_list=None, num_filter=100,
dropout=0.0, pre_trained_word2vec=False):
"""Generate network symbol
Parameters
----------
batch_size: int
sentences_size: int
num_embed: int
vocabulary... | [
"def",
"sym_gen",
"(",
"batch_size",
",",
"sentences_size",
",",
"num_embed",
",",
"vocabulary_size",
",",
"num_label",
"=",
"2",
",",
"filter_list",
"=",
"None",
",",
"num_filter",
"=",
"100",
",",
"dropout",
"=",
"0.0",
",",
"pre_trained_word2vec",
"=",
"F... | Generate network symbol
Parameters
----------
batch_size: int
sentences_size: int
num_embed: int
vocabulary_size: int
num_label: int
filter_list: list
num_filter: int
dropout: int
pre_trained_word2vec: boolean
identify the pre-trained layers or not
... | [
"Generate",
"network",
"symbol"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_text_classification/text_cnn.py#L132-L198 |
23,605 | apache/incubator-mxnet | example/cnn_text_classification/text_cnn.py | train | def train(symbol_data, train_iterator, valid_iterator, data_column_names, target_names):
"""Train cnn model
Parameters
----------
symbol_data: symbol
train_iterator: DataIter
Train DataIter
valid_iterator: DataIter
Valid DataIter
data_column_names: li... | python | def train(symbol_data, train_iterator, valid_iterator, data_column_names, target_names):
"""Train cnn model
Parameters
----------
symbol_data: symbol
train_iterator: DataIter
Train DataIter
valid_iterator: DataIter
Valid DataIter
data_column_names: li... | [
"def",
"train",
"(",
"symbol_data",
",",
"train_iterator",
",",
"valid_iterator",
",",
"data_column_names",
",",
"target_names",
")",
":",
"devs",
"=",
"mx",
".",
"cpu",
"(",
")",
"# default setting",
"if",
"args",
".",
"gpus",
"is",
"not",
"None",
":",
"f... | Train cnn model
Parameters
----------
symbol_data: symbol
train_iterator: DataIter
Train DataIter
valid_iterator: DataIter
Valid DataIter
data_column_names: list of str
Defaults to ('data') for a typical model used in image classifi... | [
"Train",
"cnn",
"model"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_text_classification/text_cnn.py#L201-L231 |
23,606 | apache/incubator-mxnet | dev_menu.py | build | def build(args) -> None:
"""Build using CMake"""
venv_exe = shutil.which('virtualenv')
pyexe = shutil.which(args.pyexe)
if not venv_exe:
logging.warn("virtualenv wasn't found in path, it's recommended to install virtualenv to manage python environments")
if not pyexe:
logging.warn("P... | python | def build(args) -> None:
"""Build using CMake"""
venv_exe = shutil.which('virtualenv')
pyexe = shutil.which(args.pyexe)
if not venv_exe:
logging.warn("virtualenv wasn't found in path, it's recommended to install virtualenv to manage python environments")
if not pyexe:
logging.warn("P... | [
"def",
"build",
"(",
"args",
")",
"->",
"None",
":",
"venv_exe",
"=",
"shutil",
".",
"which",
"(",
"'virtualenv'",
")",
"pyexe",
"=",
"shutil",
".",
"which",
"(",
"args",
".",
"pyexe",
")",
"if",
"not",
"venv_exe",
":",
"logging",
".",
"warn",
"(",
... | Build using CMake | [
"Build",
"using",
"CMake"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/dev_menu.py#L199-L212 |
23,607 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | parse_helper | def parse_helper(attrs, attrs_name, alt_value=None):
"""Helper function to parse operator attributes in required format."""
tuple_re = re.compile('\([0-9L|,| ]+\)')
if not attrs:
return alt_value
attrs_str = None if attrs.get(attrs_name) is None else str(attrs.get(attrs_name))
if attrs_str i... | python | def parse_helper(attrs, attrs_name, alt_value=None):
"""Helper function to parse operator attributes in required format."""
tuple_re = re.compile('\([0-9L|,| ]+\)')
if not attrs:
return alt_value
attrs_str = None if attrs.get(attrs_name) is None else str(attrs.get(attrs_name))
if attrs_str i... | [
"def",
"parse_helper",
"(",
"attrs",
",",
"attrs_name",
",",
"alt_value",
"=",
"None",
")",
":",
"tuple_re",
"=",
"re",
".",
"compile",
"(",
"'\\([0-9L|,| ]+\\)'",
")",
"if",
"not",
"attrs",
":",
"return",
"alt_value",
"attrs_str",
"=",
"None",
"if",
"attr... | Helper function to parse operator attributes in required format. | [
"Helper",
"function",
"to",
"parse",
"operator",
"attributes",
"in",
"required",
"format",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L69-L84 |
23,608 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | transform_padding | def transform_padding(pad_width):
"""Helper function to convert padding format for pad operator.
"""
num_pad_values = len(pad_width)
onnx_pad_width = [0]*num_pad_values
start_index = 0
# num_pad_values will always be multiple of 2
end_index = int(num_pad_values/2)
for idx in range(0, nu... | python | def transform_padding(pad_width):
"""Helper function to convert padding format for pad operator.
"""
num_pad_values = len(pad_width)
onnx_pad_width = [0]*num_pad_values
start_index = 0
# num_pad_values will always be multiple of 2
end_index = int(num_pad_values/2)
for idx in range(0, nu... | [
"def",
"transform_padding",
"(",
"pad_width",
")",
":",
"num_pad_values",
"=",
"len",
"(",
"pad_width",
")",
"onnx_pad_width",
"=",
"[",
"0",
"]",
"*",
"num_pad_values",
"start_index",
"=",
"0",
"# num_pad_values will always be multiple of 2",
"end_index",
"=",
"int... | Helper function to convert padding format for pad operator. | [
"Helper",
"function",
"to",
"convert",
"padding",
"format",
"for",
"pad",
"operator",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L86-L103 |
23,609 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_string_to_list | def convert_string_to_list(string_val):
"""Helper function to convert string to list.
Used to convert shape attribute string to list format.
"""
result_list = []
list_string = string_val.split(',')
for val in list_string:
val = str(val.strip())
val = val.replace("(", "")
... | python | def convert_string_to_list(string_val):
"""Helper function to convert string to list.
Used to convert shape attribute string to list format.
"""
result_list = []
list_string = string_val.split(',')
for val in list_string:
val = str(val.strip())
val = val.replace("(", "")
... | [
"def",
"convert_string_to_list",
"(",
"string_val",
")",
":",
"result_list",
"=",
"[",
"]",
"list_string",
"=",
"string_val",
".",
"split",
"(",
"','",
")",
"for",
"val",
"in",
"list_string",
":",
"val",
"=",
"str",
"(",
"val",
".",
"strip",
"(",
")",
... | Helper function to convert string to list.
Used to convert shape attribute string to list format. | [
"Helper",
"function",
"to",
"convert",
"string",
"to",
"list",
".",
"Used",
"to",
"convert",
"shape",
"attribute",
"string",
"to",
"list",
"format",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L106-L123 |
23,610 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | get_inputs | def get_inputs(node, kwargs):
"""Helper function to get inputs"""
name = node["name"]
proc_nodes = kwargs["proc_nodes"]
index_lookup = kwargs["index_lookup"]
inputs = node["inputs"]
attrs = node.get("attrs", {})
input_nodes = []
for ip in inputs:
input_node_id = index_lookup[ip[... | python | def get_inputs(node, kwargs):
"""Helper function to get inputs"""
name = node["name"]
proc_nodes = kwargs["proc_nodes"]
index_lookup = kwargs["index_lookup"]
inputs = node["inputs"]
attrs = node.get("attrs", {})
input_nodes = []
for ip in inputs:
input_node_id = index_lookup[ip[... | [
"def",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
":",
"name",
"=",
"node",
"[",
"\"name\"",
"]",
"proc_nodes",
"=",
"kwargs",
"[",
"\"proc_nodes\"",
"]",
"index_lookup",
"=",
"kwargs",
"[",
"\"index_lookup\"",
"]",
"inputs",
"=",
"node",
"[",
"\"input... | Helper function to get inputs | [
"Helper",
"function",
"to",
"get",
"inputs"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L133-L146 |
23,611 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | create_basic_op_node | def create_basic_op_node(op_name, node, kwargs):
"""Helper function to create a basic operator
node that doesn't contain op specific attrs"""
name, input_nodes, _ = get_inputs(node, kwargs)
node = onnx.helper.make_node(
op_name,
input_nodes,
[name],
name=name
)
r... | python | def create_basic_op_node(op_name, node, kwargs):
"""Helper function to create a basic operator
node that doesn't contain op specific attrs"""
name, input_nodes, _ = get_inputs(node, kwargs)
node = onnx.helper.make_node(
op_name,
input_nodes,
[name],
name=name
)
r... | [
"def",
"create_basic_op_node",
"(",
"op_name",
",",
"node",
",",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"_",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"node",
"=",
"onnx",
".",
"helper",
".",
"make_node",
"(",
"op_name",
",",
"i... | Helper function to create a basic operator
node that doesn't contain op specific attrs | [
"Helper",
"function",
"to",
"create",
"a",
"basic",
"operator",
"node",
"that",
"doesn",
"t",
"contain",
"op",
"specific",
"attrs"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L148-L159 |
23,612 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_weights_and_inputs | def convert_weights_and_inputs(node, **kwargs):
"""Helper function to convert weights and inputs.
"""
name, _, _ = get_inputs(node, kwargs)
if kwargs["is_input"] is False:
weights = kwargs["weights"]
initializer = kwargs["initializer"]
np_arr = weights[name]
data_type = ... | python | def convert_weights_and_inputs(node, **kwargs):
"""Helper function to convert weights and inputs.
"""
name, _, _ = get_inputs(node, kwargs)
if kwargs["is_input"] is False:
weights = kwargs["weights"]
initializer = kwargs["initializer"]
np_arr = weights[name]
data_type = ... | [
"def",
"convert_weights_and_inputs",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"_",
",",
"_",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"if",
"kwargs",
"[",
"\"is_input\"",
"]",
"is",
"False",
":",
"weights",
"=",
"kwargs",... | Helper function to convert weights and inputs. | [
"Helper",
"function",
"to",
"convert",
"weights",
"and",
"inputs",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L162-L189 |
23,613 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_convolution | def convert_convolution(node, **kwargs):
"""Map MXNet's convolution operator attributes to onnx's Conv operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
kernel_dims = list(parse_helper(attrs, "kernel"))
stride_dims = list(parse_helper(attrs, "stride",... | python | def convert_convolution(node, **kwargs):
"""Map MXNet's convolution operator attributes to onnx's Conv operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
kernel_dims = list(parse_helper(attrs, "kernel"))
stride_dims = list(parse_helper(attrs, "stride",... | [
"def",
"convert_convolution",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"kernel_dims",
"=",
"list",
"(",
"parse_helper",
"(",
"attrs",
",",
"\"kernel\"",
... | Map MXNet's convolution operator attributes to onnx's Conv operator
and return the created node. | [
"Map",
"MXNet",
"s",
"convolution",
"operator",
"attributes",
"to",
"onnx",
"s",
"Conv",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L193-L219 |
23,614 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_deconvolution | def convert_deconvolution(node, **kwargs):
"""Map MXNet's deconvolution operator attributes to onnx's ConvTranspose operator
and return the created node.
"""
name, inputs, attrs = get_inputs(node, kwargs)
kernel_dims = list(parse_helper(attrs, "kernel"))
stride_dims = list(parse_helper(attrs, "... | python | def convert_deconvolution(node, **kwargs):
"""Map MXNet's deconvolution operator attributes to onnx's ConvTranspose operator
and return the created node.
"""
name, inputs, attrs = get_inputs(node, kwargs)
kernel_dims = list(parse_helper(attrs, "kernel"))
stride_dims = list(parse_helper(attrs, "... | [
"def",
"convert_deconvolution",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"inputs",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"kernel_dims",
"=",
"list",
"(",
"parse_helper",
"(",
"attrs",
",",
"\"kernel\"",
")"... | Map MXNet's deconvolution operator attributes to onnx's ConvTranspose operator
and return the created node. | [
"Map",
"MXNet",
"s",
"deconvolution",
"operator",
"attributes",
"to",
"onnx",
"s",
"ConvTranspose",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L223-L251 |
23,615 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_crop | def convert_crop(node, **kwargs):
"""Map MXNet's crop operator attributes to onnx's Crop operator
and return the created node.
"""
name, inputs, attrs = get_inputs(node, kwargs)
num_inputs = len(inputs)
y, x = list(parse_helper(attrs, "offset", [0, 0]))
h, w = list(parse_helper(attrs, "h_w"... | python | def convert_crop(node, **kwargs):
"""Map MXNet's crop operator attributes to onnx's Crop operator
and return the created node.
"""
name, inputs, attrs = get_inputs(node, kwargs)
num_inputs = len(inputs)
y, x = list(parse_helper(attrs, "offset", [0, 0]))
h, w = list(parse_helper(attrs, "h_w"... | [
"def",
"convert_crop",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"inputs",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"num_inputs",
"=",
"len",
"(",
"inputs",
")",
"y",
",",
"x",
"=",
"list",
"(",
"parse_he... | Map MXNet's crop operator attributes to onnx's Crop operator
and return the created node. | [
"Map",
"MXNet",
"s",
"crop",
"operator",
"attributes",
"to",
"onnx",
"s",
"Crop",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L255-L281 |
23,616 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_fully_connected | def convert_fully_connected(node, **kwargs):
"""Map MXNet's FullyConnected operator attributes to onnx's Gemm operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
initializer = kwargs["initializer"]
no_bias = get_boolean_attribute_value(attrs, "no_bias"... | python | def convert_fully_connected(node, **kwargs):
"""Map MXNet's FullyConnected operator attributes to onnx's Gemm operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
initializer = kwargs["initializer"]
no_bias = get_boolean_attribute_value(attrs, "no_bias"... | [
"def",
"convert_fully_connected",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"initializer",
"=",
"kwargs",
"[",
"\"initializer\"",
"]",
"no_bias",
"=",
"get_... | Map MXNet's FullyConnected operator attributes to onnx's Gemm operator
and return the created node. | [
"Map",
"MXNet",
"s",
"FullyConnected",
"operator",
"attributes",
"to",
"onnx",
"s",
"Gemm",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L285-L337 |
23,617 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_batchnorm | def convert_batchnorm(node, **kwargs):
"""Map MXNet's BatchNorm operator attributes to onnx's BatchNormalization operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
momentum = float(attrs.get("momentum", 0.9))
eps = float(attrs.get("eps", 0.001))
b... | python | def convert_batchnorm(node, **kwargs):
"""Map MXNet's BatchNorm operator attributes to onnx's BatchNormalization operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
momentum = float(attrs.get("momentum", 0.9))
eps = float(attrs.get("eps", 0.001))
b... | [
"def",
"convert_batchnorm",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"momentum",
"=",
"float",
"(",
"attrs",
".",
"get",
"(",
"\"momentum\"",
",",
"0.9... | Map MXNet's BatchNorm operator attributes to onnx's BatchNormalization operator
and return the created node. | [
"Map",
"MXNet",
"s",
"BatchNorm",
"operator",
"attributes",
"to",
"onnx",
"s",
"BatchNormalization",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L341-L361 |
23,618 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_pad | def convert_pad(node, **kwargs):
"""Map MXNet's pad operator attributes to onnx's Pad operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
mxnet_pad_width = convert_string_to_list(attrs.get("pad_width"))
onnx_pad_width = transform_padding(mxnet_pad_width... | python | def convert_pad(node, **kwargs):
"""Map MXNet's pad operator attributes to onnx's Pad operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
mxnet_pad_width = convert_string_to_list(attrs.get("pad_width"))
onnx_pad_width = transform_padding(mxnet_pad_width... | [
"def",
"convert_pad",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"mxnet_pad_width",
"=",
"convert_string_to_list",
"(",
"attrs",
".",
"get",
"(",
"\"pad_widt... | Map MXNet's pad operator attributes to onnx's Pad operator
and return the created node. | [
"Map",
"MXNet",
"s",
"pad",
"operator",
"attributes",
"to",
"onnx",
"s",
"Pad",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L464-L497 |
23,619 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | create_helper_trans_node | def create_helper_trans_node(op_name, input_node, node_name):
"""create extra transpose node for dot operator"""
node_name = op_name + "_" + node_name
trans_node = onnx.helper.make_node(
'Transpose',
inputs=[input_node],
outputs=[node_name],
name=node_name
)
return tr... | python | def create_helper_trans_node(op_name, input_node, node_name):
"""create extra transpose node for dot operator"""
node_name = op_name + "_" + node_name
trans_node = onnx.helper.make_node(
'Transpose',
inputs=[input_node],
outputs=[node_name],
name=node_name
)
return tr... | [
"def",
"create_helper_trans_node",
"(",
"op_name",
",",
"input_node",
",",
"node_name",
")",
":",
"node_name",
"=",
"op_name",
"+",
"\"_\"",
"+",
"node_name",
"trans_node",
"=",
"onnx",
".",
"helper",
".",
"make_node",
"(",
"'Transpose'",
",",
"inputs",
"=",
... | create extra transpose node for dot operator | [
"create",
"extra",
"transpose",
"node",
"for",
"dot",
"operator"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L500-L509 |
23,620 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_dot | def convert_dot(node, **kwargs):
"""Map MXNet's dot operator attributes to onnx's
MatMul and Transpose operators based on the values set for
transpose_a, transpose_b attributes."""
name, input_nodes, attrs = get_inputs(node, kwargs)
input_node_a = input_nodes[0]
input_node_b = input_nodes[1]
... | python | def convert_dot(node, **kwargs):
"""Map MXNet's dot operator attributes to onnx's
MatMul and Transpose operators based on the values set for
transpose_a, transpose_b attributes."""
name, input_nodes, attrs = get_inputs(node, kwargs)
input_node_a = input_nodes[0]
input_node_b = input_nodes[1]
... | [
"def",
"convert_dot",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"input_node_a",
"=",
"input_nodes",
"[",
"0",
"]",
"input_node_b",
"=",
"input_nodes",
"["... | Map MXNet's dot operator attributes to onnx's
MatMul and Transpose operators based on the values set for
transpose_a, transpose_b attributes. | [
"Map",
"MXNet",
"s",
"dot",
"operator",
"attributes",
"to",
"onnx",
"s",
"MatMul",
"and",
"Transpose",
"operators",
"based",
"on",
"the",
"values",
"set",
"for",
"transpose_a",
"transpose_b",
"attributes",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L513-L550 |
23,621 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_linalg_gemm2 | def convert_linalg_gemm2(node, **kwargs):
"""Map MXNet's _linalg_gemm2 operator attributes to onnx's
MatMul and Transpose operators based on the values set for
transpose_a, transpose_b attributes.
Return multiple nodes created.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
# Getti... | python | def convert_linalg_gemm2(node, **kwargs):
"""Map MXNet's _linalg_gemm2 operator attributes to onnx's
MatMul and Transpose operators based on the values set for
transpose_a, transpose_b attributes.
Return multiple nodes created.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
# Getti... | [
"def",
"convert_linalg_gemm2",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"# Getting the attributes and assigning default values.",
"alpha",
"=",
"float",
"(",
"at... | Map MXNet's _linalg_gemm2 operator attributes to onnx's
MatMul and Transpose operators based on the values set for
transpose_a, transpose_b attributes.
Return multiple nodes created. | [
"Map",
"MXNet",
"s",
"_linalg_gemm2",
"operator",
"attributes",
"to",
"onnx",
"s",
"MatMul",
"and",
"Transpose",
"operators",
"based",
"on",
"the",
"values",
"set",
"for",
"transpose_a",
"transpose_b",
"attributes",
".",
"Return",
"multiple",
"nodes",
"created",
... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L554-L636 |
23,622 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_instancenorm | def convert_instancenorm(node, **kwargs):
"""Map MXNet's InstanceNorm operator attributes to onnx's InstanceNormalization operator
based on the input node's attributes and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
eps = float(attrs.get("eps", 0.001))
node... | python | def convert_instancenorm(node, **kwargs):
"""Map MXNet's InstanceNorm operator attributes to onnx's InstanceNormalization operator
based on the input node's attributes and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
eps = float(attrs.get("eps", 0.001))
node... | [
"def",
"convert_instancenorm",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"eps",
"=",
"float",
"(",
"attrs",
".",
"get",
"(",
"\"eps\"",
",",
"0.001",
... | Map MXNet's InstanceNorm operator attributes to onnx's InstanceNormalization operator
based on the input node's attributes and return the created node. | [
"Map",
"MXNet",
"s",
"InstanceNorm",
"operator",
"attributes",
"to",
"onnx",
"s",
"InstanceNormalization",
"operator",
"based",
"on",
"the",
"input",
"node",
"s",
"attributes",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L735-L750 |
23,623 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_softmax | def convert_softmax(node, **kwargs):
"""Map MXNet's softmax operator attributes to onnx's Softmax operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
axis = int(attrs.get("axis", -1))
softmax_node = onnx.helper.make_node(
"Softmax",
inp... | python | def convert_softmax(node, **kwargs):
"""Map MXNet's softmax operator attributes to onnx's Softmax operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
axis = int(attrs.get("axis", -1))
softmax_node = onnx.helper.make_node(
"Softmax",
inp... | [
"def",
"convert_softmax",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"axis",
"=",
"int",
"(",
"attrs",
".",
"get",
"(",
"\"axis\"",
",",
"-",
"1",
")... | Map MXNet's softmax operator attributes to onnx's Softmax operator
and return the created node. | [
"Map",
"MXNet",
"s",
"softmax",
"operator",
"attributes",
"to",
"onnx",
"s",
"Softmax",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L783-L799 |
23,624 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_concat | def convert_concat(node, **kwargs):
"""Map MXNet's Concat operator attributes to onnx's Concat operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
axis = int(attrs.get("dim", 1))
concat_node = onnx.helper.make_node(
"Concat",
input_nodes... | python | def convert_concat(node, **kwargs):
"""Map MXNet's Concat operator attributes to onnx's Concat operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
axis = int(attrs.get("dim", 1))
concat_node = onnx.helper.make_node(
"Concat",
input_nodes... | [
"def",
"convert_concat",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"axis",
"=",
"int",
"(",
"attrs",
".",
"get",
"(",
"\"dim\"",
",",
"1",
")",
")",... | Map MXNet's Concat operator attributes to onnx's Concat operator
and return the created node. | [
"Map",
"MXNet",
"s",
"Concat",
"operator",
"attributes",
"to",
"onnx",
"s",
"Concat",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L851-L865 |
23,625 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_transpose | def convert_transpose(node, **kwargs):
"""Map MXNet's transpose operator attributes to onnx's Transpose operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
axes = attrs.get("axes", ())
if axes:
axes = tuple(map(int, re.findall(r'\d+', axes)))
... | python | def convert_transpose(node, **kwargs):
"""Map MXNet's transpose operator attributes to onnx's Transpose operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
axes = attrs.get("axes", ())
if axes:
axes = tuple(map(int, re.findall(r'\d+', axes)))
... | [
"def",
"convert_transpose",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"axes",
"=",
"attrs",
".",
"get",
"(",
"\"axes\"",
",",
"(",
")",
")",
"if",
"... | Map MXNet's transpose operator attributes to onnx's Transpose operator
and return the created node. | [
"Map",
"MXNet",
"s",
"transpose",
"operator",
"attributes",
"to",
"onnx",
"s",
"Transpose",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L869-L894 |
23,626 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_lrn | def convert_lrn(node, **kwargs):
"""Map MXNet's LRN operator attributes to onnx's LRN operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
alpha = float(attrs.get("alpha", 0.0001))
beta = float(attrs.get("beta", 0.75))
bias = float(attrs.get("knorm",... | python | def convert_lrn(node, **kwargs):
"""Map MXNet's LRN operator attributes to onnx's LRN operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
alpha = float(attrs.get("alpha", 0.0001))
beta = float(attrs.get("beta", 0.75))
bias = float(attrs.get("knorm",... | [
"def",
"convert_lrn",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"alpha",
"=",
"float",
"(",
"attrs",
".",
"get",
"(",
"\"alpha\"",
",",
"0.0001",
")",... | Map MXNet's LRN operator attributes to onnx's LRN operator
and return the created node. | [
"Map",
"MXNet",
"s",
"LRN",
"operator",
"attributes",
"to",
"onnx",
"s",
"LRN",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L898-L920 |
23,627 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_l2normalization | def convert_l2normalization(node, **kwargs):
"""Map MXNet's L2Normalization operator attributes to onnx's LpNormalization operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
mode = attrs.get("mode", "instance")
if mode != "channel":
raise Attri... | python | def convert_l2normalization(node, **kwargs):
"""Map MXNet's L2Normalization operator attributes to onnx's LpNormalization operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
mode = attrs.get("mode", "instance")
if mode != "channel":
raise Attri... | [
"def",
"convert_l2normalization",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"mode",
"=",
"attrs",
".",
"get",
"(",
"\"mode\"",
",",
"\"instance\"",
")",
... | Map MXNet's L2Normalization operator attributes to onnx's LpNormalization operator
and return the created node. | [
"Map",
"MXNet",
"s",
"L2Normalization",
"operator",
"attributes",
"to",
"onnx",
"s",
"LpNormalization",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L924-L942 |
23,628 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_dropout | def convert_dropout(node, **kwargs):
"""Map MXNet's Dropout operator attributes to onnx's Dropout operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
probability = float(attrs.get("p", 0.5))
dropout_node = onnx.helper.make_node(
"Dropout",
... | python | def convert_dropout(node, **kwargs):
"""Map MXNet's Dropout operator attributes to onnx's Dropout operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
probability = float(attrs.get("p", 0.5))
dropout_node = onnx.helper.make_node(
"Dropout",
... | [
"def",
"convert_dropout",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"probability",
"=",
"float",
"(",
"attrs",
".",
"get",
"(",
"\"p\"",
",",
"0.5",
"... | Map MXNet's Dropout operator attributes to onnx's Dropout operator
and return the created node. | [
"Map",
"MXNet",
"s",
"Dropout",
"operator",
"attributes",
"to",
"onnx",
"s",
"Dropout",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L946-L961 |
23,629 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_clip | def convert_clip(node, **kwargs):
"""Map MXNet's Clip operator attributes to onnx's Clip operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
a_min = np.float(attrs.get('a_min', -np.inf))
a_max = np.float(attrs.get('a_max', np.inf))
clip_node = onnx... | python | def convert_clip(node, **kwargs):
"""Map MXNet's Clip operator attributes to onnx's Clip operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
a_min = np.float(attrs.get('a_min', -np.inf))
a_max = np.float(attrs.get('a_max', np.inf))
clip_node = onnx... | [
"def",
"convert_clip",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"a_min",
"=",
"np",
".",
"float",
"(",
"attrs",
".",
"get",
"(",
"'a_min'",
",",
"-... | Map MXNet's Clip operator attributes to onnx's Clip operator
and return the created node. | [
"Map",
"MXNet",
"s",
"Clip",
"operator",
"attributes",
"to",
"onnx",
"s",
"Clip",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L972-L989 |
23,630 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | scalar_op_helper | def scalar_op_helper(node, op_name, **kwargs):
"""Helper function for scalar arithmetic operations"""
name, input_nodes, attrs = get_inputs(node, kwargs)
from onnx import numpy_helper
input_type = kwargs["in_type"]
scalar_value = np.array([attrs.get("scalar", 1)],
dtype=o... | python | def scalar_op_helper(node, op_name, **kwargs):
"""Helper function for scalar arithmetic operations"""
name, input_nodes, attrs = get_inputs(node, kwargs)
from onnx import numpy_helper
input_type = kwargs["in_type"]
scalar_value = np.array([attrs.get("scalar", 1)],
dtype=o... | [
"def",
"scalar_op_helper",
"(",
"node",
",",
"op_name",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"from",
"onnx",
"import",
"numpy_helper",
"input_type",
"=",
"kwargs",
... | Helper function for scalar arithmetic operations | [
"Helper",
"function",
"for",
"scalar",
"arithmetic",
"operations"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L992-L1066 |
23,631 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_argmax | def convert_argmax(node, **kwargs):
"""Map MXNet's argmax operator attributes to onnx's ArgMax operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
axis = int(attrs.get("axis"))
keepdims = get_boolean_attribute_value(attrs, "keepdims")
node = onnx.h... | python | def convert_argmax(node, **kwargs):
"""Map MXNet's argmax operator attributes to onnx's ArgMax operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
axis = int(attrs.get("axis"))
keepdims = get_boolean_attribute_value(attrs, "keepdims")
node = onnx.h... | [
"def",
"convert_argmax",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"axis",
"=",
"int",
"(",
"attrs",
".",
"get",
"(",
"\"axis\"",
")",
")",
"keepdims"... | Map MXNet's argmax operator attributes to onnx's ArgMax operator
and return the created node. | [
"Map",
"MXNet",
"s",
"argmax",
"operator",
"attributes",
"to",
"onnx",
"s",
"ArgMax",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1131-L1148 |
23,632 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_reshape | def convert_reshape(node, **kwargs):
"""Map MXNet's Reshape operator attributes to onnx's Reshape operator.
Converts output shape attribute to output shape tensor
and return multiple created nodes.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
output_shape_list = convert_string_to_lis... | python | def convert_reshape(node, **kwargs):
"""Map MXNet's Reshape operator attributes to onnx's Reshape operator.
Converts output shape attribute to output shape tensor
and return multiple created nodes.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
output_shape_list = convert_string_to_lis... | [
"def",
"convert_reshape",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"output_shape_list",
"=",
"convert_string_to_list",
"(",
"attrs",
"[",
"\"shape\"",
"]",
... | Map MXNet's Reshape operator attributes to onnx's Reshape operator.
Converts output shape attribute to output shape tensor
and return multiple created nodes. | [
"Map",
"MXNet",
"s",
"Reshape",
"operator",
"attributes",
"to",
"onnx",
"s",
"Reshape",
"operator",
".",
"Converts",
"output",
"shape",
"attribute",
"to",
"output",
"shape",
"tensor",
"and",
"return",
"multiple",
"created",
"nodes",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1422-L1464 |
23,633 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_cast | def convert_cast(node, **kwargs):
"""Map MXNet's Cast operator attributes to onnx's Cast operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
dtype = attrs["dtype"]
# dtype can be mapped only with types from TensorProto
# float32 is mapped to float ... | python | def convert_cast(node, **kwargs):
"""Map MXNet's Cast operator attributes to onnx's Cast operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
dtype = attrs["dtype"]
# dtype can be mapped only with types from TensorProto
# float32 is mapped to float ... | [
"def",
"convert_cast",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"dtype",
"=",
"attrs",
"[",
"\"dtype\"",
"]",
"# dtype can be mapped only with types from Tenso... | Map MXNet's Cast operator attributes to onnx's Cast operator
and return the created node. | [
"Map",
"MXNet",
"s",
"Cast",
"operator",
"attributes",
"to",
"onnx",
"s",
"Cast",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1467-L1490 |
23,634 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_slice_axis | def convert_slice_axis(node, **kwargs):
"""Map MXNet's slice_axis operator attributes to onnx's Slice operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
axes = int(attrs.get("axis"))
starts = int(attrs.get("begin"))
ends = int(attrs.get("end", None... | python | def convert_slice_axis(node, **kwargs):
"""Map MXNet's slice_axis operator attributes to onnx's Slice operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
axes = int(attrs.get("axis"))
starts = int(attrs.get("begin"))
ends = int(attrs.get("end", None... | [
"def",
"convert_slice_axis",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"axes",
"=",
"int",
"(",
"attrs",
".",
"get",
"(",
"\"axis\"",
")",
")",
"start... | Map MXNet's slice_axis operator attributes to onnx's Slice operator
and return the created node. | [
"Map",
"MXNet",
"s",
"slice_axis",
"operator",
"attributes",
"to",
"onnx",
"s",
"Slice",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1494-L1515 |
23,635 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_slice_channel | def convert_slice_channel(node, **kwargs):
"""Map MXNet's SliceChannel operator attributes to onnx's Squeeze or Split
operator based on squeeze_axis attribute
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
num_outputs = int(attrs.get("num_outputs"))
axi... | python | def convert_slice_channel(node, **kwargs):
"""Map MXNet's SliceChannel operator attributes to onnx's Squeeze or Split
operator based on squeeze_axis attribute
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
num_outputs = int(attrs.get("num_outputs"))
axi... | [
"def",
"convert_slice_channel",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"num_outputs",
"=",
"int",
"(",
"attrs",
".",
"get",
"(",
"\"num_outputs\"",
")"... | Map MXNet's SliceChannel operator attributes to onnx's Squeeze or Split
operator based on squeeze_axis attribute
and return the created node. | [
"Map",
"MXNet",
"s",
"SliceChannel",
"operator",
"attributes",
"to",
"onnx",
"s",
"Squeeze",
"or",
"Split",
"operator",
"based",
"on",
"squeeze_axis",
"attribute",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1519-L1553 |
23,636 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_expand_dims | def convert_expand_dims(node, **kwargs):
"""Map MXNet's expand_dims operator attributes to onnx's Unsqueeze operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
axis = int(attrs.get("axis"))
node = onnx.helper.make_node(
"Unsqueeze",
inp... | python | def convert_expand_dims(node, **kwargs):
"""Map MXNet's expand_dims operator attributes to onnx's Unsqueeze operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
axis = int(attrs.get("axis"))
node = onnx.helper.make_node(
"Unsqueeze",
inp... | [
"def",
"convert_expand_dims",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"axis",
"=",
"int",
"(",
"attrs",
".",
"get",
"(",
"\"axis\"",
")",
")",
"node... | Map MXNet's expand_dims operator attributes to onnx's Unsqueeze operator
and return the created node. | [
"Map",
"MXNet",
"s",
"expand_dims",
"operator",
"attributes",
"to",
"onnx",
"s",
"Unsqueeze",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1557-L1572 |
23,637 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_squeeze | def convert_squeeze(node, **kwargs):
"""Map MXNet's squeeze operator attributes to onnx's squeeze operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
axis = attrs.get("axis", None)
if not axis:
raise AttributeError("Squeeze: Missing axis attribu... | python | def convert_squeeze(node, **kwargs):
"""Map MXNet's squeeze operator attributes to onnx's squeeze operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
axis = attrs.get("axis", None)
if not axis:
raise AttributeError("Squeeze: Missing axis attribu... | [
"def",
"convert_squeeze",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"axis",
"=",
"attrs",
".",
"get",
"(",
"\"axis\"",
",",
"None",
")",
"if",
"not",
... | Map MXNet's squeeze operator attributes to onnx's squeeze operator
and return the created node. | [
"Map",
"MXNet",
"s",
"squeeze",
"operator",
"attributes",
"to",
"onnx",
"s",
"squeeze",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1575-L1594 |
23,638 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_depthtospace | def convert_depthtospace(node, **kwargs):
"""Map MXNet's depth_to_space operator attributes to onnx's
DepthToSpace operator and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
blksize = int(attrs.get("block_size", 0))
node = onnx.helper.make_node(
"Dept... | python | def convert_depthtospace(node, **kwargs):
"""Map MXNet's depth_to_space operator attributes to onnx's
DepthToSpace operator and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
blksize = int(attrs.get("block_size", 0))
node = onnx.helper.make_node(
"Dept... | [
"def",
"convert_depthtospace",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"blksize",
"=",
"int",
"(",
"attrs",
".",
"get",
"(",
"\"block_size\"",
",",
"0... | Map MXNet's depth_to_space operator attributes to onnx's
DepthToSpace operator and return the created node. | [
"Map",
"MXNet",
"s",
"depth_to_space",
"operator",
"attributes",
"to",
"onnx",
"s",
"DepthToSpace",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1633-L1648 |
23,639 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_square | def convert_square(node, **kwargs):
"""Map MXNet's square operator attributes to onnx's Pow operator
and return the created node.
"""
name, input_nodes, _ = get_inputs(node, kwargs)
initializer = kwargs["initializer"]
data_type = onnx.mapping.NP_TYPE_TO_TENSOR_TYPE[np.dtype('int64')]
power... | python | def convert_square(node, **kwargs):
"""Map MXNet's square operator attributes to onnx's Pow operator
and return the created node.
"""
name, input_nodes, _ = get_inputs(node, kwargs)
initializer = kwargs["initializer"]
data_type = onnx.mapping.NP_TYPE_TO_TENSOR_TYPE[np.dtype('int64')]
power... | [
"def",
"convert_square",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"_",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"initializer",
"=",
"kwargs",
"[",
"\"initializer\"",
"]",
"data_type",
"=",
"onnx",
".",
... | Map MXNet's square operator attributes to onnx's Pow operator
and return the created node. | [
"Map",
"MXNet",
"s",
"square",
"operator",
"attributes",
"to",
"onnx",
"s",
"Pow",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1669-L1698 |
23,640 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_sum | def convert_sum(node, **kwargs):
"""Map MXNet's sum operator attributes to onnx's ReduceSum operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
mx_axis = attrs.get("axis", None)
axes = convert_string_to_list(str(mx_axis)) if mx_axis is not None else Non... | python | def convert_sum(node, **kwargs):
"""Map MXNet's sum operator attributes to onnx's ReduceSum operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
mx_axis = attrs.get("axis", None)
axes = convert_string_to_list(str(mx_axis)) if mx_axis is not None else Non... | [
"def",
"convert_sum",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"mx_axis",
"=",
"attrs",
".",
"get",
"(",
"\"axis\"",
",",
"None",
")",
"axes",
"=",
... | Map MXNet's sum operator attributes to onnx's ReduceSum operator
and return the created node. | [
"Map",
"MXNet",
"s",
"sum",
"operator",
"attributes",
"to",
"onnx",
"s",
"ReduceSum",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1701-L1729 |
23,641 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_hardsigmoid | def convert_hardsigmoid(node, **kwargs):
"""Map MXNet's hard_sigmoid operator attributes to onnx's HardSigmoid operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
# Converting to float32
alpha = float(attrs.get("alpha", 0.2))
beta = float(attrs.get(... | python | def convert_hardsigmoid(node, **kwargs):
"""Map MXNet's hard_sigmoid operator attributes to onnx's HardSigmoid operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
# Converting to float32
alpha = float(attrs.get("alpha", 0.2))
beta = float(attrs.get(... | [
"def",
"convert_hardsigmoid",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"# Converting to float32",
"alpha",
"=",
"float",
"(",
"attrs",
".",
"get",
"(",
"... | Map MXNet's hard_sigmoid operator attributes to onnx's HardSigmoid operator
and return the created node. | [
"Map",
"MXNet",
"s",
"hard_sigmoid",
"operator",
"attributes",
"to",
"onnx",
"s",
"HardSigmoid",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1741-L1759 |
23,642 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_logsoftmax | def convert_logsoftmax(node, **kwargs):
"""Map MXNet's log_softmax operator attributes to onnx's LogSoftMax operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
# Converting to int
axis = int(attrs.get("axis", -1))
temp = attrs.get("temperature", 'No... | python | def convert_logsoftmax(node, **kwargs):
"""Map MXNet's log_softmax operator attributes to onnx's LogSoftMax operator
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
# Converting to int
axis = int(attrs.get("axis", -1))
temp = attrs.get("temperature", 'No... | [
"def",
"convert_logsoftmax",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"# Converting to int",
"axis",
"=",
"int",
"(",
"attrs",
".",
"get",
"(",
"\"axis\"... | Map MXNet's log_softmax operator attributes to onnx's LogSoftMax operator
and return the created node. | [
"Map",
"MXNet",
"s",
"log_softmax",
"operator",
"attributes",
"to",
"onnx",
"s",
"LogSoftMax",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1824-L1843 |
23,643 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_norm | def convert_norm(node, **kwargs):
"""Map MXNet's norm operator attributes to onnx's ReduceL1 and ReduceL2 operators
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
mx_axis = attrs.get("axis", None)
axes = convert_string_to_list(str(mx_axis)) if mx_axis else ... | python | def convert_norm(node, **kwargs):
"""Map MXNet's norm operator attributes to onnx's ReduceL1 and ReduceL2 operators
and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
mx_axis = attrs.get("axis", None)
axes = convert_string_to_list(str(mx_axis)) if mx_axis else ... | [
"def",
"convert_norm",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"mx_axis",
"=",
"attrs",
".",
"get",
"(",
"\"axis\"",
",",
"None",
")",
"axes",
"=",
... | Map MXNet's norm operator attributes to onnx's ReduceL1 and ReduceL2 operators
and return the created node. | [
"Map",
"MXNet",
"s",
"norm",
"operator",
"attributes",
"to",
"onnx",
"s",
"ReduceL1",
"and",
"ReduceL2",
"operators",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1846-L1878 |
23,644 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_multinomial | def convert_multinomial(node, **kwargs):
"""Map MXNet's multinomial operator attributes to onnx's
Multinomial operator and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
dtype = onnx.mapping.NP_TYPE_TO_TENSOR_TYPE[np.dtype(attrs.get("dtype", 'int32'))]
sample_si... | python | def convert_multinomial(node, **kwargs):
"""Map MXNet's multinomial operator attributes to onnx's
Multinomial operator and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
dtype = onnx.mapping.NP_TYPE_TO_TENSOR_TYPE[np.dtype(attrs.get("dtype", 'int32'))]
sample_si... | [
"def",
"convert_multinomial",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"dtype",
"=",
"onnx",
".",
"mapping",
".",
"NP_TYPE_TO_TENSOR_TYPE",
"[",
"np",
".... | Map MXNet's multinomial operator attributes to onnx's
Multinomial operator and return the created node. | [
"Map",
"MXNet",
"s",
"multinomial",
"operator",
"attributes",
"to",
"onnx",
"s",
"Multinomial",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1881-L1900 |
23,645 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_random_uniform | def convert_random_uniform(node, **kwargs):
"""Map MXNet's random_uniform operator attributes to onnx's RandomUniform
operator and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
# Converting to float32
low = float(attrs.get("low", 0))
high = float(attrs.get... | python | def convert_random_uniform(node, **kwargs):
"""Map MXNet's random_uniform operator attributes to onnx's RandomUniform
operator and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
# Converting to float32
low = float(attrs.get("low", 0))
high = float(attrs.get... | [
"def",
"convert_random_uniform",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"# Converting to float32",
"low",
"=",
"float",
"(",
"attrs",
".",
"get",
"(",
... | Map MXNet's random_uniform operator attributes to onnx's RandomUniform
operator and return the created node. | [
"Map",
"MXNet",
"s",
"random_uniform",
"operator",
"attributes",
"to",
"onnx",
"s",
"RandomUniform",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1904-L1926 |
23,646 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_random_normal | def convert_random_normal(node, **kwargs):
"""Map MXNet's random_normal operator attributes to onnx's RandomNormal
operator and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
# Converting to float32
mean = float(attrs.get("loc", 0))
scale = float(attrs.get(... | python | def convert_random_normal(node, **kwargs):
"""Map MXNet's random_normal operator attributes to onnx's RandomNormal
operator and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
# Converting to float32
mean = float(attrs.get("loc", 0))
scale = float(attrs.get(... | [
"def",
"convert_random_normal",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"# Converting to float32",
"mean",
"=",
"float",
"(",
"attrs",
".",
"get",
"(",
... | Map MXNet's random_normal operator attributes to onnx's RandomNormal
operator and return the created node. | [
"Map",
"MXNet",
"s",
"random_normal",
"operator",
"attributes",
"to",
"onnx",
"s",
"RandomNormal",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1930-L1952 |
23,647 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_roipooling | def convert_roipooling(node, **kwargs):
"""Map MXNet's ROIPooling operator attributes to onnx's MaxRoiPool
operator and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
pooled_shape = convert_string_to_list(attrs.get('pooled_size'))
scale = float(attrs.get("spati... | python | def convert_roipooling(node, **kwargs):
"""Map MXNet's ROIPooling operator attributes to onnx's MaxRoiPool
operator and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
pooled_shape = convert_string_to_list(attrs.get('pooled_size'))
scale = float(attrs.get("spati... | [
"def",
"convert_roipooling",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"pooled_shape",
"=",
"convert_string_to_list",
"(",
"attrs",
".",
"get",
"(",
"'poole... | Map MXNet's ROIPooling operator attributes to onnx's MaxRoiPool
operator and return the created node. | [
"Map",
"MXNet",
"s",
"ROIPooling",
"operator",
"attributes",
"to",
"onnx",
"s",
"MaxRoiPool",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1956-L1973 |
23,648 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_tile | def convert_tile(node, **kwargs):
"""Map MXNet's Tile operator attributes to onnx's Tile
operator and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
reps_list = convert_string_to_list(attrs["reps"])
initializer = kwargs["initializer"]
reps_shape_np = np.ar... | python | def convert_tile(node, **kwargs):
"""Map MXNet's Tile operator attributes to onnx's Tile
operator and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
reps_list = convert_string_to_list(attrs["reps"])
initializer = kwargs["initializer"]
reps_shape_np = np.ar... | [
"def",
"convert_tile",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"reps_list",
"=",
"convert_string_to_list",
"(",
"attrs",
"[",
"\"reps\"",
"]",
")",
"ini... | Map MXNet's Tile operator attributes to onnx's Tile
operator and return the created node. | [
"Map",
"MXNet",
"s",
"Tile",
"operator",
"attributes",
"to",
"onnx",
"s",
"Tile",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L1977-L2011 |
23,649 | apache/incubator-mxnet | python/mxnet/contrib/onnx/mx2onnx/_op_translations.py | convert_broadcast_to | def convert_broadcast_to(node, **kwargs):
"""Map MXNet's broadcast_to operator attributes to onnx's Expand
operator and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
shape_list = convert_string_to_list(attrs["shape"])
initializer = kwargs["initializer"]
o... | python | def convert_broadcast_to(node, **kwargs):
"""Map MXNet's broadcast_to operator attributes to onnx's Expand
operator and return the created node.
"""
name, input_nodes, attrs = get_inputs(node, kwargs)
shape_list = convert_string_to_list(attrs["shape"])
initializer = kwargs["initializer"]
o... | [
"def",
"convert_broadcast_to",
"(",
"node",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
",",
"input_nodes",
",",
"attrs",
"=",
"get_inputs",
"(",
"node",
",",
"kwargs",
")",
"shape_list",
"=",
"convert_string_to_list",
"(",
"attrs",
"[",
"\"shape\"",
"]",
"... | Map MXNet's broadcast_to operator attributes to onnx's Expand
operator and return the created node. | [
"Map",
"MXNet",
"s",
"broadcast_to",
"operator",
"attributes",
"to",
"onnx",
"s",
"Expand",
"operator",
"and",
"return",
"the",
"created",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/mx2onnx/_op_translations.py#L2015-L2049 |
23,650 | apache/incubator-mxnet | example/reinforcement-learning/dqn/base.py | Base.exe | def exe(self):
"""Get the current executor
Returns
-------
exe : mxnet.executor.Executor
"""
return self._buckets[self.curr_bucket_key]['exe'][tuple(self.data_shapes.items())] | python | def exe(self):
"""Get the current executor
Returns
-------
exe : mxnet.executor.Executor
"""
return self._buckets[self.curr_bucket_key]['exe'][tuple(self.data_shapes.items())] | [
"def",
"exe",
"(",
"self",
")",
":",
"return",
"self",
".",
"_buckets",
"[",
"self",
".",
"curr_bucket_key",
"]",
"[",
"'exe'",
"]",
"[",
"tuple",
"(",
"self",
".",
"data_shapes",
".",
"items",
"(",
")",
")",
"]"
] | Get the current executor
Returns
-------
exe : mxnet.executor.Executor | [
"Get",
"the",
"current",
"executor"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/reinforcement-learning/dqn/base.py#L80-L87 |
23,651 | apache/incubator-mxnet | example/reinforcement-learning/dqn/base.py | Base.compute_internal | def compute_internal(self, sym_name, bucket_kwargs=None, **arg_dict):
"""
View the internal symbols using the forward function.
:param sym_name:
:param bucket_kwargs:
:param input_dict:
:return:
"""
data_shapes = {k: v.shape for k, v in arg_dict.items()}
... | python | def compute_internal(self, sym_name, bucket_kwargs=None, **arg_dict):
"""
View the internal symbols using the forward function.
:param sym_name:
:param bucket_kwargs:
:param input_dict:
:return:
"""
data_shapes = {k: v.shape for k, v in arg_dict.items()}
... | [
"def",
"compute_internal",
"(",
"self",
",",
"sym_name",
",",
"bucket_kwargs",
"=",
"None",
",",
"*",
"*",
"arg_dict",
")",
":",
"data_shapes",
"=",
"{",
"k",
":",
"v",
".",
"shape",
"for",
"k",
",",
"v",
"in",
"arg_dict",
".",
"items",
"(",
")",
"... | View the internal symbols using the forward function.
:param sym_name:
:param bucket_kwargs:
:param input_dict:
:return: | [
"View",
"the",
"internal",
"symbols",
"using",
"the",
"forward",
"function",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/reinforcement-learning/dqn/base.py#L190-L222 |
23,652 | apache/incubator-mxnet | example/fcn-xs/init_fcnxs.py | init_from_fcnxs | def init_from_fcnxs(ctx, fcnxs_symbol, fcnxs_args_from, fcnxs_auxs_from):
""" use zero initialization for better convergence, because it tends to oputut 0,
and the label 0 stands for background, which may occupy most size of one image.
"""
fcnxs_args = fcnxs_args_from.copy()
fcnxs_auxs = fcnxs_auxs_... | python | def init_from_fcnxs(ctx, fcnxs_symbol, fcnxs_args_from, fcnxs_auxs_from):
""" use zero initialization for better convergence, because it tends to oputut 0,
and the label 0 stands for background, which may occupy most size of one image.
"""
fcnxs_args = fcnxs_args_from.copy()
fcnxs_auxs = fcnxs_auxs_... | [
"def",
"init_from_fcnxs",
"(",
"ctx",
",",
"fcnxs_symbol",
",",
"fcnxs_args_from",
",",
"fcnxs_auxs_from",
")",
":",
"fcnxs_args",
"=",
"fcnxs_args_from",
".",
"copy",
"(",
")",
"fcnxs_auxs",
"=",
"fcnxs_auxs_from",
".",
"copy",
"(",
")",
"for",
"k",
",",
"v... | use zero initialization for better convergence, because it tends to oputut 0,
and the label 0 stands for background, which may occupy most size of one image. | [
"use",
"zero",
"initialization",
"for",
"better",
"convergence",
"because",
"it",
"tends",
"to",
"oputut",
"0",
"and",
"the",
"label",
"0",
"stands",
"for",
"background",
"which",
"may",
"occupy",
"most",
"size",
"of",
"one",
"image",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/fcn-xs/init_fcnxs.py#L65-L106 |
23,653 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | var | def var(name, attr=None, shape=None, lr_mult=None, wd_mult=None, dtype=None,
init=None, stype=None, **kwargs):
"""Creates a symbolic variable with specified name.
Example
-------
>>> data = mx.sym.Variable('data', attr={'a': 'b'})
>>> data
<Symbol data>
>>> csr_data = mx.sym.Variabl... | python | def var(name, attr=None, shape=None, lr_mult=None, wd_mult=None, dtype=None,
init=None, stype=None, **kwargs):
"""Creates a symbolic variable with specified name.
Example
-------
>>> data = mx.sym.Variable('data', attr={'a': 'b'})
>>> data
<Symbol data>
>>> csr_data = mx.sym.Variabl... | [
"def",
"var",
"(",
"name",
",",
"attr",
"=",
"None",
",",
"shape",
"=",
"None",
",",
"lr_mult",
"=",
"None",
",",
"wd_mult",
"=",
"None",
",",
"dtype",
"=",
"None",
",",
"init",
"=",
"None",
",",
"stype",
"=",
"None",
",",
"*",
"*",
"kwargs",
"... | Creates a symbolic variable with specified name.
Example
-------
>>> data = mx.sym.Variable('data', attr={'a': 'b'})
>>> data
<Symbol data>
>>> csr_data = mx.sym.Variable('csr_data', stype='csr')
>>> csr_data
<Symbol csr_data>
>>> row_sparse_weight = mx.sym.Variable('weight', stype=... | [
"Creates",
"a",
"symbolic",
"variable",
"with",
"specified",
"name",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L2574-L2649 |
23,654 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Group | def Group(symbols):
"""Creates a symbol that contains a collection of other symbols, grouped together.
Example
-------
>>> a = mx.sym.Variable('a')
>>> b = mx.sym.Variable('b')
>>> mx.sym.Group([a,b])
<Symbol Grouped>
Parameters
----------
symbols : list
List of symbols... | python | def Group(symbols):
"""Creates a symbol that contains a collection of other symbols, grouped together.
Example
-------
>>> a = mx.sym.Variable('a')
>>> b = mx.sym.Variable('b')
>>> mx.sym.Group([a,b])
<Symbol Grouped>
Parameters
----------
symbols : list
List of symbols... | [
"def",
"Group",
"(",
"symbols",
")",
":",
"if",
"not",
"symbols",
"or",
"any",
"(",
"not",
"isinstance",
"(",
"sym",
",",
"Symbol",
")",
"for",
"sym",
"in",
"symbols",
")",
":",
"raise",
"TypeError",
"(",
"'Expected a list of symbols as input'",
")",
"hand... | Creates a symbol that contains a collection of other symbols, grouped together.
Example
-------
>>> a = mx.sym.Variable('a')
>>> b = mx.sym.Variable('b')
>>> mx.sym.Group([a,b])
<Symbol Grouped>
Parameters
----------
symbols : list
List of symbols to be grouped.
Return... | [
"Creates",
"a",
"symbol",
"that",
"contains",
"a",
"collection",
"of",
"other",
"symbols",
"grouped",
"together",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L2656-L2682 |
23,655 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | load | def load(fname):
"""Loads symbol from a JSON file.
You can also use pickle to do the job if you only work on python.
The advantage of load/save is the file is language agnostic.
This means the file saved using save can be loaded by other language binding of mxnet.
You also get the benefit being abl... | python | def load(fname):
"""Loads symbol from a JSON file.
You can also use pickle to do the job if you only work on python.
The advantage of load/save is the file is language agnostic.
This means the file saved using save can be loaded by other language binding of mxnet.
You also get the benefit being abl... | [
"def",
"load",
"(",
"fname",
")",
":",
"if",
"not",
"isinstance",
"(",
"fname",
",",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'fname need to be string'",
")",
"handle",
"=",
"SymbolHandle",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolCrea... | Loads symbol from a JSON file.
You can also use pickle to do the job if you only work on python.
The advantage of load/save is the file is language agnostic.
This means the file saved using save can be loaded by other language binding of mxnet.
You also get the benefit being able to directly load/save ... | [
"Loads",
"symbol",
"from",
"a",
"JSON",
"file",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L2685-L2715 |
23,656 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | load_json | def load_json(json_str):
"""Loads symbol from json string.
Parameters
----------
json_str : str
A JSON string.
Returns
-------
sym : Symbol
The loaded symbol.
See Also
--------
Symbol.tojson : Used to save symbol into json string.
"""
if not isinstance(... | python | def load_json(json_str):
"""Loads symbol from json string.
Parameters
----------
json_str : str
A JSON string.
Returns
-------
sym : Symbol
The loaded symbol.
See Also
--------
Symbol.tojson : Used to save symbol into json string.
"""
if not isinstance(... | [
"def",
"load_json",
"(",
"json_str",
")",
":",
"if",
"not",
"isinstance",
"(",
"json_str",
",",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'fname required to be string'",
")",
"handle",
"=",
"SymbolHandle",
"(",
")",
"check_call",
"(",
"_LIB",
".",
... | Loads symbol from json string.
Parameters
----------
json_str : str
A JSON string.
Returns
-------
sym : Symbol
The loaded symbol.
See Also
--------
Symbol.tojson : Used to save symbol into json string. | [
"Loads",
"symbol",
"from",
"json",
"string",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L2718-L2739 |
23,657 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | maximum | def maximum(left, right):
"""Returns element-wise maximum of the input elements.
Both inputs can be Symbol or scalar number. Broadcasting is not supported.
Parameters
---------
left : Symbol or scalar
First symbol to be compared.
right : Symbol or scalar
Second symbol to be com... | python | def maximum(left, right):
"""Returns element-wise maximum of the input elements.
Both inputs can be Symbol or scalar number. Broadcasting is not supported.
Parameters
---------
left : Symbol or scalar
First symbol to be compared.
right : Symbol or scalar
Second symbol to be com... | [
"def",
"maximum",
"(",
"left",
",",
"right",
")",
":",
"if",
"isinstance",
"(",
"left",
",",
"Symbol",
")",
"and",
"isinstance",
"(",
"right",
",",
"Symbol",
")",
":",
"return",
"_internal",
".",
"_Maximum",
"(",
"left",
",",
"right",
")",
"if",
"isi... | Returns element-wise maximum of the input elements.
Both inputs can be Symbol or scalar number. Broadcasting is not supported.
Parameters
---------
left : Symbol or scalar
First symbol to be compared.
right : Symbol or scalar
Second symbol to be compared.
Returns
-------
... | [
"Returns",
"element",
"-",
"wise",
"maximum",
"of",
"the",
"input",
"elements",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L2831-L2870 |
23,658 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | minimum | def minimum(left, right):
"""Returns element-wise minimum of the input elements.
Both inputs can be Symbol or scalar number. Broadcasting is not supported.
Parameters
---------
left : Symbol or scalar
First symbol to be compared.
right : Symbol or scalar
Second symbol to be com... | python | def minimum(left, right):
"""Returns element-wise minimum of the input elements.
Both inputs can be Symbol or scalar number. Broadcasting is not supported.
Parameters
---------
left : Symbol or scalar
First symbol to be compared.
right : Symbol or scalar
Second symbol to be com... | [
"def",
"minimum",
"(",
"left",
",",
"right",
")",
":",
"if",
"isinstance",
"(",
"left",
",",
"Symbol",
")",
"and",
"isinstance",
"(",
"right",
",",
"Symbol",
")",
":",
"return",
"_internal",
".",
"_Minimum",
"(",
"left",
",",
"right",
")",
"if",
"isi... | Returns element-wise minimum of the input elements.
Both inputs can be Symbol or scalar number. Broadcasting is not supported.
Parameters
---------
left : Symbol or scalar
First symbol to be compared.
right : Symbol or scalar
Second symbol to be compared.
Returns
-------
... | [
"Returns",
"element",
"-",
"wise",
"minimum",
"of",
"the",
"input",
"elements",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L2875-L2914 |
23,659 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | hypot | def hypot(left, right):
"""Given the "legs" of a right triangle, returns its hypotenuse.
Equivalent to :math:`\\sqrt(left^2 + right^2)`, element-wise.
Both inputs can be Symbol or scalar number. Broadcasting is not supported.
Parameters
---------
left : Symbol or scalar
First leg of th... | python | def hypot(left, right):
"""Given the "legs" of a right triangle, returns its hypotenuse.
Equivalent to :math:`\\sqrt(left^2 + right^2)`, element-wise.
Both inputs can be Symbol or scalar number. Broadcasting is not supported.
Parameters
---------
left : Symbol or scalar
First leg of th... | [
"def",
"hypot",
"(",
"left",
",",
"right",
")",
":",
"if",
"isinstance",
"(",
"left",
",",
"Symbol",
")",
"and",
"isinstance",
"(",
"right",
",",
"Symbol",
")",
":",
"return",
"_internal",
".",
"_Hypot",
"(",
"left",
",",
"right",
")",
"if",
"isinsta... | Given the "legs" of a right triangle, returns its hypotenuse.
Equivalent to :math:`\\sqrt(left^2 + right^2)`, element-wise.
Both inputs can be Symbol or scalar number. Broadcasting is not supported.
Parameters
---------
left : Symbol or scalar
First leg of the triangle(s).
right : Symb... | [
"Given",
"the",
"legs",
"of",
"a",
"right",
"triangle",
"returns",
"its",
"hypotenuse",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L2919-L2959 |
23,660 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | eye | def eye(N, M=0, k=0, dtype=None, **kwargs):
"""Returns a new symbol of 2-D shpae, filled with ones on the diagonal and zeros elsewhere.
Parameters
----------
N: int
Number of rows in the output.
M: int, optional
Number of columns in the output. If 0, defaults to N.
k: int, optio... | python | def eye(N, M=0, k=0, dtype=None, **kwargs):
"""Returns a new symbol of 2-D shpae, filled with ones on the diagonal and zeros elsewhere.
Parameters
----------
N: int
Number of rows in the output.
M: int, optional
Number of columns in the output. If 0, defaults to N.
k: int, optio... | [
"def",
"eye",
"(",
"N",
",",
"M",
"=",
"0",
",",
"k",
"=",
"0",
",",
"dtype",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"dtype",
"is",
"None",
":",
"dtype",
"=",
"_numpy",
".",
"float32",
"return",
"_internal",
".",
"_eye",
"(",
"... | Returns a new symbol of 2-D shpae, filled with ones on the diagonal and zeros elsewhere.
Parameters
----------
N: int
Number of rows in the output.
M: int, optional
Number of columns in the output. If 0, defaults to N.
k: int, optional
Index of the diagonal: 0 (the default) ... | [
"Returns",
"a",
"new",
"symbol",
"of",
"2",
"-",
"D",
"shpae",
"filled",
"with",
"ones",
"on",
"the",
"diagonal",
"and",
"zeros",
"elsewhere",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L2962-L2985 |
23,661 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | zeros | def zeros(shape, dtype=None, **kwargs):
"""Returns a new symbol of given shape and type, filled with zeros.
Parameters
----------
shape : int or sequence of ints
Shape of the new array.
dtype : str or numpy.dtype, optional
The value type of the inner value, default to ``np.float32`... | python | def zeros(shape, dtype=None, **kwargs):
"""Returns a new symbol of given shape and type, filled with zeros.
Parameters
----------
shape : int or sequence of ints
Shape of the new array.
dtype : str or numpy.dtype, optional
The value type of the inner value, default to ``np.float32`... | [
"def",
"zeros",
"(",
"shape",
",",
"dtype",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"dtype",
"is",
"None",
":",
"dtype",
"=",
"_numpy",
".",
"float32",
"return",
"_internal",
".",
"_zeros",
"(",
"shape",
"=",
"shape",
",",
"dtype",
"=... | Returns a new symbol of given shape and type, filled with zeros.
Parameters
----------
shape : int or sequence of ints
Shape of the new array.
dtype : str or numpy.dtype, optional
The value type of the inner value, default to ``np.float32``.
Returns
-------
out : Symbol
... | [
"Returns",
"a",
"new",
"symbol",
"of",
"given",
"shape",
"and",
"type",
"filled",
"with",
"zeros",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L2987-L3004 |
23,662 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | ones | def ones(shape, dtype=None, **kwargs):
"""Returns a new symbol of given shape and type, filled with ones.
Parameters
----------
shape : int or sequence of ints
Shape of the new array.
dtype : str or numpy.dtype, optional
The value type of the inner value, default to ``np.float32``.... | python | def ones(shape, dtype=None, **kwargs):
"""Returns a new symbol of given shape and type, filled with ones.
Parameters
----------
shape : int or sequence of ints
Shape of the new array.
dtype : str or numpy.dtype, optional
The value type of the inner value, default to ``np.float32``.... | [
"def",
"ones",
"(",
"shape",
",",
"dtype",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"dtype",
"is",
"None",
":",
"dtype",
"=",
"_numpy",
".",
"float32",
"return",
"_internal",
".",
"_ones",
"(",
"shape",
"=",
"shape",
",",
"dtype",
"=",... | Returns a new symbol of given shape and type, filled with ones.
Parameters
----------
shape : int or sequence of ints
Shape of the new array.
dtype : str or numpy.dtype, optional
The value type of the inner value, default to ``np.float32``.
Returns
-------
out : Symbol
... | [
"Returns",
"a",
"new",
"symbol",
"of",
"given",
"shape",
"and",
"type",
"filled",
"with",
"ones",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L3007-L3024 |
23,663 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.name | def name(self):
"""Gets name string from the symbol, this function only works for non-grouped symbol.
Returns
-------
value : str
The name of this symbol, returns ``None`` for grouped symbol.
"""
ret = ctypes.c_char_p()
success = ctypes.c_int()
... | python | def name(self):
"""Gets name string from the symbol, this function only works for non-grouped symbol.
Returns
-------
value : str
The name of this symbol, returns ``None`` for grouped symbol.
"""
ret = ctypes.c_char_p()
success = ctypes.c_int()
... | [
"def",
"name",
"(",
"self",
")",
":",
"ret",
"=",
"ctypes",
".",
"c_char_p",
"(",
")",
"success",
"=",
"ctypes",
".",
"c_int",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolGetName",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
... | Gets name string from the symbol, this function only works for non-grouped symbol.
Returns
-------
value : str
The name of this symbol, returns ``None`` for grouped symbol. | [
"Gets",
"name",
"string",
"from",
"the",
"symbol",
"this",
"function",
"only",
"works",
"for",
"non",
"-",
"grouped",
"symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L534-L549 |
23,664 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.attr | def attr(self, key):
"""Returns the attribute string for corresponding input key from the symbol.
This function only works for non-grouped symbols.
Example
-------
>>> data = mx.sym.Variable('data', attr={'mood': 'angry'})
>>> data.attr('mood')
'angry'
... | python | def attr(self, key):
"""Returns the attribute string for corresponding input key from the symbol.
This function only works for non-grouped symbols.
Example
-------
>>> data = mx.sym.Variable('data', attr={'mood': 'angry'})
>>> data.attr('mood')
'angry'
... | [
"def",
"attr",
"(",
"self",
",",
"key",
")",
":",
"ret",
"=",
"ctypes",
".",
"c_char_p",
"(",
")",
"success",
"=",
"ctypes",
".",
"c_int",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolGetAttr",
"(",
"self",
".",
"handle",
",",
"c_str",
"(",
"... | Returns the attribute string for corresponding input key from the symbol.
This function only works for non-grouped symbols.
Example
-------
>>> data = mx.sym.Variable('data', attr={'mood': 'angry'})
>>> data.attr('mood')
'angry'
Parameters
----------
... | [
"Returns",
"the",
"attribute",
"string",
"for",
"corresponding",
"input",
"key",
"from",
"the",
"symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L551-L579 |
23,665 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.list_attr | def list_attr(self, recursive=False):
"""Gets all attributes from the symbol.
Example
-------
>>> data = mx.sym.Variable('data', attr={'mood': 'angry'})
>>> data.list_attr()
{'mood': 'angry'}
Returns
-------
ret : Dict of str to str
A... | python | def list_attr(self, recursive=False):
"""Gets all attributes from the symbol.
Example
-------
>>> data = mx.sym.Variable('data', attr={'mood': 'angry'})
>>> data.list_attr()
{'mood': 'angry'}
Returns
-------
ret : Dict of str to str
A... | [
"def",
"list_attr",
"(",
"self",
",",
"recursive",
"=",
"False",
")",
":",
"if",
"recursive",
":",
"raise",
"DeprecationWarning",
"(",
"\"Symbol.list_attr with recursive=True has been deprecated. \"",
"\"Please use attr_dict instead.\"",
")",
"size",
"=",
"mx_uint",
"(",
... | Gets all attributes from the symbol.
Example
-------
>>> data = mx.sym.Variable('data', attr={'mood': 'angry'})
>>> data.list_attr()
{'mood': 'angry'}
Returns
-------
ret : Dict of str to str
A dictionary mapping attribute keys to values. | [
"Gets",
"all",
"attributes",
"from",
"the",
"symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L581-L602 |
23,666 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.attr_dict | def attr_dict(self):
"""Recursively gets all attributes from the symbol and its children.
Example
-------
>>> a = mx.sym.Variable('a', attr={'a1':'a2'})
>>> b = mx.sym.Variable('b', attr={'b1':'b2'})
>>> c = a+b
>>> c.attr_dict()
{'a': {'a1': 'a2'}, 'b': ... | python | def attr_dict(self):
"""Recursively gets all attributes from the symbol and its children.
Example
-------
>>> a = mx.sym.Variable('a', attr={'a1':'a2'})
>>> b = mx.sym.Variable('b', attr={'b1':'b2'})
>>> c = a+b
>>> c.attr_dict()
{'a': {'a1': 'a2'}, 'b': ... | [
"def",
"attr_dict",
"(",
"self",
")",
":",
"size",
"=",
"mx_uint",
"(",
")",
"pairs",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_char_p",
")",
"(",
")",
"f_handle",
"=",
"_LIB",
".",
"MXSymbolListAttr",
"check_call",
"(",
"f_handle",
"(",
"s... | Recursively gets all attributes from the symbol and its children.
Example
-------
>>> a = mx.sym.Variable('a', attr={'a1':'a2'})
>>> b = mx.sym.Variable('b', attr={'b1':'b2'})
>>> c = a+b
>>> c.attr_dict()
{'a': {'a1': 'a2'}, 'b': {'b1': 'b2'}}
Returns
... | [
"Recursively",
"gets",
"all",
"attributes",
"from",
"the",
"symbol",
"and",
"its",
"children",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L604-L633 |
23,667 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol._set_attr | def _set_attr(self, **kwargs):
"""Sets an attribute of the symbol.
For example. A._set_attr(foo="bar") adds the mapping ``"{foo: bar}"``
to the symbol's attribute dictionary.
Parameters
----------
**kwargs
The attributes to set
"""
for key, v... | python | def _set_attr(self, **kwargs):
"""Sets an attribute of the symbol.
For example. A._set_attr(foo="bar") adds the mapping ``"{foo: bar}"``
to the symbol's attribute dictionary.
Parameters
----------
**kwargs
The attributes to set
"""
for key, v... | [
"def",
"_set_attr",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"string_types",
")",
":",
"raise",
"ValueError",
"(",
"\"Set At... | Sets an attribute of the symbol.
For example. A._set_attr(foo="bar") adds the mapping ``"{foo: bar}"``
to the symbol's attribute dictionary.
Parameters
----------
**kwargs
The attributes to set | [
"Sets",
"an",
"attribute",
"of",
"the",
"symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L635-L650 |
23,668 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.get_internals | def get_internals(self):
"""Gets a new grouped symbol `sgroup`. The output of `sgroup` is a list of
outputs of all of the internal nodes.
Consider the following code:
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>... | python | def get_internals(self):
"""Gets a new grouped symbol `sgroup`. The output of `sgroup` is a list of
outputs of all of the internal nodes.
Consider the following code:
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>... | [
"def",
"get_internals",
"(",
"self",
")",
":",
"handle",
"=",
"SymbolHandle",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolGetInternals",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"handle",
")",
")",
")",
"return",
"Symbol",
"("... | Gets a new grouped symbol `sgroup`. The output of `sgroup` is a list of
outputs of all of the internal nodes.
Consider the following code:
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> d = c.get_internals()
>>>... | [
"Gets",
"a",
"new",
"grouped",
"symbol",
"sgroup",
".",
"The",
"output",
"of",
"sgroup",
"is",
"a",
"list",
"of",
"outputs",
"of",
"all",
"of",
"the",
"internal",
"nodes",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L652-L678 |
23,669 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.get_children | def get_children(self):
"""Gets a new grouped symbol whose output contains
inputs to output nodes of the original symbol.
Example
-------
>>> x = mx.sym.Variable('x')
>>> y = mx.sym.Variable('y')
>>> z = mx.sym.Variable('z')
>>> a = y+z
>>> b = x+... | python | def get_children(self):
"""Gets a new grouped symbol whose output contains
inputs to output nodes of the original symbol.
Example
-------
>>> x = mx.sym.Variable('x')
>>> y = mx.sym.Variable('y')
>>> z = mx.sym.Variable('z')
>>> a = y+z
>>> b = x+... | [
"def",
"get_children",
"(",
"self",
")",
":",
"handle",
"=",
"SymbolHandle",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolGetChildren",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"handle",
")",
")",
")",
"ret",
"=",
"Symbol",
"... | Gets a new grouped symbol whose output contains
inputs to output nodes of the original symbol.
Example
-------
>>> x = mx.sym.Variable('x')
>>> y = mx.sym.Variable('y')
>>> z = mx.sym.Variable('z')
>>> a = y+z
>>> b = x+a
>>> b.get_children()
... | [
"Gets",
"a",
"new",
"grouped",
"symbol",
"whose",
"output",
"contains",
"inputs",
"to",
"output",
"nodes",
"of",
"the",
"original",
"symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L680-L710 |
23,670 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.list_arguments | def list_arguments(self):
"""Lists all the arguments in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_arguments
['a', 'b']
Returns
-------
args : list of string
Li... | python | def list_arguments(self):
"""Lists all the arguments in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_arguments
['a', 'b']
Returns
-------
args : list of string
Li... | [
"def",
"list_arguments",
"(",
"self",
")",
":",
"size",
"=",
"ctypes",
".",
"c_uint",
"(",
")",
"sarr",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_char_p",
")",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolListArguments",
"(",
"self",
... | Lists all the arguments in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_arguments
['a', 'b']
Returns
-------
args : list of string
List containing the names of all the ar... | [
"Lists",
"all",
"the",
"arguments",
"in",
"the",
"symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L712-L732 |
23,671 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.list_outputs | def list_outputs(self):
"""Lists all the outputs in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_outputs()
['_plus12_output']
Returns
-------
list of str
List of ... | python | def list_outputs(self):
"""Lists all the outputs in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_outputs()
['_plus12_output']
Returns
-------
list of str
List of ... | [
"def",
"list_outputs",
"(",
"self",
")",
":",
"size",
"=",
"ctypes",
".",
"c_uint",
"(",
")",
"sarr",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_char_p",
")",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolListOutputs",
"(",
"self",
".",... | Lists all the outputs in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_outputs()
['_plus12_output']
Returns
-------
list of str
List of all the outputs.
For mo... | [
"Lists",
"all",
"the",
"outputs",
"in",
"the",
"symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L734-L757 |
23,672 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.list_auxiliary_states | def list_auxiliary_states(self):
"""Lists all the auxiliary states in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_auxiliary_states()
[]
Example of auxiliary states in `BatchNorm`.
... | python | def list_auxiliary_states(self):
"""Lists all the auxiliary states in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_auxiliary_states()
[]
Example of auxiliary states in `BatchNorm`.
... | [
"def",
"list_auxiliary_states",
"(",
"self",
")",
":",
"size",
"=",
"ctypes",
".",
"c_uint",
"(",
")",
"sarr",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_char_p",
")",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolListAuxiliaryStates",
"(",... | Lists all the auxiliary states in the symbol.
Example
-------
>>> a = mx.sym.var('a')
>>> b = mx.sym.var('b')
>>> c = a + b
>>> c.list_auxiliary_states()
[]
Example of auxiliary states in `BatchNorm`.
>>> data = mx.symbol.Variable('data')
... | [
"Lists",
"all",
"the",
"auxiliary",
"states",
"in",
"the",
"symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L779-L815 |
23,673 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.list_inputs | def list_inputs(self):
"""Lists all arguments and auxiliary states of this Symbol.
Returns
-------
inputs : list of str
List of all inputs.
Examples
--------
>>> bn = mx.sym.BatchNorm(name='bn')
>>> bn.list_arguments()
['bn_data', 'bn... | python | def list_inputs(self):
"""Lists all arguments and auxiliary states of this Symbol.
Returns
-------
inputs : list of str
List of all inputs.
Examples
--------
>>> bn = mx.sym.BatchNorm(name='bn')
>>> bn.list_arguments()
['bn_data', 'bn... | [
"def",
"list_inputs",
"(",
"self",
")",
":",
"size",
"=",
"ctypes",
".",
"c_uint",
"(",
")",
"sarr",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_char_p",
")",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"NNSymbolListInputNames",
"(",
"self",
".... | Lists all arguments and auxiliary states of this Symbol.
Returns
-------
inputs : list of str
List of all inputs.
Examples
--------
>>> bn = mx.sym.BatchNorm(name='bn')
>>> bn.list_arguments()
['bn_data', 'bn_gamma', 'bn_beta']
>>> bn... | [
"Lists",
"all",
"arguments",
"and",
"auxiliary",
"states",
"of",
"this",
"Symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L817-L839 |
23,674 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.infer_type | def infer_type(self, *args, **kwargs):
"""Infers the type of all arguments and all outputs, given the known types
for some arguments.
This function takes the known types of some arguments in either positional way
or keyword argument way as input. It returns a tuple of `None` values
... | python | def infer_type(self, *args, **kwargs):
"""Infers the type of all arguments and all outputs, given the known types
for some arguments.
This function takes the known types of some arguments in either positional way
or keyword argument way as input. It returns a tuple of `None` values
... | [
"def",
"infer_type",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"_infer_type_impl",
"(",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"res",
"[",
"1",
"]",
"is",
"Non... | Infers the type of all arguments and all outputs, given the known types
for some arguments.
This function takes the known types of some arguments in either positional way
or keyword argument way as input. It returns a tuple of `None` values
if there is not enough information to deduce t... | [
"Infers",
"the",
"type",
"of",
"all",
"arguments",
"and",
"all",
"outputs",
"given",
"the",
"known",
"types",
"for",
"some",
"arguments",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L841-L908 |
23,675 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol._infer_type_impl | def _infer_type_impl(self, partial, *args, **kwargs):
"""The actual implementation for calling type inference API."""
# pylint: disable=too-many-locals
if len(args) != 0 and len(kwargs) != 0:
raise ValueError('Can only specify known argument \
types either by posi... | python | def _infer_type_impl(self, partial, *args, **kwargs):
"""The actual implementation for calling type inference API."""
# pylint: disable=too-many-locals
if len(args) != 0 and len(kwargs) != 0:
raise ValueError('Can only specify known argument \
types either by posi... | [
"def",
"_infer_type_impl",
"(",
"self",
",",
"partial",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=too-many-locals",
"if",
"len",
"(",
"args",
")",
"!=",
"0",
"and",
"len",
"(",
"kwargs",
")",
"!=",
"0",
":",
"raise",
"Valu... | The actual implementation for calling type inference API. | [
"The",
"actual",
"implementation",
"for",
"calling",
"type",
"inference",
"API",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L958-L1015 |
23,676 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.infer_shape | def infer_shape(self, *args, **kwargs):
"""Infers the shapes of all arguments and all outputs given the known shapes of
some arguments.
This function takes the known shapes of some arguments in either positional way
or keyword argument way as input. It returns a tuple of `None` values
... | python | def infer_shape(self, *args, **kwargs):
"""Infers the shapes of all arguments and all outputs given the known shapes of
some arguments.
This function takes the known shapes of some arguments in either positional way
or keyword argument way as input. It returns a tuple of `None` values
... | [
"def",
"infer_shape",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"_infer_shape_impl",
"(",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"res",
"[",
"1",
"]",
"is",
"N... | Infers the shapes of all arguments and all outputs given the known shapes of
some arguments.
This function takes the known shapes of some arguments in either positional way
or keyword argument way as input. It returns a tuple of `None` values
if there is not enough information to deduce... | [
"Infers",
"the",
"shapes",
"of",
"all",
"arguments",
"and",
"all",
"outputs",
"given",
"the",
"known",
"shapes",
"of",
"some",
"arguments",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1018-L1102 |
23,677 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.save | def save(self, fname):
"""Saves symbol to a file.
You can also use pickle to do the job if you only work on python.
The advantage of `load`/`save` functions is that the file contents are language agnostic.
This means the model saved by one language binding can be loaded by a different
... | python | def save(self, fname):
"""Saves symbol to a file.
You can also use pickle to do the job if you only work on python.
The advantage of `load`/`save` functions is that the file contents are language agnostic.
This means the model saved by one language binding can be loaded by a different
... | [
"def",
"save",
"(",
"self",
",",
"fname",
")",
":",
"if",
"not",
"isinstance",
"(",
"fname",
",",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'fname need to be string'",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolSaveToFile",
"(",
"self",
".",
... | Saves symbol to a file.
You can also use pickle to do the job if you only work on python.
The advantage of `load`/`save` functions is that the file contents are language agnostic.
This means the model saved by one language binding can be loaded by a different
language binding of `MXNet`... | [
"Saves",
"symbol",
"to",
"a",
"file",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1278-L1302 |
23,678 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.tojson | def tojson(self):
"""Saves symbol to a JSON string.
See Also
--------
symbol.load_json : Used to load symbol from JSON string.
"""
json_str = ctypes.c_char_p()
check_call(_LIB.MXSymbolSaveToJSON(self.handle, ctypes.byref(json_str)))
return py_str(json_str... | python | def tojson(self):
"""Saves symbol to a JSON string.
See Also
--------
symbol.load_json : Used to load symbol from JSON string.
"""
json_str = ctypes.c_char_p()
check_call(_LIB.MXSymbolSaveToJSON(self.handle, ctypes.byref(json_str)))
return py_str(json_str... | [
"def",
"tojson",
"(",
"self",
")",
":",
"json_str",
"=",
"ctypes",
".",
"c_char_p",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolSaveToJSON",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"json_str",
")",
")",
")",
"return",
"py_s... | Saves symbol to a JSON string.
See Also
--------
symbol.load_json : Used to load symbol from JSON string. | [
"Saves",
"symbol",
"to",
"a",
"JSON",
"string",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1304-L1313 |
23,679 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol._get_ndarray_inputs | def _get_ndarray_inputs(arg_key, args, arg_names, allow_missing):
"""Helper function to get NDArray lists handles from various inputs.
Parameters
----------
arg_key : str
The name of argument, used for error message.
args : list of NDArray or dict of str to NDArray
... | python | def _get_ndarray_inputs(arg_key, args, arg_names, allow_missing):
"""Helper function to get NDArray lists handles from various inputs.
Parameters
----------
arg_key : str
The name of argument, used for error message.
args : list of NDArray or dict of str to NDArray
... | [
"def",
"_get_ndarray_inputs",
"(",
"arg_key",
",",
"args",
",",
"arg_names",
",",
"allow_missing",
")",
":",
"# setup args",
"arg_handles",
"=",
"[",
"]",
"arg_arrays",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"args",
",",
"list",
")",
":",
"if",
"len",
"... | Helper function to get NDArray lists handles from various inputs.
Parameters
----------
arg_key : str
The name of argument, used for error message.
args : list of NDArray or dict of str to NDArray
Input arguments to the symbols.
If type is list of ND... | [
"Helper",
"function",
"to",
"get",
"NDArray",
"lists",
"handles",
"from",
"various",
"inputs",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1316-L1372 |
23,680 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.bind | def bind(self, ctx, args, args_grad=None, grad_req='write',
aux_states=None, group2ctx=None, shared_exec=None):
"""Binds the current symbol to an executor and returns it.
We first declare the computation and then bind to the data to run.
This function returns an executor which prov... | python | def bind(self, ctx, args, args_grad=None, grad_req='write',
aux_states=None, group2ctx=None, shared_exec=None):
"""Binds the current symbol to an executor and returns it.
We first declare the computation and then bind to the data to run.
This function returns an executor which prov... | [
"def",
"bind",
"(",
"self",
",",
"ctx",
",",
"args",
",",
"args_grad",
"=",
"None",
",",
"grad_req",
"=",
"'write'",
",",
"aux_states",
"=",
"None",
",",
"group2ctx",
"=",
"None",
",",
"shared_exec",
"=",
"None",
")",
":",
"# pylint: disable=too-many-local... | Binds the current symbol to an executor and returns it.
We first declare the computation and then bind to the data to run.
This function returns an executor which provides method `forward()` method for evaluation
and a `outputs()` method to get all the results.
Example
-------
... | [
"Binds",
"the",
"current",
"symbol",
"to",
"an",
"executor",
"and",
"returns",
"it",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1639-L1795 |
23,681 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.gradient | def gradient(self, wrt):
"""Gets the autodiff of current symbol.
This function can only be used if current symbol is a loss function.
.. note:: This function is currently not implemented.
Parameters
----------
wrt : Array of String
keyword arguments of the ... | python | def gradient(self, wrt):
"""Gets the autodiff of current symbol.
This function can only be used if current symbol is a loss function.
.. note:: This function is currently not implemented.
Parameters
----------
wrt : Array of String
keyword arguments of the ... | [
"def",
"gradient",
"(",
"self",
",",
"wrt",
")",
":",
"handle",
"=",
"SymbolHandle",
"(",
")",
"c_wrt",
"=",
"c_str_array",
"(",
"wrt",
")",
"check_call",
"(",
"_LIB",
".",
"MXSymbolGrad",
"(",
"self",
".",
"handle",
",",
"mx_uint",
"(",
"len",
"(",
... | Gets the autodiff of current symbol.
This function can only be used if current symbol is a loss function.
.. note:: This function is currently not implemented.
Parameters
----------
wrt : Array of String
keyword arguments of the symbol that the gradients are taken.... | [
"Gets",
"the",
"autodiff",
"of",
"current",
"symbol",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1797-L1820 |
23,682 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.eval | def eval(self, ctx=None, **kwargs):
"""Evaluates a symbol given arguments.
The `eval` method combines a call to `bind` (which returns an executor)
with a call to `forward` (executor method).
For the common use case, where you might repeatedly evaluate with same arguments,
eval i... | python | def eval(self, ctx=None, **kwargs):
"""Evaluates a symbol given arguments.
The `eval` method combines a call to `bind` (which returns an executor)
with a call to `forward` (executor method).
For the common use case, where you might repeatedly evaluate with same arguments,
eval i... | [
"def",
"eval",
"(",
"self",
",",
"ctx",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"ctx",
"is",
"None",
":",
"ctx",
"=",
"current_context",
"(",
")",
"return",
"self",
".",
"bind",
"(",
"ctx",
",",
"kwargs",
")",
".",
"forward",
"(",
... | Evaluates a symbol given arguments.
The `eval` method combines a call to `bind` (which returns an executor)
with a call to `forward` (executor method).
For the common use case, where you might repeatedly evaluate with same arguments,
eval is slow.
In that case, you should call `... | [
"Evaluates",
"a",
"symbol",
"given",
"arguments",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L1824-L1862 |
23,683 | apache/incubator-mxnet | python/mxnet/symbol/symbol.py | Symbol.get_backend_symbol | def get_backend_symbol(self, backend):
"""Return symbol for target backend.
Parameters
----------
backend : str
The backend names.
Returns
-------
out : Symbol
The created Symbol for target backend.
"""
out = SymbolHandle(... | python | def get_backend_symbol(self, backend):
"""Return symbol for target backend.
Parameters
----------
backend : str
The backend names.
Returns
-------
out : Symbol
The created Symbol for target backend.
"""
out = SymbolHandle(... | [
"def",
"get_backend_symbol",
"(",
"self",
",",
"backend",
")",
":",
"out",
"=",
"SymbolHandle",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXGenBackendSubgraph",
"(",
"self",
".",
"handle",
",",
"c_str",
"(",
"backend",
")",
",",
"ctypes",
".",
"byref",
... | Return symbol for target backend.
Parameters
----------
backend : str
The backend names.
Returns
-------
out : Symbol
The created Symbol for target backend. | [
"Return",
"symbol",
"for",
"target",
"backend",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/symbol/symbol.py#L2536-L2551 |
23,684 | apache/incubator-mxnet | tools/coreml/converter/utils.py | load_model | def load_model(model_name, epoch_num, data_shapes, label_shapes, label_names, gpus=''):
"""Returns a module loaded with the provided model.
Parameters
----------
model_name: str
Prefix of the MXNet model name as stored on the local directory.
epoch_num : int
Epoch number of model w... | python | def load_model(model_name, epoch_num, data_shapes, label_shapes, label_names, gpus=''):
"""Returns a module loaded with the provided model.
Parameters
----------
model_name: str
Prefix of the MXNet model name as stored on the local directory.
epoch_num : int
Epoch number of model w... | [
"def",
"load_model",
"(",
"model_name",
",",
"epoch_num",
",",
"data_shapes",
",",
"label_shapes",
",",
"label_names",
",",
"gpus",
"=",
"''",
")",
":",
"sym",
",",
"arg_params",
",",
"aux_params",
"=",
"mx",
".",
"model",
".",
"load_checkpoint",
"(",
"mod... | Returns a module loaded with the provided model.
Parameters
----------
model_name: str
Prefix of the MXNet model name as stored on the local directory.
epoch_num : int
Epoch number of model we would like to load.
input_shape: tuple
The shape of the input data in the form o... | [
"Returns",
"a",
"module",
"loaded",
"with",
"the",
"provided",
"model",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/utils.py#L21-L65 |
23,685 | apache/incubator-mxnet | tools/coreml/converter/utils.py | create_module | def create_module(sym, data_shapes, label_shapes, label_names, gpus=''):
"""Creates a new MXNet module.
Parameters
----------
sym : Symbol
An MXNet symbol.
input_shape: tuple
The shape of the input data in the form of (batch_size, channels, height, width)
files: list of string... | python | def create_module(sym, data_shapes, label_shapes, label_names, gpus=''):
"""Creates a new MXNet module.
Parameters
----------
sym : Symbol
An MXNet symbol.
input_shape: tuple
The shape of the input data in the form of (batch_size, channels, height, width)
files: list of string... | [
"def",
"create_module",
"(",
"sym",
",",
"data_shapes",
",",
"label_shapes",
",",
"label_names",
",",
"gpus",
"=",
"''",
")",
":",
"if",
"gpus",
"==",
"''",
":",
"devices",
"=",
"mx",
".",
"cpu",
"(",
")",
"else",
":",
"devices",
"=",
"[",
"mx",
".... | Creates a new MXNet module.
Parameters
----------
sym : Symbol
An MXNet symbol.
input_shape: tuple
The shape of the input data in the form of (batch_size, channels, height, width)
files: list of strings
List of URLs pertaining to files that need to be downloaded in order t... | [
"Creates",
"a",
"new",
"MXNet",
"module",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/utils.py#L68-L117 |
23,686 | apache/incubator-mxnet | example/ssd/evaluate/evaluate_net.py | evaluate_net | def evaluate_net(net, path_imgrec, num_classes, num_batch, mean_pixels, data_shape,
model_prefix, epoch, ctx=mx.cpu(), batch_size=32,
path_imglist="", nms_thresh=0.45, force_nms=False,
ovp_thresh=0.5, use_difficult=False, class_names=None,
voc07_metric... | python | def evaluate_net(net, path_imgrec, num_classes, num_batch, mean_pixels, data_shape,
model_prefix, epoch, ctx=mx.cpu(), batch_size=32,
path_imglist="", nms_thresh=0.45, force_nms=False,
ovp_thresh=0.5, use_difficult=False, class_names=None,
voc07_metric... | [
"def",
"evaluate_net",
"(",
"net",
",",
"path_imgrec",
",",
"num_classes",
",",
"num_batch",
",",
"mean_pixels",
",",
"data_shape",
",",
"model_prefix",
",",
"epoch",
",",
"ctx",
"=",
"mx",
".",
"cpu",
"(",
")",
",",
"batch_size",
"=",
"32",
",",
"path_i... | evalute network given validation record file
Parameters:
----------
net : str or None
Network name or use None to load from json without modifying
path_imgrec : str
path to the record validation file
path_imglist : str
path to the list file to replace labels in record file, ... | [
"evalute",
"network",
"given",
"validation",
"record",
"file"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/evaluate/evaluate_net.py#L34-L133 |
23,687 | apache/incubator-mxnet | python/mxnet/module/python_module.py | PythonModule.init_params | def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None,
allow_missing=False, force_init=False, allow_extra=False):
"""Initializes the parameters and auxiliary states. By default this function
does nothing. Subclass should override this method if contains pa... | python | def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None,
allow_missing=False, force_init=False, allow_extra=False):
"""Initializes the parameters and auxiliary states. By default this function
does nothing. Subclass should override this method if contains pa... | [
"def",
"init_params",
"(",
"self",
",",
"initializer",
"=",
"Uniform",
"(",
"0.01",
")",
",",
"arg_params",
"=",
"None",
",",
"aux_params",
"=",
"None",
",",
"allow_missing",
"=",
"False",
",",
"force_init",
"=",
"False",
",",
"allow_extra",
"=",
"False",
... | Initializes the parameters and auxiliary states. By default this function
does nothing. Subclass should override this method if contains parameters.
Parameters
----------
initializer : Initializer
Called to initialize parameters if needed.
arg_params : dict
... | [
"Initializes",
"the",
"parameters",
"and",
"auxiliary",
"states",
".",
"By",
"default",
"this",
"function",
"does",
"nothing",
".",
"Subclass",
"should",
"override",
"this",
"method",
"if",
"contains",
"parameters",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/python_module.py#L107-L132 |
23,688 | apache/incubator-mxnet | python/mxnet/module/python_module.py | PythonModule.update_metric | def update_metric(self, eval_metric, labels, pre_sliced=False):
"""Evaluates and accumulates evaluation metric on outputs of the last forward computation.
Subclass should override this method if needed.
Parameters
----------
eval_metric : EvalMetric
labels : list of NDAr... | python | def update_metric(self, eval_metric, labels, pre_sliced=False):
"""Evaluates and accumulates evaluation metric on outputs of the last forward computation.
Subclass should override this method if needed.
Parameters
----------
eval_metric : EvalMetric
labels : list of NDAr... | [
"def",
"update_metric",
"(",
"self",
",",
"eval_metric",
",",
"labels",
",",
"pre_sliced",
"=",
"False",
")",
":",
"if",
"self",
".",
"_label_shapes",
"is",
"None",
":",
"# since we do not need labels, we are probably not a module with a loss",
"# function or predictions,... | Evaluates and accumulates evaluation metric on outputs of the last forward computation.
Subclass should override this method if needed.
Parameters
----------
eval_metric : EvalMetric
labels : list of NDArray
Typically ``data_batch.label``. | [
"Evaluates",
"and",
"accumulates",
"evaluation",
"metric",
"on",
"outputs",
"of",
"the",
"last",
"forward",
"computation",
".",
"Subclass",
"should",
"override",
"this",
"method",
"if",
"needed",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/python_module.py#L141-L160 |
23,689 | apache/incubator-mxnet | python/mxnet/module/python_module.py | PythonLossModule.forward | def forward(self, data_batch, is_train=None):
"""Forward computation. Here we do nothing but to keep a reference to
the scores and the labels so that we can do backward computation.
Parameters
----------
data_batch : DataBatch
Could be anything with similar API imple... | python | def forward(self, data_batch, is_train=None):
"""Forward computation. Here we do nothing but to keep a reference to
the scores and the labels so that we can do backward computation.
Parameters
----------
data_batch : DataBatch
Could be anything with similar API imple... | [
"def",
"forward",
"(",
"self",
",",
"data_batch",
",",
"is_train",
"=",
"None",
")",
":",
"self",
".",
"_scores",
"=",
"data_batch",
".",
"data",
"[",
"0",
"]",
"if",
"is_train",
"is",
"None",
":",
"is_train",
"=",
"self",
".",
"for_training",
"if",
... | Forward computation. Here we do nothing but to keep a reference to
the scores and the labels so that we can do backward computation.
Parameters
----------
data_batch : DataBatch
Could be anything with similar API implemented.
is_train : bool
Default is ``... | [
"Forward",
"computation",
".",
"Here",
"we",
"do",
"nothing",
"but",
"to",
"keep",
"a",
"reference",
"to",
"the",
"scores",
"and",
"the",
"labels",
"so",
"that",
"we",
"can",
"do",
"backward",
"computation",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/python_module.py#L285-L302 |
23,690 | apache/incubator-mxnet | python/mxnet/module/python_module.py | PythonLossModule._backward_impl | def _backward_impl(self):
"""Actual implementation of the backward computation. The computation
should take ``self._scores`` and ``self._labels`` and then compute the
gradients with respect to the scores, store it as an `NDArray` in
``self._scores_grad``.
Instead of defining a s... | python | def _backward_impl(self):
"""Actual implementation of the backward computation. The computation
should take ``self._scores`` and ``self._labels`` and then compute the
gradients with respect to the scores, store it as an `NDArray` in
``self._scores_grad``.
Instead of defining a s... | [
"def",
"_backward_impl",
"(",
"self",
")",
":",
"if",
"self",
".",
"_grad_func",
"is",
"not",
"None",
":",
"grad",
"=",
"self",
".",
"_grad_func",
"(",
"self",
".",
"_scores",
",",
"self",
".",
"_labels",
")",
"if",
"not",
"isinstance",
"(",
"grad",
... | Actual implementation of the backward computation. The computation
should take ``self._scores`` and ``self._labels`` and then compute the
gradients with respect to the scores, store it as an `NDArray` in
``self._scores_grad``.
Instead of defining a subclass and overriding this function,... | [
"Actual",
"implementation",
"of",
"the",
"backward",
"computation",
".",
"The",
"computation",
"should",
"take",
"self",
".",
"_scores",
"and",
"self",
".",
"_labels",
"and",
"then",
"compute",
"the",
"gradients",
"with",
"respect",
"to",
"the",
"scores",
"sto... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/python_module.py#L331-L347 |
23,691 | apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | RNNParams.get | def get(self, name, **kwargs):
"""Get the variable given a name if one exists or create a new one if missing.
Parameters
----------
name : str
name of the variable
**kwargs :
more arguments that's passed to symbol.Variable
"""
name = self.... | python | def get(self, name, **kwargs):
"""Get the variable given a name if one exists or create a new one if missing.
Parameters
----------
name : str
name of the variable
**kwargs :
more arguments that's passed to symbol.Variable
"""
name = self.... | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"name",
"=",
"self",
".",
"_prefix",
"+",
"name",
"if",
"name",
"not",
"in",
"self",
".",
"_params",
":",
"self",
".",
"_params",
"[",
"name",
"]",
"=",
"symbol",
".",
"... | Get the variable given a name if one exists or create a new one if missing.
Parameters
----------
name : str
name of the variable
**kwargs :
more arguments that's passed to symbol.Variable | [
"Get",
"the",
"variable",
"given",
"a",
"name",
"if",
"one",
"exists",
"or",
"create",
"a",
"new",
"one",
"if",
"missing",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L92-L105 |
23,692 | apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | BaseRNNCell.unpack_weights | def unpack_weights(self, args):
"""Unpack fused weight matrices into separate
weight matrices.
For example, say you use a module object `mod` to run a network that has an lstm cell.
In `mod.get_params()[0]`, the lstm parameters are all represented as a single big vector.
`cell.u... | python | def unpack_weights(self, args):
"""Unpack fused weight matrices into separate
weight matrices.
For example, say you use a module object `mod` to run a network that has an lstm cell.
In `mod.get_params()[0]`, the lstm parameters are all represented as a single big vector.
`cell.u... | [
"def",
"unpack_weights",
"(",
"self",
",",
"args",
")",
":",
"args",
"=",
"args",
".",
"copy",
"(",
")",
"if",
"not",
"self",
".",
"_gate_names",
":",
"return",
"args",
"h",
"=",
"self",
".",
"_num_hidden",
"for",
"group_name",
"in",
"[",
"'i2h'",
",... | Unpack fused weight matrices into separate
weight matrices.
For example, say you use a module object `mod` to run a network that has an lstm cell.
In `mod.get_params()[0]`, the lstm parameters are all represented as a single big vector.
`cell.unpack_weights(mod.get_params()[0])` will un... | [
"Unpack",
"fused",
"weight",
"matrices",
"into",
"separate",
"weight",
"matrices",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L225-L263 |
23,693 | apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | BaseRNNCell.pack_weights | def pack_weights(self, args):
"""Pack separate weight matrices into a single packed
weight.
Parameters
----------
args : dict of str -> NDArray
Dictionary containing unpacked weights.
Returns
-------
args : dict of str -> NDArray
... | python | def pack_weights(self, args):
"""Pack separate weight matrices into a single packed
weight.
Parameters
----------
args : dict of str -> NDArray
Dictionary containing unpacked weights.
Returns
-------
args : dict of str -> NDArray
... | [
"def",
"pack_weights",
"(",
"self",
",",
"args",
")",
":",
"args",
"=",
"args",
".",
"copy",
"(",
")",
"if",
"not",
"self",
".",
"_gate_names",
":",
"return",
"args",
"for",
"group_name",
"in",
"[",
"'i2h'",
",",
"'h2h'",
"]",
":",
"weight",
"=",
"... | Pack separate weight matrices into a single packed
weight.
Parameters
----------
args : dict of str -> NDArray
Dictionary containing unpacked weights.
Returns
-------
args : dict of str -> NDArray
Dictionary with packed weights associated... | [
"Pack",
"separate",
"weight",
"matrices",
"into",
"a",
"single",
"packed",
"weight",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L265-L293 |
23,694 | apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | BaseRNNCell.unroll | def unroll(self, length, inputs, begin_state=None, layout='NTC', merge_outputs=None):
"""Unroll an RNN cell across time steps.
Parameters
----------
length : int
Number of steps to unroll.
inputs : Symbol, list of Symbol, or None
If `inputs` is a single S... | python | def unroll(self, length, inputs, begin_state=None, layout='NTC', merge_outputs=None):
"""Unroll an RNN cell across time steps.
Parameters
----------
length : int
Number of steps to unroll.
inputs : Symbol, list of Symbol, or None
If `inputs` is a single S... | [
"def",
"unroll",
"(",
"self",
",",
"length",
",",
"inputs",
",",
"begin_state",
"=",
"None",
",",
"layout",
"=",
"'NTC'",
",",
"merge_outputs",
"=",
"None",
")",
":",
"self",
".",
"reset",
"(",
")",
"inputs",
",",
"_",
"=",
"_normalize_sequence",
"(",
... | Unroll an RNN cell across time steps.
Parameters
----------
length : int
Number of steps to unroll.
inputs : Symbol, list of Symbol, or None
If `inputs` is a single Symbol (usually the output
of Embedding symbol), it should have shape
(bat... | [
"Unroll",
"an",
"RNN",
"cell",
"across",
"time",
"steps",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L295-L351 |
23,695 | apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | FusedRNNCell._slice_weights | def _slice_weights(self, arr, li, lh):
"""slice fused rnn weights"""
args = {}
gate_names = self._gate_names
directions = self._directions
b = len(directions)
p = 0
for layer in range(self._num_layers):
for direction in directions:
for... | python | def _slice_weights(self, arr, li, lh):
"""slice fused rnn weights"""
args = {}
gate_names = self._gate_names
directions = self._directions
b = len(directions)
p = 0
for layer in range(self._num_layers):
for direction in directions:
for... | [
"def",
"_slice_weights",
"(",
"self",
",",
"arr",
",",
"li",
",",
"lh",
")",
":",
"args",
"=",
"{",
"}",
"gate_names",
"=",
"self",
".",
"_gate_names",
"directions",
"=",
"self",
".",
"_directions",
"b",
"=",
"len",
"(",
"directions",
")",
"p",
"=",
... | slice fused rnn weights | [
"slice",
"fused",
"rnn",
"weights"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L600-L637 |
23,696 | apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | FusedRNNCell.unfuse | def unfuse(self):
"""Unfuse the fused RNN in to a stack of rnn cells.
Returns
-------
cell : mxnet.rnn.SequentialRNNCell
unfused cell that can be used for stepping, and can run on CPU.
"""
stack = SequentialRNNCell()
get_cell = {'rnn_relu': lambda cel... | python | def unfuse(self):
"""Unfuse the fused RNN in to a stack of rnn cells.
Returns
-------
cell : mxnet.rnn.SequentialRNNCell
unfused cell that can be used for stepping, and can run on CPU.
"""
stack = SequentialRNNCell()
get_cell = {'rnn_relu': lambda cel... | [
"def",
"unfuse",
"(",
"self",
")",
":",
"stack",
"=",
"SequentialRNNCell",
"(",
")",
"get_cell",
"=",
"{",
"'rnn_relu'",
":",
"lambda",
"cell_prefix",
":",
"RNNCell",
"(",
"self",
".",
"_num_hidden",
",",
"activation",
"=",
"'relu'",
",",
"prefix",
"=",
... | Unfuse the fused RNN in to a stack of rnn cells.
Returns
-------
cell : mxnet.rnn.SequentialRNNCell
unfused cell that can be used for stepping, and can run on CPU. | [
"Unfuse",
"the",
"fused",
"RNN",
"in",
"to",
"a",
"stack",
"of",
"rnn",
"cells",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L714-L745 |
23,697 | apache/incubator-mxnet | python/mxnet/rnn/rnn_cell.py | SequentialRNNCell.add | def add(self, cell):
"""Append a cell into the stack.
Parameters
----------
cell : BaseRNNCell
The cell to be appended. During unroll, previous cell's output (or raw inputs if
no previous cell) is used as the input to this cell.
"""
self._cells.ap... | python | def add(self, cell):
"""Append a cell into the stack.
Parameters
----------
cell : BaseRNNCell
The cell to be appended. During unroll, previous cell's output (or raw inputs if
no previous cell) is used as the input to this cell.
"""
self._cells.ap... | [
"def",
"add",
"(",
"self",
",",
"cell",
")",
":",
"self",
".",
"_cells",
".",
"append",
"(",
"cell",
")",
"if",
"self",
".",
"_override_cell_params",
":",
"assert",
"cell",
".",
"_own_params",
",",
"\"Either specify params for SequentialRNNCell \"",
"\"or child ... | Append a cell into the stack.
Parameters
----------
cell : BaseRNNCell
The cell to be appended. During unroll, previous cell's output (or raw inputs if
no previous cell) is used as the input to this cell. | [
"Append",
"a",
"cell",
"into",
"the",
"stack",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn_cell.py#L761-L776 |
23,698 | apache/incubator-mxnet | tools/caffe_converter/compare_layers.py | main | def main():
"""Entrypoint for compare_layers"""
parser = argparse.ArgumentParser(
description='Tool for testing caffe to mxnet conversion layer by layer')
parser.add_argument('--image_url', type=str,
default='https://github.com/dmlc/web-data/raw/master/mxnet/doc/'\
... | python | def main():
"""Entrypoint for compare_layers"""
parser = argparse.ArgumentParser(
description='Tool for testing caffe to mxnet conversion layer by layer')
parser.add_argument('--image_url', type=str,
default='https://github.com/dmlc/web-data/raw/master/mxnet/doc/'\
... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Tool for testing caffe to mxnet conversion layer by layer'",
")",
"parser",
".",
"add_argument",
"(",
"'--image_url'",
",",
"type",
"=",
"str",
",",
"default",... | Entrypoint for compare_layers | [
"Entrypoint",
"for",
"compare_layers"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_converter/compare_layers.py#L338-L364 |
23,699 | apache/incubator-mxnet | example/bayesian-methods/utils.py | copy_param | def copy_param(exe, new_param=None):
"""Create copy of parameters"""
if new_param is None:
new_param = {k: nd.empty(v.shape, ctx=mx.cpu()) for k, v in exe.arg_dict.items()}
for k, v in new_param.items():
exe.arg_dict[k].copyto(v)
return new_param | python | def copy_param(exe, new_param=None):
"""Create copy of parameters"""
if new_param is None:
new_param = {k: nd.empty(v.shape, ctx=mx.cpu()) for k, v in exe.arg_dict.items()}
for k, v in new_param.items():
exe.arg_dict[k].copyto(v)
return new_param | [
"def",
"copy_param",
"(",
"exe",
",",
"new_param",
"=",
"None",
")",
":",
"if",
"new_param",
"is",
"None",
":",
"new_param",
"=",
"{",
"k",
":",
"nd",
".",
"empty",
"(",
"v",
".",
"shape",
",",
"ctx",
"=",
"mx",
".",
"cpu",
"(",
")",
")",
"for"... | Create copy of parameters | [
"Create",
"copy",
"of",
"parameters"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/utils.py#L69-L75 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.