partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
Train.load_dataloader
Description : Setup the dataloader
example/gluon/lipnet/trainer.py
def load_dataloader(self): """ Description : Setup the dataloader """ input_transform = transforms.Compose([transforms.ToTensor(), \ transforms.Normalize((0.7136, 0.4906, 0.3283), \ ...
def load_dataloader(self): """ Description : Setup the dataloader """ input_transform = transforms.Compose([transforms.ToTensor(), \ transforms.Normalize((0.7136, 0.4906, 0.3283), \ ...
[ "Description", ":", "Setup", "the", "dataloader" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/trainer.py#L110-L138
[ "def", "load_dataloader", "(", "self", ")", ":", "input_transform", "=", "transforms", ".", "Compose", "(", "[", "transforms", ".", "ToTensor", "(", ")", ",", "transforms", ".", "Normalize", "(", "(", "0.7136", ",", "0.4906", ",", "0.3283", ")", ",", "("...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Train.train
Description : training for LipNet
example/gluon/lipnet/trainer.py
def train(self, data, label, batch_size): """ Description : training for LipNet """ # pylint: disable=no-member sum_losses = 0 len_losses = 0 with autograd.record(): losses = [self.loss_fn(self.net(X), Y) for X, Y in zip(data, label)] for loss ...
def train(self, data, label, batch_size): """ Description : training for LipNet """ # pylint: disable=no-member sum_losses = 0 len_losses = 0 with autograd.record(): losses = [self.loss_fn(self.net(X), Y) for X, Y in zip(data, label)] for loss ...
[ "Description", ":", "training", "for", "LipNet" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/trainer.py#L140-L154
[ "def", "train", "(", "self", ",", "data", ",", "label", ",", "batch_size", ")", ":", "# pylint: disable=no-member", "sum_losses", "=", "0", "len_losses", "=", "0", "with", "autograd", ".", "record", "(", ")", ":", "losses", "=", "[", "self", ".", "loss_f...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Train.infer
Description : Print sentence for prediction result
example/gluon/lipnet/trainer.py
def infer(self, input_data, input_label): """ Description : Print sentence for prediction result """ sum_losses = 0 len_losses = 0 for data, label in zip(input_data, input_label): pred = self.net(data) sum_losses += mx.nd.array(self.loss_fn(pred, l...
def infer(self, input_data, input_label): """ Description : Print sentence for prediction result """ sum_losses = 0 len_losses = 0 for data, label in zip(input_data, input_label): pred = self.net(data) sum_losses += mx.nd.array(self.loss_fn(pred, l...
[ "Description", ":", "Print", "sentence", "for", "prediction", "result" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/trainer.py#L156-L170
[ "def", "infer", "(", "self", ",", "input_data", ",", "input_label", ")", ":", "sum_losses", "=", "0", "len_losses", "=", "0", "for", "data", ",", "label", "in", "zip", "(", "input_data", ",", "input_label", ")", ":", "pred", "=", "self", ".", "net", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Train.train_batch
Description : training for LipNet
example/gluon/lipnet/trainer.py
def train_batch(self, dataloader): """ Description : training for LipNet """ sum_losses = 0 len_losses = 0 for input_data, input_label in tqdm(dataloader): data = gluon.utils.split_and_load(input_data, self.ctx, even_split=False) label = gluon.util...
def train_batch(self, dataloader): """ Description : training for LipNet """ sum_losses = 0 len_losses = 0 for input_data, input_label in tqdm(dataloader): data = gluon.utils.split_and_load(input_data, self.ctx, even_split=False) label = gluon.util...
[ "Description", ":", "training", "for", "LipNet" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/trainer.py#L172-L186
[ "def", "train_batch", "(", "self", ",", "dataloader", ")", ":", "sum_losses", "=", "0", "len_losses", "=", "0", "for", "input_data", ",", "input_label", "in", "tqdm", "(", "dataloader", ")", ":", "data", "=", "gluon", ".", "utils", ".", "split_and_load", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Train.infer_batch
Description : inference for LipNet
example/gluon/lipnet/trainer.py
def infer_batch(self, dataloader): """ Description : inference for LipNet """ sum_losses = 0 len_losses = 0 for input_data, input_label in dataloader: data = gluon.utils.split_and_load(input_data, self.ctx, even_split=False) label = gluon.utils.spl...
def infer_batch(self, dataloader): """ Description : inference for LipNet """ sum_losses = 0 len_losses = 0 for input_data, input_label in dataloader: data = gluon.utils.split_and_load(input_data, self.ctx, even_split=False) label = gluon.utils.spl...
[ "Description", ":", "inference", "for", "LipNet" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/trainer.py#L188-L201
[ "def", "infer_batch", "(", "self", ",", "dataloader", ")", ":", "sum_losses", "=", "0", "len_losses", "=", "0", "for", "input_data", ",", "input_label", "in", "dataloader", ":", "data", "=", "gluon", ".", "utils", ".", "split_and_load", "(", "input_data", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Train.run
Description : Run training for LipNet
example/gluon/lipnet/trainer.py
def run(self, epochs): """ Description : Run training for LipNet """ best_loss = sys.maxsize for epoch in trange(epochs): iter_no = 0 ## train sum_losses, len_losses = self.train_batch(self.train_dataloader) if iter_no % 20 == 0: ...
def run(self, epochs): """ Description : Run training for LipNet """ best_loss = sys.maxsize for epoch in trange(epochs): iter_no = 0 ## train sum_losses, len_losses = self.train_batch(self.train_dataloader) if iter_no % 20 == 0: ...
[ "Description", ":", "Run", "training", "for", "LipNet" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/trainer.py#L203-L232
[ "def", "run", "(", "self", ",", "epochs", ")", ":", "best_loss", "=", "sys", ".", "maxsize", "for", "epoch", "in", "trange", "(", "epochs", ")", ":", "iter_no", "=", "0", "## train", "sum_losses", ",", "len_losses", "=", "self", ".", "train_batch", "("...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
sample_categorical
Sample from independent categorical distributions Each batch is an independent categorical distribution. Parameters ---------- prob : numpy.ndarray Probability of the categorical distribution. Shape --> (batch_num, category_num) rng : numpy.random.RandomState Returns ------- ret...
example/reinforcement-learning/dqn/utils.py
def sample_categorical(prob, rng): """Sample from independent categorical distributions Each batch is an independent categorical distribution. Parameters ---------- prob : numpy.ndarray Probability of the categorical distribution. Shape --> (batch_num, category_num) rng : numpy.random.Ra...
def sample_categorical(prob, rng): """Sample from independent categorical distributions Each batch is an independent categorical distribution. Parameters ---------- prob : numpy.ndarray Probability of the categorical distribution. Shape --> (batch_num, category_num) rng : numpy.random.Ra...
[ "Sample", "from", "independent", "categorical", "distributions" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/reinforcement-learning/dqn/utils.py#L133-L154
[ "def", "sample_categorical", "(", "prob", ",", "rng", ")", ":", "ret", "=", "numpy", ".", "empty", "(", "prob", ".", "shape", "[", "0", "]", ",", "dtype", "=", "numpy", ".", "float32", ")", "for", "ind", "in", "range", "(", "prob", ".", "shape", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
sample_normal
Sample from independent normal distributions Each element is an independent normal distribution. Parameters ---------- mean : numpy.ndarray Means of the normal distribution. Shape --> (batch_num, sample_dim) var : numpy.ndarray Variance of the normal distribution. Shape --> (batch_num,...
example/reinforcement-learning/dqn/utils.py
def sample_normal(mean, var, rng): """Sample from independent normal distributions Each element is an independent normal distribution. Parameters ---------- mean : numpy.ndarray Means of the normal distribution. Shape --> (batch_num, sample_dim) var : numpy.ndarray Variance of the ...
def sample_normal(mean, var, rng): """Sample from independent normal distributions Each element is an independent normal distribution. Parameters ---------- mean : numpy.ndarray Means of the normal distribution. Shape --> (batch_num, sample_dim) var : numpy.ndarray Variance of the ...
[ "Sample", "from", "independent", "normal", "distributions" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/reinforcement-learning/dqn/utils.py#L157-L176
[ "def", "sample_normal", "(", "mean", ",", "var", ",", "rng", ")", ":", "ret", "=", "numpy", ".", "sqrt", "(", "var", ")", "*", "rng", ".", "randn", "(", "*", "mean", ".", "shape", ")", "+", "mean", "return", "ret" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
sample_mog
Sample from independent mixture of gaussian (MoG) distributions Each batch is an independent MoG distribution. Parameters ---------- prob : numpy.ndarray mixture probability of each gaussian. Shape --> (batch_num, center_num) mean : numpy.ndarray mean of each gaussian. Shape --> (batch...
example/reinforcement-learning/dqn/utils.py
def sample_mog(prob, mean, var, rng): """Sample from independent mixture of gaussian (MoG) distributions Each batch is an independent MoG distribution. Parameters ---------- prob : numpy.ndarray mixture probability of each gaussian. Shape --> (batch_num, center_num) mean : numpy.ndarray ...
def sample_mog(prob, mean, var, rng): """Sample from independent mixture of gaussian (MoG) distributions Each batch is an independent MoG distribution. Parameters ---------- prob : numpy.ndarray mixture probability of each gaussian. Shape --> (batch_num, center_num) mean : numpy.ndarray ...
[ "Sample", "from", "independent", "mixture", "of", "gaussian", "(", "MoG", ")", "distributions" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/reinforcement-learning/dqn/utils.py#L179-L203
[ "def", "sample_mog", "(", "prob", ",", "mean", ",", "var", ",", "rng", ")", ":", "gaussian_inds", "=", "sample_categorical", "(", "prob", ",", "rng", ")", ".", "astype", "(", "numpy", ".", "int32", ")", "mean", "=", "mean", "[", "numpy", ".", "arange...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
nce_loss_subwords
NCE-Loss layer under subword-units input.
example/nce-loss/nce.py
def nce_loss_subwords( data, label, label_mask, label_weight, embed_weight, vocab_size, num_hidden): """NCE-Loss layer under subword-units input. """ # get subword-units embedding. label_units_embed = mx.sym.Embedding(data=label, input_dim=vocab_size, ...
def nce_loss_subwords( data, label, label_mask, label_weight, embed_weight, vocab_size, num_hidden): """NCE-Loss layer under subword-units input. """ # get subword-units embedding. label_units_embed = mx.sym.Embedding(data=label, input_dim=vocab_size, ...
[ "NCE", "-", "Loss", "layer", "under", "subword", "-", "units", "input", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/nce-loss/nce.py#L38-L62
[ "def", "nce_loss_subwords", "(", "data", ",", "label", ",", "label_mask", ",", "label_weight", ",", "embed_weight", ",", "vocab_size", ",", "num_hidden", ")", ":", "# get subword-units embedding.", "label_units_embed", "=", "mx", ".", "sym", ".", "Embedding", "(",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_dataset
Download the BSDS500 dataset and return train and test iters.
example/gluon/super_resolution/super_resolution.py
def get_dataset(prefetch=False): """Download the BSDS500 dataset and return train and test iters.""" if path.exists(data_dir): print( "Directory {} already exists, skipping.\n" "To force download and extraction, delete the directory and re-run." "".format(data_dir), ...
def get_dataset(prefetch=False): """Download the BSDS500 dataset and return train and test iters.""" if path.exists(data_dir): print( "Directory {} already exists, skipping.\n" "To force download and extraction, delete the directory and re-run." "".format(data_dir), ...
[ "Download", "the", "BSDS500", "dataset", "and", "return", "train", "and", "test", "iters", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/super_resolution/super_resolution.py#L69-L130
[ "def", "get_dataset", "(", "prefetch", "=", "False", ")", ":", "if", "path", ".", "exists", "(", "data_dir", ")", ":", "print", "(", "\"Directory {} already exists, skipping.\\n\"", "\"To force download and extraction, delete the directory and re-run.\"", "\"\"", ".", "fo...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
evaluate
Run evaluation on cpu.
example/rnn/large_word_lm/run_utils.py
def evaluate(mod, data_iter, epoch, log_interval): """ Run evaluation on cpu. """ start = time.time() total_L = 0.0 nbatch = 0 density = 0 mod.set_states(value=0) for batch in data_iter: mod.forward(batch, is_train=False) outputs = mod.get_outputs(merge_multi_context=False) ...
def evaluate(mod, data_iter, epoch, log_interval): """ Run evaluation on cpu. """ start = time.time() total_L = 0.0 nbatch = 0 density = 0 mod.set_states(value=0) for batch in data_iter: mod.forward(batch, is_train=False) outputs = mod.get_outputs(merge_multi_context=False) ...
[ "Run", "evaluation", "on", "cpu", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/large_word_lm/run_utils.py#L66-L90
[ "def", "evaluate", "(", "mod", ",", "data_iter", ",", "epoch", ",", "log_interval", ")", ":", "start", "=", "time", ".", "time", "(", ")", "total_L", "=", "0.0", "nbatch", "=", "0", "density", "=", "0", "mod", ".", "set_states", "(", "value", "=", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
FileIter._read
get two list, each list contains two elements: name and nd.array value
example/fcn-xs/data.py
def _read(self): """get two list, each list contains two elements: name and nd.array value""" _, data_img_name, label_img_name = self.f.readline().strip('\n').split("\t") data = {} label = {} data[self.data_name], label[self.label_name] = self._read_img(data_img_name, label_img_n...
def _read(self): """get two list, each list contains two elements: name and nd.array value""" _, data_img_name, label_img_name = self.f.readline().strip('\n').split("\t") data = {} label = {} data[self.data_name], label[self.label_name] = self._read_img(data_img_name, label_img_n...
[ "get", "two", "list", "each", "list", "contains", "two", "elements", ":", "name", "and", "nd", ".", "array", "value" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/fcn-xs/data.py#L64-L70
[ "def", "_read", "(", "self", ")", ":", "_", ",", "data_img_name", ",", "label_img_name", "=", "self", ".", "f", ".", "readline", "(", ")", ".", "strip", "(", "'\\n'", ")", ".", "split", "(", "\"\\t\"", ")", "data", "=", "{", "}", "label", "=", "{...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
FileIter.next
return one dict which contains "data" and "label"
example/fcn-xs/data.py
def next(self): """return one dict which contains "data" and "label" """ if self.iter_next(): self.data, self.label = self._read() return {self.data_name : self.data[0][1], self.label_name : self.label[0][1]} else: raise StopIteration
def next(self): """return one dict which contains "data" and "label" """ if self.iter_next(): self.data, self.label = self._read() return {self.data_name : self.data[0][1], self.label_name : self.label[0][1]} else: raise StopIteration
[ "return", "one", "dict", "which", "contains", "data", "and", "label" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/fcn-xs/data.py#L132-L139
[ "def", "next", "(", "self", ")", ":", "if", "self", ".", "iter_next", "(", ")", ":", "self", ".", "data", ",", "self", ".", "label", "=", "self", ".", "_read", "(", ")", "return", "{", "self", ".", "data_name", ":", "self", ".", "data", "[", "0...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
GraphProto._convert_operator
Convert from onnx operator to mxnet operator. The converter must specify conversions explicitly for incompatible name, and apply handlers to operator attributes. Parameters ---------- :param node_name : str name of the node to be translated. :param op_name : ...
python/mxnet/contrib/onnx/onnx2mx/import_onnx.py
def _convert_operator(self, node_name, op_name, attrs, inputs): """Convert from onnx operator to mxnet operator. The converter must specify conversions explicitly for incompatible name, and apply handlers to operator attributes. Parameters ---------- :param node_name : s...
def _convert_operator(self, node_name, op_name, attrs, inputs): """Convert from onnx operator to mxnet operator. The converter must specify conversions explicitly for incompatible name, and apply handlers to operator attributes. Parameters ---------- :param node_name : s...
[ "Convert", "from", "onnx", "operator", "to", "mxnet", "operator", ".", "The", "converter", "must", "specify", "conversions", "explicitly", "for", "incompatible", "name", "and", "apply", "handlers", "to", "operator", "attributes", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/import_onnx.py#L41-L74
[ "def", "_convert_operator", "(", "self", ",", "node_name", ",", "op_name", ",", "attrs", ",", "inputs", ")", ":", "if", "op_name", "in", "convert_map", ":", "op_name", ",", "new_attrs", ",", "inputs", "=", "convert_map", "[", "op_name", "]", "(", "attrs", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
GraphProto.from_onnx
Construct symbol from onnx graph. Parameters ---------- graph : onnx protobuf object The loaded onnx graph Returns ------- sym :symbol.Symbol The returned mxnet symbol params : dict A dict of name: nd.array pairs, used as pret...
python/mxnet/contrib/onnx/onnx2mx/import_onnx.py
def from_onnx(self, graph): """Construct symbol from onnx graph. Parameters ---------- graph : onnx protobuf object The loaded onnx graph Returns ------- sym :symbol.Symbol The returned mxnet symbol params : dict A dic...
def from_onnx(self, graph): """Construct symbol from onnx graph. Parameters ---------- graph : onnx protobuf object The loaded onnx graph Returns ------- sym :symbol.Symbol The returned mxnet symbol params : dict A dic...
[ "Construct", "symbol", "from", "onnx", "graph", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/import_onnx.py#L76-L135
[ "def", "from_onnx", "(", "self", ",", "graph", ")", ":", "# get input, output shapes", "self", ".", "model_metadata", "=", "self", ".", "get_graph_metadata", "(", "graph", ")", "# parse network inputs, aka parameters", "for", "init_tensor", "in", "graph", ".", "init...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
GraphProto.get_graph_metadata
Get the model metadata from a given onnx graph.
python/mxnet/contrib/onnx/onnx2mx/import_onnx.py
def get_graph_metadata(self, graph): """ Get the model metadata from a given onnx graph. """ _params = set() for tensor_vals in graph.initializer: _params.add(tensor_vals.name) input_data = [] for graph_input in graph.input: if graph_input...
def get_graph_metadata(self, graph): """ Get the model metadata from a given onnx graph. """ _params = set() for tensor_vals in graph.initializer: _params.add(tensor_vals.name) input_data = [] for graph_input in graph.input: if graph_input...
[ "Get", "the", "model", "metadata", "from", "a", "given", "onnx", "graph", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/import_onnx.py#L137-L158
[ "def", "get_graph_metadata", "(", "self", ",", "graph", ")", ":", "_params", "=", "set", "(", ")", "for", "tensor_vals", "in", "graph", ".", "initializer", ":", "_params", ".", "add", "(", "tensor_vals", ".", "name", ")", "input_data", "=", "[", "]", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
GraphProto.graph_to_gluon
Construct SymbolBlock from onnx graph. Parameters ---------- graph : onnx protobuf object The loaded onnx graph ctx : Context or list of Context Loads the model into one or many context(s). Returns ------- sym_block :gluon.nn.SymbolBlock ...
python/mxnet/contrib/onnx/onnx2mx/import_onnx.py
def graph_to_gluon(self, graph, ctx): """Construct SymbolBlock from onnx graph. Parameters ---------- graph : onnx protobuf object The loaded onnx graph ctx : Context or list of Context Loads the model into one or many context(s). Returns ...
def graph_to_gluon(self, graph, ctx): """Construct SymbolBlock from onnx graph. Parameters ---------- graph : onnx protobuf object The loaded onnx graph ctx : Context or list of Context Loads the model into one or many context(s). Returns ...
[ "Construct", "SymbolBlock", "from", "onnx", "graph", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/import_onnx.py#L160-L191
[ "def", "graph_to_gluon", "(", "self", ",", "graph", ",", "ctx", ")", ":", "sym", ",", "arg_params", ",", "aux_params", "=", "self", ".", "from_onnx", "(", "graph", ")", "metadata", "=", "self", ".", "get_graph_metadata", "(", "graph", ")", "data_names", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
GraphProto._parse_array
Grab data in TensorProto and convert to numpy array.
python/mxnet/contrib/onnx/onnx2mx/import_onnx.py
def _parse_array(self, tensor_proto): """Grab data in TensorProto and convert to numpy array.""" try: from onnx.numpy_helper import to_array except ImportError: raise ImportError("Onnx and protobuf need to be installed. " + "Instructions to i...
def _parse_array(self, tensor_proto): """Grab data in TensorProto and convert to numpy array.""" try: from onnx.numpy_helper import to_array except ImportError: raise ImportError("Onnx and protobuf need to be installed. " + "Instructions to i...
[ "Grab", "data", "in", "TensorProto", "and", "convert", "to", "numpy", "array", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/import_onnx.py#L193-L205
[ "def", "_parse_array", "(", "self", ",", "tensor_proto", ")", ":", "try", ":", "from", "onnx", ".", "numpy_helper", "import", "to_array", "except", "ImportError", ":", "raise", "ImportError", "(", "\"Onnx and protobuf need to be installed. \"", "+", "\"Instructions to...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
GraphProto._parse_attr
Convert a list of AttributeProto to a dict, with names as keys.
python/mxnet/contrib/onnx/onnx2mx/import_onnx.py
def _parse_attr(self, attr_proto): """Convert a list of AttributeProto to a dict, with names as keys.""" attrs = {} for a in attr_proto: for f in ['f', 'i', 's']: if a.HasField(f): attrs[a.name] = getattr(a, f) # Needed for supp...
def _parse_attr(self, attr_proto): """Convert a list of AttributeProto to a dict, with names as keys.""" attrs = {} for a in attr_proto: for f in ['f', 'i', 's']: if a.HasField(f): attrs[a.name] = getattr(a, f) # Needed for supp...
[ "Convert", "a", "list", "of", "AttributeProto", "to", "a", "dict", "with", "names", "as", "keys", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/import_onnx.py#L207-L229
[ "def", "_parse_attr", "(", "self", ",", "attr_proto", ")", ":", "attrs", "=", "{", "}", "for", "a", "in", "attr_proto", ":", "for", "f", "in", "[", "'f'", ",", "'i'", ",", "'s'", "]", ":", "if", "a", ".", "HasField", "(", "f", ")", ":", "attrs"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SVRGModule.reshape
Reshapes both modules for new input shapes. Parameters ---------- data_shapes : list of (str, tuple) Typically is ``data_iter.provide_data``. label_shapes : list of (str, tuple) Typically is ``data_iter.provide_label``.
python/mxnet/contrib/svrg_optimization/svrg_module.py
def reshape(self, data_shapes, label_shapes=None): """Reshapes both modules for new input shapes. Parameters ---------- data_shapes : list of (str, tuple) Typically is ``data_iter.provide_data``. label_shapes : list of (str, tuple) Typically is ``data_ite...
def reshape(self, data_shapes, label_shapes=None): """Reshapes both modules for new input shapes. Parameters ---------- data_shapes : list of (str, tuple) Typically is ``data_iter.provide_data``. label_shapes : list of (str, tuple) Typically is ``data_ite...
[ "Reshapes", "both", "modules", "for", "new", "input", "shapes", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/svrg_optimization/svrg_module.py#L101-L112
[ "def", "reshape", "(", "self", ",", "data_shapes", ",", "label_shapes", "=", "None", ")", ":", "super", "(", "SVRGModule", ",", "self", ")", ".", "reshape", "(", "data_shapes", ",", "label_shapes", "=", "label_shapes", ")", "self", ".", "_mod_aux", ".", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SVRGModule.init_optimizer
Installs and initializes SVRGOptimizer. The SVRGOptimizer is a wrapper class for a regular optimizer that is passed in and a special AssignmentOptimizer to accumulate the full gradients. If KVStore is 'local' or None, the full gradients will be accumulated locally without pushing to the KVStore. Otherw...
python/mxnet/contrib/svrg_optimization/svrg_module.py
def init_optimizer(self, kvstore='local', optimizer='sgd', optimizer_params=(('learning_rate', 0.01),), force_init=False): """Installs and initializes SVRGOptimizer. The SVRGOptimizer is a wrapper class for a regular optimizer that is passed in and a special AssignmentOptimizer to...
def init_optimizer(self, kvstore='local', optimizer='sgd', optimizer_params=(('learning_rate', 0.01),), force_init=False): """Installs and initializes SVRGOptimizer. The SVRGOptimizer is a wrapper class for a regular optimizer that is passed in and a special AssignmentOptimizer to...
[ "Installs", "and", "initializes", "SVRGOptimizer", ".", "The", "SVRGOptimizer", "is", "a", "wrapper", "class", "for", "a", "regular", "optimizer", "that", "is", "passed", "in", "and", "a", "special", "AssignmentOptimizer", "to", "accumulate", "the", "full", "gra...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/svrg_optimization/svrg_module.py#L114-L151
[ "def", "init_optimizer", "(", "self", ",", "kvstore", "=", "'local'", ",", "optimizer", "=", "'sgd'", ",", "optimizer_params", "=", "(", "(", "'learning_rate'", ",", "0.01", ")", ",", ")", ",", "force_init", "=", "False", ")", ":", "# Init dict for storing a...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SVRGModule._create_optimizer
Helper function to create a svrg optimizer. SVRG optimizer encapsulates two optimizers and will redirect update() to the correct optimizer based on the key. Parameters ---------- kvstore : str or KVStore Default `'local'`. optimizer: str Name for SVRGOpti...
python/mxnet/contrib/svrg_optimization/svrg_module.py
def _create_optimizer(self, optimizer, default_opt, kvstore, optimizer_params): """Helper function to create a svrg optimizer. SVRG optimizer encapsulates two optimizers and will redirect update() to the correct optimizer based on the key. Parameters ---------- kvstore : str or ...
def _create_optimizer(self, optimizer, default_opt, kvstore, optimizer_params): """Helper function to create a svrg optimizer. SVRG optimizer encapsulates two optimizers and will redirect update() to the correct optimizer based on the key. Parameters ---------- kvstore : str or ...
[ "Helper", "function", "to", "create", "a", "svrg", "optimizer", ".", "SVRG", "optimizer", "encapsulates", "two", "optimizers", "and", "will", "redirect", "update", "()", "to", "the", "correct", "optimizer", "based", "on", "the", "key", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/svrg_optimization/svrg_module.py#L153-L196
[ "def", "_create_optimizer", "(", "self", ",", "optimizer", ",", "default_opt", ",", "kvstore", ",", "optimizer_params", ")", ":", "# code partially copied from mxnet module.init_optimizer() to accomodate svrg_optimizer", "batch_size", "=", "self", ".", "_exec_group", ".", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SVRGModule.bind
Binds the symbols to construct executors for both two modules. This is necessary before one can perform computation with the SVRGModule. Parameters ---------- data_shapes : list of (str, tuple) Typically is ``data_iter.provide_data``. label_shapes : list of (str, tup...
python/mxnet/contrib/svrg_optimization/svrg_module.py
def bind(self, data_shapes, label_shapes=None, for_training=True, inputs_need_grad=False, force_rebind=False, shared_module=None, grad_req='write'): """Binds the symbols to construct executors for both two modules. This is necessary before one can perform computation with the SVRGModule. ...
def bind(self, data_shapes, label_shapes=None, for_training=True, inputs_need_grad=False, force_rebind=False, shared_module=None, grad_req='write'): """Binds the symbols to construct executors for both two modules. This is necessary before one can perform computation with the SVRGModule. ...
[ "Binds", "the", "symbols", "to", "construct", "executors", "for", "both", "two", "modules", ".", "This", "is", "necessary", "before", "one", "can", "perform", "computation", "with", "the", "SVRGModule", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/svrg_optimization/svrg_module.py#L198-L230
[ "def", "bind", "(", "self", ",", "data_shapes", ",", "label_shapes", "=", "None", ",", "for_training", "=", "True", ",", "inputs_need_grad", "=", "False", ",", "force_rebind", "=", "False", ",", "shared_module", "=", "None", ",", "grad_req", "=", "'write'", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SVRGModule.forward
Forward computation for both two modules. It supports data batches with different shapes, such as different batch sizes or different image sizes. If reshaping of data batch relates to modification of symbol or module, such as changing image layout ordering or switching from training to predictin...
python/mxnet/contrib/svrg_optimization/svrg_module.py
def forward(self, data_batch, is_train=None): """Forward computation for both two modules. It supports data batches with different shapes, such as different batch sizes or different image sizes. If reshaping of data batch relates to modification of symbol or module, such as changing imag...
def forward(self, data_batch, is_train=None): """Forward computation for both two modules. It supports data batches with different shapes, such as different batch sizes or different image sizes. If reshaping of data batch relates to modification of symbol or module, such as changing imag...
[ "Forward", "computation", "for", "both", "two", "modules", ".", "It", "supports", "data", "batches", "with", "different", "shapes", "such", "as", "different", "batch", "sizes", "or", "different", "image", "sizes", ".", "If", "reshaping", "of", "data", "batch",...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/svrg_optimization/svrg_module.py#L232-L253
[ "def", "forward", "(", "self", ",", "data_batch", ",", "is_train", "=", "None", ")", ":", "super", "(", "SVRGModule", ",", "self", ")", ".", "forward", "(", "data_batch", ",", "is_train", ")", "if", "is_train", ":", "self", ".", "_mod_aux", ".", "forwa...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SVRGModule.backward
Backward computation. See Also ---------- :meth:`BaseModule.backward`. Parameters ---------- out_grads : NDArray or list of NDArray, optional Gradient on the outputs to be propagated back. This parameter is only needed when bind is called ...
python/mxnet/contrib/svrg_optimization/svrg_module.py
def backward(self, out_grads=None): """Backward computation. See Also ---------- :meth:`BaseModule.backward`. Parameters ---------- out_grads : NDArray or list of NDArray, optional Gradient on the outputs to be propagated back. This param...
def backward(self, out_grads=None): """Backward computation. See Also ---------- :meth:`BaseModule.backward`. Parameters ---------- out_grads : NDArray or list of NDArray, optional Gradient on the outputs to be propagated back. This param...
[ "Backward", "computation", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/svrg_optimization/svrg_module.py#L255-L272
[ "def", "backward", "(", "self", ",", "out_grads", "=", "None", ")", ":", "super", "(", "SVRGModule", ",", "self", ")", ".", "backward", "(", "out_grads", ")", "if", "self", ".", "_mod_aux", ".", "binded", ":", "self", ".", "_mod_aux", ".", "backward", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SVRGModule.update_full_grads
Computes the gradients over all data w.r.t weights of past m epochs. For distributed env, it will accumulate full grads in the kvstore. Parameters ---------- train_data: DataIter Train data iterator
python/mxnet/contrib/svrg_optimization/svrg_module.py
def update_full_grads(self, train_data): """Computes the gradients over all data w.r.t weights of past m epochs. For distributed env, it will accumulate full grads in the kvstore. Parameters ---------- train_data: DataIter Train data iterator """ para...
def update_full_grads(self, train_data): """Computes the gradients over all data w.r.t weights of past m epochs. For distributed env, it will accumulate full grads in the kvstore. Parameters ---------- train_data: DataIter Train data iterator """ para...
[ "Computes", "the", "gradients", "over", "all", "data", "w", ".", "r", ".", "t", "weights", "of", "past", "m", "epochs", ".", "For", "distributed", "env", "it", "will", "accumulate", "full", "grads", "in", "the", "kvstore", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/svrg_optimization/svrg_module.py#L292-L325
[ "def", "update_full_grads", "(", "self", ",", "train_data", ")", ":", "param_names", "=", "self", ".", "_exec_group", ".", "param_names", "arg", ",", "aux", "=", "self", ".", "get_params", "(", ")", "self", ".", "_mod_aux", ".", "set_params", "(", "arg_par...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SVRGModule._accumulate_kvstore
Accumulate gradients over all data in the KVStore. In distributed setting, each worker sees a portion of data. The full gradients will be aggregated from each worker in the KVStore. Parameters ---------- key: int or str Key in the KVStore. value: NDArray, RowSparseN...
python/mxnet/contrib/svrg_optimization/svrg_module.py
def _accumulate_kvstore(self, key, value): """Accumulate gradients over all data in the KVStore. In distributed setting, each worker sees a portion of data. The full gradients will be aggregated from each worker in the KVStore. Parameters ---------- key: int or str ...
def _accumulate_kvstore(self, key, value): """Accumulate gradients over all data in the KVStore. In distributed setting, each worker sees a portion of data. The full gradients will be aggregated from each worker in the KVStore. Parameters ---------- key: int or str ...
[ "Accumulate", "gradients", "over", "all", "data", "in", "the", "KVStore", ".", "In", "distributed", "setting", "each", "worker", "sees", "a", "portion", "of", "data", ".", "The", "full", "gradients", "will", "be", "aggregated", "from", "each", "worker", "in"...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/svrg_optimization/svrg_module.py#L327-L344
[ "def", "_accumulate_kvstore", "(", "self", ",", "key", ",", "value", ")", ":", "# Accumulate full gradients for current epochs", "self", ".", "_kvstore", ".", "push", "(", "key", "+", "\"_full\"", ",", "value", ")", "self", ".", "_kvstore", ".", "_barrier", "(...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SVRGModule._allocate_gradients
Allocate average of full gradients accumulated in the KVStore to each device. Parameters ---------- key: int or str Key in the kvstore. value: List of NDArray, List of RowSparseNDArray A list of average of the full gradients in the KVStore.
python/mxnet/contrib/svrg_optimization/svrg_module.py
def _allocate_gradients(self, key, value): """Allocate average of full gradients accumulated in the KVStore to each device. Parameters ---------- key: int or str Key in the kvstore. value: List of NDArray, List of RowSparseNDArray A list of average of th...
def _allocate_gradients(self, key, value): """Allocate average of full gradients accumulated in the KVStore to each device. Parameters ---------- key: int or str Key in the kvstore. value: List of NDArray, List of RowSparseNDArray A list of average of th...
[ "Allocate", "average", "of", "full", "gradients", "accumulated", "in", "the", "KVStore", "to", "each", "device", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/svrg_optimization/svrg_module.py#L346-L358
[ "def", "_allocate_gradients", "(", "self", ",", "key", ",", "value", ")", ":", "for", "i", "in", "range", "(", "self", ".", "_ctx_len", ")", ":", "self", ".", "_param_dict", "[", "i", "]", "[", "key", "]", "=", "value", "[", "i", "]", "/", "self"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SVRGModule._svrg_grads_update_rule
Calculates the gradient based on the SVRG update rule. Parameters ---------- g_curr_batch_curr_weight : NDArray gradients of current weight of self.mod w.r.t current batch of data g_curr_batch_special_weight: NDArray gradients of the weight of past m epochs of sel...
python/mxnet/contrib/svrg_optimization/svrg_module.py
def _svrg_grads_update_rule(self, g_curr_batch_curr_weight, g_curr_batch_special_weight, g_special_weight_all_batch): """Calculates the gradient based on the SVRG update rule. Parameters ---------- g_curr_batch_curr_weight : NDArray gradients o...
def _svrg_grads_update_rule(self, g_curr_batch_curr_weight, g_curr_batch_special_weight, g_special_weight_all_batch): """Calculates the gradient based on the SVRG update rule. Parameters ---------- g_curr_batch_curr_weight : NDArray gradients o...
[ "Calculates", "the", "gradient", "based", "on", "the", "SVRG", "update", "rule", ".", "Parameters", "----------", "g_curr_batch_curr_weight", ":", "NDArray", "gradients", "of", "current", "weight", "of", "self", ".", "mod", "w", ".", "r", ".", "t", "current", ...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/svrg_optimization/svrg_module.py#L360-L380
[ "def", "_svrg_grads_update_rule", "(", "self", ",", "g_curr_batch_curr_weight", ",", "g_curr_batch_special_weight", ",", "g_special_weight_all_batch", ")", ":", "for", "index", ",", "grad", "in", "enumerate", "(", "g_curr_batch_curr_weight", ")", ":", "grad", "-=", "g...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SVRGModule._update_svrg_gradients
Calculates gradients based on the SVRG update rule.
python/mxnet/contrib/svrg_optimization/svrg_module.py
def _update_svrg_gradients(self): """Calculates gradients based on the SVRG update rule. """ param_names = self._exec_group.param_names for ctx in range(self._ctx_len): for index, name in enumerate(param_names): g_curr_batch_reg = self._exec_group.grad_arrays[...
def _update_svrg_gradients(self): """Calculates gradients based on the SVRG update rule. """ param_names = self._exec_group.param_names for ctx in range(self._ctx_len): for index, name in enumerate(param_names): g_curr_batch_reg = self._exec_group.grad_arrays[...
[ "Calculates", "gradients", "based", "on", "the", "SVRG", "update", "rule", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/svrg_optimization/svrg_module.py#L382-L393
[ "def", "_update_svrg_gradients", "(", "self", ")", ":", "param_names", "=", "self", ".", "_exec_group", ".", "param_names", "for", "ctx", "in", "range", "(", "self", ".", "_ctx_len", ")", ":", "for", "index", ",", "name", "in", "enumerate", "(", "param_nam...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SVRGModule.fit
Trains the module parameters. Parameters ---------- train_data : DataIter Train DataIter. eval_data : DataIter If not ``None``, will be used as validation set and the performance after each epoch will be evaluated. eval_metric : str or EvalMet...
python/mxnet/contrib/svrg_optimization/svrg_module.py
def fit(self, train_data, eval_data=None, eval_metric='acc', epoch_end_callback=None, batch_end_callback=None, kvstore='local', optimizer='sgd', optimizer_params=(('learning_rate', 0.01),), eval_end_callback=None, eval_batch_end_callback=None, initializer=mx.init.Uniform(...
def fit(self, train_data, eval_data=None, eval_metric='acc', epoch_end_callback=None, batch_end_callback=None, kvstore='local', optimizer='sgd', optimizer_params=(('learning_rate', 0.01),), eval_end_callback=None, eval_batch_end_callback=None, initializer=mx.init.Uniform(...
[ "Trains", "the", "module", "parameters", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/svrg_optimization/svrg_module.py#L395-L552
[ "def", "fit", "(", "self", ",", "train_data", ",", "eval_data", "=", "None", ",", "eval_metric", "=", "'acc'", ",", "epoch_end_callback", "=", "None", ",", "batch_end_callback", "=", "None", ",", "kvstore", "=", "'local'", ",", "optimizer", "=", "'sgd'", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SVRGModule.prepare
Prepares two modules for processing a data batch. Usually involves switching bucket and reshaping. For modules that contain `row_sparse` parameters in KVStore, it prepares the `row_sparse` parameters based on the sparse_row_id_fn. When KVStore is used to update parameters for multi-dev...
python/mxnet/contrib/svrg_optimization/svrg_module.py
def prepare(self, data_batch, sparse_row_id_fn=None): """Prepares two modules for processing a data batch. Usually involves switching bucket and reshaping. For modules that contain `row_sparse` parameters in KVStore, it prepares the `row_sparse` parameters based on the sparse_row_id_fn....
def prepare(self, data_batch, sparse_row_id_fn=None): """Prepares two modules for processing a data batch. Usually involves switching bucket and reshaping. For modules that contain `row_sparse` parameters in KVStore, it prepares the `row_sparse` parameters based on the sparse_row_id_fn....
[ "Prepares", "two", "modules", "for", "processing", "a", "data", "batch", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/svrg_optimization/svrg_module.py#L554-L579
[ "def", "prepare", "(", "self", ",", "data_batch", ",", "sparse_row_id_fn", "=", "None", ")", ":", "super", "(", "SVRGModule", ",", "self", ")", ".", "prepare", "(", "data_batch", ",", "sparse_row_id_fn", "=", "sparse_row_id_fn", ")", "self", ".", "_mod_aux",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
YoloFormat._load_image_set_index
find out which indexes correspond to given image set (train or val) Parameters: ---------- shuffle : boolean whether to shuffle the image list Returns: ---------- entire list of images specified in the setting
example/ssd/dataset/yolo_format.py
def _load_image_set_index(self, shuffle): """ find out which indexes correspond to given image set (train or val) Parameters: ---------- shuffle : boolean whether to shuffle the image list Returns: ---------- entire list of images specified in...
def _load_image_set_index(self, shuffle): """ find out which indexes correspond to given image set (train or val) Parameters: ---------- shuffle : boolean whether to shuffle the image list Returns: ---------- entire list of images specified in...
[ "find", "out", "which", "indexes", "correspond", "to", "given", "image", "set", "(", "train", "or", "val", ")" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/yolo_format.py#L72-L89
[ "def", "_load_image_set_index", "(", "self", ",", "shuffle", ")", ":", "assert", "os", ".", "path", ".", "exists", "(", "self", ".", "list_file", ")", ",", "'Path does not exists: {}'", ".", "format", "(", "self", ".", "list_file", ")", "with", "open", "("...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
YoloFormat._label_path_from_index
given image index, find out annotation path Parameters: ---------- index: int index of a specific image Returns: ---------- full path of annotation file
example/ssd/dataset/yolo_format.py
def _label_path_from_index(self, index): """ given image index, find out annotation path Parameters: ---------- index: int index of a specific image Returns: ---------- full path of annotation file """ label_file = os.path.joi...
def _label_path_from_index(self, index): """ given image index, find out annotation path Parameters: ---------- index: int index of a specific image Returns: ---------- full path of annotation file """ label_file = os.path.joi...
[ "given", "image", "index", "find", "out", "annotation", "path" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/yolo_format.py#L124-L139
[ "def", "_label_path_from_index", "(", "self", ",", "index", ")", ":", "label_file", "=", "os", ".", "path", ".", "join", "(", "self", ".", "label_dir", ",", "index", "+", "self", ".", "label_extension", ")", "assert", "os", ".", "path", ".", "exists", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
YoloFormat._load_image_labels
preprocess all ground-truths Returns: ---------- labels packed in [num_images x max_num_objects x 5] tensor
example/ssd/dataset/yolo_format.py
def _load_image_labels(self): """ preprocess all ground-truths Returns: ---------- labels packed in [num_images x max_num_objects x 5] tensor """ temp = [] # load ground-truths for idx in self.image_set_index: label_file = self._label...
def _load_image_labels(self): """ preprocess all ground-truths Returns: ---------- labels packed in [num_images x max_num_objects x 5] tensor """ temp = [] # load ground-truths for idx in self.image_set_index: label_file = self._label...
[ "preprocess", "all", "ground", "-", "truths" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/yolo_format.py#L141-L170
[ "def", "_load_image_labels", "(", "self", ")", ":", "temp", "=", "[", "]", "# load ground-truths", "for", "idx", "in", "self", ".", "image_set_index", ":", "label_file", "=", "self", ".", "_label_path_from_index", "(", "idx", ")", "with", "open", "(", "label...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_register_func
Get registrator function. Parameters ---------- base_class : type base class for classes that will be reigstered nickname : str nickname of base_class for logging Returns ------- a registrator function
python/mxnet/registry.py
def get_register_func(base_class, nickname): """Get registrator function. Parameters ---------- base_class : type base class for classes that will be reigstered nickname : str nickname of base_class for logging Returns ------- a registrator function """ if base_...
def get_register_func(base_class, nickname): """Get registrator function. Parameters ---------- base_class : type base class for classes that will be reigstered nickname : str nickname of base_class for logging Returns ------- a registrator function """ if base_...
[ "Get", "registrator", "function", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/registry.py#L49-L85
[ "def", "get_register_func", "(", "base_class", ",", "nickname", ")", ":", "if", "base_class", "not", "in", "_REGISTRY", ":", "_REGISTRY", "[", "base_class", "]", "=", "{", "}", "registry", "=", "_REGISTRY", "[", "base_class", "]", "def", "register", "(", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_alias_func
Get registrator function that allow aliases. Parameters ---------- base_class : type base class for classes that will be reigstered nickname : str nickname of base_class for logging Returns ------- a registrator function
python/mxnet/registry.py
def get_alias_func(base_class, nickname): """Get registrator function that allow aliases. Parameters ---------- base_class : type base class for classes that will be reigstered nickname : str nickname of base_class for logging Returns ------- a registrator function ...
def get_alias_func(base_class, nickname): """Get registrator function that allow aliases. Parameters ---------- base_class : type base class for classes that will be reigstered nickname : str nickname of base_class for logging Returns ------- a registrator function ...
[ "Get", "registrator", "function", "that", "allow", "aliases", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/registry.py#L88-L112
[ "def", "get_alias_func", "(", "base_class", ",", "nickname", ")", ":", "register", "=", "get_register_func", "(", "base_class", ",", "nickname", ")", "def", "alias", "(", "*", "aliases", ")", ":", "\"\"\"alias registrator\"\"\"", "def", "reg", "(", "klass", ")...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_create_func
Get creator function Parameters ---------- base_class : type base class for classes that will be reigstered nickname : str nickname of base_class for logging Returns ------- a creator function
python/mxnet/registry.py
def get_create_func(base_class, nickname): """Get creator function Parameters ---------- base_class : type base class for classes that will be reigstered nickname : str nickname of base_class for logging Returns ------- a creator function """ if base_class not i...
def get_create_func(base_class, nickname): """Get creator function Parameters ---------- base_class : type base class for classes that will be reigstered nickname : str nickname of base_class for logging Returns ------- a creator function """ if base_class not i...
[ "Get", "creator", "function" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/registry.py#L115-L176
[ "def", "get_create_func", "(", "base_class", ",", "nickname", ")", ":", "if", "base_class", "not", "in", "_REGISTRY", ":", "_REGISTRY", "[", "base_class", "]", "=", "{", "}", "registry", "=", "_REGISTRY", "[", "base_class", "]", "def", "create", "(", "*", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
parse_args
Parse arguments.
tools/diagnose.py
def parse_args(): """Parse arguments.""" parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Diagnose script for checking the current system.') choices = ['python', 'pip', 'mxnet', 'os', 'hardware', 'network'] for choice in choices: ...
def parse_args(): """Parse arguments.""" parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Diagnose script for checking the current system.') choices = ['python', 'pip', 'mxnet', 'os', 'hardware', 'network'] for choice in choices: ...
[ "Parse", "arguments", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/diagnose.py#L33-L48
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "formatter_class", "=", "argparse", ".", "ArgumentDefaultsHelpFormatter", ",", "description", "=", "'Diagnose script for checking the current system.'", ")", "choices", "=", "[", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
clean_str
Tokenization/string cleaning for all datasets except for SST. Original taken from https://github.com/yoonkim/CNN_sentence/blob/master/process_data.py
example/cnn_text_classification/data_helpers.py
def clean_str(string): """Tokenization/string cleaning for all datasets except for SST. Original taken from https://github.com/yoonkim/CNN_sentence/blob/master/process_data.py """ string = re.sub(r"[^A-Za-z0-9(),!?\'\`]", " ", string) string = re.sub(r"\'s", " \'s", string) string = re.sub(r"\'v...
def clean_str(string): """Tokenization/string cleaning for all datasets except for SST. Original taken from https://github.com/yoonkim/CNN_sentence/blob/master/process_data.py """ string = re.sub(r"[^A-Za-z0-9(),!?\'\`]", " ", string) string = re.sub(r"\'s", " \'s", string) string = re.sub(r"\'v...
[ "Tokenization", "/", "string", "cleaning", "for", "all", "datasets", "except", "for", "SST", ".", "Original", "taken", "from", "https", ":", "//", "github", ".", "com", "/", "yoonkim", "/", "CNN_sentence", "/", "blob", "/", "master", "/", "process_data", "...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_text_classification/data_helpers.py#L33-L50
[ "def", "clean_str", "(", "string", ")", ":", "string", "=", "re", ".", "sub", "(", "r\"[^A-Za-z0-9(),!?\\'\\`]\"", ",", "\" \"", ",", "string", ")", "string", "=", "re", ".", "sub", "(", "r\"\\'s\"", ",", "\" \\'s\"", ",", "string", ")", "string", "=", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
load_data_and_labels
Loads MR polarity data from files, splits the data into words and generates labels. Returns split sentences and labels.
example/cnn_text_classification/data_helpers.py
def load_data_and_labels(): """Loads MR polarity data from files, splits the data into words and generates labels. Returns split sentences and labels. """ # Load data from files pos_path = "./data/rt-polaritydata/rt-polarity.pos" neg_path = "./data/rt-polaritydata/rt-polarity.neg" if not os....
def load_data_and_labels(): """Loads MR polarity data from files, splits the data into words and generates labels. Returns split sentences and labels. """ # Load data from files pos_path = "./data/rt-polaritydata/rt-polarity.pos" neg_path = "./data/rt-polaritydata/rt-polarity.neg" if not os....
[ "Loads", "MR", "polarity", "data", "from", "files", "splits", "the", "data", "into", "words", "and", "generates", "labels", ".", "Returns", "split", "sentences", "and", "labels", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_text_classification/data_helpers.py#L53-L76
[ "def", "load_data_and_labels", "(", ")", ":", "# Load data from files", "pos_path", "=", "\"./data/rt-polaritydata/rt-polarity.pos\"", "neg_path", "=", "\"./data/rt-polaritydata/rt-polarity.neg\"", "if", "not", "os", ".", "path", ".", "exists", "(", "pos_path", ")", ":", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
pad_sentences
Pads all sentences to the same length. The length is defined by the longest sentence. Returns padded sentences.
example/cnn_text_classification/data_helpers.py
def pad_sentences(sentences, padding_word="</s>"): """Pads all sentences to the same length. The length is defined by the longest sentence. Returns padded sentences. """ sequence_length = max(len(x) for x in sentences) padded_sentences = [] for i, sentence in enumerate(sentences): num_pa...
def pad_sentences(sentences, padding_word="</s>"): """Pads all sentences to the same length. The length is defined by the longest sentence. Returns padded sentences. """ sequence_length = max(len(x) for x in sentences) padded_sentences = [] for i, sentence in enumerate(sentences): num_pa...
[ "Pads", "all", "sentences", "to", "the", "same", "length", ".", "The", "length", "is", "defined", "by", "the", "longest", "sentence", ".", "Returns", "padded", "sentences", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_text_classification/data_helpers.py#L79-L89
[ "def", "pad_sentences", "(", "sentences", ",", "padding_word", "=", "\"</s>\"", ")", ":", "sequence_length", "=", "max", "(", "len", "(", "x", ")", "for", "x", "in", "sentences", ")", "padded_sentences", "=", "[", "]", "for", "i", ",", "sentence", "in", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
build_input_data
Maps sentencs and labels to vectors based on a vocabulary.
example/cnn_text_classification/data_helpers.py
def build_input_data(sentences, labels, vocabulary): """Maps sentencs and labels to vectors based on a vocabulary.""" x = np.array([[vocabulary[word] for word in sentence] for sentence in sentences]) y = np.array(labels) return [x, y]
def build_input_data(sentences, labels, vocabulary): """Maps sentencs and labels to vectors based on a vocabulary.""" x = np.array([[vocabulary[word] for word in sentence] for sentence in sentences]) y = np.array(labels) return [x, y]
[ "Maps", "sentencs", "and", "labels", "to", "vectors", "based", "on", "a", "vocabulary", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_text_classification/data_helpers.py#L105-L109
[ "def", "build_input_data", "(", "sentences", ",", "labels", ",", "vocabulary", ")", ":", "x", "=", "np", ".", "array", "(", "[", "[", "vocabulary", "[", "word", "]", "for", "word", "in", "sentence", "]", "for", "sentence", "in", "sentences", "]", ")", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
build_input_data_with_word2vec
Map sentences and labels to vectors based on a pretrained word2vec
example/cnn_text_classification/data_helpers.py
def build_input_data_with_word2vec(sentences, labels, word2vec_list): """ Map sentences and labels to vectors based on a pretrained word2vec """ x_vec = [] for sent in sentences: vec = [] for word in sent: if word in word2vec_list: vec.append(word2vec_list...
def build_input_data_with_word2vec(sentences, labels, word2vec_list): """ Map sentences and labels to vectors based on a pretrained word2vec """ x_vec = [] for sent in sentences: vec = [] for word in sent: if word in word2vec_list: vec.append(word2vec_list...
[ "Map", "sentences", "and", "labels", "to", "vectors", "based", "on", "a", "pretrained", "word2vec" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_text_classification/data_helpers.py#L112-L127
[ "def", "build_input_data_with_word2vec", "(", "sentences", ",", "labels", ",", "word2vec_list", ")", ":", "x_vec", "=", "[", "]", "for", "sent", "in", "sentences", ":", "vec", "=", "[", "]", "for", "word", "in", "sent", ":", "if", "word", "in", "word2vec...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
load_data_with_word2vec
Loads and preprocessed data for the MR dataset. Returns input vectors, labels, vocabulary, and inverse vocabulary.
example/cnn_text_classification/data_helpers.py
def load_data_with_word2vec(word2vec_list): """Loads and preprocessed data for the MR dataset. Returns input vectors, labels, vocabulary, and inverse vocabulary. """ # Load and preprocess data sentences, labels = load_data_and_labels() sentences_padded = pad_sentences(sentences) # vocabulary...
def load_data_with_word2vec(word2vec_list): """Loads and preprocessed data for the MR dataset. Returns input vectors, labels, vocabulary, and inverse vocabulary. """ # Load and preprocess data sentences, labels = load_data_and_labels() sentences_padded = pad_sentences(sentences) # vocabulary...
[ "Loads", "and", "preprocessed", "data", "for", "the", "MR", "dataset", ".", "Returns", "input", "vectors", "labels", "vocabulary", "and", "inverse", "vocabulary", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_text_classification/data_helpers.py#L130-L138
[ "def", "load_data_with_word2vec", "(", "word2vec_list", ")", ":", "# Load and preprocess data", "sentences", ",", "labels", "=", "load_data_and_labels", "(", ")", "sentences_padded", "=", "pad_sentences", "(", "sentences", ")", "# vocabulary, vocabulary_inv = build_vocab(sent...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
load_data
Loads and preprocessed data for the MR dataset. Returns input vectors, labels, vocabulary, and inverse vocabulary.
example/cnn_text_classification/data_helpers.py
def load_data(): """Loads and preprocessed data for the MR dataset. Returns input vectors, labels, vocabulary, and inverse vocabulary. """ # Load and preprocess data sentences, labels = load_data_and_labels() sentences_padded = pad_sentences(sentences) vocabulary, vocabulary_inv = build_voca...
def load_data(): """Loads and preprocessed data for the MR dataset. Returns input vectors, labels, vocabulary, and inverse vocabulary. """ # Load and preprocess data sentences, labels = load_data_and_labels() sentences_padded = pad_sentences(sentences) vocabulary, vocabulary_inv = build_voca...
[ "Loads", "and", "preprocessed", "data", "for", "the", "MR", "dataset", ".", "Returns", "input", "vectors", "labels", "vocabulary", "and", "inverse", "vocabulary", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_text_classification/data_helpers.py#L141-L150
[ "def", "load_data", "(", ")", ":", "# Load and preprocess data", "sentences", ",", "labels", "=", "load_data_and_labels", "(", ")", "sentences_padded", "=", "pad_sentences", "(", "sentences", ")", "vocabulary", ",", "vocabulary_inv", "=", "build_vocab", "(", "senten...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
batch_iter
Generates a batch iterator for a dataset.
example/cnn_text_classification/data_helpers.py
def batch_iter(data, batch_size, num_epochs): """Generates a batch iterator for a dataset.""" data = np.array(data) data_size = len(data) num_batches_per_epoch = int(len(data)/batch_size) + 1 for epoch in range(num_epochs): # Shuffle the data at each epoch shuffle_indices = np.random...
def batch_iter(data, batch_size, num_epochs): """Generates a batch iterator for a dataset.""" data = np.array(data) data_size = len(data) num_batches_per_epoch = int(len(data)/batch_size) + 1 for epoch in range(num_epochs): # Shuffle the data at each epoch shuffle_indices = np.random...
[ "Generates", "a", "batch", "iterator", "for", "a", "dataset", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_text_classification/data_helpers.py#L153-L165
[ "def", "batch_iter", "(", "data", ",", "batch_size", ",", "num_epochs", ")", ":", "data", "=", "np", ".", "array", "(", "data", ")", "data_size", "=", "len", "(", "data", ")", "num_batches_per_epoch", "=", "int", "(", "len", "(", "data", ")", "/", "b...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
load_pretrained_word2vec
Load the pre-trained word2vec from file.
example/cnn_text_classification/data_helpers.py
def load_pretrained_word2vec(infile): """Load the pre-trained word2vec from file.""" if isinstance(infile, str): infile = open(infile) word2vec_list = {} for idx, line in enumerate(infile): if idx == 0: vocab_size, dim = line.strip().split() else: tks = l...
def load_pretrained_word2vec(infile): """Load the pre-trained word2vec from file.""" if isinstance(infile, str): infile = open(infile) word2vec_list = {} for idx, line in enumerate(infile): if idx == 0: vocab_size, dim = line.strip().split() else: tks = l...
[ "Load", "the", "pre", "-", "trained", "word2vec", "from", "file", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/cnn_text_classification/data_helpers.py#L168-L181
[ "def", "load_pretrained_word2vec", "(", "infile", ")", ":", "if", "isinstance", "(", "infile", ",", "str", ")", ":", "infile", "=", "open", "(", "infile", ")", "word2vec_list", "=", "{", "}", "for", "idx", ",", "line", "in", "enumerate", "(", "infile", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
generate_batch
return batch
example/rcnn/symdata/loader.py
def generate_batch(im_tensor, im_info): """return batch""" data = [im_tensor, im_info] data_shapes = [('data', im_tensor.shape), ('im_info', im_info.shape)] data_batch = mx.io.DataBatch(data=data, label=None, provide_data=data_shapes, provide_label=None) return data_batch
def generate_batch(im_tensor, im_info): """return batch""" data = [im_tensor, im_info] data_shapes = [('data', im_tensor.shape), ('im_info', im_info.shape)] data_batch = mx.io.DataBatch(data=data, label=None, provide_data=data_shapes, provide_label=None) return data_batch
[ "return", "batch" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rcnn/symdata/loader.py#L44-L49
[ "def", "generate_batch", "(", "im_tensor", ",", "im_info", ")", ":", "data", "=", "[", "im_tensor", ",", "im_info", "]", "data_shapes", "=", "[", "(", "'data'", ",", "im_tensor", ".", "shape", ")", ",", "(", "'im_info'", ",", "im_info", ".", "shape", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_symbol
VGG 16 layers network This is a modified version, with fc6/fc7 layers replaced by conv layers And the network is slightly smaller than original VGG 16 network
example/ssd/symbol/vgg16_reduced.py
def get_symbol(num_classes=1000, **kwargs): """ VGG 16 layers network This is a modified version, with fc6/fc7 layers replaced by conv layers And the network is slightly smaller than original VGG 16 network """ data = mx.symbol.Variable(name="data") label = mx.symbol.Variable(name="label") ...
def get_symbol(num_classes=1000, **kwargs): """ VGG 16 layers network This is a modified version, with fc6/fc7 layers replaced by conv layers And the network is slightly smaller than original VGG 16 network """ data = mx.symbol.Variable(name="data") label = mx.symbol.Variable(name="label") ...
[ "VGG", "16", "layers", "network", "This", "is", "a", "modified", "version", "with", "fc6", "/", "fc7", "layers", "replaced", "by", "conv", "layers", "And", "the", "network", "is", "slightly", "smaller", "than", "original", "VGG", "16", "network" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/symbol/vgg16_reduced.py#L20-L103
[ "def", "get_symbol", "(", "num_classes", "=", "1000", ",", "*", "*", "kwargs", ")", ":", "data", "=", "mx", ".", "symbol", ".", "Variable", "(", "name", "=", "\"data\"", ")", "label", "=", "mx", ".", "symbol", ".", "Variable", "(", "name", "=", "\"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_mlp
Get multi-layer perceptron
example/caffe/caffe_net.py
def get_mlp(): """Get multi-layer perceptron""" data = mx.symbol.Variable('data') fc1 = mx.symbol.CaffeOp(data_0=data, num_weight=2, name='fc1', prototxt="layer{type:\"InnerProduct\" inner_product_param{num_output: 128} }") act1 = mx.symbol.CaffeOp(data_0=fc1, prototxt="layer...
def get_mlp(): """Get multi-layer perceptron""" data = mx.symbol.Variable('data') fc1 = mx.symbol.CaffeOp(data_0=data, num_weight=2, name='fc1', prototxt="layer{type:\"InnerProduct\" inner_product_param{num_output: 128} }") act1 = mx.symbol.CaffeOp(data_0=fc1, prototxt="layer...
[ "Get", "multi", "-", "layer", "perceptron" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/caffe/caffe_net.py#L25-L42
[ "def", "get_mlp", "(", ")", ":", "data", "=", "mx", ".", "symbol", ".", "Variable", "(", "'data'", ")", "fc1", "=", "mx", ".", "symbol", ".", "CaffeOp", "(", "data_0", "=", "data", ",", "num_weight", "=", "2", ",", "name", "=", "'fc1'", ",", "pro...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_lenet
LeCun, Yann, Leon Bottou, Yoshua Bengio, and Patrick Haffner. "Gradient-based learning applied to document recognition." Proceedings of the IEEE (1998)
example/caffe/caffe_net.py
def get_lenet(): """LeCun, Yann, Leon Bottou, Yoshua Bengio, and Patrick Haffner. "Gradient-based learning applied to document recognition." Proceedings of the IEEE (1998) """ data = mx.symbol.Variable('data') # first conv conv1 = mx.symbol.CaffeOp(data_0=data, num_weight=2, ...
def get_lenet(): """LeCun, Yann, Leon Bottou, Yoshua Bengio, and Patrick Haffner. "Gradient-based learning applied to document recognition." Proceedings of the IEEE (1998) """ data = mx.symbol.Variable('data') # first conv conv1 = mx.symbol.CaffeOp(data_0=data, num_weight=2, ...
[ "LeCun", "Yann", "Leon", "Bottou", "Yoshua", "Bengio", "and", "Patrick", "Haffner", ".", "Gradient", "-", "based", "learning", "applied", "to", "document", "recognition", ".", "Proceedings", "of", "the", "IEEE", "(", "1998", ")" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/caffe/caffe_net.py#L45-L81
[ "def", "get_lenet", "(", ")", ":", "data", "=", "mx", ".", "symbol", ".", "Variable", "(", "'data'", ")", "# first conv", "conv1", "=", "mx", ".", "symbol", ".", "CaffeOp", "(", "data_0", "=", "data", ",", "num_weight", "=", "2", ",", "prototxt", "="...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
parse_args
Parse the arguments
example/caffe/caffe_net.py
def parse_args(): """Parse the arguments""" parser = argparse.ArgumentParser(description='train an image classifier on mnist') parser.add_argument('--network', type=str, default='lenet', help='the cnn to use (mlp | lenet | <path to network json file>') parser.add_argument('--caff...
def parse_args(): """Parse the arguments""" parser = argparse.ArgumentParser(description='train an image classifier on mnist') parser.add_argument('--network', type=str, default='lenet', help='the cnn to use (mlp | lenet | <path to network json file>') parser.add_argument('--caff...
[ "Parse", "the", "arguments" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/caffe/caffe_net.py#L89-L122
[ "def", "parse_args", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'train an image classifier on mnist'", ")", "parser", ".", "add_argument", "(", "'--network'", ",", "type", "=", "str", ",", "default", "=", "'lenet'"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
WeightedSoftmaxCrossEntropyLoss.forward
Implements forward computation. is_train : bool, whether forwarding for training or testing. req : list of {'null', 'write', 'inplace', 'add'}, how to assign to out_data. 'null' means skip assignment, etc. in_data : list of NDArray, input data. out_data : list of NDArray, pre-allocated ...
example/sparse/linear_classification/weighted_softmax_ce.py
def forward(self, is_train, req, in_data, out_data, aux): """Implements forward computation. is_train : bool, whether forwarding for training or testing. req : list of {'null', 'write', 'inplace', 'add'}, how to assign to out_data. 'null' means skip assignment, etc. in_data : list of ND...
def forward(self, is_train, req, in_data, out_data, aux): """Implements forward computation. is_train : bool, whether forwarding for training or testing. req : list of {'null', 'write', 'inplace', 'add'}, how to assign to out_data. 'null' means skip assignment, etc. in_data : list of ND...
[ "Implements", "forward", "computation", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/sparse/linear_classification/weighted_softmax_ce.py#L30-L42
[ "def", "forward", "(", "self", ",", "is_train", ",", "req", ",", "in_data", ",", "out_data", ",", "aux", ")", ":", "data", "=", "in_data", "[", "0", "]", "label", "=", "in_data", "[", "1", "]", "pred", "=", "mx", ".", "nd", ".", "SoftmaxOutput", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
WeightedSoftmaxCrossEntropyLoss.backward
Implements backward computation req : list of {'null', 'write', 'inplace', 'add'}, how to assign to in_grad out_grad : list of NDArray, gradient w.r.t. output data. in_grad : list of NDArray, gradient w.r.t. input data. This is the output buffer.
example/sparse/linear_classification/weighted_softmax_ce.py
def backward(self, req, out_grad, in_data, out_data, in_grad, aux): """Implements backward computation req : list of {'null', 'write', 'inplace', 'add'}, how to assign to in_grad out_grad : list of NDArray, gradient w.r.t. output data. in_grad : list of NDArray, gradient w.r.t. input da...
def backward(self, req, out_grad, in_data, out_data, in_grad, aux): """Implements backward computation req : list of {'null', 'write', 'inplace', 'add'}, how to assign to in_grad out_grad : list of NDArray, gradient w.r.t. output data. in_grad : list of NDArray, gradient w.r.t. input da...
[ "Implements", "backward", "computation" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/sparse/linear_classification/weighted_softmax_ce.py#L44-L57
[ "def", "backward", "(", "self", ",", "req", ",", "out_grad", ",", "in_data", ",", "out_data", ",", "in_grad", ",", "aux", ")", ":", "label", "=", "in_data", "[", "1", "]", "pred", "=", "out_data", "[", "0", "]", "dx", "=", "pred", "-", "mx", ".",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule._reset_bind
Internal utility function to reset binding.
python/mxnet/module/bucketing_module.py
def _reset_bind(self): """Internal utility function to reset binding.""" self.binded = False self._buckets = {} self._curr_module = None self._curr_bucket_key = None
def _reset_bind(self): """Internal utility function to reset binding.""" self.binded = False self._buckets = {} self._curr_module = None self._curr_bucket_key = None
[ "Internal", "utility", "function", "to", "reset", "binding", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L100-L105
[ "def", "_reset_bind", "(", "self", ")", ":", "self", ".", "binded", "=", "False", "self", ".", "_buckets", "=", "{", "}", "self", ".", "_curr_module", "=", "None", "self", ".", "_curr_bucket_key", "=", "None" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.data_names
A list of names for data required by this module.
python/mxnet/module/bucketing_module.py
def data_names(self): """A list of names for data required by this module.""" if self.binded: return self._curr_module.data_names else: _, data_names, _ = self._call_sym_gen(self._default_bucket_key) return data_names
def data_names(self): """A list of names for data required by this module.""" if self.binded: return self._curr_module.data_names else: _, data_names, _ = self._call_sym_gen(self._default_bucket_key) return data_names
[ "A", "list", "of", "names", "for", "data", "required", "by", "this", "module", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L112-L118
[ "def", "data_names", "(", "self", ")", ":", "if", "self", ".", "binded", ":", "return", "self", ".", "_curr_module", ".", "data_names", "else", ":", "_", ",", "data_names", ",", "_", "=", "self", ".", "_call_sym_gen", "(", "self", ".", "_default_bucket_k...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.output_names
A list of names for the outputs of this module.
python/mxnet/module/bucketing_module.py
def output_names(self): """A list of names for the outputs of this module.""" if self.binded: return self._curr_module.output_names else: symbol, _, _ = self._call_sym_gen(self._default_bucket_key) return symbol.list_outputs()
def output_names(self): """A list of names for the outputs of this module.""" if self.binded: return self._curr_module.output_names else: symbol, _, _ = self._call_sym_gen(self._default_bucket_key) return symbol.list_outputs()
[ "A", "list", "of", "names", "for", "the", "outputs", "of", "this", "module", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L121-L127
[ "def", "output_names", "(", "self", ")", ":", "if", "self", ".", "binded", ":", "return", "self", ".", "_curr_module", ".", "output_names", "else", ":", "symbol", ",", "_", ",", "_", "=", "self", ".", "_call_sym_gen", "(", "self", ".", "_default_bucket_k...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.get_params
Gets current parameters. Returns ------- `(arg_params, aux_params)` A pair of dictionaries each mapping parameter names to NDArray values.
python/mxnet/module/bucketing_module.py
def get_params(self): """Gets current parameters. Returns ------- `(arg_params, aux_params)` A pair of dictionaries each mapping parameter names to NDArray values. """ assert self.binded and self.params_initialized self._curr_module._params_dirty = se...
def get_params(self): """Gets current parameters. Returns ------- `(arg_params, aux_params)` A pair of dictionaries each mapping parameter names to NDArray values. """ assert self.binded and self.params_initialized self._curr_module._params_dirty = se...
[ "Gets", "current", "parameters", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L165-L177
[ "def", "get_params", "(", "self", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "self", ".", "_curr_module", ".", "_params_dirty", "=", "self", ".", "_params_dirty", "params", "=", "self", ".", "_curr_module", ".", "get...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.init_params
Initializes parameters. Parameters ---------- initializer : Initializer arg_params : dict Defaults to ``None``. Existing parameters. This has higher priority than `initializer`. aux_params : dict Defaults to ``None``. Existing auxiliary states...
python/mxnet/module/bucketing_module.py
def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None, allow_missing=False, force_init=False, allow_extra=False): """Initializes parameters. Parameters ---------- initializer : Initializer arg_params : dict Defaults to ...
def init_params(self, initializer=Uniform(0.01), arg_params=None, aux_params=None, allow_missing=False, force_init=False, allow_extra=False): """Initializes parameters. Parameters ---------- initializer : Initializer arg_params : dict Defaults to ...
[ "Initializes", "parameters", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L222-L252
[ "def", "init_params", "(", "self", ",", "initializer", "=", "Uniform", "(", "0.01", ")", ",", "arg_params", "=", "None", ",", "aux_params", "=", "None", ",", "allow_missing", "=", "False", ",", "force_init", "=", "False", ",", "allow_extra", "=", "False", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.get_states
Gets states from all devices. Parameters ---------- merge_multi_context : bool Default is `True`. In the case when data-parallelism is used, the states will be collected from multiple devices. A `True` value indicate that we should merge the collected results...
python/mxnet/module/bucketing_module.py
def get_states(self, merge_multi_context=True): """Gets states from all devices. Parameters ---------- merge_multi_context : bool Default is `True`. In the case when data-parallelism is used, the states will be collected from multiple devices. A `True` value indi...
def get_states(self, merge_multi_context=True): """Gets states from all devices. Parameters ---------- merge_multi_context : bool Default is `True`. In the case when data-parallelism is used, the states will be collected from multiple devices. A `True` value indi...
[ "Gets", "states", "from", "all", "devices", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L254-L273
[ "def", "get_states", "(", "self", ",", "merge_multi_context", "=", "True", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "return", "self", ".", "_curr_module", ".", "get_states", "(", "merge_multi_context", "=", "merge_mult...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.set_states
Sets value for states. Only one of states & values can be specified. Parameters ---------- states : list of list of NDArrays Source states arrays formatted like ``[[state1_dev1, state1_dev2], [state2_dev1, state2_dev2]]``. value : number A single scal...
python/mxnet/module/bucketing_module.py
def set_states(self, states=None, value=None): """Sets value for states. Only one of states & values can be specified. Parameters ---------- states : list of list of NDArrays Source states arrays formatted like ``[[state1_dev1, state1_dev2], [state2_dev1, state2_...
def set_states(self, states=None, value=None): """Sets value for states. Only one of states & values can be specified. Parameters ---------- states : list of list of NDArrays Source states arrays formatted like ``[[state1_dev1, state1_dev2], [state2_dev1, state2_...
[ "Sets", "value", "for", "states", ".", "Only", "one", "of", "states", "&", "values", "can", "be", "specified", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L275-L287
[ "def", "set_states", "(", "self", ",", "states", "=", "None", ",", "value", "=", "None", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "self", ".", "_curr_module", ".", "set_states", "(", "states", ",", "value", ")"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.bind
Binding for a `BucketingModule` means setting up the buckets and binding the executor for the default bucket key. Executors corresponding to other keys are bound afterwards with `switch_bucket`. Parameters ---------- data_shapes : list of (str, tuple) This should cor...
python/mxnet/module/bucketing_module.py
def bind(self, data_shapes, label_shapes=None, for_training=True, inputs_need_grad=False, force_rebind=False, shared_module=None, grad_req='write'): """Binding for a `BucketingModule` means setting up the buckets and binding the executor for the default bucket key. Executors co...
def bind(self, data_shapes, label_shapes=None, for_training=True, inputs_need_grad=False, force_rebind=False, shared_module=None, grad_req='write'): """Binding for a `BucketingModule` means setting up the buckets and binding the executor for the default bucket key. Executors co...
[ "Binding", "for", "a", "BucketingModule", "means", "setting", "up", "the", "buckets", "and", "binding", "the", "executor", "for", "the", "default", "bucket", "key", ".", "Executors", "corresponding", "to", "other", "keys", "are", "bound", "afterwards", "with", ...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L289-L352
[ "def", "bind", "(", "self", ",", "data_shapes", ",", "label_shapes", "=", "None", ",", "for_training", "=", "True", ",", "inputs_need_grad", "=", "False", ",", "force_rebind", "=", "False", ",", "shared_module", "=", "None", ",", "grad_req", "=", "'write'", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.switch_bucket
Switches to a different bucket. This will change ``self.curr_module``. Parameters ---------- bucket_key : str (or any python object) The key of the target bucket. data_shapes : list of (str, tuple) Typically ``data_batch.provide_data``. label_shapes : lis...
python/mxnet/module/bucketing_module.py
def switch_bucket(self, bucket_key, data_shapes, label_shapes=None): """Switches to a different bucket. This will change ``self.curr_module``. Parameters ---------- bucket_key : str (or any python object) The key of the target bucket. data_shapes : list of (str, tupl...
def switch_bucket(self, bucket_key, data_shapes, label_shapes=None): """Switches to a different bucket. This will change ``self.curr_module``. Parameters ---------- bucket_key : str (or any python object) The key of the target bucket. data_shapes : list of (str, tupl...
[ "Switches", "to", "a", "different", "bucket", ".", "This", "will", "change", "self", ".", "curr_module", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L354-L385
[ "def", "switch_bucket", "(", "self", ",", "bucket_key", ",", "data_shapes", ",", "label_shapes", "=", "None", ")", ":", "assert", "self", ".", "binded", ",", "'call bind before switching bucket'", "if", "not", "bucket_key", "in", "self", ".", "_buckets", ":", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.init_optimizer
Installs and initializes optimizers. Parameters ---------- kvstore : str or KVStore Defaults to `'local'`. optimizer : str or Optimizer Defaults to `'sgd'` optimizer_params : dict Defaults to `(('learning_rate', 0.01),)`. The default value is ...
python/mxnet/module/bucketing_module.py
def init_optimizer(self, kvstore='local', optimizer='sgd', optimizer_params=(('learning_rate', 0.01),), force_init=False): """Installs and initializes optimizers. Parameters ---------- kvstore : str or KVStore Defaults to `'local...
def init_optimizer(self, kvstore='local', optimizer='sgd', optimizer_params=(('learning_rate', 0.01),), force_init=False): """Installs and initializes optimizers. Parameters ---------- kvstore : str or KVStore Defaults to `'local...
[ "Installs", "and", "initializes", "optimizers", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L387-L416
[ "def", "init_optimizer", "(", "self", ",", "kvstore", "=", "'local'", ",", "optimizer", "=", "'sgd'", ",", "optimizer_params", "=", "(", "(", "'learning_rate'", ",", "0.01", ")", ",", ")", ",", "force_init", "=", "False", ")", ":", "assert", "self", ".",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.prepare
Prepares the module for processing a data batch. Usually involves switching bucket and reshaping. For modules that contain `row_sparse` parameters in KVStore, it prepares the `row_sparse` parameters based on the sparse_row_id_fn. Parameters ---------- data_batch : DataB...
python/mxnet/module/bucketing_module.py
def prepare(self, data_batch, sparse_row_id_fn=None): '''Prepares the module for processing a data batch. Usually involves switching bucket and reshaping. For modules that contain `row_sparse` parameters in KVStore, it prepares the `row_sparse` parameters based on the sparse_row_id_fn. ...
def prepare(self, data_batch, sparse_row_id_fn=None): '''Prepares the module for processing a data batch. Usually involves switching bucket and reshaping. For modules that contain `row_sparse` parameters in KVStore, it prepares the `row_sparse` parameters based on the sparse_row_id_fn. ...
[ "Prepares", "the", "module", "for", "processing", "a", "data", "batch", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L418-L445
[ "def", "prepare", "(", "self", ",", "data_batch", ",", "sparse_row_id_fn", "=", "None", ")", ":", "# perform bind if haven't done so", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "bucket_key", "=", "data_batch", ".", "bucket_key", "o...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.forward
Forward computation. Parameters ---------- data_batch : DataBatch is_train : bool Defaults to ``None``, in which case `is_train` is take as ``self.for_training``.
python/mxnet/module/bucketing_module.py
def forward(self, data_batch, is_train=None): """Forward computation. Parameters ---------- data_batch : DataBatch is_train : bool Defaults to ``None``, in which case `is_train` is take as ``self.for_training``. """ assert self.binded and self.params_...
def forward(self, data_batch, is_train=None): """Forward computation. Parameters ---------- data_batch : DataBatch is_train : bool Defaults to ``None``, in which case `is_train` is take as ``self.for_training``. """ assert self.binded and self.params_...
[ "Forward", "computation", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L447-L459
[ "def", "forward", "(", "self", ",", "data_batch", ",", "is_train", "=", "None", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "self", ".", "switch_bucket", "(", "data_batch", ".", "bucket_key", ",", "data_batch", ".", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.backward
Backward computation.
python/mxnet/module/bucketing_module.py
def backward(self, out_grads=None): """Backward computation.""" assert self.binded and self.params_initialized self._curr_module.backward(out_grads=out_grads)
def backward(self, out_grads=None): """Backward computation.""" assert self.binded and self.params_initialized self._curr_module.backward(out_grads=out_grads)
[ "Backward", "computation", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L461-L464
[ "def", "backward", "(", "self", ",", "out_grads", "=", "None", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "self", ".", "_curr_module", ".", "backward", "(", "out_grads", "=", "out_grads", ")" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.update
Updates parameters according to installed optimizer and the gradient computed in the previous forward-backward cycle. When KVStore is used to update parameters for multi-device or multi-machine training, a copy of the parameters are stored in KVStore. Note that for `row_sparse` parameters, ...
python/mxnet/module/bucketing_module.py
def update(self): """Updates parameters according to installed optimizer and the gradient computed in the previous forward-backward cycle. When KVStore is used to update parameters for multi-device or multi-machine training, a copy of the parameters are stored in KVStore. Note that for ...
def update(self): """Updates parameters according to installed optimizer and the gradient computed in the previous forward-backward cycle. When KVStore is used to update parameters for multi-device or multi-machine training, a copy of the parameters are stored in KVStore. Note that for ...
[ "Updates", "parameters", "according", "to", "installed", "optimizer", "and", "the", "gradient", "computed", "in", "the", "previous", "forward", "-", "backward", "cycle", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L466-L479
[ "def", "update", "(", "self", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "and", "self", ".", "optimizer_initialized", "self", ".", "_params_dirty", "=", "True", "self", ".", "_curr_module", ".", "update", "(", ")" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.get_outputs
Gets outputs from a previous forward computation. Parameters ---------- merge_multi_context : bool Defaults to ``True``. In the case when data-parallelism is used, the outputs will be collected from multiple devices. A ``True`` value indicate that we should m...
python/mxnet/module/bucketing_module.py
def get_outputs(self, merge_multi_context=True): """Gets outputs from a previous forward computation. Parameters ---------- merge_multi_context : bool Defaults to ``True``. In the case when data-parallelism is used, the outputs will be collected from multiple dev...
def get_outputs(self, merge_multi_context=True): """Gets outputs from a previous forward computation. Parameters ---------- merge_multi_context : bool Defaults to ``True``. In the case when data-parallelism is used, the outputs will be collected from multiple dev...
[ "Gets", "outputs", "from", "a", "previous", "forward", "computation", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L481-L500
[ "def", "get_outputs", "(", "self", ",", "merge_multi_context", "=", "True", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "return", "self", ".", "_curr_module", ".", "get_outputs", "(", "merge_multi_context", "=", "merge_mu...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.get_input_grads
Gets the gradients with respect to the inputs of the module. Parameters ---------- merge_multi_context : bool Defaults to ``True``. In the case when data-parallelism is used, the outputs will be collected from multiple devices. A ``True`` value indicate that we ...
python/mxnet/module/bucketing_module.py
def get_input_grads(self, merge_multi_context=True): """Gets the gradients with respect to the inputs of the module. Parameters ---------- merge_multi_context : bool Defaults to ``True``. In the case when data-parallelism is used, the outputs will be collected fr...
def get_input_grads(self, merge_multi_context=True): """Gets the gradients with respect to the inputs of the module. Parameters ---------- merge_multi_context : bool Defaults to ``True``. In the case when data-parallelism is used, the outputs will be collected fr...
[ "Gets", "the", "gradients", "with", "respect", "to", "the", "inputs", "of", "the", "module", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L502-L521
[ "def", "get_input_grads", "(", "self", ",", "merge_multi_context", "=", "True", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "and", "self", ".", "inputs_need_grad", "return", "self", ".", "_curr_module", ".", "get_input_gr...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.update_metric
Evaluates and accumulates evaluation metric on outputs of the last forward computation. Parameters ---------- eval_metric : EvalMetric labels : list of NDArray Typically ``data_batch.label``.
python/mxnet/module/bucketing_module.py
def update_metric(self, eval_metric, labels, pre_sliced=False): """Evaluates and accumulates evaluation metric on outputs of the last forward computation. Parameters ---------- eval_metric : EvalMetric labels : list of NDArray Typically ``data_batch.label``. ...
def update_metric(self, eval_metric, labels, pre_sliced=False): """Evaluates and accumulates evaluation metric on outputs of the last forward computation. Parameters ---------- eval_metric : EvalMetric labels : list of NDArray Typically ``data_batch.label``. ...
[ "Evaluates", "and", "accumulates", "evaluation", "metric", "on", "outputs", "of", "the", "last", "forward", "computation", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L523-L533
[ "def", "update_metric", "(", "self", ",", "eval_metric", ",", "labels", ",", "pre_sliced", "=", "False", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "self", ".", "_curr_module", ".", "update_metric", "(", "eval_metric",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BucketingModule.install_monitor
Installs monitor on all executors
python/mxnet/module/bucketing_module.py
def install_monitor(self, mon): """Installs monitor on all executors """ assert self.binded self._monitor = mon for mod in self._buckets.values(): mod.install_monitor(mon)
def install_monitor(self, mon): """Installs monitor on all executors """ assert self.binded self._monitor = mon for mod in self._buckets.values(): mod.install_monitor(mon)
[ "Installs", "monitor", "on", "all", "executors" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/bucketing_module.py#L541-L546
[ "def", "install_monitor", "(", "self", ",", "mon", ")", ":", "assert", "self", ".", "binded", "self", ".", "_monitor", "=", "mon", "for", "mod", "in", "self", ".", "_buckets", ".", "values", "(", ")", ":", "mod", ".", "install_monitor", "(", "mon", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
set_recording
Set status to recording/not recording. When recording, graph will be constructed for gradient computation. Parameters ---------- is_recording: bool Returns ------- previous state before this set.
python/mxnet/autograd.py
def set_recording(is_recording): #pylint: disable=redefined-outer-name """Set status to recording/not recording. When recording, graph will be constructed for gradient computation. Parameters ---------- is_recording: bool Returns ------- previous state before this set. """ prev...
def set_recording(is_recording): #pylint: disable=redefined-outer-name """Set status to recording/not recording. When recording, graph will be constructed for gradient computation. Parameters ---------- is_recording: bool Returns ------- previous state before this set. """ prev...
[ "Set", "status", "to", "recording", "/", "not", "recording", ".", "When", "recording", "graph", "will", "be", "constructed", "for", "gradient", "computation", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/autograd.py#L35-L50
[ "def", "set_recording", "(", "is_recording", ")", ":", "#pylint: disable=redefined-outer-name", "prev", "=", "ctypes", ".", "c_int", "(", ")", "check_call", "(", "_LIB", ".", "MXAutogradSetIsRecording", "(", "ctypes", ".", "c_int", "(", "is_recording", ")", ",", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
set_training
Set status to training/predicting. This affects ctx.is_train in operator running context. For example, Dropout will drop inputs randomly when train_mode=True while simply passing through if train_mode=False. Parameters ---------- train_mode: bool Returns ------- previous state before t...
python/mxnet/autograd.py
def set_training(train_mode): #pylint: disable=redefined-outer-name """Set status to training/predicting. This affects ctx.is_train in operator running context. For example, Dropout will drop inputs randomly when train_mode=True while simply passing through if train_mode=False. Parameters ---------...
def set_training(train_mode): #pylint: disable=redefined-outer-name """Set status to training/predicting. This affects ctx.is_train in operator running context. For example, Dropout will drop inputs randomly when train_mode=True while simply passing through if train_mode=False. Parameters ---------...
[ "Set", "status", "to", "training", "/", "predicting", ".", "This", "affects", "ctx", ".", "is_train", "in", "operator", "running", "context", ".", "For", "example", "Dropout", "will", "drop", "inputs", "randomly", "when", "train_mode", "=", "True", "while", ...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/autograd.py#L52-L68
[ "def", "set_training", "(", "train_mode", ")", ":", "#pylint: disable=redefined-outer-name", "prev", "=", "ctypes", ".", "c_int", "(", ")", "check_call", "(", "_LIB", ".", "MXAutogradSetIsTraining", "(", "ctypes", ".", "c_int", "(", "train_mode", ")", ",", "ctyp...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
is_recording
Get status on recording/not recording. Returns ------- Current state of recording.
python/mxnet/autograd.py
def is_recording(): """Get status on recording/not recording. Returns ------- Current state of recording. """ curr = ctypes.c_bool() check_call(_LIB.MXAutogradIsRecording(ctypes.byref(curr))) return curr.value
def is_recording(): """Get status on recording/not recording. Returns ------- Current state of recording. """ curr = ctypes.c_bool() check_call(_LIB.MXAutogradIsRecording(ctypes.byref(curr))) return curr.value
[ "Get", "status", "on", "recording", "/", "not", "recording", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/autograd.py#L70-L79
[ "def", "is_recording", "(", ")", ":", "curr", "=", "ctypes", ".", "c_bool", "(", ")", "check_call", "(", "_LIB", ".", "MXAutogradIsRecording", "(", "ctypes", ".", "byref", "(", "curr", ")", ")", ")", "return", "curr", ".", "value" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
is_training
Get status on training/predicting. Returns ------- Current state of training/predicting.
python/mxnet/autograd.py
def is_training(): """Get status on training/predicting. Returns ------- Current state of training/predicting. """ curr = ctypes.c_bool() check_call(_LIB.MXAutogradIsTraining(ctypes.byref(curr))) return curr.value
def is_training(): """Get status on training/predicting. Returns ------- Current state of training/predicting. """ curr = ctypes.c_bool() check_call(_LIB.MXAutogradIsTraining(ctypes.byref(curr))) return curr.value
[ "Get", "status", "on", "training", "/", "predicting", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/autograd.py#L81-L90
[ "def", "is_training", "(", ")", ":", "curr", "=", "ctypes", ".", "c_bool", "(", ")", "check_call", "(", "_LIB", ".", "MXAutogradIsTraining", "(", "ctypes", ".", "byref", "(", "curr", ")", ")", ")", "return", "curr", ".", "value" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
mark_variables
Mark NDArrays as variables to compute gradient for autograd. Parameters ---------- variables: NDArray or list of NDArray gradients: NDArray or list of NDArray grad_reqs: str or list of str
python/mxnet/autograd.py
def mark_variables(variables, gradients, grad_reqs='write'): """Mark NDArrays as variables to compute gradient for autograd. Parameters ---------- variables: NDArray or list of NDArray gradients: NDArray or list of NDArray grad_reqs: str or list of str """ if isinstance(variables, NDArr...
def mark_variables(variables, gradients, grad_reqs='write'): """Mark NDArrays as variables to compute gradient for autograd. Parameters ---------- variables: NDArray or list of NDArray gradients: NDArray or list of NDArray grad_reqs: str or list of str """ if isinstance(variables, NDArr...
[ "Mark", "NDArrays", "as", "variables", "to", "compute", "gradient", "for", "autograd", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/autograd.py#L197-L220
[ "def", "mark_variables", "(", "variables", ",", "gradients", ",", "grad_reqs", "=", "'write'", ")", ":", "if", "isinstance", "(", "variables", ",", "NDArray", ")", ":", "assert", "isinstance", "(", "gradients", ",", "NDArray", ")", "variables", "=", "[", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_parse_head
parse head gradient for backward and grad.
python/mxnet/autograd.py
def _parse_head(heads, head_grads): """parse head gradient for backward and grad.""" if isinstance(heads, NDArray): heads = [heads] if isinstance(head_grads, NDArray): head_grads = [head_grads] head_handles = c_handle_array(heads) if head_grads is None: hgrad_handles = ctyp...
def _parse_head(heads, head_grads): """parse head gradient for backward and grad.""" if isinstance(heads, NDArray): heads = [heads] if isinstance(head_grads, NDArray): head_grads = [head_grads] head_handles = c_handle_array(heads) if head_grads is None: hgrad_handles = ctyp...
[ "parse", "head", "gradient", "for", "backward", "and", "grad", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/autograd.py#L223-L240
[ "def", "_parse_head", "(", "heads", ",", "head_grads", ")", ":", "if", "isinstance", "(", "heads", ",", "NDArray", ")", ":", "heads", "=", "[", "heads", "]", "if", "isinstance", "(", "head_grads", ",", "NDArray", ")", ":", "head_grads", "=", "[", "head...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
backward
Compute the gradients of heads w.r.t previously marked variables. Parameters ---------- heads: NDArray or list of NDArray Output NDArray(s) head_grads: NDArray or list of NDArray or None Gradients with respect to heads. train_mode: bool, optional Whether to do backward for t...
python/mxnet/autograd.py
def backward(heads, head_grads=None, retain_graph=False, train_mode=True): #pylint: disable=redefined-outer-name """Compute the gradients of heads w.r.t previously marked variables. Parameters ---------- heads: NDArray or list of NDArray Output NDArray(s) head_grads: NDArray or list of NDAr...
def backward(heads, head_grads=None, retain_graph=False, train_mode=True): #pylint: disable=redefined-outer-name """Compute the gradients of heads w.r.t previously marked variables. Parameters ---------- heads: NDArray or list of NDArray Output NDArray(s) head_grads: NDArray or list of NDAr...
[ "Compute", "the", "gradients", "of", "heads", "w", ".", "r", ".", "t", "previously", "marked", "variables", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/autograd.py#L243-L267
[ "def", "backward", "(", "heads", ",", "head_grads", "=", "None", ",", "retain_graph", "=", "False", ",", "train_mode", "=", "True", ")", ":", "#pylint: disable=redefined-outer-name", "head_handles", ",", "hgrad_handles", "=", "_parse_head", "(", "heads", ",", "h...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
grad
Compute the gradients of heads w.r.t variables. Gradients will be returned as new NDArrays instead of stored into `variable.grad`. Supports recording gradient graph for computing higher order gradients. .. note:: Currently only a very limited set of operators support higher order \ gradients. ...
python/mxnet/autograd.py
def grad(heads, variables, head_grads=None, retain_graph=None, create_graph=False, train_mode=True): #pylint: disable=redefined-outer-name """Compute the gradients of heads w.r.t variables. Gradients will be returned as new NDArrays instead of stored into `variable.grad`. Supports recording gradie...
def grad(heads, variables, head_grads=None, retain_graph=None, create_graph=False, train_mode=True): #pylint: disable=redefined-outer-name """Compute the gradients of heads w.r.t variables. Gradients will be returned as new NDArrays instead of stored into `variable.grad`. Supports recording gradie...
[ "Compute", "the", "gradients", "of", "heads", "w", ".", "r", ".", "t", "variables", ".", "Gradients", "will", "be", "returned", "as", "new", "NDArrays", "instead", "of", "stored", "into", "variable", ".", "grad", ".", "Supports", "recording", "gradient", "...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/autograd.py#L270-L344
[ "def", "grad", "(", "heads", ",", "variables", ",", "head_grads", "=", "None", ",", "retain_graph", "=", "None", ",", "create_graph", "=", "False", ",", "train_mode", "=", "True", ")", ":", "#pylint: disable=redefined-outer-name", "head_handles", ",", "hgrad_han...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_symbol
Retrieve recorded computation history as `Symbol`. Parameters ---------- x : NDArray Array representing the head of computation graph. Returns ------- Symbol The retrieved Symbol.
python/mxnet/autograd.py
def get_symbol(x): """Retrieve recorded computation history as `Symbol`. Parameters ---------- x : NDArray Array representing the head of computation graph. Returns ------- Symbol The retrieved Symbol. """ hdl = SymbolHandle() check_call(_LIB.MXAutogradGetSymbol...
def get_symbol(x): """Retrieve recorded computation history as `Symbol`. Parameters ---------- x : NDArray Array representing the head of computation graph. Returns ------- Symbol The retrieved Symbol. """ hdl = SymbolHandle() check_call(_LIB.MXAutogradGetSymbol...
[ "Retrieve", "recorded", "computation", "history", "as", "Symbol", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/autograd.py#L347-L362
[ "def", "get_symbol", "(", "x", ")", ":", "hdl", "=", "SymbolHandle", "(", ")", "check_call", "(", "_LIB", ".", "MXAutogradGetSymbol", "(", "x", ".", "handle", ",", "ctypes", ".", "byref", "(", "hdl", ")", ")", ")", "return", "Symbol", "(", "hdl", ")"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
load_mldataset
Not particularly fast code to parse the text file and load it into three NDArray's and product an NDArrayIter
example/recommenders/movielens_data.py
def load_mldataset(filename): """Not particularly fast code to parse the text file and load it into three NDArray's and product an NDArrayIter """ user = [] item = [] score = [] with open(filename) as f: for line in f: tks = line.strip().split('\t') if len(tks...
def load_mldataset(filename): """Not particularly fast code to parse the text file and load it into three NDArray's and product an NDArrayIter """ user = [] item = [] score = [] with open(filename) as f: for line in f: tks = line.strip().split('\t') if len(tks...
[ "Not", "particularly", "fast", "code", "to", "parse", "the", "text", "file", "and", "load", "it", "into", "three", "NDArray", "s", "and", "product", "an", "NDArrayIter" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/recommenders/movielens_data.py#L25-L43
[ "def", "load_mldataset", "(", "filename", ")", ":", "user", "=", "[", "]", "item", "=", "[", "]", "score", "=", "[", "]", "with", "open", "(", "filename", ")", "as", "f", ":", "for", "line", "in", "f", ":", "tks", "=", "line", ".", "strip", "("...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
ParseAllOps
MXNET_DLL int MXSymbolListAtomicSymbolCreators(mx_uint *out_size, AtomicSymbolCreator **out_array); MXNET_DLL int MXSymbolGetAtomicSymbolInfo(AtomicSymbolCreator creator, const char **name, ...
cpp-package/scripts/OpWrapperGenerator.py
def ParseAllOps(): """ MXNET_DLL int MXSymbolListAtomicSymbolCreators(mx_uint *out_size, AtomicSymbolCreator **out_array); MXNET_DLL int MXSymbolGetAtomicSymbolInfo(AtomicSymbolCreator creator, const char **nam...
def ParseAllOps(): """ MXNET_DLL int MXSymbolListAtomicSymbolCreators(mx_uint *out_size, AtomicSymbolCreator **out_array); MXNET_DLL int MXSymbolGetAtomicSymbolInfo(AtomicSymbolCreator creator, const char **nam...
[ "MXNET_DLL", "int", "MXSymbolListAtomicSymbolCreators", "(", "mx_uint", "*", "out_size", "AtomicSymbolCreator", "**", "out_array", ")", ";" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/cpp-package/scripts/OpWrapperGenerator.py#L306-L371
[ "def", "ParseAllOps", "(", ")", ":", "cdll", ".", "libmxnet", "=", "cdll", ".", "LoadLibrary", "(", "sys", ".", "argv", "[", "1", "]", ")", "ListOP", "=", "cdll", ".", "libmxnet", ".", "MXSymbolListAtomicSymbolCreators", "GetOpInfo", "=", "cdll", ".", "l...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
main
Read .caffemodel path and .params path as input from command line and use CaffeModelConverter to do the conversion
tools/caffe_translator/scripts/convert_caffe_model.py
def main(): """Read .caffemodel path and .params path as input from command line and use CaffeModelConverter to do the conversion""" parser = argparse.ArgumentParser(description='.caffemodel to MXNet .params converter.') parser.add_argument('caffemodel', help='Path to the .caffemodel file to convert.') ...
def main(): """Read .caffemodel path and .params path as input from command line and use CaffeModelConverter to do the conversion""" parser = argparse.ArgumentParser(description='.caffemodel to MXNet .params converter.') parser.add_argument('caffemodel', help='Path to the .caffemodel file to convert.') ...
[ "Read", ".", "caffemodel", "path", "and", ".", "params", "path", "as", "input", "from", "command", "line", "and", "use", "CaffeModelConverter", "to", "do", "the", "conversion" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_translator/scripts/convert_caffe_model.py#L108-L118
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'.caffemodel to MXNet .params converter.'", ")", "parser", ".", "add_argument", "(", "'caffemodel'", ",", "help", "=", "'Path to the .caffemodel file to convert.'",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
CaffeModelConverter.add_param
Add a param to the .params file
tools/caffe_translator/scripts/convert_caffe_model.py
def add_param(self, param_name, layer_index, blob_index): """Add a param to the .params file""" blobs = self.layers[layer_index].blobs self.dict_param[param_name] = mx.nd.array(caffe.io.blobproto_to_array(blobs[blob_index]))
def add_param(self, param_name, layer_index, blob_index): """Add a param to the .params file""" blobs = self.layers[layer_index].blobs self.dict_param[param_name] = mx.nd.array(caffe.io.blobproto_to_array(blobs[blob_index]))
[ "Add", "a", "param", "to", "the", ".", "params", "file" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_translator/scripts/convert_caffe_model.py#L33-L36
[ "def", "add_param", "(", "self", ",", "param_name", ",", "layer_index", ",", "blob_index", ")", ":", "blobs", "=", "self", ".", "layers", "[", "layer_index", "]", ".", "blobs", "self", ".", "dict_param", "[", "param_name", "]", "=", "mx", ".", "nd", "....
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
CaffeModelConverter.add_arg_param
Add an arg param to .params file. Example: weights of a fully connected layer.
tools/caffe_translator/scripts/convert_caffe_model.py
def add_arg_param(self, param_name, layer_index, blob_index): """Add an arg param to .params file. Example: weights of a fully connected layer.""" self.add_param('arg:%s' % param_name, layer_index, blob_index)
def add_arg_param(self, param_name, layer_index, blob_index): """Add an arg param to .params file. Example: weights of a fully connected layer.""" self.add_param('arg:%s' % param_name, layer_index, blob_index)
[ "Add", "an", "arg", "param", "to", ".", "params", "file", ".", "Example", ":", "weights", "of", "a", "fully", "connected", "layer", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_translator/scripts/convert_caffe_model.py#L38-L40
[ "def", "add_arg_param", "(", "self", ",", "param_name", ",", "layer_index", ",", "blob_index", ")", ":", "self", ".", "add_param", "(", "'arg:%s'", "%", "param_name", ",", "layer_index", ",", "blob_index", ")" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
CaffeModelConverter.add_aux_param
Add an aux param to .params file. Example: moving_mean in BatchNorm layer
tools/caffe_translator/scripts/convert_caffe_model.py
def add_aux_param(self, param_name, layer_index, blob_index): """Add an aux param to .params file. Example: moving_mean in BatchNorm layer """ self.add_param('aux:%s' % param_name, layer_index, blob_index)
def add_aux_param(self, param_name, layer_index, blob_index): """Add an aux param to .params file. Example: moving_mean in BatchNorm layer """ self.add_param('aux:%s' % param_name, layer_index, blob_index)
[ "Add", "an", "aux", "param", "to", ".", "params", "file", ".", "Example", ":", "moving_mean", "in", "BatchNorm", "layer" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_translator/scripts/convert_caffe_model.py#L42-L44
[ "def", "add_aux_param", "(", "self", ",", "param_name", ",", "layer_index", ",", "blob_index", ")", ":", "self", ".", "add_param", "(", "'aux:%s'", "%", "param_name", ",", "layer_index", ",", "blob_index", ")" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
CaffeModelConverter.add_optional_arg_param
Add an arg param. If there is no such param in .caffemodel fie, silently ignore it.
tools/caffe_translator/scripts/convert_caffe_model.py
def add_optional_arg_param(self, param_name, layer_index, blob_index): """Add an arg param. If there is no such param in .caffemodel fie, silently ignore it.""" blobs = self.layers[layer_index].blobs if blob_index < len(blobs): self.add_arg_param(param_name, layer_index, blob_index)
def add_optional_arg_param(self, param_name, layer_index, blob_index): """Add an arg param. If there is no such param in .caffemodel fie, silently ignore it.""" blobs = self.layers[layer_index].blobs if blob_index < len(blobs): self.add_arg_param(param_name, layer_index, blob_index)
[ "Add", "an", "arg", "param", ".", "If", "there", "is", "no", "such", "param", "in", ".", "caffemodel", "fie", "silently", "ignore", "it", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_translator/scripts/convert_caffe_model.py#L46-L50
[ "def", "add_optional_arg_param", "(", "self", ",", "param_name", ",", "layer_index", ",", "blob_index", ")", ":", "blobs", "=", "self", ".", "layers", "[", "layer_index", "]", ".", "blobs", "if", "blob_index", "<", "len", "(", "blobs", ")", ":", "self", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
CaffeModelConverter.convert
Convert a Caffe .caffemodel file to MXNet .params file
tools/caffe_translator/scripts/convert_caffe_model.py
def convert(self, caffemodel_path, outmodel_path): """Convert a Caffe .caffemodel file to MXNet .params file""" net_param = caffe_pb2.NetParameter() with open(caffemodel_path, 'rb') as caffe_model_file: net_param.ParseFromString(caffe_model_file.read()) layers = net_param.la...
def convert(self, caffemodel_path, outmodel_path): """Convert a Caffe .caffemodel file to MXNet .params file""" net_param = caffe_pb2.NetParameter() with open(caffemodel_path, 'rb') as caffe_model_file: net_param.ParseFromString(caffe_model_file.read()) layers = net_param.la...
[ "Convert", "a", "Caffe", ".", "caffemodel", "file", "to", "MXNet", ".", "params", "file" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/caffe_translator/scripts/convert_caffe_model.py#L52-L106
[ "def", "convert", "(", "self", ",", "caffemodel_path", ",", "outmodel_path", ")", ":", "net_param", "=", "caffe_pb2", ".", "NetParameter", "(", ")", "with", "open", "(", "caffemodel_path", ",", "'rb'", ")", "as", "caffe_model_file", ":", "net_param", ".", "P...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
sample_rois
generate random sample of ROIs comprising foreground and background examples :param rois: [n, 5] (batch_index, x1, y1, x2, y2) :param gt_boxes: [n, 5] (x1, y1, x2, y2, cls) :param num_classes: number of classes :param rois_per_image: total roi number :param fg_rois_per_image: foreground roi number ...
example/rcnn/symnet/proposal_target.py
def sample_rois(rois, gt_boxes, num_classes, rois_per_image, fg_rois_per_image, fg_overlap, box_stds): """ generate random sample of ROIs comprising foreground and background examples :param rois: [n, 5] (batch_index, x1, y1, x2, y2) :param gt_boxes: [n, 5] (x1, y1, x2, y2, cls) :param num_classes: ...
def sample_rois(rois, gt_boxes, num_classes, rois_per_image, fg_rois_per_image, fg_overlap, box_stds): """ generate random sample of ROIs comprising foreground and background examples :param rois: [n, 5] (batch_index, x1, y1, x2, y2) :param gt_boxes: [n, 5] (x1, y1, x2, y2, cls) :param num_classes: ...
[ "generate", "random", "sample", "of", "ROIs", "comprising", "foreground", "and", "background", "examples", ":", "param", "rois", ":", "[", "n", "5", "]", "(", "batch_index", "x1", "y1", "x2", "y2", ")", ":", "param", "gt_boxes", ":", "[", "n", "5", "]"...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rcnn/symnet/proposal_target.py#L28-L85
[ "def", "sample_rois", "(", "rois", ",", "gt_boxes", ",", "num_classes", ",", "rois_per_image", ",", "fg_rois_per_image", ",", "fg_overlap", ",", "box_stds", ")", ":", "overlaps", "=", "bbox_overlaps", "(", "rois", "[", ":", ",", "1", ":", "]", ",", "gt_box...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
register
Register a subclass of CustomOpProp to the registry with name reg_name.
python/mxnet/operator.py
def register(reg_name): """Register a subclass of CustomOpProp to the registry with name reg_name.""" def do_register(prop_cls): """Register a subclass of CustomOpProp to the registry.""" fb_functype = CFUNCTYPE(c_int, c_int, POINTER(c_void_p), POINTER(c_int), POI...
def register(reg_name): """Register a subclass of CustomOpProp to the registry with name reg_name.""" def do_register(prop_cls): """Register a subclass of CustomOpProp to the registry.""" fb_functype = CFUNCTYPE(c_int, c_int, POINTER(c_void_p), POINTER(c_int), POI...
[ "Register", "a", "subclass", "of", "CustomOpProp", "to", "the", "registry", "with", "name", "reg_name", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/operator.py#L692-L1099
[ "def", "register", "(", "reg_name", ")", ":", "def", "do_register", "(", "prop_cls", ")", ":", "\"\"\"Register a subclass of CustomOpProp to the registry.\"\"\"", "fb_functype", "=", "CFUNCTYPE", "(", "c_int", ",", "c_int", ",", "POINTER", "(", "c_void_p", ")", ",",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
NDArrayOp.declare_backward_dependency
Declare dependencies of this operator for backward pass. Parameters ---------- out_grad : list of int ids of out_grad blobs. in_data : list of int ids of in_data blobs. out_data: list of int ids of out_data blobs. Returns ----...
python/mxnet/operator.py
def declare_backward_dependency(self, out_grad, in_data, out_data): """Declare dependencies of this operator for backward pass. Parameters ---------- out_grad : list of int ids of out_grad blobs. in_data : list of int ids of in_data blobs. out_dat...
def declare_backward_dependency(self, out_grad, in_data, out_data): """Declare dependencies of this operator for backward pass. Parameters ---------- out_grad : list of int ids of out_grad blobs. in_data : list of int ids of in_data blobs. out_dat...
[ "Declare", "dependencies", "of", "this", "operator", "for", "backward", "pass", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/operator.py#L402-L424
[ "def", "declare_backward_dependency", "(", "self", ",", "out_grad", ",", "in_data", ",", "out_data", ")", ":", "deps", "=", "[", "]", "if", "self", ".", "need_top_grad", "(", ")", ":", "deps", ".", "extend", "(", "out_grad", ")", "deps", ".", "extend", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
CustomOp.assign
Helper function for assigning into dst depending on requirements.
python/mxnet/operator.py
def assign(self, dst, req, src): """Helper function for assigning into dst depending on requirements.""" if req == 'null': return elif req in ('write', 'inplace'): dst[:] = src elif req == 'add': dst[:] += src
def assign(self, dst, req, src): """Helper function for assigning into dst depending on requirements.""" if req == 'null': return elif req in ('write', 'inplace'): dst[:] = src elif req == 'add': dst[:] += src
[ "Helper", "function", "for", "assigning", "into", "dst", "depending", "on", "requirements", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/operator.py#L463-L470
[ "def", "assign", "(", "self", ",", "dst", ",", "req", ",", "src", ")", ":", "if", "req", "==", "'null'", ":", "return", "elif", "req", "in", "(", "'write'", ",", "'inplace'", ")", ":", "dst", "[", ":", "]", "=", "src", "elif", "req", "==", "'ad...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
CustomOpProp.infer_type
infer_type interface. override to create new operators Parameters ---------- in_type : list of np.dtype list of argument types in the same order as declared in list_arguments. Returns ------- in_type : list list of argument types. Can...
python/mxnet/operator.py
def infer_type(self, in_type): """infer_type interface. override to create new operators Parameters ---------- in_type : list of np.dtype list of argument types in the same order as declared in list_arguments. Returns ------- in_type : li...
def infer_type(self, in_type): """infer_type interface. override to create new operators Parameters ---------- in_type : list of np.dtype list of argument types in the same order as declared in list_arguments. Returns ------- in_type : li...
[ "infer_type", "interface", ".", "override", "to", "create", "new", "operators" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/operator.py#L506-L527
[ "def", "infer_type", "(", "self", ",", "in_type", ")", ":", "return", "in_type", ",", "[", "in_type", "[", "0", "]", "]", "*", "len", "(", "self", ".", "list_outputs", "(", ")", ")", ",", "[", "in_type", "[", "0", "]", "]", "*", "len", "(", "se...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
CustomOpProp.infer_storage_type
infer_storage_type interface. Used to infer storage type of inputs and outputs in the forward pass. When this interface is not implemented, all stypes will be inferred as default. Parameters ---------- in_stype : list of stypes, valid stypes are default, row_sparse and ...
python/mxnet/operator.py
def infer_storage_type(self, in_stype): """infer_storage_type interface. Used to infer storage type of inputs and outputs in the forward pass. When this interface is not implemented, all stypes will be inferred as default. Parameters ---------- in_stype : list of stypes,...
def infer_storage_type(self, in_stype): """infer_storage_type interface. Used to infer storage type of inputs and outputs in the forward pass. When this interface is not implemented, all stypes will be inferred as default. Parameters ---------- in_stype : list of stypes,...
[ "infer_storage_type", "interface", ".", "Used", "to", "infer", "storage", "type", "of", "inputs", "and", "outputs", "in", "the", "forward", "pass", ".", "When", "this", "interface", "is", "not", "implemented", "all", "stypes", "will", "be", "inferred", "as", ...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/operator.py#L529-L558
[ "def", "infer_storage_type", "(", "self", ",", "in_stype", ")", ":", "for", "i", ",", "stype", "in", "enumerate", "(", "in_stype", ")", ":", "assert", "stype", "==", "_STORAGE_TYPE_ID_TO_STR", "[", "_STORAGE_TYPE_DEFAULT", "]", ",", "\"Default infer_storage_type i...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
CustomOpProp.infer_storage_type_backward
infer_storage_type_backward interface. Used to infer storage type of inputs and outputs in the backward pass. Will raise an error if undefined storage type is returned. Returned lists have to be the same size as the input lists to infer_storage_type_backward, otherwise an exception will...
python/mxnet/operator.py
def infer_storage_type_backward(self, ograd_stype, in_stype, out_stype, igrad_stype, aux_stype): """infer_storage_type_backward interface. Used to infer storage type of inputs and outputs in the backward pass. Will raise an error if undefined storage type is returned. Returned lists hav...
def infer_storage_type_backward(self, ograd_stype, in_stype, out_stype, igrad_stype, aux_stype): """infer_storage_type_backward interface. Used to infer storage type of inputs and outputs in the backward pass. Will raise an error if undefined storage type is returned. Returned lists hav...
[ "infer_storage_type_backward", "interface", ".", "Used", "to", "infer", "storage", "type", "of", "inputs", "and", "outputs", "in", "the", "backward", "pass", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/operator.py#L560-L612
[ "def", "infer_storage_type_backward", "(", "self", ",", "ograd_stype", ",", "in_stype", ",", "out_stype", ",", "igrad_stype", ",", "aux_stype", ")", ":", "for", "i", ",", "stype", "in", "enumerate", "(", "ograd_stype", ")", ":", "assert", "stype", "==", "_ST...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
CustomOpProp.declare_backward_dependency
Declare dependencies of this operator for backward pass. Parameters ---------- out_grad : list of int ids of out_grad blobs. in_data : list of int ids of in_data blobs. out_data: list of int ids of out_data blobs. Returns ----...
python/mxnet/operator.py
def declare_backward_dependency(self, out_grad, in_data, out_data): """Declare dependencies of this operator for backward pass. Parameters ---------- out_grad : list of int ids of out_grad blobs. in_data : list of int ids of in_data blobs. out_dat...
def declare_backward_dependency(self, out_grad, in_data, out_data): """Declare dependencies of this operator for backward pass. Parameters ---------- out_grad : list of int ids of out_grad blobs. in_data : list of int ids of in_data blobs. out_dat...
[ "Declare", "dependencies", "of", "this", "operator", "for", "backward", "pass", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/operator.py#L644-L666
[ "def", "declare_backward_dependency", "(", "self", ",", "out_grad", ",", "in_data", ",", "out_data", ")", ":", "deps", "=", "[", "]", "if", "self", ".", "need_top_grad_", ":", "deps", ".", "extend", "(", "out_grad", ")", "deps", ".", "extend", "(", "in_d...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_Registry.inc
Get index for new entry.
python/mxnet/operator.py
def inc(self): """Get index for new entry.""" self.lock.acquire() cur = self.counter self.counter += 1 self.lock.release() return cur
def inc(self): """Get index for new entry.""" self.lock.acquire() cur = self.counter self.counter += 1 self.lock.release() return cur
[ "Get", "index", "for", "new", "entry", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/operator.py#L682-L688
[ "def", "inc", "(", "self", ")", ":", "self", ".", "lock", ".", "acquire", "(", ")", "cur", "=", "self", ".", "counter", "self", ".", "counter", "+=", "1", "self", ".", "lock", ".", "release", "(", ")", "return", "cur" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7