id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
23,400 | apache/incubator-mxnet | python/mxnet/image/image.py | color_normalize | def color_normalize(src, mean, std=None):
"""Normalize src with mean and std.
Parameters
----------
src : NDArray
Input image
mean : NDArray
RGB mean to be subtracted
std : NDArray
RGB standard deviation to be divided
Returns
-------
NDArray
An `NDAr... | python | def color_normalize(src, mean, std=None):
"""Normalize src with mean and std.
Parameters
----------
src : NDArray
Input image
mean : NDArray
RGB mean to be subtracted
std : NDArray
RGB standard deviation to be divided
Returns
-------
NDArray
An `NDAr... | [
"def",
"color_normalize",
"(",
"src",
",",
"mean",
",",
"std",
"=",
"None",
")",
":",
"if",
"mean",
"is",
"not",
"None",
":",
"src",
"-=",
"mean",
"if",
"std",
"is",
"not",
"None",
":",
"src",
"/=",
"std",
"return",
"src"
] | Normalize src with mean and std.
Parameters
----------
src : NDArray
Input image
mean : NDArray
RGB mean to be subtracted
std : NDArray
RGB standard deviation to be divided
Returns
-------
NDArray
An `NDArray` containing the normalized image. | [
"Normalize",
"src",
"with",
"mean",
"and",
"std",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L526-L547 |
23,401 | apache/incubator-mxnet | python/mxnet/image/image.py | random_size_crop | def random_size_crop(src, size, area, ratio, interp=2, **kwargs):
"""Randomly crop src with size. Randomize area and aspect ratio.
Parameters
----------
src : NDArray
Input image
size : tuple of (int, int)
Size of the crop formatted as (width, height).
area : float in (0, 1] or ... | python | def random_size_crop(src, size, area, ratio, interp=2, **kwargs):
"""Randomly crop src with size. Randomize area and aspect ratio.
Parameters
----------
src : NDArray
Input image
size : tuple of (int, int)
Size of the crop formatted as (width, height).
area : float in (0, 1] or ... | [
"def",
"random_size_crop",
"(",
"src",
",",
"size",
",",
"area",
",",
"ratio",
",",
"interp",
"=",
"2",
",",
"*",
"*",
"kwargs",
")",
":",
"h",
",",
"w",
",",
"_",
"=",
"src",
".",
"shape",
"src_area",
"=",
"h",
"*",
"w",
"if",
"'min_area'",
"i... | Randomly crop src with size. Randomize area and aspect ratio.
Parameters
----------
src : NDArray
Input image
size : tuple of (int, int)
Size of the crop formatted as (width, height).
area : float in (0, 1] or tuple of (float, float)
If tuple, minimum area and maximum area t... | [
"Randomly",
"crop",
"src",
"with",
"size",
".",
"Randomize",
"area",
"and",
"aspect",
"ratio",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L550-L602 |
23,402 | apache/incubator-mxnet | python/mxnet/image/image.py | CreateAugmenter | def CreateAugmenter(data_shape, resize=0, rand_crop=False, rand_resize=False, rand_mirror=False,
mean=None, std=None, brightness=0, contrast=0, saturation=0, hue=0,
pca_noise=0, rand_gray=0, inter_method=2):
"""Creates an augmenter list.
Parameters
----------
dat... | python | def CreateAugmenter(data_shape, resize=0, rand_crop=False, rand_resize=False, rand_mirror=False,
mean=None, std=None, brightness=0, contrast=0, saturation=0, hue=0,
pca_noise=0, rand_gray=0, inter_method=2):
"""Creates an augmenter list.
Parameters
----------
dat... | [
"def",
"CreateAugmenter",
"(",
"data_shape",
",",
"resize",
"=",
"0",
",",
"rand_crop",
"=",
"False",
",",
"rand_resize",
"=",
"False",
",",
"rand_mirror",
"=",
"False",
",",
"mean",
"=",
"None",
",",
"std",
"=",
"None",
",",
"brightness",
"=",
"0",
",... | Creates an augmenter list.
Parameters
----------
data_shape : tuple of int
Shape for output data
resize : int
Resize shorter edge if larger than 0 at the begining
rand_crop : bool
Whether to enable random cropping other than center crop
rand_resize : bool
Whether... | [
"Creates",
"an",
"augmenter",
"list",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L1015-L1126 |
23,403 | apache/incubator-mxnet | python/mxnet/image/image.py | Augmenter.dumps | def dumps(self):
"""Saves the Augmenter to string
Returns
-------
str
JSON formatted string that describes the Augmenter.
"""
return json.dumps([self.__class__.__name__.lower(), self._kwargs]) | python | def dumps(self):
"""Saves the Augmenter to string
Returns
-------
str
JSON formatted string that describes the Augmenter.
"""
return json.dumps([self.__class__.__name__.lower(), self._kwargs]) | [
"def",
"dumps",
"(",
"self",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"[",
"self",
".",
"__class__",
".",
"__name__",
".",
"lower",
"(",
")",
",",
"self",
".",
"_kwargs",
"]",
")"
] | Saves the Augmenter to string
Returns
-------
str
JSON formatted string that describes the Augmenter. | [
"Saves",
"the",
"Augmenter",
"to",
"string"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L616-L624 |
23,404 | apache/incubator-mxnet | python/mxnet/image/image.py | SequentialAug.dumps | def dumps(self):
"""Override the default to avoid duplicate dump."""
return [self.__class__.__name__.lower(), [x.dumps() for x in self.ts]] | python | def dumps(self):
"""Override the default to avoid duplicate dump."""
return [self.__class__.__name__.lower(), [x.dumps() for x in self.ts]] | [
"def",
"dumps",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"__class__",
".",
"__name__",
".",
"lower",
"(",
")",
",",
"[",
"x",
".",
"dumps",
"(",
")",
"for",
"x",
"in",
"self",
".",
"ts",
"]",
"]"
] | Override the default to avoid duplicate dump. | [
"Override",
"the",
"default",
"to",
"avoid",
"duplicate",
"dump",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L643-L645 |
23,405 | apache/incubator-mxnet | python/mxnet/image/image.py | ImageIter.hard_reset | def hard_reset(self):
"""Resets the iterator and ignore roll over data"""
if self.seq is not None and self.shuffle:
random.shuffle(self.seq)
if self.imgrec is not None:
self.imgrec.reset()
self.cur = 0
self._allow_read = True
self._cache_data = Non... | python | def hard_reset(self):
"""Resets the iterator and ignore roll over data"""
if self.seq is not None and self.shuffle:
random.shuffle(self.seq)
if self.imgrec is not None:
self.imgrec.reset()
self.cur = 0
self._allow_read = True
self._cache_data = Non... | [
"def",
"hard_reset",
"(",
"self",
")",
":",
"if",
"self",
".",
"seq",
"is",
"not",
"None",
"and",
"self",
".",
"shuffle",
":",
"random",
".",
"shuffle",
"(",
"self",
".",
"seq",
")",
"if",
"self",
".",
"imgrec",
"is",
"not",
"None",
":",
"self",
... | Resets the iterator and ignore roll over data | [
"Resets",
"the",
"iterator",
"and",
"ignore",
"roll",
"over",
"data"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L1290-L1300 |
23,406 | apache/incubator-mxnet | python/mxnet/image/image.py | ImageIter.next_sample | def next_sample(self):
"""Helper function for reading in next sample."""
if self._allow_read is False:
raise StopIteration
if self.seq is not None:
if self.cur < self.num_image:
idx = self.seq[self.cur]
else:
if self.last_batch_... | python | def next_sample(self):
"""Helper function for reading in next sample."""
if self._allow_read is False:
raise StopIteration
if self.seq is not None:
if self.cur < self.num_image:
idx = self.seq[self.cur]
else:
if self.last_batch_... | [
"def",
"next_sample",
"(",
"self",
")",
":",
"if",
"self",
".",
"_allow_read",
"is",
"False",
":",
"raise",
"StopIteration",
"if",
"self",
".",
"seq",
"is",
"not",
"None",
":",
"if",
"self",
".",
"cur",
"<",
"self",
".",
"num_image",
":",
"idx",
"=",... | Helper function for reading in next sample. | [
"Helper",
"function",
"for",
"reading",
"in",
"next",
"sample",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L1302-L1331 |
23,407 | apache/incubator-mxnet | python/mxnet/image/image.py | ImageIter._batchify | def _batchify(self, batch_data, batch_label, start=0):
"""Helper function for batchifying data"""
i = start
batch_size = self.batch_size
try:
while i < batch_size:
label, s = self.next_sample()
data = self.imdecode(s)
try:
... | python | def _batchify(self, batch_data, batch_label, start=0):
"""Helper function for batchifying data"""
i = start
batch_size = self.batch_size
try:
while i < batch_size:
label, s = self.next_sample()
data = self.imdecode(s)
try:
... | [
"def",
"_batchify",
"(",
"self",
",",
"batch_data",
",",
"batch_label",
",",
"start",
"=",
"0",
")",
":",
"i",
"=",
"start",
"batch_size",
"=",
"self",
".",
"batch_size",
"try",
":",
"while",
"i",
"<",
"batch_size",
":",
"label",
",",
"s",
"=",
"self... | Helper function for batchifying data | [
"Helper",
"function",
"for",
"batchifying",
"data"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L1333-L1354 |
23,408 | apache/incubator-mxnet | python/mxnet/image/image.py | ImageIter.imdecode | def imdecode(self, s):
"""Decodes a string or byte string to an NDArray.
See mx.img.imdecode for more details."""
def locate():
"""Locate the image file/index if decode fails."""
if self.seq is not None:
idx = self.seq[(self.cur % self.num_image) - 1]
... | python | def imdecode(self, s):
"""Decodes a string or byte string to an NDArray.
See mx.img.imdecode for more details."""
def locate():
"""Locate the image file/index if decode fails."""
if self.seq is not None:
idx = self.seq[(self.cur % self.num_image) - 1]
... | [
"def",
"imdecode",
"(",
"self",
",",
"s",
")",
":",
"def",
"locate",
"(",
")",
":",
"\"\"\"Locate the image file/index if decode fails.\"\"\"",
"if",
"self",
".",
"seq",
"is",
"not",
"None",
":",
"idx",
"=",
"self",
".",
"seq",
"[",
"(",
"self",
".",
"cu... | Decodes a string or byte string to an NDArray.
See mx.img.imdecode for more details. | [
"Decodes",
"a",
"string",
"or",
"byte",
"string",
"to",
"an",
"NDArray",
".",
"See",
"mx",
".",
"img",
".",
"imdecode",
"for",
"more",
"details",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/image.py#L1409-L1428 |
23,409 | apache/incubator-mxnet | example/gluon/lipnet/utils/common.py | word_to_vector | def word_to_vector(word):
"""
Convert character vectors to integer vectors.
"""
vector = []
for char in list(word):
vector.append(char2int(char))
return vector | python | def word_to_vector(word):
"""
Convert character vectors to integer vectors.
"""
vector = []
for char in list(word):
vector.append(char2int(char))
return vector | [
"def",
"word_to_vector",
"(",
"word",
")",
":",
"vector",
"=",
"[",
"]",
"for",
"char",
"in",
"list",
"(",
"word",
")",
":",
"vector",
".",
"append",
"(",
"char2int",
"(",
"char",
")",
")",
"return",
"vector"
] | Convert character vectors to integer vectors. | [
"Convert",
"character",
"vectors",
"to",
"integer",
"vectors",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/utils/common.py#L46-L53 |
23,410 | apache/incubator-mxnet | example/gluon/lipnet/utils/common.py | vector_to_word | def vector_to_word(vector):
"""
Convert integer vectors to character vectors.
"""
word = ""
for vec in vector:
word = word + int2char(vec)
return word | python | def vector_to_word(vector):
"""
Convert integer vectors to character vectors.
"""
word = ""
for vec in vector:
word = word + int2char(vec)
return word | [
"def",
"vector_to_word",
"(",
"vector",
")",
":",
"word",
"=",
"\"\"",
"for",
"vec",
"in",
"vector",
":",
"word",
"=",
"word",
"+",
"int2char",
"(",
"vec",
")",
"return",
"word"
] | Convert integer vectors to character vectors. | [
"Convert",
"integer",
"vectors",
"to",
"character",
"vectors",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/utils/common.py#L56-L63 |
23,411 | apache/incubator-mxnet | example/gluon/lipnet/utils/common.py | char_conv | def char_conv(out):
"""
Convert integer vectors to character vectors for batch.
"""
out_conv = list()
for i in range(out.shape[0]):
tmp_str = ''
for j in range(out.shape[1]):
if int(out[i][j]) >= 0:
tmp_char = int2char(int(out[i][j]))
if in... | python | def char_conv(out):
"""
Convert integer vectors to character vectors for batch.
"""
out_conv = list()
for i in range(out.shape[0]):
tmp_str = ''
for j in range(out.shape[1]):
if int(out[i][j]) >= 0:
tmp_char = int2char(int(out[i][j]))
if in... | [
"def",
"char_conv",
"(",
"out",
")",
":",
"out_conv",
"=",
"list",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"out",
".",
"shape",
"[",
"0",
"]",
")",
":",
"tmp_str",
"=",
"''",
"for",
"j",
"in",
"range",
"(",
"out",
".",
"shape",
"[",
"1",
"]... | Convert integer vectors to character vectors for batch. | [
"Convert",
"integer",
"vectors",
"to",
"character",
"vectors",
"for",
"batch",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/utils/common.py#L66-L80 |
23,412 | apache/incubator-mxnet | example/kaggle-ndsb2/Preprocessing.py | get_frames | def get_frames(root_path):
"""Get path to all the frame in view SAX and contain complete frames"""
ret = []
for root, _, files in os.walk(root_path):
root=root.replace('\\','/')
files=[s for s in files if ".dcm" in s]
if len(files) == 0 or not files[0].endswith(".dcm") or root.find("sax") ... | python | def get_frames(root_path):
"""Get path to all the frame in view SAX and contain complete frames"""
ret = []
for root, _, files in os.walk(root_path):
root=root.replace('\\','/')
files=[s for s in files if ".dcm" in s]
if len(files) == 0 or not files[0].endswith(".dcm") or root.find("sax") ... | [
"def",
"get_frames",
"(",
"root_path",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"root",
",",
"_",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"root_path",
")",
":",
"root",
"=",
"root",
".",
"replace",
"(",
"'\\\\'",
",",
"'/'",
")",
"files",
"=",
... | Get path to all the frame in view SAX and contain complete frames | [
"Get",
"path",
"to",
"all",
"the",
"frame",
"in",
"view",
"SAX",
"and",
"contain",
"complete",
"frames"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/kaggle-ndsb2/Preprocessing.py#L39-L53 |
23,413 | apache/incubator-mxnet | example/kaggle-ndsb2/Preprocessing.py | write_data_csv | def write_data_csv(fname, frames, preproc):
"""Write data to csv file"""
fdata = open(fname, "w")
dr = Parallel()(delayed(get_data)(lst,preproc) for lst in frames)
data,result = zip(*dr)
for entry in data:
fdata.write(','.join(entry)+'\r\n')
print("All finished, %d slices in total" % len(data))
... | python | def write_data_csv(fname, frames, preproc):
"""Write data to csv file"""
fdata = open(fname, "w")
dr = Parallel()(delayed(get_data)(lst,preproc) for lst in frames)
data,result = zip(*dr)
for entry in data:
fdata.write(','.join(entry)+'\r\n')
print("All finished, %d slices in total" % len(data))
... | [
"def",
"write_data_csv",
"(",
"fname",
",",
"frames",
",",
"preproc",
")",
":",
"fdata",
"=",
"open",
"(",
"fname",
",",
"\"w\"",
")",
"dr",
"=",
"Parallel",
"(",
")",
"(",
"delayed",
"(",
"get_data",
")",
"(",
"lst",
",",
"preproc",
")",
"for",
"l... | Write data to csv file | [
"Write",
"data",
"to",
"csv",
"file"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/kaggle-ndsb2/Preprocessing.py#L94-L104 |
23,414 | apache/incubator-mxnet | example/kaggle-ndsb2/Preprocessing.py | crop_resize | def crop_resize(img, size):
"""crop center and resize"""
if img.shape[0] < img.shape[1]:
img = img.T
# we crop image from center
short_egde = min(img.shape[:2])
yy = int((img.shape[0] - short_egde) / 2)
xx = int((img.shape[1] - short_egde) / 2)
crop_img = img[yy : yy + short_egde, xx : xx + ... | python | def crop_resize(img, size):
"""crop center and resize"""
if img.shape[0] < img.shape[1]:
img = img.T
# we crop image from center
short_egde = min(img.shape[:2])
yy = int((img.shape[0] - short_egde) / 2)
xx = int((img.shape[1] - short_egde) / 2)
crop_img = img[yy : yy + short_egde, xx : xx + ... | [
"def",
"crop_resize",
"(",
"img",
",",
"size",
")",
":",
"if",
"img",
".",
"shape",
"[",
"0",
"]",
"<",
"img",
".",
"shape",
"[",
"1",
"]",
":",
"img",
"=",
"img",
".",
"T",
"# we crop image from center",
"short_egde",
"=",
"min",
"(",
"img",
".",
... | crop center and resize | [
"crop",
"center",
"and",
"resize"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/kaggle-ndsb2/Preprocessing.py#L107-L119 |
23,415 | apache/incubator-mxnet | example/gluon/sn_gan/model.py | get_generator | def get_generator():
""" construct and return generator """
g_net = gluon.nn.Sequential()
with g_net.name_scope():
g_net.add(gluon.nn.Conv2DTranspose(
channels=512, kernel_size=4, strides=1, padding=0, use_bias=False))
g_net.add(gluon.nn.BatchNorm())
g_net.add(gluon.nn.L... | python | def get_generator():
""" construct and return generator """
g_net = gluon.nn.Sequential()
with g_net.name_scope():
g_net.add(gluon.nn.Conv2DTranspose(
channels=512, kernel_size=4, strides=1, padding=0, use_bias=False))
g_net.add(gluon.nn.BatchNorm())
g_net.add(gluon.nn.L... | [
"def",
"get_generator",
"(",
")",
":",
"g_net",
"=",
"gluon",
".",
"nn",
".",
"Sequential",
"(",
")",
"with",
"g_net",
".",
"name_scope",
"(",
")",
":",
"g_net",
".",
"add",
"(",
"gluon",
".",
"nn",
".",
"Conv2DTranspose",
"(",
"channels",
"=",
"512"... | construct and return generator | [
"construct",
"and",
"return",
"generator"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/sn_gan/model.py#L89-L117 |
23,416 | apache/incubator-mxnet | example/gluon/sn_gan/model.py | get_descriptor | def get_descriptor(ctx):
""" construct and return descriptor """
d_net = gluon.nn.Sequential()
with d_net.name_scope():
d_net.add(SNConv2D(num_filter=64, kernel_size=4, strides=2, padding=1, in_channels=3, ctx=ctx))
d_net.add(gluon.nn.LeakyReLU(0.2))
d_net.add(SNConv2D(num_filter=1... | python | def get_descriptor(ctx):
""" construct and return descriptor """
d_net = gluon.nn.Sequential()
with d_net.name_scope():
d_net.add(SNConv2D(num_filter=64, kernel_size=4, strides=2, padding=1, in_channels=3, ctx=ctx))
d_net.add(gluon.nn.LeakyReLU(0.2))
d_net.add(SNConv2D(num_filter=1... | [
"def",
"get_descriptor",
"(",
"ctx",
")",
":",
"d_net",
"=",
"gluon",
".",
"nn",
".",
"Sequential",
"(",
")",
"with",
"d_net",
".",
"name_scope",
"(",
")",
":",
"d_net",
".",
"add",
"(",
"SNConv2D",
"(",
"num_filter",
"=",
"64",
",",
"kernel_size",
"... | construct and return descriptor | [
"construct",
"and",
"return",
"descriptor"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/sn_gan/model.py#L120-L139 |
23,417 | apache/incubator-mxnet | example/ssd/tools/rand_sampler.py | RandCropper.sample | def sample(self, label):
"""
generate random cropping boxes according to parameters
if satifactory crops generated, apply to ground-truth as well
Parameters:
----------
label : numpy.array (n x 5 matrix)
ground-truths
Returns:
----------
... | python | def sample(self, label):
"""
generate random cropping boxes according to parameters
if satifactory crops generated, apply to ground-truth as well
Parameters:
----------
label : numpy.array (n x 5 matrix)
ground-truths
Returns:
----------
... | [
"def",
"sample",
"(",
"self",
",",
"label",
")",
":",
"samples",
"=",
"[",
"]",
"count",
"=",
"0",
"for",
"trial",
"in",
"range",
"(",
"self",
".",
"max_trials",
")",
":",
"if",
"count",
">=",
"self",
".",
"max_sample",
":",
"return",
"samples",
"s... | generate random cropping boxes according to parameters
if satifactory crops generated, apply to ground-truth as well
Parameters:
----------
label : numpy.array (n x 5 matrix)
ground-truths
Returns:
----------
list of (crop_box, label) tuples, if fail... | [
"generate",
"random",
"cropping",
"boxes",
"according",
"to",
"parameters",
"if",
"satifactory",
"crops",
"generated",
"apply",
"to",
"ground",
"-",
"truth",
"as",
"well"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/tools/rand_sampler.py#L93-L145 |
23,418 | apache/incubator-mxnet | example/ssd/tools/rand_sampler.py | RandCropper._check_satisfy | def _check_satisfy(self, rand_box, gt_boxes):
"""
check if overlap with any gt box is larger than threshold
"""
l, t, r, b = rand_box
num_gt = gt_boxes.shape[0]
ls = np.ones(num_gt) * l
ts = np.ones(num_gt) * t
rs = np.ones(num_gt) * r
bs = np.ones... | python | def _check_satisfy(self, rand_box, gt_boxes):
"""
check if overlap with any gt box is larger than threshold
"""
l, t, r, b = rand_box
num_gt = gt_boxes.shape[0]
ls = np.ones(num_gt) * l
ts = np.ones(num_gt) * t
rs = np.ones(num_gt) * r
bs = np.ones... | [
"def",
"_check_satisfy",
"(",
"self",
",",
"rand_box",
",",
"gt_boxes",
")",
":",
"l",
",",
"t",
",",
"r",
",",
"b",
"=",
"rand_box",
"num_gt",
"=",
"gt_boxes",
".",
"shape",
"[",
"0",
"]",
"ls",
"=",
"np",
".",
"ones",
"(",
"num_gt",
")",
"*",
... | check if overlap with any gt box is larger than threshold | [
"check",
"if",
"overlap",
"with",
"any",
"gt",
"box",
"is",
"larger",
"than",
"threshold"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/tools/rand_sampler.py#L147-L192 |
23,419 | apache/incubator-mxnet | example/ssd/tools/rand_sampler.py | RandPadder.sample | def sample(self, label):
"""
generate random padding boxes according to parameters
if satifactory padding generated, apply to ground-truth as well
Parameters:
----------
label : numpy.array (n x 5 matrix)
ground-truths
Returns:
----------
... | python | def sample(self, label):
"""
generate random padding boxes according to parameters
if satifactory padding generated, apply to ground-truth as well
Parameters:
----------
label : numpy.array (n x 5 matrix)
ground-truths
Returns:
----------
... | [
"def",
"sample",
"(",
"self",
",",
"label",
")",
":",
"samples",
"=",
"[",
"]",
"count",
"=",
"0",
"for",
"trial",
"in",
"range",
"(",
"self",
".",
"max_trials",
")",
":",
"if",
"count",
">=",
"self",
".",
"max_sample",
":",
"return",
"samples",
"s... | generate random padding boxes according to parameters
if satifactory padding generated, apply to ground-truth as well
Parameters:
----------
label : numpy.array (n x 5 matrix)
ground-truths
Returns:
----------
list of (crop_box, label) tuples, if fai... | [
"generate",
"random",
"padding",
"boxes",
"according",
"to",
"parameters",
"if",
"satifactory",
"padding",
"generated",
"apply",
"to",
"ground",
"-",
"truth",
"as",
"well"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/tools/rand_sampler.py#L232-L287 |
23,420 | apache/incubator-mxnet | benchmark/python/sparse/dot.py | measure_cost | def measure_cost(repeat, scipy_trans_lhs, scipy_dns_lhs, func_name, *args, **kwargs):
"""Measure time cost of running a function
"""
mx.nd.waitall()
args_list = []
for arg in args:
args_list.append(arg)
start = time.time()
if scipy_trans_lhs:
args_list[0] = np.transpose(args_... | python | def measure_cost(repeat, scipy_trans_lhs, scipy_dns_lhs, func_name, *args, **kwargs):
"""Measure time cost of running a function
"""
mx.nd.waitall()
args_list = []
for arg in args:
args_list.append(arg)
start = time.time()
if scipy_trans_lhs:
args_list[0] = np.transpose(args_... | [
"def",
"measure_cost",
"(",
"repeat",
",",
"scipy_trans_lhs",
",",
"scipy_dns_lhs",
",",
"func_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"mx",
".",
"nd",
".",
"waitall",
"(",
")",
"args_list",
"=",
"[",
"]",
"for",
"arg",
"in",
"arg... | Measure time cost of running a function | [
"Measure",
"time",
"cost",
"of",
"running",
"a",
"function"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/benchmark/python/sparse/dot.py#L110-L125 |
23,421 | apache/incubator-mxnet | python/mxnet/gluon/data/dataloader.py | default_batchify_fn | def default_batchify_fn(data):
"""Collate data into batch."""
if isinstance(data[0], nd.NDArray):
return nd.stack(*data)
elif isinstance(data[0], tuple):
data = zip(*data)
return [default_batchify_fn(i) for i in data]
else:
data = np.asarray(data)
return nd.array(... | python | def default_batchify_fn(data):
"""Collate data into batch."""
if isinstance(data[0], nd.NDArray):
return nd.stack(*data)
elif isinstance(data[0], tuple):
data = zip(*data)
return [default_batchify_fn(i) for i in data]
else:
data = np.asarray(data)
return nd.array(... | [
"def",
"default_batchify_fn",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
"[",
"0",
"]",
",",
"nd",
".",
"NDArray",
")",
":",
"return",
"nd",
".",
"stack",
"(",
"*",
"data",
")",
"elif",
"isinstance",
"(",
"data",
"[",
"0",
"]",
",",
... | Collate data into batch. | [
"Collate",
"data",
"into",
"batch",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L127-L136 |
23,422 | apache/incubator-mxnet | python/mxnet/gluon/data/dataloader.py | default_mp_batchify_fn | def default_mp_batchify_fn(data):
"""Collate data into batch. Use shared memory for stacking."""
if isinstance(data[0], nd.NDArray):
out = nd.empty((len(data),) + data[0].shape, dtype=data[0].dtype,
ctx=context.Context('cpu_shared', 0))
return nd.stack(*data, out=out)
... | python | def default_mp_batchify_fn(data):
"""Collate data into batch. Use shared memory for stacking."""
if isinstance(data[0], nd.NDArray):
out = nd.empty((len(data),) + data[0].shape, dtype=data[0].dtype,
ctx=context.Context('cpu_shared', 0))
return nd.stack(*data, out=out)
... | [
"def",
"default_mp_batchify_fn",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
"[",
"0",
"]",
",",
"nd",
".",
"NDArray",
")",
":",
"out",
"=",
"nd",
".",
"empty",
"(",
"(",
"len",
"(",
"data",
")",
",",
")",
"+",
"data",
"[",
"0",
"]"... | Collate data into batch. Use shared memory for stacking. | [
"Collate",
"data",
"into",
"batch",
".",
"Use",
"shared",
"memory",
"for",
"stacking",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L139-L151 |
23,423 | apache/incubator-mxnet | python/mxnet/gluon/data/dataloader.py | _as_in_context | def _as_in_context(data, ctx):
"""Move data into new context."""
if isinstance(data, nd.NDArray):
return data.as_in_context(ctx)
elif isinstance(data, (list, tuple)):
return [_as_in_context(d, ctx) for d in data]
return data | python | def _as_in_context(data, ctx):
"""Move data into new context."""
if isinstance(data, nd.NDArray):
return data.as_in_context(ctx)
elif isinstance(data, (list, tuple)):
return [_as_in_context(d, ctx) for d in data]
return data | [
"def",
"_as_in_context",
"(",
"data",
",",
"ctx",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"nd",
".",
"NDArray",
")",
":",
"return",
"data",
".",
"as_in_context",
"(",
"ctx",
")",
"elif",
"isinstance",
"(",
"data",
",",
"(",
"list",
",",
"tupl... | Move data into new context. | [
"Move",
"data",
"into",
"new",
"context",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L154-L160 |
23,424 | apache/incubator-mxnet | python/mxnet/gluon/data/dataloader.py | worker_loop_v1 | def worker_loop_v1(dataset, key_queue, data_queue, batchify_fn):
"""Worker loop for multiprocessing DataLoader."""
while True:
idx, samples = key_queue.get()
if idx is None:
break
batch = batchify_fn([dataset[i] for i in samples])
data_queue.put((idx, batch)) | python | def worker_loop_v1(dataset, key_queue, data_queue, batchify_fn):
"""Worker loop for multiprocessing DataLoader."""
while True:
idx, samples = key_queue.get()
if idx is None:
break
batch = batchify_fn([dataset[i] for i in samples])
data_queue.put((idx, batch)) | [
"def",
"worker_loop_v1",
"(",
"dataset",
",",
"key_queue",
",",
"data_queue",
",",
"batchify_fn",
")",
":",
"while",
"True",
":",
"idx",
",",
"samples",
"=",
"key_queue",
".",
"get",
"(",
")",
"if",
"idx",
"is",
"None",
":",
"break",
"batch",
"=",
"bat... | Worker loop for multiprocessing DataLoader. | [
"Worker",
"loop",
"for",
"multiprocessing",
"DataLoader",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L163-L170 |
23,425 | apache/incubator-mxnet | python/mxnet/gluon/data/dataloader.py | fetcher_loop_v1 | def fetcher_loop_v1(data_queue, data_buffer, pin_memory=False,
pin_device_id=0, data_buffer_lock=None):
"""Fetcher loop for fetching data from queue and put in reorder dict."""
while True:
idx, batch = data_queue.get()
if idx is None:
break
if pin_memory:
... | python | def fetcher_loop_v1(data_queue, data_buffer, pin_memory=False,
pin_device_id=0, data_buffer_lock=None):
"""Fetcher loop for fetching data from queue and put in reorder dict."""
while True:
idx, batch = data_queue.get()
if idx is None:
break
if pin_memory:
... | [
"def",
"fetcher_loop_v1",
"(",
"data_queue",
",",
"data_buffer",
",",
"pin_memory",
"=",
"False",
",",
"pin_device_id",
"=",
"0",
",",
"data_buffer_lock",
"=",
"None",
")",
":",
"while",
"True",
":",
"idx",
",",
"batch",
"=",
"data_queue",
".",
"get",
"(",... | Fetcher loop for fetching data from queue and put in reorder dict. | [
"Fetcher",
"loop",
"for",
"fetching",
"data",
"from",
"queue",
"and",
"put",
"in",
"reorder",
"dict",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L172-L187 |
23,426 | apache/incubator-mxnet | python/mxnet/gluon/data/dataloader.py | _MultiWorkerIterV1.shutdown | def shutdown(self):
"""Shutdown internal workers by pushing terminate signals."""
if not self._shutdown:
# send shutdown signal to the fetcher and join data queue first
# Remark: loop_fetcher need to be joined prior to the workers.
# otherwise, the the fet... | python | def shutdown(self):
"""Shutdown internal workers by pushing terminate signals."""
if not self._shutdown:
# send shutdown signal to the fetcher and join data queue first
# Remark: loop_fetcher need to be joined prior to the workers.
# otherwise, the the fet... | [
"def",
"shutdown",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_shutdown",
":",
"# send shutdown signal to the fetcher and join data queue first",
"# Remark: loop_fetcher need to be joined prior to the workers.",
"# otherwise, the the fetcher may fail at getting data",
... | Shutdown internal workers by pushing terminate signals. | [
"Shutdown",
"internal",
"workers",
"by",
"pushing",
"terminate",
"signals",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/data/dataloader.py#L266-L281 |
23,427 | apache/incubator-mxnet | python/mxnet/kvstore.py | _ctype_key_value | def _ctype_key_value(keys, vals):
"""
Returns ctype arrays for the key-value args, and the whether string keys are used.
For internal use only.
"""
if isinstance(keys, (tuple, list)):
assert(len(keys) == len(vals))
c_keys = []
c_vals = []
use_str_keys = None
f... | python | def _ctype_key_value(keys, vals):
"""
Returns ctype arrays for the key-value args, and the whether string keys are used.
For internal use only.
"""
if isinstance(keys, (tuple, list)):
assert(len(keys) == len(vals))
c_keys = []
c_vals = []
use_str_keys = None
f... | [
"def",
"_ctype_key_value",
"(",
"keys",
",",
"vals",
")",
":",
"if",
"isinstance",
"(",
"keys",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"assert",
"(",
"len",
"(",
"keys",
")",
"==",
"len",
"(",
"vals",
")",
")",
"c_keys",
"=",
"[",
"]",
... | Returns ctype arrays for the key-value args, and the whether string keys are used.
For internal use only. | [
"Returns",
"ctype",
"arrays",
"for",
"the",
"key",
"-",
"value",
"args",
"and",
"the",
"whether",
"string",
"keys",
"are",
"used",
".",
"For",
"internal",
"use",
"only",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L33-L66 |
23,428 | apache/incubator-mxnet | python/mxnet/kvstore.py | create | def create(name='local'):
"""Creates a new KVStore.
For single machine training, there are two commonly used types:
``local``: Copies all gradients to CPU memory and updates weights there.
``device``: Aggregates gradients and updates weights on GPUs. With this setting,
the KVStore also attempts t... | python | def create(name='local'):
"""Creates a new KVStore.
For single machine training, there are two commonly used types:
``local``: Copies all gradients to CPU memory and updates weights there.
``device``: Aggregates gradients and updates weights on GPUs. With this setting,
the KVStore also attempts t... | [
"def",
"create",
"(",
"name",
"=",
"'local'",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'name must be a string'",
")",
"handle",
"=",
"KVStoreHandle",
"(",
")",
"check_call",
"(",
"_LIB",
"... | Creates a new KVStore.
For single machine training, there are two commonly used types:
``local``: Copies all gradients to CPU memory and updates weights there.
``device``: Aggregates gradients and updates weights on GPUs. With this setting,
the KVStore also attempts to use GPU peer-to-peer communicat... | [
"Creates",
"a",
"new",
"KVStore",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L635-L677 |
23,429 | apache/incubator-mxnet | python/mxnet/kvstore.py | KVStore.init | def init(self, key, value):
""" Initializes a single or a sequence of key-value pairs into the store.
For each key, one must `init` it before calling `push` or `pull`.
When multiple workers invoke `init` for the same key, only
the value supplied by worker with rank `0` is used. This fun... | python | def init(self, key, value):
""" Initializes a single or a sequence of key-value pairs into the store.
For each key, one must `init` it before calling `push` or `pull`.
When multiple workers invoke `init` for the same key, only
the value supplied by worker with rank `0` is used. This fun... | [
"def",
"init",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"ckeys",
",",
"cvals",
",",
"use_str_keys",
"=",
"_ctype_key_value",
"(",
"key",
",",
"value",
")",
"if",
"use_str_keys",
":",
"check_call",
"(",
"_LIB",
".",
"MXKVStoreInitEx",
"(",
"self",... | Initializes a single or a sequence of key-value pairs into the store.
For each key, one must `init` it before calling `push` or `pull`.
When multiple workers invoke `init` for the same key, only
the value supplied by worker with rank `0` is used. This function returns
after data has bee... | [
"Initializes",
"a",
"single",
"or",
"a",
"sequence",
"of",
"key",
"-",
"value",
"pairs",
"into",
"the",
"store",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L116-L158 |
23,430 | apache/incubator-mxnet | python/mxnet/kvstore.py | KVStore.push | def push(self, key, value, priority=0):
""" Pushes a single or a sequence of key-value pairs into the store.
This function returns immediately after adding an operator to the engine.
The actual operation is executed asynchronously. If there are consecutive
pushes to the same key, there ... | python | def push(self, key, value, priority=0):
""" Pushes a single or a sequence of key-value pairs into the store.
This function returns immediately after adding an operator to the engine.
The actual operation is executed asynchronously. If there are consecutive
pushes to the same key, there ... | [
"def",
"push",
"(",
"self",
",",
"key",
",",
"value",
",",
"priority",
"=",
"0",
")",
":",
"ckeys",
",",
"cvals",
",",
"use_str_keys",
"=",
"_ctype_key_value",
"(",
"key",
",",
"value",
")",
"if",
"use_str_keys",
":",
"check_call",
"(",
"_LIB",
".",
... | Pushes a single or a sequence of key-value pairs into the store.
This function returns immediately after adding an operator to the engine.
The actual operation is executed asynchronously. If there are consecutive
pushes to the same key, there is no guarantee on the serialization of pushes.
... | [
"Pushes",
"a",
"single",
"or",
"a",
"sequence",
"of",
"key",
"-",
"value",
"pairs",
"into",
"the",
"store",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L160-L237 |
23,431 | apache/incubator-mxnet | python/mxnet/kvstore.py | KVStore.pull | def pull(self, key, out=None, priority=0, ignore_sparse=True):
""" Pulls a single value or a sequence of values from the store.
This function returns immediately after adding an operator to the engine.
Subsequent attempts to read from the `out` variable will be blocked until the
pull op... | python | def pull(self, key, out=None, priority=0, ignore_sparse=True):
""" Pulls a single value or a sequence of values from the store.
This function returns immediately after adding an operator to the engine.
Subsequent attempts to read from the `out` variable will be blocked until the
pull op... | [
"def",
"pull",
"(",
"self",
",",
"key",
",",
"out",
"=",
"None",
",",
"priority",
"=",
"0",
",",
"ignore_sparse",
"=",
"True",
")",
":",
"assert",
"(",
"out",
"is",
"not",
"None",
")",
"ckeys",
",",
"cvals",
",",
"use_str_keys",
"=",
"_ctype_key_valu... | Pulls a single value or a sequence of values from the store.
This function returns immediately after adding an operator to the engine.
Subsequent attempts to read from the `out` variable will be blocked until the
pull operation completes.
`pull` is executed asynchronously after all pre... | [
"Pulls",
"a",
"single",
"value",
"or",
"a",
"sequence",
"of",
"values",
"from",
"the",
"store",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L240-L312 |
23,432 | apache/incubator-mxnet | python/mxnet/kvstore.py | KVStore.row_sparse_pull | def row_sparse_pull(self, key, out=None, priority=0, row_ids=None):
""" Pulls a single RowSparseNDArray value or a sequence of RowSparseNDArray values \
from the store with specified row_ids. When there is only one row_id, KVStoreRowSparsePull \
is invoked just once and the result is broadcast t... | python | def row_sparse_pull(self, key, out=None, priority=0, row_ids=None):
""" Pulls a single RowSparseNDArray value or a sequence of RowSparseNDArray values \
from the store with specified row_ids. When there is only one row_id, KVStoreRowSparsePull \
is invoked just once and the result is broadcast t... | [
"def",
"row_sparse_pull",
"(",
"self",
",",
"key",
",",
"out",
"=",
"None",
",",
"priority",
"=",
"0",
",",
"row_ids",
"=",
"None",
")",
":",
"assert",
"(",
"out",
"is",
"not",
"None",
")",
"assert",
"(",
"row_ids",
"is",
"not",
"None",
")",
"if",
... | Pulls a single RowSparseNDArray value or a sequence of RowSparseNDArray values \
from the store with specified row_ids. When there is only one row_id, KVStoreRowSparsePull \
is invoked just once and the result is broadcast to all the rest of outputs.
`row_sparse_pull` is executed asynchronously... | [
"Pulls",
"a",
"single",
"RowSparseNDArray",
"value",
"or",
"a",
"sequence",
"of",
"RowSparseNDArray",
"values",
"\\",
"from",
"the",
"store",
"with",
"specified",
"row_ids",
".",
"When",
"there",
"is",
"only",
"one",
"row_id",
"KVStoreRowSparsePull",
"\\",
"is",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L314-L392 |
23,433 | apache/incubator-mxnet | python/mxnet/kvstore.py | KVStore.set_gradient_compression | def set_gradient_compression(self, compression_params):
""" Specifies type of low-bit quantization for gradient compression \
and additional arguments depending on the type of compression being used.
2bit Gradient Compression takes a positive float `threshold`.
The technique works by t... | python | def set_gradient_compression(self, compression_params):
""" Specifies type of low-bit quantization for gradient compression \
and additional arguments depending on the type of compression being used.
2bit Gradient Compression takes a positive float `threshold`.
The technique works by t... | [
"def",
"set_gradient_compression",
"(",
"self",
",",
"compression_params",
")",
":",
"if",
"(",
"'device'",
"in",
"self",
".",
"type",
")",
"or",
"(",
"'dist'",
"in",
"self",
".",
"type",
")",
":",
"# pylint: disable=unsupported-membership-test",
"ckeys",
",",
... | Specifies type of low-bit quantization for gradient compression \
and additional arguments depending on the type of compression being used.
2bit Gradient Compression takes a positive float `threshold`.
The technique works by thresholding values such that positive values in the
gradient... | [
"Specifies",
"type",
"of",
"low",
"-",
"bit",
"quantization",
"for",
"gradient",
"compression",
"\\",
"and",
"additional",
"arguments",
"depending",
"on",
"the",
"type",
"of",
"compression",
"being",
"used",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L394-L448 |
23,434 | apache/incubator-mxnet | python/mxnet/kvstore.py | KVStore.set_optimizer | def set_optimizer(self, optimizer):
""" Registers an optimizer with the kvstore.
When using a single machine, this function updates the local optimizer.
If using multiple machines and this operation is invoked from a worker node,
it will serialized the optimizer with pickle and send it ... | python | def set_optimizer(self, optimizer):
""" Registers an optimizer with the kvstore.
When using a single machine, this function updates the local optimizer.
If using multiple machines and this operation is invoked from a worker node,
it will serialized the optimizer with pickle and send it ... | [
"def",
"set_optimizer",
"(",
"self",
",",
"optimizer",
")",
":",
"is_worker",
"=",
"ctypes",
".",
"c_int",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXKVStoreIsWorkerNode",
"(",
"ctypes",
".",
"byref",
"(",
"is_worker",
")",
")",
")",
"# pylint: disable=inv... | Registers an optimizer with the kvstore.
When using a single machine, this function updates the local optimizer.
If using multiple machines and this operation is invoked from a worker node,
it will serialized the optimizer with pickle and send it to all servers.
The function returns aft... | [
"Registers",
"an",
"optimizer",
"with",
"the",
"kvstore",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L450-L497 |
23,435 | apache/incubator-mxnet | python/mxnet/kvstore.py | KVStore.type | def type(self):
""" Returns the type of this kvstore.
Returns
-------
type : str
the string type
"""
kv_type = ctypes.c_char_p()
check_call(_LIB.MXKVStoreGetType(self.handle, ctypes.byref(kv_type)))
return py_str(kv_type.value) | python | def type(self):
""" Returns the type of this kvstore.
Returns
-------
type : str
the string type
"""
kv_type = ctypes.c_char_p()
check_call(_LIB.MXKVStoreGetType(self.handle, ctypes.byref(kv_type)))
return py_str(kv_type.value) | [
"def",
"type",
"(",
"self",
")",
":",
"kv_type",
"=",
"ctypes",
".",
"c_char_p",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXKVStoreGetType",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"kv_type",
")",
")",
")",
"return",
"py_str",
... | Returns the type of this kvstore.
Returns
-------
type : str
the string type | [
"Returns",
"the",
"type",
"of",
"this",
"kvstore",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L500-L510 |
23,436 | apache/incubator-mxnet | python/mxnet/kvstore.py | KVStore.rank | def rank(self):
""" Returns the rank of this worker node.
Returns
-------
rank : int
The rank of this node, which is in range [0, num_workers())
"""
rank = ctypes.c_int()
check_call(_LIB.MXKVStoreGetRank(self.handle, ctypes.byref(rank)))
retur... | python | def rank(self):
""" Returns the rank of this worker node.
Returns
-------
rank : int
The rank of this node, which is in range [0, num_workers())
"""
rank = ctypes.c_int()
check_call(_LIB.MXKVStoreGetRank(self.handle, ctypes.byref(rank)))
retur... | [
"def",
"rank",
"(",
"self",
")",
":",
"rank",
"=",
"ctypes",
".",
"c_int",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXKVStoreGetRank",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"rank",
")",
")",
")",
"return",
"rank",
".",
"va... | Returns the rank of this worker node.
Returns
-------
rank : int
The rank of this node, which is in range [0, num_workers()) | [
"Returns",
"the",
"rank",
"of",
"this",
"worker",
"node",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L513-L523 |
23,437 | apache/incubator-mxnet | python/mxnet/kvstore.py | KVStore.num_workers | def num_workers(self):
"""Returns the number of worker nodes.
Returns
-------
size :int
The number of worker nodes.
"""
size = ctypes.c_int()
check_call(_LIB.MXKVStoreGetGroupSize(self.handle, ctypes.byref(size)))
return size.value | python | def num_workers(self):
"""Returns the number of worker nodes.
Returns
-------
size :int
The number of worker nodes.
"""
size = ctypes.c_int()
check_call(_LIB.MXKVStoreGetGroupSize(self.handle, ctypes.byref(size)))
return size.value | [
"def",
"num_workers",
"(",
"self",
")",
":",
"size",
"=",
"ctypes",
".",
"c_int",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXKVStoreGetGroupSize",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"size",
")",
")",
")",
"return",
"size",
... | Returns the number of worker nodes.
Returns
-------
size :int
The number of worker nodes. | [
"Returns",
"the",
"number",
"of",
"worker",
"nodes",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L526-L536 |
23,438 | apache/incubator-mxnet | python/mxnet/kvstore.py | KVStore._set_updater | def _set_updater(self, updater):
"""Sets a push updater into the store.
This function only changes the local store. When running on multiple machines one must
use `set_optimizer`.
Parameters
----------
updater : function
The updater function.
Exampl... | python | def _set_updater(self, updater):
"""Sets a push updater into the store.
This function only changes the local store. When running on multiple machines one must
use `set_optimizer`.
Parameters
----------
updater : function
The updater function.
Exampl... | [
"def",
"_set_updater",
"(",
"self",
",",
"updater",
")",
":",
"self",
".",
"_updater",
"=",
"updater",
"# set updater with int keys",
"_updater_proto",
"=",
"ctypes",
".",
"CFUNCTYPE",
"(",
"None",
",",
"ctypes",
".",
"c_int",
",",
"NDArrayHandle",
",",
"NDArr... | Sets a push updater into the store.
This function only changes the local store. When running on multiple machines one must
use `set_optimizer`.
Parameters
----------
updater : function
The updater function.
Examples
--------
>>> def update(k... | [
"Sets",
"a",
"push",
"updater",
"into",
"the",
"store",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L565-L603 |
23,439 | apache/incubator-mxnet | python/mxnet/kvstore.py | KVStore._send_command_to_servers | def _send_command_to_servers(self, head, body):
"""Sends a command to all server nodes.
Sending command to a server node will cause that server node to invoke
``KVStoreServer.controller`` to execute the command.
This function returns after the command has been executed on all server
... | python | def _send_command_to_servers(self, head, body):
"""Sends a command to all server nodes.
Sending command to a server node will cause that server node to invoke
``KVStoreServer.controller`` to execute the command.
This function returns after the command has been executed on all server
... | [
"def",
"_send_command_to_servers",
"(",
"self",
",",
"head",
",",
"body",
")",
":",
"check_call",
"(",
"_LIB",
".",
"MXKVStoreSendCommmandToServers",
"(",
"self",
".",
"handle",
",",
"mx_uint",
"(",
"head",
")",
",",
"c_str",
"(",
"body",
")",
")",
")"
] | Sends a command to all server nodes.
Sending command to a server node will cause that server node to invoke
``KVStoreServer.controller`` to execute the command.
This function returns after the command has been executed on all server
nodes.
Parameters
----------
... | [
"Sends",
"a",
"command",
"to",
"all",
"server",
"nodes",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/kvstore.py#L616-L633 |
23,440 | apache/incubator-mxnet | python/mxnet/module/sequential_module.py | SequentialModule.add | def add(self, module, **kwargs):
"""Add a module to the chain.
Parameters
----------
module : BaseModule
The new module to add.
kwargs : ``**keywords``
All the keyword arguments are saved as meta information
for the added module. The currently... | python | def add(self, module, **kwargs):
"""Add a module to the chain.
Parameters
----------
module : BaseModule
The new module to add.
kwargs : ``**keywords``
All the keyword arguments are saved as meta information
for the added module. The currently... | [
"def",
"add",
"(",
"self",
",",
"module",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_modules",
".",
"append",
"(",
"module",
")",
"# a sanity check to avoid typo",
"for",
"key",
"in",
"kwargs",
":",
"assert",
"key",
"in",
"self",
".",
"_meta_keys"... | Add a module to the chain.
Parameters
----------
module : BaseModule
The new module to add.
kwargs : ``**keywords``
All the keyword arguments are saved as meta information
for the added module. The currently known meta includes
- `take_la... | [
"Add",
"a",
"module",
"to",
"the",
"chain",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/sequential_module.py#L52-L97 |
23,441 | apache/incubator-mxnet | python/mxnet/module/sequential_module.py | SequentialModule.install_monitor | def install_monitor(self, mon):
"""Installs monitor on all executors."""
assert self.binded
for module in self._modules:
module.install_monitor(mon) | python | def install_monitor(self, mon):
"""Installs monitor on all executors."""
assert self.binded
for module in self._modules:
module.install_monitor(mon) | [
"def",
"install_monitor",
"(",
"self",
",",
"mon",
")",
":",
"assert",
"self",
".",
"binded",
"for",
"module",
"in",
"self",
".",
"_modules",
":",
"module",
".",
"install_monitor",
"(",
"mon",
")"
] | Installs monitor on all executors. | [
"Installs",
"monitor",
"on",
"all",
"executors",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/sequential_module.py#L436-L440 |
23,442 | apache/incubator-mxnet | example/caffe/data.py | get_iterator | def get_iterator(data_shape, use_caffe_data):
"""Generate the iterator of mnist dataset"""
def get_iterator_impl_mnist(args, kv):
"""return train and val iterators for mnist"""
# download data
get_mnist_ubyte()
flat = False if len(data_shape) != 1 else True
train = mx.io... | python | def get_iterator(data_shape, use_caffe_data):
"""Generate the iterator of mnist dataset"""
def get_iterator_impl_mnist(args, kv):
"""return train and val iterators for mnist"""
# download data
get_mnist_ubyte()
flat = False if len(data_shape) != 1 else True
train = mx.io... | [
"def",
"get_iterator",
"(",
"data_shape",
",",
"use_caffe_data",
")",
":",
"def",
"get_iterator_impl_mnist",
"(",
"args",
",",
"kv",
")",
":",
"\"\"\"return train and val iterators for mnist\"\"\"",
"# download data",
"get_mnist_ubyte",
"(",
")",
"flat",
"=",
"False",
... | Generate the iterator of mnist dataset | [
"Generate",
"the",
"iterator",
"of",
"mnist",
"dataset"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/caffe/data.py#L22-L106 |
23,443 | apache/incubator-mxnet | example/gluon/audio/urban_sounds/predict.py | predict | def predict(prediction_dir='./Test'):
"""The function is used to run predictions on the audio files in the directory `pred_directory`.
Parameters
----------
net:
The model that has been trained.
prediction_dir: string, default ./Test
The directory that contains the audio files on wh... | python | def predict(prediction_dir='./Test'):
"""The function is used to run predictions on the audio files in the directory `pred_directory`.
Parameters
----------
net:
The model that has been trained.
prediction_dir: string, default ./Test
The directory that contains the audio files on wh... | [
"def",
"predict",
"(",
"prediction_dir",
"=",
"'./Test'",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"prediction_dir",
")",
":",
"warnings",
".",
"warn",
"(",
"\"The directory on which predictions are to be made is not found!\"",
")",
"return",
... | The function is used to run predictions on the audio files in the directory `pred_directory`.
Parameters
----------
net:
The model that has been trained.
prediction_dir: string, default ./Test
The directory that contains the audio files on which predictions are to be made | [
"The",
"function",
"is",
"used",
"to",
"run",
"predictions",
"on",
"the",
"audio",
"files",
"in",
"the",
"directory",
"pred_directory",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/audio/urban_sounds/predict.py#L32-L77 |
23,444 | apache/incubator-mxnet | example/ctc/multiproc_data.py | MPData._proc_loop | def _proc_loop(proc_id, alive, queue, fn):
"""Thread loop for generating data
Parameters
----------
proc_id: int
Process id
alive: multiprocessing.Value
variable for signaling whether process should continue or not
queue: multiprocessing.Queue
... | python | def _proc_loop(proc_id, alive, queue, fn):
"""Thread loop for generating data
Parameters
----------
proc_id: int
Process id
alive: multiprocessing.Value
variable for signaling whether process should continue or not
queue: multiprocessing.Queue
... | [
"def",
"_proc_loop",
"(",
"proc_id",
",",
"alive",
",",
"queue",
",",
"fn",
")",
":",
"print",
"(",
"\"proc {} started\"",
".",
"format",
"(",
"proc_id",
")",
")",
"try",
":",
"while",
"alive",
".",
"value",
":",
"data",
"=",
"fn",
"(",
")",
"put_suc... | Thread loop for generating data
Parameters
----------
proc_id: int
Process id
alive: multiprocessing.Value
variable for signaling whether process should continue or not
queue: multiprocessing.Queue
queue for passing data back
fn: funct... | [
"Thread",
"loop",
"for",
"generating",
"data"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/multiproc_data.py#L59-L88 |
23,445 | apache/incubator-mxnet | example/ctc/multiproc_data.py | MPData._init_proc | def _init_proc(self):
"""Start processes if not already started"""
if not self.proc:
self.proc = [
mp.Process(target=self._proc_loop, args=(i, self.alive, self.queue, self.fn))
for i in range(self.num_proc)
]
self.alive.value = True
... | python | def _init_proc(self):
"""Start processes if not already started"""
if not self.proc:
self.proc = [
mp.Process(target=self._proc_loop, args=(i, self.alive, self.queue, self.fn))
for i in range(self.num_proc)
]
self.alive.value = True
... | [
"def",
"_init_proc",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"proc",
":",
"self",
".",
"proc",
"=",
"[",
"mp",
".",
"Process",
"(",
"target",
"=",
"self",
".",
"_proc_loop",
",",
"args",
"=",
"(",
"i",
",",
"self",
".",
"alive",
",",
"... | Start processes if not already started | [
"Start",
"processes",
"if",
"not",
"already",
"started"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/multiproc_data.py#L90-L99 |
23,446 | apache/incubator-mxnet | example/ctc/multiproc_data.py | MPData.reset | def reset(self):
"""Resets the generator by stopping all processes"""
self.alive.value = False
qsize = 0
try:
while True:
self.queue.get(timeout=0.1)
qsize += 1
except QEmptyExcept:
pass
print("Queue size on reset: {... | python | def reset(self):
"""Resets the generator by stopping all processes"""
self.alive.value = False
qsize = 0
try:
while True:
self.queue.get(timeout=0.1)
qsize += 1
except QEmptyExcept:
pass
print("Queue size on reset: {... | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"alive",
".",
"value",
"=",
"False",
"qsize",
"=",
"0",
"try",
":",
"while",
"True",
":",
"self",
".",
"queue",
".",
"get",
"(",
"timeout",
"=",
"0.1",
")",
"qsize",
"+=",
"1",
"except",
"QEmpty... | Resets the generator by stopping all processes | [
"Resets",
"the",
"generator",
"by",
"stopping",
"all",
"processes"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/multiproc_data.py#L112-L125 |
23,447 | apache/incubator-mxnet | python/mxnet/base.py | _load_lib | def _load_lib():
"""Load library by searching possible path."""
lib_path = libinfo.find_lib_path()
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
# DMatrix functions
lib.MXGetLastError.restype = ctypes.c_char_p
return lib | python | def _load_lib():
"""Load library by searching possible path."""
lib_path = libinfo.find_lib_path()
lib = ctypes.CDLL(lib_path[0], ctypes.RTLD_LOCAL)
# DMatrix functions
lib.MXGetLastError.restype = ctypes.c_char_p
return lib | [
"def",
"_load_lib",
"(",
")",
":",
"lib_path",
"=",
"libinfo",
".",
"find_lib_path",
"(",
")",
"lib",
"=",
"ctypes",
".",
"CDLL",
"(",
"lib_path",
"[",
"0",
"]",
",",
"ctypes",
".",
"RTLD_LOCAL",
")",
"# DMatrix functions",
"lib",
".",
"MXGetLastError",
... | Load library by searching possible path. | [
"Load",
"library",
"by",
"searching",
"possible",
"path",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/base.py#L202-L208 |
23,448 | apache/incubator-mxnet | python/mxnet/base.py | c_array | def c_array(ctype, values):
"""Create ctypes array from a Python array.
Parameters
----------
ctype : ctypes data type
Data type of the array we want to convert to, such as mx_float.
values : tuple or list
Data content.
Returns
-------
out : ctypes array
Create... | python | def c_array(ctype, values):
"""Create ctypes array from a Python array.
Parameters
----------
ctype : ctypes data type
Data type of the array we want to convert to, such as mx_float.
values : tuple or list
Data content.
Returns
-------
out : ctypes array
Create... | [
"def",
"c_array",
"(",
"ctype",
",",
"values",
")",
":",
"out",
"=",
"(",
"ctype",
"*",
"len",
"(",
"values",
")",
")",
"(",
")",
"out",
"[",
":",
"]",
"=",
"values",
"return",
"out"
] | Create ctypes array from a Python array.
Parameters
----------
ctype : ctypes data type
Data type of the array we want to convert to, such as mx_float.
values : tuple or list
Data content.
Returns
-------
out : ctypes array
Created ctypes array.
Examples
-... | [
"Create",
"ctypes",
"array",
"from",
"a",
"Python",
"array",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/base.py#L336-L362 |
23,449 | apache/incubator-mxnet | python/mxnet/base.py | ctypes2numpy_shared | def ctypes2numpy_shared(cptr, shape):
"""Convert a ctypes pointer to a numpy array.
The resulting NumPy array shares the memory with the pointer.
Parameters
----------
cptr : ctypes.POINTER(mx_float)
pointer to the memory region
shape : tuple
Shape of target `NDArray`.
Re... | python | def ctypes2numpy_shared(cptr, shape):
"""Convert a ctypes pointer to a numpy array.
The resulting NumPy array shares the memory with the pointer.
Parameters
----------
cptr : ctypes.POINTER(mx_float)
pointer to the memory region
shape : tuple
Shape of target `NDArray`.
Re... | [
"def",
"ctypes2numpy_shared",
"(",
"cptr",
",",
"shape",
")",
":",
"if",
"not",
"isinstance",
"(",
"cptr",
",",
"ctypes",
".",
"POINTER",
"(",
"mx_float",
")",
")",
":",
"raise",
"RuntimeError",
"(",
"'expected float pointer'",
")",
"size",
"=",
"1",
"for"... | Convert a ctypes pointer to a numpy array.
The resulting NumPy array shares the memory with the pointer.
Parameters
----------
cptr : ctypes.POINTER(mx_float)
pointer to the memory region
shape : tuple
Shape of target `NDArray`.
Returns
-------
out : numpy_array
... | [
"Convert",
"a",
"ctypes",
"pointer",
"to",
"a",
"numpy",
"array",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/base.py#L436-L460 |
23,450 | apache/incubator-mxnet | python/mxnet/base.py | build_param_doc | def build_param_doc(arg_names, arg_types, arg_descs, remove_dup=True):
"""Build argument docs in python style.
arg_names : list of str
Argument names.
arg_types : list of str
Argument type information.
arg_descs : list of str
Argument description information.
remove_dup :... | python | def build_param_doc(arg_names, arg_types, arg_descs, remove_dup=True):
"""Build argument docs in python style.
arg_names : list of str
Argument names.
arg_types : list of str
Argument type information.
arg_descs : list of str
Argument description information.
remove_dup :... | [
"def",
"build_param_doc",
"(",
"arg_names",
",",
"arg_types",
",",
"arg_descs",
",",
"remove_dup",
"=",
"True",
")",
":",
"param_keys",
"=",
"set",
"(",
")",
"param_str",
"=",
"[",
"]",
"for",
"key",
",",
"type_info",
",",
"desc",
"in",
"zip",
"(",
"ar... | Build argument docs in python style.
arg_names : list of str
Argument names.
arg_types : list of str
Argument type information.
arg_descs : list of str
Argument description information.
remove_dup : boolean, optional
Whether remove duplication or not.
Returns
... | [
"Build",
"argument",
"docs",
"in",
"python",
"style",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/base.py#L463-L499 |
23,451 | apache/incubator-mxnet | python/mxnet/base.py | add_fileline_to_docstring | def add_fileline_to_docstring(module, incursive=True):
"""Append the definition position to each function contained in module.
Examples
--------
# Put the following codes at the end of a file
add_fileline_to_docstring(__name__)
"""
def _add_fileline(obj):
"""Add fileinto to a objec... | python | def add_fileline_to_docstring(module, incursive=True):
"""Append the definition position to each function contained in module.
Examples
--------
# Put the following codes at the end of a file
add_fileline_to_docstring(__name__)
"""
def _add_fileline(obj):
"""Add fileinto to a objec... | [
"def",
"add_fileline_to_docstring",
"(",
"module",
",",
"incursive",
"=",
"True",
")",
":",
"def",
"_add_fileline",
"(",
"obj",
")",
":",
"\"\"\"Add fileinto to a object.\n \"\"\"",
"if",
"obj",
".",
"__doc__",
"is",
"None",
"or",
"'From:'",
"in",
"obj",
... | Append the definition position to each function contained in module.
Examples
--------
# Put the following codes at the end of a file
add_fileline_to_docstring(__name__) | [
"Append",
"the",
"definition",
"position",
"to",
"each",
"function",
"contained",
"in",
"module",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/base.py#L510-L543 |
23,452 | apache/incubator-mxnet | python/mxnet/base.py | is_np_compat | def is_np_compat():
"""
Checks whether the NumPy compatibility is currently turned on.
NumPy-compatibility is turned off by default in backend.
Returns
-------
A bool value indicating whether the NumPy compatibility is currently on.
"""
curr = ctypes.c_bool()
check_call(_LIB.MXI... | python | def is_np_compat():
"""
Checks whether the NumPy compatibility is currently turned on.
NumPy-compatibility is turned off by default in backend.
Returns
-------
A bool value indicating whether the NumPy compatibility is currently on.
"""
curr = ctypes.c_bool()
check_call(_LIB.MXI... | [
"def",
"is_np_compat",
"(",
")",
":",
"curr",
"=",
"ctypes",
".",
"c_bool",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXIsNumpyCompatible",
"(",
"ctypes",
".",
"byref",
"(",
"curr",
")",
")",
")",
"return",
"curr",
".",
"value"
] | Checks whether the NumPy compatibility is currently turned on.
NumPy-compatibility is turned off by default in backend.
Returns
-------
A bool value indicating whether the NumPy compatibility is currently on. | [
"Checks",
"whether",
"the",
"NumPy",
"compatibility",
"is",
"currently",
"turned",
"on",
".",
"NumPy",
"-",
"compatibility",
"is",
"turned",
"off",
"by",
"default",
"in",
"backend",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/base.py#L758-L769 |
23,453 | apache/incubator-mxnet | python/mxnet/base.py | use_np_compat | def use_np_compat(func):
"""Wraps a function with an activated NumPy-compatibility scope. This ensures
that the execution of the function is guaranteed with NumPy compatible semantics,
such as zero-dim and zero size tensors.
Example::
import mxnet as mx
@mx.use_np_compat
def sca... | python | def use_np_compat(func):
"""Wraps a function with an activated NumPy-compatibility scope. This ensures
that the execution of the function is guaranteed with NumPy compatible semantics,
such as zero-dim and zero size tensors.
Example::
import mxnet as mx
@mx.use_np_compat
def sca... | [
"def",
"use_np_compat",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"_with_np_compat",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"np_compat",
"(",
"active",
"=",
"True",
")",
":",
"return",
"func",
"(",
"*",
"ar... | Wraps a function with an activated NumPy-compatibility scope. This ensures
that the execution of the function is guaranteed with NumPy compatible semantics,
such as zero-dim and zero size tensors.
Example::
import mxnet as mx
@mx.use_np_compat
def scalar_one():
return mx... | [
"Wraps",
"a",
"function",
"with",
"an",
"activated",
"NumPy",
"-",
"compatibility",
"scope",
".",
"This",
"ensures",
"that",
"the",
"execution",
"of",
"the",
"function",
"is",
"guaranteed",
"with",
"NumPy",
"compatible",
"semantics",
"such",
"as",
"zero",
"-",... | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/base.py#L848-L874 |
23,454 | apache/incubator-mxnet | example/multivariate_time_series/src/metrics.py | corr | def corr(label, pred):
"""computes the empirical correlation coefficient"""
numerator1 = label - np.mean(label, axis=0)
numerator2 = pred - np.mean(pred, axis = 0)
numerator = np.mean(numerator1 * numerator2, axis=0)
denominator = np.std(label, axis=0) * np.std(pred, axis=0)
return np.mean(numer... | python | def corr(label, pred):
"""computes the empirical correlation coefficient"""
numerator1 = label - np.mean(label, axis=0)
numerator2 = pred - np.mean(pred, axis = 0)
numerator = np.mean(numerator1 * numerator2, axis=0)
denominator = np.std(label, axis=0) * np.std(pred, axis=0)
return np.mean(numer... | [
"def",
"corr",
"(",
"label",
",",
"pred",
")",
":",
"numerator1",
"=",
"label",
"-",
"np",
".",
"mean",
"(",
"label",
",",
"axis",
"=",
"0",
")",
"numerator2",
"=",
"pred",
"-",
"np",
".",
"mean",
"(",
"pred",
",",
"axis",
"=",
"0",
")",
"numer... | computes the empirical correlation coefficient | [
"computes",
"the",
"empirical",
"correlation",
"coefficient"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/multivariate_time_series/src/metrics.py#L37-L43 |
23,455 | apache/incubator-mxnet | example/ssd/tools/caffe_converter/convert_symbol.py | _get_input | def _get_input(proto):
"""Get input size
"""
layer = caffe_parser.get_layers(proto)
if len(proto.input_dim) > 0:
input_dim = proto.input_dim
elif len(proto.input_shape) > 0:
input_dim = proto.input_shape[0].dim
elif layer[0].type == "Input":
input_dim = layer[0].input_par... | python | def _get_input(proto):
"""Get input size
"""
layer = caffe_parser.get_layers(proto)
if len(proto.input_dim) > 0:
input_dim = proto.input_dim
elif len(proto.input_shape) > 0:
input_dim = proto.input_shape[0].dim
elif layer[0].type == "Input":
input_dim = layer[0].input_par... | [
"def",
"_get_input",
"(",
"proto",
")",
":",
"layer",
"=",
"caffe_parser",
".",
"get_layers",
"(",
"proto",
")",
"if",
"len",
"(",
"proto",
".",
"input_dim",
")",
">",
"0",
":",
"input_dim",
"=",
"proto",
".",
"input_dim",
"elif",
"len",
"(",
"proto",
... | Get input size | [
"Get",
"input",
"size"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/tools/caffe_converter/convert_symbol.py#L23-L40 |
23,456 | apache/incubator-mxnet | example/ssd/tools/caffe_converter/convert_symbol.py | _convert_conv_param | def _convert_conv_param(param):
"""
Convert convolution layer parameter from Caffe to MXNet
"""
param_string = "num_filter=%d" % param.num_output
pad_w = 0
pad_h = 0
if isinstance(param.pad, int):
pad = param.pad
param_string += ", pad=(%d, %d)" % (pad, pad)
else:
... | python | def _convert_conv_param(param):
"""
Convert convolution layer parameter from Caffe to MXNet
"""
param_string = "num_filter=%d" % param.num_output
pad_w = 0
pad_h = 0
if isinstance(param.pad, int):
pad = param.pad
param_string += ", pad=(%d, %d)" % (pad, pad)
else:
... | [
"def",
"_convert_conv_param",
"(",
"param",
")",
":",
"param_string",
"=",
"\"num_filter=%d\"",
"%",
"param",
".",
"num_output",
"pad_w",
"=",
"0",
"pad_h",
"=",
"0",
"if",
"isinstance",
"(",
"param",
".",
"pad",
",",
"int",
")",
":",
"pad",
"=",
"param"... | Convert convolution layer parameter from Caffe to MXNet | [
"Convert",
"convolution",
"layer",
"parameter",
"from",
"Caffe",
"to",
"MXNet"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/tools/caffe_converter/convert_symbol.py#L42-L103 |
23,457 | apache/incubator-mxnet | example/ssd/tools/caffe_converter/convert_symbol.py | _convert_pooling_param | def _convert_pooling_param(param):
"""Convert the pooling layer parameter
"""
param_string = "pooling_convention='full', "
if param.global_pooling:
param_string += "global_pool=True, kernel=(1,1)"
else:
param_string += "pad=(%d,%d), kernel=(%d,%d), stride=(%d,%d)" % (
par... | python | def _convert_pooling_param(param):
"""Convert the pooling layer parameter
"""
param_string = "pooling_convention='full', "
if param.global_pooling:
param_string += "global_pool=True, kernel=(1,1)"
else:
param_string += "pad=(%d,%d), kernel=(%d,%d), stride=(%d,%d)" % (
par... | [
"def",
"_convert_pooling_param",
"(",
"param",
")",
":",
"param_string",
"=",
"\"pooling_convention='full', \"",
"if",
"param",
".",
"global_pooling",
":",
"param_string",
"+=",
"\"global_pool=True, kernel=(1,1)\"",
"else",
":",
"param_string",
"+=",
"\"pad=(%d,%d), kernel=... | Convert the pooling layer parameter | [
"Convert",
"the",
"pooling",
"layer",
"parameter"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/tools/caffe_converter/convert_symbol.py#L105-L121 |
23,458 | apache/incubator-mxnet | example/ssd/tools/caffe_converter/caffe_parse/parse_from_protobuf.py | parse_caffemodel | def parse_caffemodel(file_path):
"""
parses the trained .caffemodel file
filepath: /path/to/trained-model.caffemodel
returns: layers
"""
f = open(file_path, 'rb')
contents = f.read()
net_param = caffe_pb2.NetParameter()
net_param.ParseFromString(contents)
layers = find_layers... | python | def parse_caffemodel(file_path):
"""
parses the trained .caffemodel file
filepath: /path/to/trained-model.caffemodel
returns: layers
"""
f = open(file_path, 'rb')
contents = f.read()
net_param = caffe_pb2.NetParameter()
net_param.ParseFromString(contents)
layers = find_layers... | [
"def",
"parse_caffemodel",
"(",
"file_path",
")",
":",
"f",
"=",
"open",
"(",
"file_path",
",",
"'rb'",
")",
"contents",
"=",
"f",
".",
"read",
"(",
")",
"net_param",
"=",
"caffe_pb2",
".",
"NetParameter",
"(",
")",
"net_param",
".",
"ParseFromString",
"... | parses the trained .caffemodel file
filepath: /path/to/trained-model.caffemodel
returns: layers | [
"parses",
"the",
"trained",
".",
"caffemodel",
"file"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/tools/caffe_converter/caffe_parse/parse_from_protobuf.py#L23-L38 |
23,459 | apache/incubator-mxnet | example/gluon/embedding_learning/data.py | transform | def transform(data, target_wd, target_ht, is_train, box):
"""Crop and normnalize an image nd array."""
if box is not None:
x, y, w, h = box
data = data[y:min(y+h, data.shape[0]), x:min(x+w, data.shape[1])]
# Resize to target_wd * target_ht.
data = mx.image.imresize(data, target_wd, targ... | python | def transform(data, target_wd, target_ht, is_train, box):
"""Crop and normnalize an image nd array."""
if box is not None:
x, y, w, h = box
data = data[y:min(y+h, data.shape[0]), x:min(x+w, data.shape[1])]
# Resize to target_wd * target_ht.
data = mx.image.imresize(data, target_wd, targ... | [
"def",
"transform",
"(",
"data",
",",
"target_wd",
",",
"target_ht",
",",
"is_train",
",",
"box",
")",
":",
"if",
"box",
"is",
"not",
"None",
":",
"x",
",",
"y",
",",
"w",
",",
"h",
"=",
"box",
"data",
"=",
"data",
"[",
"y",
":",
"min",
"(",
... | Crop and normnalize an image nd array. | [
"Crop",
"and",
"normnalize",
"an",
"image",
"nd",
"array",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/embedding_learning/data.py#L26-L53 |
23,460 | apache/incubator-mxnet | example/gluon/embedding_learning/data.py | cub200_iterator | def cub200_iterator(data_path, batch_k, batch_size, data_shape):
"""Return training and testing iterator for the CUB200-2011 dataset."""
return (CUB200Iter(data_path, batch_k, batch_size, data_shape, is_train=True),
CUB200Iter(data_path, batch_k, batch_size, data_shape, is_train=False)) | python | def cub200_iterator(data_path, batch_k, batch_size, data_shape):
"""Return training and testing iterator for the CUB200-2011 dataset."""
return (CUB200Iter(data_path, batch_k, batch_size, data_shape, is_train=True),
CUB200Iter(data_path, batch_k, batch_size, data_shape, is_train=False)) | [
"def",
"cub200_iterator",
"(",
"data_path",
",",
"batch_k",
",",
"batch_size",
",",
"data_shape",
")",
":",
"return",
"(",
"CUB200Iter",
"(",
"data_path",
",",
"batch_k",
",",
"batch_size",
",",
"data_shape",
",",
"is_train",
"=",
"True",
")",
",",
"CUB200It... | Return training and testing iterator for the CUB200-2011 dataset. | [
"Return",
"training",
"and",
"testing",
"iterator",
"for",
"the",
"CUB200",
"-",
"2011",
"dataset",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/embedding_learning/data.py#L155-L158 |
23,461 | apache/incubator-mxnet | example/gluon/embedding_learning/data.py | CUB200Iter.get_image | def get_image(self, img, is_train):
"""Load and transform an image."""
img_arr = mx.image.imread(img)
img_arr = transform(img_arr, 256, 256, is_train, self.boxes[img])
return img_arr | python | def get_image(self, img, is_train):
"""Load and transform an image."""
img_arr = mx.image.imread(img)
img_arr = transform(img_arr, 256, 256, is_train, self.boxes[img])
return img_arr | [
"def",
"get_image",
"(",
"self",
",",
"img",
",",
"is_train",
")",
":",
"img_arr",
"=",
"mx",
".",
"image",
".",
"imread",
"(",
"img",
")",
"img_arr",
"=",
"transform",
"(",
"img_arr",
",",
"256",
",",
"256",
",",
"is_train",
",",
"self",
".",
"box... | Load and transform an image. | [
"Load",
"and",
"transform",
"an",
"image",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/embedding_learning/data.py#L105-L109 |
23,462 | apache/incubator-mxnet | example/gluon/embedding_learning/data.py | CUB200Iter.next | def next(self):
"""Return a batch."""
if self.is_train:
data, labels = self.sample_train_batch()
else:
if self.test_count * self.batch_size < len(self.test_image_files):
data, labels = self.get_test_batch()
self.test_count += 1
... | python | def next(self):
"""Return a batch."""
if self.is_train:
data, labels = self.sample_train_batch()
else:
if self.test_count * self.batch_size < len(self.test_image_files):
data, labels = self.get_test_batch()
self.test_count += 1
... | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_train",
":",
"data",
",",
"labels",
"=",
"self",
".",
"sample_train_batch",
"(",
")",
"else",
":",
"if",
"self",
".",
"test_count",
"*",
"self",
".",
"batch_size",
"<",
"len",
"(",
"self",
... | Return a batch. | [
"Return",
"a",
"batch",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/embedding_learning/data.py#L142-L153 |
23,463 | apache/incubator-mxnet | example/bayesian-methods/data_loader.py | load_mnist | def load_mnist(training_num=50000):
"""Load mnist dataset"""
data_path = os.path.join(os.path.dirname(os.path.realpath('__file__')), 'mnist.npz')
if not os.path.isfile(data_path):
from six.moves import urllib
origin = (
'https://github.com/sxjscience/mxnet/raw/master/example/baye... | python | def load_mnist(training_num=50000):
"""Load mnist dataset"""
data_path = os.path.join(os.path.dirname(os.path.realpath('__file__')), 'mnist.npz')
if not os.path.isfile(data_path):
from six.moves import urllib
origin = (
'https://github.com/sxjscience/mxnet/raw/master/example/baye... | [
"def",
"load_mnist",
"(",
"training_num",
"=",
"50000",
")",
":",
"data_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"'__file__'",
")",
")",
",",
"'mnist.npz'",
")",... | Load mnist dataset | [
"Load",
"mnist",
"dataset"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/data_loader.py#L24-L44 |
23,464 | apache/incubator-mxnet | python/mxnet/runtime.py | feature_list | def feature_list():
"""
Check the library for compile-time features. The list of features are maintained in libinfo.h and libinfo.cc
Returns
-------
list
List of :class:`.Feature` objects
"""
lib_features_c_array = ctypes.POINTER(Feature)()
lib_features_size = ctypes.c_size_t()
... | python | def feature_list():
"""
Check the library for compile-time features. The list of features are maintained in libinfo.h and libinfo.cc
Returns
-------
list
List of :class:`.Feature` objects
"""
lib_features_c_array = ctypes.POINTER(Feature)()
lib_features_size = ctypes.c_size_t()
... | [
"def",
"feature_list",
"(",
")",
":",
"lib_features_c_array",
"=",
"ctypes",
".",
"POINTER",
"(",
"Feature",
")",
"(",
")",
"lib_features_size",
"=",
"ctypes",
".",
"c_size_t",
"(",
")",
"check_call",
"(",
"_LIB",
".",
"MXLibInfoFeatures",
"(",
"ctypes",
"."... | Check the library for compile-time features. The list of features are maintained in libinfo.h and libinfo.cc
Returns
-------
list
List of :class:`.Feature` objects | [
"Check",
"the",
"library",
"for",
"compile",
"-",
"time",
"features",
".",
"The",
"list",
"of",
"features",
"are",
"maintained",
"in",
"libinfo",
".",
"h",
"and",
"libinfo",
".",
"cc"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/runtime.py#L57-L70 |
23,465 | apache/incubator-mxnet | python/mxnet/runtime.py | Features.is_enabled | def is_enabled(self, feature_name):
"""
Check for a particular feature by name
Parameters
----------
feature_name: str
The name of a valid feature as string for example 'CUDA'
Returns
-------
Boolean
True if it's enabled, False if... | python | def is_enabled(self, feature_name):
"""
Check for a particular feature by name
Parameters
----------
feature_name: str
The name of a valid feature as string for example 'CUDA'
Returns
-------
Boolean
True if it's enabled, False if... | [
"def",
"is_enabled",
"(",
"self",
",",
"feature_name",
")",
":",
"feature_name",
"=",
"feature_name",
".",
"upper",
"(",
")",
"if",
"feature_name",
"not",
"in",
"self",
":",
"raise",
"RuntimeError",
"(",
"\"Feature '{}' is unknown, known features are: {}\"",
".",
... | Check for a particular feature by name
Parameters
----------
feature_name: str
The name of a valid feature as string for example 'CUDA'
Returns
-------
Boolean
True if it's enabled, False if it's disabled, RuntimeError if the feature is not known | [
"Check",
"for",
"a",
"particular",
"feature",
"by",
"name"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/runtime.py#L82-L100 |
23,466 | apache/incubator-mxnet | example/ssd/dataset/pascal_voc.py | PascalVoc.cache_path | def cache_path(self):
"""
make a directory to store all caches
Returns:
---------
cache path
"""
cache_path = os.path.join(os.path.dirname(__file__), '..', 'cache')
if not os.path.exists(cache_path):
os.mkdir(cache_path)
return cac... | python | def cache_path(self):
"""
make a directory to store all caches
Returns:
---------
cache path
"""
cache_path = os.path.join(os.path.dirname(__file__), '..', 'cache')
if not os.path.exists(cache_path):
os.mkdir(cache_path)
return cac... | [
"def",
"cache_path",
"(",
"self",
")",
":",
"cache_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'..'",
",",
"'cache'",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"ca... | make a directory to store all caches
Returns:
---------
cache path | [
"make",
"a",
"directory",
"to",
"store",
"all",
"caches"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/pascal_voc.py#L67-L78 |
23,467 | apache/incubator-mxnet | example/ssd/dataset/pascal_voc.py | PascalVoc.do_python_eval | def do_python_eval(self):
"""
python evaluation wrapper
Returns:
----------
None
"""
annopath = os.path.join(self.data_path, 'Annotations', '{:s}.xml')
imageset_file = os.path.join(self.data_path, 'ImageSets', 'Main', self.image_set + '.txt')
cach... | python | def do_python_eval(self):
"""
python evaluation wrapper
Returns:
----------
None
"""
annopath = os.path.join(self.data_path, 'Annotations', '{:s}.xml')
imageset_file = os.path.join(self.data_path, 'ImageSets', 'Main', self.image_set + '.txt')
cach... | [
"def",
"do_python_eval",
"(",
"self",
")",
":",
"annopath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"data_path",
",",
"'Annotations'",
",",
"'{:s}.xml'",
")",
"imageset_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"data_... | python evaluation wrapper
Returns:
----------
None | [
"python",
"evaluation",
"wrapper"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/dataset/pascal_voc.py#L255-L276 |
23,468 | apache/incubator-mxnet | python/mxnet/image/detection.py | CreateMultiRandCropAugmenter | def CreateMultiRandCropAugmenter(min_object_covered=0.1, aspect_ratio_range=(0.75, 1.33),
area_range=(0.05, 1.0), min_eject_coverage=0.3,
max_attempts=50, skip_prob=0):
"""Helper function to create multiple random crop augmenters.
Parameters
... | python | def CreateMultiRandCropAugmenter(min_object_covered=0.1, aspect_ratio_range=(0.75, 1.33),
area_range=(0.05, 1.0), min_eject_coverage=0.3,
max_attempts=50, skip_prob=0):
"""Helper function to create multiple random crop augmenters.
Parameters
... | [
"def",
"CreateMultiRandCropAugmenter",
"(",
"min_object_covered",
"=",
"0.1",
",",
"aspect_ratio_range",
"=",
"(",
"0.75",
",",
"1.33",
")",
",",
"area_range",
"=",
"(",
"0.05",
",",
"1.0",
")",
",",
"min_eject_coverage",
"=",
"0.3",
",",
"max_attempts",
"=",
... | Helper function to create multiple random crop augmenters.
Parameters
----------
min_object_covered : float or list of float, default=0.1
The cropped area of the image must contain at least this fraction of
any bounding box supplied. The value of this parameter should be non-negative.
... | [
"Helper",
"function",
"to",
"create",
"multiple",
"random",
"crop",
"augmenters",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L417-L479 |
23,469 | apache/incubator-mxnet | python/mxnet/image/detection.py | CreateDetAugmenter | def CreateDetAugmenter(data_shape, resize=0, rand_crop=0, rand_pad=0, rand_gray=0,
rand_mirror=False, mean=None, std=None, brightness=0, contrast=0,
saturation=0, pca_noise=0, hue=0, inter_method=2, min_object_covered=0.1,
aspect_ratio_range=(0.75, 1.... | python | def CreateDetAugmenter(data_shape, resize=0, rand_crop=0, rand_pad=0, rand_gray=0,
rand_mirror=False, mean=None, std=None, brightness=0, contrast=0,
saturation=0, pca_noise=0, hue=0, inter_method=2, min_object_covered=0.1,
aspect_ratio_range=(0.75, 1.... | [
"def",
"CreateDetAugmenter",
"(",
"data_shape",
",",
"resize",
"=",
"0",
",",
"rand_crop",
"=",
"0",
",",
"rand_pad",
"=",
"0",
",",
"rand_gray",
"=",
"0",
",",
"rand_mirror",
"=",
"False",
",",
"mean",
"=",
"None",
",",
"std",
"=",
"None",
",",
"bri... | Create augmenters for detection.
Parameters
----------
data_shape : tuple of int
Shape for output data
resize : int
Resize shorter edge if larger than 0 at the begining
rand_crop : float
[0, 1], probability to apply random cropping
rand_pad : float
[0, 1], probab... | [
"Create",
"augmenters",
"for",
"detection",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L482-L621 |
23,470 | apache/incubator-mxnet | python/mxnet/image/detection.py | DetRandomSelectAug.dumps | def dumps(self):
"""Override default."""
return [self.__class__.__name__.lower(), [x.dumps() for x in self.aug_list]] | python | def dumps(self):
"""Override default."""
return [self.__class__.__name__.lower(), [x.dumps() for x in self.aug_list]] | [
"def",
"dumps",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"__class__",
".",
"__name__",
".",
"lower",
"(",
")",
",",
"[",
"x",
".",
"dumps",
"(",
")",
"for",
"x",
"in",
"self",
".",
"aug_list",
"]",
"]"
] | Override default. | [
"Override",
"default",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L113-L115 |
23,471 | apache/incubator-mxnet | python/mxnet/image/detection.py | DetRandomCropAug._calculate_areas | def _calculate_areas(self, label):
"""Calculate areas for multiple labels"""
heights = np.maximum(0, label[:, 3] - label[:, 1])
widths = np.maximum(0, label[:, 2] - label[:, 0])
return heights * widths | python | def _calculate_areas(self, label):
"""Calculate areas for multiple labels"""
heights = np.maximum(0, label[:, 3] - label[:, 1])
widths = np.maximum(0, label[:, 2] - label[:, 0])
return heights * widths | [
"def",
"_calculate_areas",
"(",
"self",
",",
"label",
")",
":",
"heights",
"=",
"np",
".",
"maximum",
"(",
"0",
",",
"label",
"[",
":",
",",
"3",
"]",
"-",
"label",
"[",
":",
",",
"1",
"]",
")",
"widths",
"=",
"np",
".",
"maximum",
"(",
"0",
... | Calculate areas for multiple labels | [
"Calculate",
"areas",
"for",
"multiple",
"labels"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L213-L217 |
23,472 | apache/incubator-mxnet | python/mxnet/image/detection.py | DetRandomCropAug._intersect | def _intersect(self, label, xmin, ymin, xmax, ymax):
"""Calculate intersect areas, normalized."""
left = np.maximum(label[:, 0], xmin)
right = np.minimum(label[:, 2], xmax)
top = np.maximum(label[:, 1], ymin)
bot = np.minimum(label[:, 3], ymax)
invalid = np.where(np.logic... | python | def _intersect(self, label, xmin, ymin, xmax, ymax):
"""Calculate intersect areas, normalized."""
left = np.maximum(label[:, 0], xmin)
right = np.minimum(label[:, 2], xmax)
top = np.maximum(label[:, 1], ymin)
bot = np.minimum(label[:, 3], ymax)
invalid = np.where(np.logic... | [
"def",
"_intersect",
"(",
"self",
",",
"label",
",",
"xmin",
",",
"ymin",
",",
"xmax",
",",
"ymax",
")",
":",
"left",
"=",
"np",
".",
"maximum",
"(",
"label",
"[",
":",
",",
"0",
"]",
",",
"xmin",
")",
"right",
"=",
"np",
".",
"minimum",
"(",
... | Calculate intersect areas, normalized. | [
"Calculate",
"intersect",
"areas",
"normalized",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L220-L233 |
23,473 | apache/incubator-mxnet | python/mxnet/image/detection.py | DetRandomCropAug._check_satisfy_constraints | def _check_satisfy_constraints(self, label, xmin, ymin, xmax, ymax, width, height):
"""Check if constrains are satisfied"""
if (xmax - xmin) * (ymax - ymin) < 2:
return False # only 1 pixel
x1 = float(xmin) / width
y1 = float(ymin) / height
x2 = float(xmax) / width
... | python | def _check_satisfy_constraints(self, label, xmin, ymin, xmax, ymax, width, height):
"""Check if constrains are satisfied"""
if (xmax - xmin) * (ymax - ymin) < 2:
return False # only 1 pixel
x1 = float(xmin) / width
y1 = float(ymin) / height
x2 = float(xmax) / width
... | [
"def",
"_check_satisfy_constraints",
"(",
"self",
",",
"label",
",",
"xmin",
",",
"ymin",
",",
"xmax",
",",
"ymax",
",",
"width",
",",
"height",
")",
":",
"if",
"(",
"xmax",
"-",
"xmin",
")",
"*",
"(",
"ymax",
"-",
"ymin",
")",
"<",
"2",
":",
"re... | Check if constrains are satisfied | [
"Check",
"if",
"constrains",
"are",
"satisfied"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L235-L250 |
23,474 | apache/incubator-mxnet | python/mxnet/image/detection.py | DetRandomCropAug._update_labels | def _update_labels(self, label, crop_box, height, width):
"""Convert labels according to crop box"""
xmin = float(crop_box[0]) / width
ymin = float(crop_box[1]) / height
w = float(crop_box[2]) / width
h = float(crop_box[3]) / height
out = label.copy()
out[:, (1, 3... | python | def _update_labels(self, label, crop_box, height, width):
"""Convert labels according to crop box"""
xmin = float(crop_box[0]) / width
ymin = float(crop_box[1]) / height
w = float(crop_box[2]) / width
h = float(crop_box[3]) / height
out = label.copy()
out[:, (1, 3... | [
"def",
"_update_labels",
"(",
"self",
",",
"label",
",",
"crop_box",
",",
"height",
",",
"width",
")",
":",
"xmin",
"=",
"float",
"(",
"crop_box",
"[",
"0",
"]",
")",
"/",
"width",
"ymin",
"=",
"float",
"(",
"crop_box",
"[",
"1",
"]",
")",
"/",
"... | Convert labels according to crop box | [
"Convert",
"labels",
"according",
"to",
"crop",
"box"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L252-L272 |
23,475 | apache/incubator-mxnet | python/mxnet/image/detection.py | DetRandomCropAug._random_crop_proposal | def _random_crop_proposal(self, label, height, width):
"""Propose cropping areas"""
from math import sqrt
if not self.enabled or height <= 0 or width <= 0:
return ()
min_area = self.area_range[0] * height * width
max_area = self.area_range[1] * height * width
... | python | def _random_crop_proposal(self, label, height, width):
"""Propose cropping areas"""
from math import sqrt
if not self.enabled or height <= 0 or width <= 0:
return ()
min_area = self.area_range[0] * height * width
max_area = self.area_range[1] * height * width
... | [
"def",
"_random_crop_proposal",
"(",
"self",
",",
"label",
",",
"height",
",",
"width",
")",
":",
"from",
"math",
"import",
"sqrt",
"if",
"not",
"self",
".",
"enabled",
"or",
"height",
"<=",
"0",
"or",
"width",
"<=",
"0",
":",
"return",
"(",
")",
"mi... | Propose cropping areas | [
"Propose",
"cropping",
"areas"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L274-L320 |
23,476 | apache/incubator-mxnet | python/mxnet/image/detection.py | DetRandomPadAug._update_labels | def _update_labels(self, label, pad_box, height, width):
"""Update label according to padding region"""
out = label.copy()
out[:, (1, 3)] = (out[:, (1, 3)] * width + pad_box[0]) / pad_box[2]
out[:, (2, 4)] = (out[:, (2, 4)] * height + pad_box[1]) / pad_box[3]
return out | python | def _update_labels(self, label, pad_box, height, width):
"""Update label according to padding region"""
out = label.copy()
out[:, (1, 3)] = (out[:, (1, 3)] * width + pad_box[0]) / pad_box[2]
out[:, (2, 4)] = (out[:, (2, 4)] * height + pad_box[1]) / pad_box[3]
return out | [
"def",
"_update_labels",
"(",
"self",
",",
"label",
",",
"pad_box",
",",
"height",
",",
"width",
")",
":",
"out",
"=",
"label",
".",
"copy",
"(",
")",
"out",
"[",
":",
",",
"(",
"1",
",",
"3",
")",
"]",
"=",
"(",
"out",
"[",
":",
",",
"(",
... | Update label according to padding region | [
"Update",
"label",
"according",
"to",
"padding",
"region"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L378-L383 |
23,477 | apache/incubator-mxnet | python/mxnet/image/detection.py | DetRandomPadAug._random_pad_proposal | def _random_pad_proposal(self, label, height, width):
"""Generate random padding region"""
from math import sqrt
if not self.enabled or height <= 0 or width <= 0:
return ()
min_area = self.area_range[0] * height * width
max_area = self.area_range[1] * height * width
... | python | def _random_pad_proposal(self, label, height, width):
"""Generate random padding region"""
from math import sqrt
if not self.enabled or height <= 0 or width <= 0:
return ()
min_area = self.area_range[0] * height * width
max_area = self.area_range[1] * height * width
... | [
"def",
"_random_pad_proposal",
"(",
"self",
",",
"label",
",",
"height",
",",
"width",
")",
":",
"from",
"math",
"import",
"sqrt",
"if",
"not",
"self",
".",
"enabled",
"or",
"height",
"<=",
"0",
"or",
"width",
"<=",
"0",
":",
"return",
"(",
")",
"min... | Generate random padding region | [
"Generate",
"random",
"padding",
"region"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L385-L414 |
23,478 | apache/incubator-mxnet | python/mxnet/image/detection.py | ImageDetIter._check_valid_label | def _check_valid_label(self, label):
"""Validate label and its shape."""
if len(label.shape) != 2 or label.shape[1] < 5:
msg = "Label with shape (1+, 5+) required, %s received." % str(label)
raise RuntimeError(msg)
valid_label = np.where(np.logical_and(label[:, 0] >= 0, l... | python | def _check_valid_label(self, label):
"""Validate label and its shape."""
if len(label.shape) != 2 or label.shape[1] < 5:
msg = "Label with shape (1+, 5+) required, %s received." % str(label)
raise RuntimeError(msg)
valid_label = np.where(np.logical_and(label[:, 0] >= 0, l... | [
"def",
"_check_valid_label",
"(",
"self",
",",
"label",
")",
":",
"if",
"len",
"(",
"label",
".",
"shape",
")",
"!=",
"2",
"or",
"label",
".",
"shape",
"[",
"1",
"]",
"<",
"5",
":",
"msg",
"=",
"\"Label with shape (1+, 5+) required, %s received.\"",
"%",
... | Validate label and its shape. | [
"Validate",
"label",
"and",
"its",
"shape",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L692-L700 |
23,479 | apache/incubator-mxnet | python/mxnet/image/detection.py | ImageDetIter._estimate_label_shape | def _estimate_label_shape(self):
"""Helper function to estimate label shape"""
max_count = 0
self.reset()
try:
while True:
label, _ = self.next_sample()
label = self._parse_label(label)
max_count = max(max_count, label.shape[0])... | python | def _estimate_label_shape(self):
"""Helper function to estimate label shape"""
max_count = 0
self.reset()
try:
while True:
label, _ = self.next_sample()
label = self._parse_label(label)
max_count = max(max_count, label.shape[0])... | [
"def",
"_estimate_label_shape",
"(",
"self",
")",
":",
"max_count",
"=",
"0",
"self",
".",
"reset",
"(",
")",
"try",
":",
"while",
"True",
":",
"label",
",",
"_",
"=",
"self",
".",
"next_sample",
"(",
")",
"label",
"=",
"self",
".",
"_parse_label",
"... | Helper function to estimate label shape | [
"Helper",
"function",
"to",
"estimate",
"label",
"shape"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L702-L714 |
23,480 | apache/incubator-mxnet | python/mxnet/image/detection.py | ImageDetIter._parse_label | def _parse_label(self, label):
"""Helper function to parse object detection label.
Format for raw label:
n \t k \t ... \t [id \t xmin\t ymin \t xmax \t ymax \t ...] \t [repeat]
where n is the width of header, 2 or larger
k is the width of each object annotation, can be arbitrary... | python | def _parse_label(self, label):
"""Helper function to parse object detection label.
Format for raw label:
n \t k \t ... \t [id \t xmin\t ymin \t xmax \t ymax \t ...] \t [repeat]
where n is the width of header, 2 or larger
k is the width of each object annotation, can be arbitrary... | [
"def",
"_parse_label",
"(",
"self",
",",
"label",
")",
":",
"if",
"isinstance",
"(",
"label",
",",
"nd",
".",
"NDArray",
")",
":",
"label",
"=",
"label",
".",
"asnumpy",
"(",
")",
"raw",
"=",
"label",
".",
"ravel",
"(",
")",
"if",
"raw",
".",
"si... | Helper function to parse object detection label.
Format for raw label:
n \t k \t ... \t [id \t xmin\t ymin \t xmax \t ymax \t ...] \t [repeat]
where n is the width of header, 2 or larger
k is the width of each object annotation, can be arbitrary, at least 5 | [
"Helper",
"function",
"to",
"parse",
"object",
"detection",
"label",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L716-L740 |
23,481 | apache/incubator-mxnet | python/mxnet/image/detection.py | ImageDetIter.reshape | def reshape(self, data_shape=None, label_shape=None):
"""Reshape iterator for data_shape or label_shape.
Parameters
----------
data_shape : tuple or None
Reshape the data_shape to the new shape if not None
label_shape : tuple or None
Reshape label shape t... | python | def reshape(self, data_shape=None, label_shape=None):
"""Reshape iterator for data_shape or label_shape.
Parameters
----------
data_shape : tuple or None
Reshape the data_shape to the new shape if not None
label_shape : tuple or None
Reshape label shape t... | [
"def",
"reshape",
"(",
"self",
",",
"data_shape",
"=",
"None",
",",
"label_shape",
"=",
"None",
")",
":",
"if",
"data_shape",
"is",
"not",
"None",
":",
"self",
".",
"check_data_shape",
"(",
"data_shape",
")",
"self",
".",
"provide_data",
"=",
"[",
"(",
... | Reshape iterator for data_shape or label_shape.
Parameters
----------
data_shape : tuple or None
Reshape the data_shape to the new shape if not None
label_shape : tuple or None
Reshape label shape to new shape if not None | [
"Reshape",
"iterator",
"for",
"data_shape",
"or",
"label_shape",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L742-L759 |
23,482 | apache/incubator-mxnet | python/mxnet/image/detection.py | ImageDetIter._batchify | def _batchify(self, batch_data, batch_label, start=0):
"""Override the helper function for batchifying data"""
i = start
batch_size = self.batch_size
try:
while i < batch_size:
label, s = self.next_sample()
data = self.imdecode(s)
... | python | def _batchify(self, batch_data, batch_label, start=0):
"""Override the helper function for batchifying data"""
i = start
batch_size = self.batch_size
try:
while i < batch_size:
label, s = self.next_sample()
data = self.imdecode(s)
... | [
"def",
"_batchify",
"(",
"self",
",",
"batch_data",
",",
"batch_label",
",",
"start",
"=",
"0",
")",
":",
"i",
"=",
"start",
"batch_size",
"=",
"self",
".",
"batch_size",
"try",
":",
"while",
"i",
"<",
"batch_size",
":",
"label",
",",
"s",
"=",
"self... | Override the helper function for batchifying data | [
"Override",
"the",
"helper",
"function",
"for",
"batchifying",
"data"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L761-L789 |
23,483 | apache/incubator-mxnet | python/mxnet/image/detection.py | ImageDetIter.next | def next(self):
"""Override the function for returning next batch."""
batch_size = self.batch_size
c, h, w = self.data_shape
# if last batch data is rolled over
if self._cache_data is not None:
# check both the data and label have values
assert self._cache... | python | def next(self):
"""Override the function for returning next batch."""
batch_size = self.batch_size
c, h, w = self.data_shape
# if last batch data is rolled over
if self._cache_data is not None:
# check both the data and label have values
assert self._cache... | [
"def",
"next",
"(",
"self",
")",
":",
"batch_size",
"=",
"self",
".",
"batch_size",
"c",
",",
"h",
",",
"w",
"=",
"self",
".",
"data_shape",
"# if last batch data is rolled over",
"if",
"self",
".",
"_cache_data",
"is",
"not",
"None",
":",
"# check both the ... | Override the function for returning next batch. | [
"Override",
"the",
"function",
"for",
"returning",
"next",
"batch",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L791-L830 |
23,484 | apache/incubator-mxnet | python/mxnet/image/detection.py | ImageDetIter.augmentation_transform | def augmentation_transform(self, data, label): # pylint: disable=arguments-differ
"""Override Transforms input data with specified augmentations."""
for aug in self.auglist:
data, label = aug(data, label)
return (data, label) | python | def augmentation_transform(self, data, label): # pylint: disable=arguments-differ
"""Override Transforms input data with specified augmentations."""
for aug in self.auglist:
data, label = aug(data, label)
return (data, label) | [
"def",
"augmentation_transform",
"(",
"self",
",",
"data",
",",
"label",
")",
":",
"# pylint: disable=arguments-differ",
"for",
"aug",
"in",
"self",
".",
"auglist",
":",
"data",
",",
"label",
"=",
"aug",
"(",
"data",
",",
"label",
")",
"return",
"(",
"data... | Override Transforms input data with specified augmentations. | [
"Override",
"Transforms",
"input",
"data",
"with",
"specified",
"augmentations",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L832-L836 |
23,485 | apache/incubator-mxnet | python/mxnet/image/detection.py | ImageDetIter.check_label_shape | def check_label_shape(self, label_shape):
"""Checks if the new label shape is valid"""
if not len(label_shape) == 2:
raise ValueError('label_shape should have length 2')
if label_shape[0] < self.label_shape[0]:
msg = 'Attempts to reduce label count from %d to %d, not allo... | python | def check_label_shape(self, label_shape):
"""Checks if the new label shape is valid"""
if not len(label_shape) == 2:
raise ValueError('label_shape should have length 2')
if label_shape[0] < self.label_shape[0]:
msg = 'Attempts to reduce label count from %d to %d, not allo... | [
"def",
"check_label_shape",
"(",
"self",
",",
"label_shape",
")",
":",
"if",
"not",
"len",
"(",
"label_shape",
")",
"==",
"2",
":",
"raise",
"ValueError",
"(",
"'label_shape should have length 2'",
")",
"if",
"label_shape",
"[",
"0",
"]",
"<",
"self",
".",
... | Checks if the new label shape is valid | [
"Checks",
"if",
"the",
"new",
"label",
"shape",
"is",
"valid"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/image/detection.py#L838-L849 |
23,486 | apache/incubator-mxnet | example/rcnn/symdata/anchor.py | AnchorGenerator._ratio_enum | def _ratio_enum(anchor, ratios):
"""
Enumerate a set of anchors for each aspect ratio wrt an anchor.
"""
w, h, x_ctr, y_ctr = AnchorGenerator._whctrs(anchor)
size = w * h
size_ratios = size / ratios
ws = np.round(np.sqrt(size_ratios))
hs = np.round(ws * ra... | python | def _ratio_enum(anchor, ratios):
"""
Enumerate a set of anchors for each aspect ratio wrt an anchor.
"""
w, h, x_ctr, y_ctr = AnchorGenerator._whctrs(anchor)
size = w * h
size_ratios = size / ratios
ws = np.round(np.sqrt(size_ratios))
hs = np.round(ws * ra... | [
"def",
"_ratio_enum",
"(",
"anchor",
",",
"ratios",
")",
":",
"w",
",",
"h",
",",
"x_ctr",
",",
"y_ctr",
"=",
"AnchorGenerator",
".",
"_whctrs",
"(",
"anchor",
")",
"size",
"=",
"w",
"*",
"h",
"size_ratios",
"=",
"size",
"/",
"ratios",
"ws",
"=",
"... | Enumerate a set of anchors for each aspect ratio wrt an anchor. | [
"Enumerate",
"a",
"set",
"of",
"anchors",
"for",
"each",
"aspect",
"ratio",
"wrt",
"an",
"anchor",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rcnn/symdata/anchor.py#L81-L91 |
23,487 | apache/incubator-mxnet | example/rcnn/symdata/anchor.py | AnchorGenerator._scale_enum | def _scale_enum(anchor, scales):
"""
Enumerate a set of anchors for each scale wrt an anchor.
"""
w, h, x_ctr, y_ctr = AnchorGenerator._whctrs(anchor)
ws = w * scales
hs = h * scales
anchors = AnchorGenerator._mkanchors(ws, hs, x_ctr, y_ctr)
return anchors | python | def _scale_enum(anchor, scales):
"""
Enumerate a set of anchors for each scale wrt an anchor.
"""
w, h, x_ctr, y_ctr = AnchorGenerator._whctrs(anchor)
ws = w * scales
hs = h * scales
anchors = AnchorGenerator._mkanchors(ws, hs, x_ctr, y_ctr)
return anchors | [
"def",
"_scale_enum",
"(",
"anchor",
",",
"scales",
")",
":",
"w",
",",
"h",
",",
"x_ctr",
",",
"y_ctr",
"=",
"AnchorGenerator",
".",
"_whctrs",
"(",
"anchor",
")",
"ws",
"=",
"w",
"*",
"scales",
"hs",
"=",
"h",
"*",
"scales",
"anchors",
"=",
"Anch... | Enumerate a set of anchors for each scale wrt an anchor. | [
"Enumerate",
"a",
"set",
"of",
"anchors",
"for",
"each",
"scale",
"wrt",
"an",
"anchor",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rcnn/symdata/anchor.py#L94-L102 |
23,488 | apache/incubator-mxnet | example/speech_recognition/arch_deepspeech.py | prepare_data | def prepare_data(args):
"""
set atual shape of data
"""
rnn_type = args.config.get("arch", "rnn_type")
num_rnn_layer = args.config.getint("arch", "num_rnn_layer")
num_hidden_rnn_list = json.loads(args.config.get("arch", "num_hidden_rnn_list"))
batch_size = args.config.getint("common", "batc... | python | def prepare_data(args):
"""
set atual shape of data
"""
rnn_type = args.config.get("arch", "rnn_type")
num_rnn_layer = args.config.getint("arch", "num_rnn_layer")
num_hidden_rnn_list = json.loads(args.config.get("arch", "num_hidden_rnn_list"))
batch_size = args.config.getint("common", "batc... | [
"def",
"prepare_data",
"(",
"args",
")",
":",
"rnn_type",
"=",
"args",
".",
"config",
".",
"get",
"(",
"\"arch\"",
",",
"\"rnn_type\"",
")",
"num_rnn_layer",
"=",
"args",
".",
"config",
".",
"getint",
"(",
"\"arch\"",
",",
"\"num_rnn_layer\"",
")",
"num_hi... | set atual shape of data | [
"set",
"atual",
"shape",
"of",
"data"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/speech_recognition/arch_deepspeech.py#L38-L80 |
23,489 | apache/incubator-mxnet | tools/coreml/converter/_mxnet_converter.py | check_error | def check_error(model, path, shapes, output = 'softmax_output', verbose = True):
"""
Check the difference between predictions from MXNet and CoreML.
"""
coreml_model = _coremltools.models.MLModel(path)
input_data = {}
input_data_copy = {}
for ip in shapes:
input_data[ip] = _np.random... | python | def check_error(model, path, shapes, output = 'softmax_output', verbose = True):
"""
Check the difference between predictions from MXNet and CoreML.
"""
coreml_model = _coremltools.models.MLModel(path)
input_data = {}
input_data_copy = {}
for ip in shapes:
input_data[ip] = _np.random... | [
"def",
"check_error",
"(",
"model",
",",
"path",
",",
"shapes",
",",
"output",
"=",
"'softmax_output'",
",",
"verbose",
"=",
"True",
")",
":",
"coreml_model",
"=",
"_coremltools",
".",
"models",
".",
"MLModel",
"(",
"path",
")",
"input_data",
"=",
"{",
"... | Check the difference between predictions from MXNet and CoreML. | [
"Check",
"the",
"difference",
"between",
"predictions",
"from",
"MXNet",
"and",
"CoreML",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/tools/coreml/converter/_mxnet_converter.py#L56-L78 |
23,490 | apache/incubator-mxnet | example/reinforcement-learning/dqn/utils.py | sample_categorical | 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... | python | 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",
")",
":",
"ret",
"=",
"numpy",
".",
"empty",
"(",
"prob",
".",
"shape",
"[",
"0",
"]",
",",
"dtype",
"=",
"numpy",
".",
"float32",
")",
"for",
"ind",
"in",
"range",
"(",
"prob",
".",
"shape",
... | 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... | [
"Sample",
"from",
"independent",
"categorical",
"distributions"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/reinforcement-learning/dqn/utils.py#L133-L154 |
23,491 | apache/incubator-mxnet | example/reinforcement-learning/dqn/utils.py | sample_normal | 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 ... | python | 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",
")",
":",
"ret",
"=",
"numpy",
".",
"sqrt",
"(",
"var",
")",
"*",
"rng",
".",
"randn",
"(",
"*",
"mean",
".",
"shape",
")",
"+",
"mean",
"return",
"ret"
] | 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,... | [
"Sample",
"from",
"independent",
"normal",
"distributions"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/reinforcement-learning/dqn/utils.py#L157-L176 |
23,492 | apache/incubator-mxnet | example/nce-loss/nce.py | nce_loss_subwords | 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,
... | python | 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",
")",
":",
"# get subword-units embedding.",
"label_units_embed",
"=",
"mx",
".",
"sym",
".",
"Embedding",
"(",... | NCE-Loss layer under subword-units input. | [
"NCE",
"-",
"Loss",
"layer",
"under",
"subword",
"-",
"units",
"input",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/nce-loss/nce.py#L38-L62 |
23,493 | apache/incubator-mxnet | example/gluon/super_resolution/super_resolution.py | get_dataset | 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),
... | python | 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",
")",
":",
"if",
"path",
".",
"exists",
"(",
"data_dir",
")",
":",
"print",
"(",
"\"Directory {} already exists, skipping.\\n\"",
"\"To force download and extraction, delete the directory and re-run.\"",
"\"\"",
".",
"fo... | Download the BSDS500 dataset and return train and test iters. | [
"Download",
"the",
"BSDS500",
"dataset",
"and",
"return",
"train",
"and",
"test",
"iters",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/super_resolution/super_resolution.py#L69-L130 |
23,494 | apache/incubator-mxnet | example/rnn/large_word_lm/run_utils.py | evaluate | 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)
... | python | 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",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"total_L",
"=",
"0.0",
"nbatch",
"=",
"0",
"density",
"=",
"0",
"mod",
".",
"set_states",
"(",
"value",
"=",
... | Run evaluation on cpu. | [
"Run",
"evaluation",
"on",
"cpu",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/large_word_lm/run_utils.py#L66-L90 |
23,495 | apache/incubator-mxnet | example/fcn-xs/data.py | FileIter.next | 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 | python | 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",
")",
":",
"if",
"self",
".",
"iter_next",
"(",
")",
":",
"self",
".",
"data",
",",
"self",
".",
"label",
"=",
"self",
".",
"_read",
"(",
")",
"return",
"{",
"self",
".",
"data_name",
":",
"self",
".",
"data",
"[",
"0... | return one dict which contains "data" and "label" | [
"return",
"one",
"dict",
"which",
"contains",
"data",
"and",
"label"
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/fcn-xs/data.py#L132-L139 |
23,496 | apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/import_onnx.py | GraphProto.from_onnx | 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... | python | 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",
")",
":",
"# get input, output shapes",
"self",
".",
"model_metadata",
"=",
"self",
".",
"get_graph_metadata",
"(",
"graph",
")",
"# parse network inputs, aka parameters",
"for",
"init_tensor",
"in",
"graph",
".",
"init... | 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... | [
"Construct",
"symbol",
"from",
"onnx",
"graph",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/import_onnx.py#L76-L135 |
23,497 | apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/import_onnx.py | GraphProto.get_graph_metadata | 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... | python | 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",
")",
":",
"_params",
"=",
"set",
"(",
")",
"for",
"tensor_vals",
"in",
"graph",
".",
"initializer",
":",
"_params",
".",
"add",
"(",
"tensor_vals",
".",
"name",
")",
"input_data",
"=",
"[",
"]",
"... | Get the model metadata from a given onnx graph. | [
"Get",
"the",
"model",
"metadata",
"from",
"a",
"given",
"onnx",
"graph",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/import_onnx.py#L137-L158 |
23,498 | apache/incubator-mxnet | python/mxnet/contrib/onnx/onnx2mx/import_onnx.py | GraphProto.graph_to_gluon | 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
... | python | 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",
")",
":",
"sym",
",",
"arg_params",
",",
"aux_params",
"=",
"self",
".",
"from_onnx",
"(",
"graph",
")",
"metadata",
"=",
"self",
".",
"get_graph_metadata",
"(",
"graph",
")",
"data_names",
... | 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
... | [
"Construct",
"SymbolBlock",
"from",
"onnx",
"graph",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/onnx/onnx2mx/import_onnx.py#L160-L191 |
23,499 | apache/incubator-mxnet | python/mxnet/contrib/svrg_optimization/svrg_module.py | SVRGModule.reshape | 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... | python | 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",
")",
":",
"super",
"(",
"SVRGModule",
",",
"self",
")",
".",
"reshape",
"(",
"data_shapes",
",",
"label_shapes",
"=",
"label_shapes",
")",
"self",
".",
"_mod_aux",
".",
... | 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``. | [
"Reshapes",
"both",
"modules",
"for",
"new",
"input",
"shapes",
"."
] | 1af29e9c060a4c7d60eeaacba32afdb9a7775ba7 | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/contrib/svrg_optimization/svrg_module.py#L101-L112 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.