partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
SGD
Generate the implementation of SGD
example/bayesian-methods/algos.py
def SGD(sym, data_inputs, X, Y, X_test, Y_test, total_iter_num, lr=None, lr_scheduler=None, prior_precision=1, out_grad_f=None, initializer=None, minibatch_size=100, dev=mx.gpu()): """Generate the implementation of SGD""" if out_grad_f is None: label_key = list(se...
def SGD(sym, data_inputs, X, Y, X_test, Y_test, total_iter_num, lr=None, lr_scheduler=None, prior_precision=1, out_grad_f=None, initializer=None, minibatch_size=100, dev=mx.gpu()): """Generate the implementation of SGD""" if out_grad_f is None: label_key = list(se...
[ "Generate", "the", "implementation", "of", "SGD" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/algos.py#L133-L168
[ "def", "SGD", "(", "sym", ",", "data_inputs", ",", "X", ",", "Y", ",", "X_test", ",", "Y_test", ",", "total_iter_num", ",", "lr", "=", "None", ",", "lr_scheduler", "=", "None", ",", "prior_precision", "=", "1", ",", "out_grad_f", "=", "None", ",", "i...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
SGLD
Generate the implementation of SGLD
example/bayesian-methods/algos.py
def SGLD(sym, X, Y, X_test, Y_test, total_iter_num, data_inputs=None, learning_rate=None, lr_scheduler=None, prior_precision=1, out_grad_f=None, initializer=None, minibatch_size=100, thin_interval=100, burn_in_iter_num=1000, task='classification', dev=mx.gp...
def SGLD(sym, X, Y, X_test, Y_test, total_iter_num, data_inputs=None, learning_rate=None, lr_scheduler=None, prior_precision=1, out_grad_f=None, initializer=None, minibatch_size=100, thin_interval=100, burn_in_iter_num=1000, task='classification', dev=mx.gp...
[ "Generate", "the", "implementation", "of", "SGLD" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/algos.py#L171-L228
[ "def", "SGLD", "(", "sym", ",", "X", ",", "Y", ",", "X_test", ",", "Y_test", ",", "total_iter_num", ",", "data_inputs", "=", "None", ",", "learning_rate", "=", "None", ",", "lr_scheduler", "=", "None", ",", "prior_precision", "=", "1", ",", "out_grad_f",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DistilledSGLD
Generate the implementation of DistilledSGLD
example/bayesian-methods/algos.py
def DistilledSGLD(teacher_sym, student_sym, teacher_data_inputs, student_data_inputs, X, Y, X_test, Y_test, total_iter_num, teacher_learning_rate, student_learning_rate, teacher_lr_scheduler=None, student_lr_scheduler=None, studen...
def DistilledSGLD(teacher_sym, student_sym, teacher_data_inputs, student_data_inputs, X, Y, X_test, Y_test, total_iter_num, teacher_learning_rate, student_learning_rate, teacher_lr_scheduler=None, student_lr_scheduler=None, studen...
[ "Generate", "the", "implementation", "of", "DistilledSGLD" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/bayesian-methods/algos.py#L231-L343
[ "def", "DistilledSGLD", "(", "teacher_sym", ",", "student_sym", ",", "teacher_data_inputs", ",", "student_data_inputs", ",", "X", ",", "Y", ",", "X_test", ",", "Y_test", ",", "total_iter_num", ",", "teacher_learning_rate", ",", "student_learning_rate", ",", "teacher...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_platforms
Get a list of architectures given our dockerfiles
ci/build.py
def get_platforms(path: str = get_dockerfiles_path()) -> List[str]: """Get a list of architectures given our dockerfiles""" dockerfiles = glob.glob(os.path.join(path, "Dockerfile.*")) dockerfiles = list(filter(lambda x: x[-1] != '~', dockerfiles)) files = list(map(lambda x: re.sub(r"Dockerfile.(.*)", r"...
def get_platforms(path: str = get_dockerfiles_path()) -> List[str]: """Get a list of architectures given our dockerfiles""" dockerfiles = glob.glob(os.path.join(path, "Dockerfile.*")) dockerfiles = list(filter(lambda x: x[-1] != '~', dockerfiles)) files = list(map(lambda x: re.sub(r"Dockerfile.(.*)", r"...
[ "Get", "a", "list", "of", "architectures", "given", "our", "dockerfiles" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/build.py#L93-L99
[ "def", "get_platforms", "(", "path", ":", "str", "=", "get_dockerfiles_path", "(", ")", ")", "->", "List", "[", "str", "]", ":", "dockerfiles", "=", "glob", ".", "glob", "(", "os", ".", "path", ".", "join", "(", "path", ",", "\"Dockerfile.*\"", ")", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_docker_tag
:return: docker tag to be used for the container
ci/build.py
def get_docker_tag(platform: str, registry: str) -> str: """:return: docker tag to be used for the container""" platform = platform if any(x in platform for x in ['build.', 'publish.']) else 'build.{}'.format(platform) if not registry: registry = "mxnet_local" return "{0}/{1}".format(registry, p...
def get_docker_tag(platform: str, registry: str) -> str: """:return: docker tag to be used for the container""" platform = platform if any(x in platform for x in ['build.', 'publish.']) else 'build.{}'.format(platform) if not registry: registry = "mxnet_local" return "{0}/{1}".format(registry, p...
[ ":", "return", ":", "docker", "tag", "to", "be", "used", "for", "the", "container" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/build.py#L102-L107
[ "def", "get_docker_tag", "(", "platform", ":", "str", ",", "registry", ":", "str", ")", "->", "str", ":", "platform", "=", "platform", "if", "any", "(", "x", "in", "platform", "for", "x", "in", "[", "'build.'", ",", "'publish.'", "]", ")", "else", "'...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
build_docker
Build a container for the given platform :param platform: Platform :param docker_binary: docker binary to use (docker/nvidia-docker) :param registry: Dockerhub registry name :param num_retries: Number of retries to build the docker image :param no_cache: pass no-cache to docker to rebuild the images...
ci/build.py
def build_docker(platform: str, docker_binary: str, registry: str, num_retries: int, no_cache: bool) -> str: """ Build a container for the given platform :param platform: Platform :param docker_binary: docker binary to use (docker/nvidia-docker) :param registry: Dockerhub registry name :param nu...
def build_docker(platform: str, docker_binary: str, registry: str, num_retries: int, no_cache: bool) -> str: """ Build a container for the given platform :param platform: Platform :param docker_binary: docker binary to use (docker/nvidia-docker) :param registry: Dockerhub registry name :param nu...
[ "Build", "a", "container", "for", "the", "given", "platform", ":", "param", "platform", ":", "Platform", ":", "param", "docker_binary", ":", "docker", "binary", "to", "use", "(", "docker", "/", "nvidia", "-", "docker", ")", ":", "param", "registry", ":", ...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/build.py#L119-L168
[ "def", "build_docker", "(", "platform", ":", "str", ",", "docker_binary", ":", "str", ",", "registry", ":", "str", ",", "num_retries", ":", "int", ",", "no_cache", ":", "bool", ")", "->", "str", ":", "tag", "=", "get_docker_tag", "(", "platform", "=", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_get_local_image_id
Get the image id of the local docker layer with the passed tag :param docker_tag: docker tag :return: Image id as string or None if tag does not exist
ci/build.py
def _get_local_image_id(docker_binary, docker_tag): """ Get the image id of the local docker layer with the passed tag :param docker_tag: docker tag :return: Image id as string or None if tag does not exist """ cmd = [docker_binary, "images", "-q", docker_tag] image_id_b = check_output(cmd) ...
def _get_local_image_id(docker_binary, docker_tag): """ Get the image id of the local docker layer with the passed tag :param docker_tag: docker tag :return: Image id as string or None if tag does not exist """ cmd = [docker_binary, "images", "-q", docker_tag] image_id_b = check_output(cmd) ...
[ "Get", "the", "image", "id", "of", "the", "local", "docker", "layer", "with", "the", "passed", "tag", ":", "param", "docker_tag", ":", "docker", "tag", ":", "return", ":", "Image", "id", "as", "string", "or", "None", "if", "tag", "does", "not", "exist"...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/build.py#L171-L182
[ "def", "_get_local_image_id", "(", "docker_binary", ",", "docker_tag", ")", ":", "cmd", "=", "[", "docker_binary", ",", "\"images\"", ",", "\"-q\"", ",", "docker_tag", "]", "image_id_b", "=", "check_output", "(", "cmd", ")", "image_id", "=", "image_id_b", ".",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
default_ccache_dir
:return: ccache directory for the current platform
ci/build.py
def default_ccache_dir() -> str: """:return: ccache directory for the current platform""" # Share ccache across containers if 'CCACHE_DIR' in os.environ: ccache_dir = os.path.realpath(os.environ['CCACHE_DIR']) try: os.makedirs(ccache_dir, exist_ok=True) return ccache_...
def default_ccache_dir() -> str: """:return: ccache directory for the current platform""" # Share ccache across containers if 'CCACHE_DIR' in os.environ: ccache_dir = os.path.realpath(os.environ['CCACHE_DIR']) try: os.makedirs(ccache_dir, exist_ok=True) return ccache_...
[ ":", "return", ":", "ccache", "directory", "for", "the", "current", "platform" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/build.py#L189-L205
[ "def", "default_ccache_dir", "(", ")", "->", "str", ":", "# Share ccache across containers", "if", "'CCACHE_DIR'", "in", "os", ".", "environ", ":", "ccache_dir", "=", "os", ".", "path", ".", "realpath", "(", "os", ".", "environ", "[", "'CCACHE_DIR'", "]", ")...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
container_run
Run command in a container
ci/build.py
def container_run(platform: str, nvidia_runtime: bool, docker_registry: str, shared_memory_size: str, local_ccache_dir: str, command: List[str], cleanup: Cleanup, environment: Dict[str, str], ...
def container_run(platform: str, nvidia_runtime: bool, docker_registry: str, shared_memory_size: str, local_ccache_dir: str, command: List[str], cleanup: Cleanup, environment: Dict[str, str], ...
[ "Run", "command", "in", "a", "container" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/build.py#L213-L361
[ "def", "container_run", "(", "platform", ":", "str", ",", "nvidia_runtime", ":", "bool", ",", "docker_registry", ":", "str", ",", "shared_memory_size", ":", "str", ",", "local_ccache_dir", ":", "str", ",", "command", ":", "List", "[", "str", "]", ",", "cle...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
load_docker_cache
Imports tagged container from the given docker registry
ci/build.py
def load_docker_cache(tag, docker_registry) -> None: """Imports tagged container from the given docker registry""" if docker_registry: # noinspection PyBroadException try: import docker_cache logging.info('Docker cache download is enabled from registry %s', docker_registr...
def load_docker_cache(tag, docker_registry) -> None: """Imports tagged container from the given docker registry""" if docker_registry: # noinspection PyBroadException try: import docker_cache logging.info('Docker cache download is enabled from registry %s', docker_registr...
[ "Imports", "tagged", "container", "from", "the", "given", "docker", "registry" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/ci/build.py#L368-L379
[ "def", "load_docker_cache", "(", "tag", ",", "docker_registry", ")", "->", "None", ":", "if", "docker_registry", ":", "# noinspection PyBroadException", "try", ":", "import", "docker_cache", "logging", ".", "info", "(", "'Docker cache download is enabled from registry %s'...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_load_general
Load a list of arrays into a list of arrays specified by slices.
python/mxnet/module/executor_group.py
def _load_general(data, targets, major_axis): """Load a list of arrays into a list of arrays specified by slices.""" for d_src, d_targets, axis in zip(data, targets, major_axis): # pylint: disable=too-many-nested-blocks if isinstance(d_targets, nd.NDArray): d_src.copyto(d_targets) el...
def _load_general(data, targets, major_axis): """Load a list of arrays into a list of arrays specified by slices.""" for d_src, d_targets, axis in zip(data, targets, major_axis): # pylint: disable=too-many-nested-blocks if isinstance(d_targets, nd.NDArray): d_src.copyto(d_targets) el...
[ "Load", "a", "list", "of", "arrays", "into", "a", "list", "of", "arrays", "specified", "by", "slices", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L31-L62
[ "def", "_load_general", "(", "data", ",", "targets", ",", "major_axis", ")", ":", "for", "d_src", ",", "d_targets", ",", "axis", "in", "zip", "(", "data", ",", "targets", ",", "major_axis", ")", ":", "# pylint: disable=too-many-nested-blocks", "if", "isinstanc...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_load_data
Load data into sliced arrays.
python/mxnet/module/executor_group.py
def _load_data(batch, targets, major_axis): """Load data into sliced arrays.""" if isinstance(batch, list): new_batch = [] for i in range(len(targets)): new_batch.append([b.data[i] for b in batch]) new_targets = [[dst for _, dst in d_target] for d_target in targets] _...
def _load_data(batch, targets, major_axis): """Load data into sliced arrays.""" if isinstance(batch, list): new_batch = [] for i in range(len(targets)): new_batch.append([b.data[i] for b in batch]) new_targets = [[dst for _, dst in d_target] for d_target in targets] _...
[ "Load", "data", "into", "sliced", "arrays", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L65-L74
[ "def", "_load_data", "(", "batch", ",", "targets", ",", "major_axis", ")", ":", "if", "isinstance", "(", "batch", ",", "list", ")", ":", "new_batch", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "targets", ")", ")", ":", "new_batch", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_merge_multi_context
Merge outputs that lives on multiple context into one, so that they look like living on one context.
python/mxnet/module/executor_group.py
def _merge_multi_context(outputs, major_axis): """Merge outputs that lives on multiple context into one, so that they look like living on one context. """ rets = [] for tensors, axis in zip(outputs, major_axis): if axis >= 0: # pylint: disable=no-member,protected-access ...
def _merge_multi_context(outputs, major_axis): """Merge outputs that lives on multiple context into one, so that they look like living on one context. """ rets = [] for tensors, axis in zip(outputs, major_axis): if axis >= 0: # pylint: disable=no-member,protected-access ...
[ "Merge", "outputs", "that", "lives", "on", "multiple", "context", "into", "one", "so", "that", "they", "look", "like", "living", "on", "one", "context", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L89-L110
[ "def", "_merge_multi_context", "(", "outputs", ",", "major_axis", ")", ":", "rets", "=", "[", "]", "for", "tensors", ",", "axis", "in", "zip", "(", "outputs", ",", "major_axis", ")", ":", "if", "axis", ">=", "0", ":", "# pylint: disable=no-member,protected-a...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_prepare_group2ctxs
Prepare the group2contexts, will duplicate the context if some ctx_group map to only one context.
python/mxnet/module/executor_group.py
def _prepare_group2ctxs(group2ctxs, ctx_len): """Prepare the group2contexts, will duplicate the context if some ctx_group map to only one context. """ if group2ctxs is None: return [None] * ctx_len elif isinstance(group2ctxs, list): assert(len(group2ctxs) == ctx_len), "length of grou...
def _prepare_group2ctxs(group2ctxs, ctx_len): """Prepare the group2contexts, will duplicate the context if some ctx_group map to only one context. """ if group2ctxs is None: return [None] * ctx_len elif isinstance(group2ctxs, list): assert(len(group2ctxs) == ctx_len), "length of grou...
[ "Prepare", "the", "group2contexts", "will", "duplicate", "the", "context", "if", "some", "ctx_group", "map", "to", "only", "one", "context", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L112-L141
[ "def", "_prepare_group2ctxs", "(", "group2ctxs", ",", "ctx_len", ")", ":", "if", "group2ctxs", "is", "None", ":", "return", "[", "None", "]", "*", "ctx_len", "elif", "isinstance", "(", "group2ctxs", ",", "list", ")", ":", "assert", "(", "len", "(", "grou...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup.decide_slices
Decide the slices for each context according to the workload. Parameters ---------- data_shapes : list list of (name, shape) specifying the shapes for the input data or label.
python/mxnet/module/executor_group.py
def decide_slices(self, data_shapes): """Decide the slices for each context according to the workload. Parameters ---------- data_shapes : list list of (name, shape) specifying the shapes for the input data or label. """ assert len(data_shapes) > 0 ma...
def decide_slices(self, data_shapes): """Decide the slices for each context according to the workload. Parameters ---------- data_shapes : list list of (name, shape) specifying the shapes for the input data or label. """ assert len(data_shapes) > 0 ma...
[ "Decide", "the", "slices", "for", "each", "context", "according", "to", "the", "workload", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L281-L305
[ "def", "decide_slices", "(", "self", ",", "data_shapes", ")", ":", "assert", "len", "(", "data_shapes", ")", ">", "0", "major_axis", "=", "[", "DataDesc", ".", "get_batch_axis", "(", "x", ".", "layout", ")", "for", "x", "in", "data_shapes", "]", "for", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup._collect_arrays
Collect internal arrays from executors.
python/mxnet/module/executor_group.py
def _collect_arrays(self): """Collect internal arrays from executors.""" # convenient data structures self.data_arrays = [[(self.slices[i], e.arg_dict[name]) for i, e in enumerate(self.execs)] for name, _ in self.data_shapes] self.state_arrays = [[e.arg_dict[...
def _collect_arrays(self): """Collect internal arrays from executors.""" # convenient data structures self.data_arrays = [[(self.slices[i], e.arg_dict[name]) for i, e in enumerate(self.execs)] for name, _ in self.data_shapes] self.state_arrays = [[e.arg_dict[...
[ "Collect", "internal", "arrays", "from", "executors", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L307-L342
[ "def", "_collect_arrays", "(", "self", ")", ":", "# convenient data structures", "self", ".", "data_arrays", "=", "[", "[", "(", "self", ".", "slices", "[", "i", "]", ",", "e", ".", "arg_dict", "[", "name", "]", ")", "for", "i", ",", "e", "in", "enum...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup.bind_exec
Bind executors on their respective devices. Parameters ---------- data_shapes : list label_shapes : list shared_group : DataParallelExecutorGroup reshape : bool
python/mxnet/module/executor_group.py
def bind_exec(self, data_shapes, label_shapes, shared_group=None, reshape=False): """Bind executors on their respective devices. Parameters ---------- data_shapes : list label_shapes : list shared_group : DataParallelExecutorGroup reshape : bool """ ...
def bind_exec(self, data_shapes, label_shapes, shared_group=None, reshape=False): """Bind executors on their respective devices. Parameters ---------- data_shapes : list label_shapes : list shared_group : DataParallelExecutorGroup reshape : bool """ ...
[ "Bind", "executors", "on", "their", "respective", "devices", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L344-L382
[ "def", "bind_exec", "(", "self", ",", "data_shapes", ",", "label_shapes", ",", "shared_group", "=", "None", ",", "reshape", "=", "False", ")", ":", "assert", "reshape", "or", "not", "self", ".", "execs", "self", ".", "batch_size", "=", "None", "# calculate...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup.reshape
Reshape executors. Parameters ---------- data_shapes : list label_shapes : list
python/mxnet/module/executor_group.py
def reshape(self, data_shapes, label_shapes): """Reshape executors. Parameters ---------- data_shapes : list label_shapes : list """ if data_shapes == self.data_shapes and label_shapes == self.label_shapes: return if self._default_execs is Non...
def reshape(self, data_shapes, label_shapes): """Reshape executors. Parameters ---------- data_shapes : list label_shapes : list """ if data_shapes == self.data_shapes and label_shapes == self.label_shapes: return if self._default_execs is Non...
[ "Reshape", "executors", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L384-L396
[ "def", "reshape", "(", "self", ",", "data_shapes", ",", "label_shapes", ")", ":", "if", "data_shapes", "==", "self", ".", "data_shapes", "and", "label_shapes", "==", "self", ".", "label_shapes", ":", "return", "if", "self", ".", "_default_execs", "is", "None...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup.set_params
Assign, i.e. copy parameters to all the executors. Parameters ---------- arg_params : dict A dictionary of name to `NDArray` parameter mapping. aux_params : dict A dictionary of name to `NDArray` auxiliary variable mapping. allow_extra : boolean, optional...
python/mxnet/module/executor_group.py
def set_params(self, arg_params, aux_params, allow_extra=False): """Assign, i.e. copy parameters to all the executors. Parameters ---------- arg_params : dict A dictionary of name to `NDArray` parameter mapping. aux_params : dict A dictionary of name to `...
def set_params(self, arg_params, aux_params, allow_extra=False): """Assign, i.e. copy parameters to all the executors. Parameters ---------- arg_params : dict A dictionary of name to `NDArray` parameter mapping. aux_params : dict A dictionary of name to `...
[ "Assign", "i", ".", "e", ".", "copy", "parameters", "to", "all", "the", "executors", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L398-L413
[ "def", "set_params", "(", "self", ",", "arg_params", ",", "aux_params", ",", "allow_extra", "=", "False", ")", ":", "for", "exec_", "in", "self", ".", "execs", ":", "exec_", ".", "copy_params_from", "(", "arg_params", ",", "aux_params", ",", "allow_extra_par...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup.get_params
Copy data from each executor to `arg_params` and `aux_params`. Parameters ---------- arg_params : list of NDArray Target parameter arrays. aux_params : list of NDArray Target aux arrays. Notes ----- - This function will inplace update the...
python/mxnet/module/executor_group.py
def get_params(self, arg_params, aux_params): """ Copy data from each executor to `arg_params` and `aux_params`. Parameters ---------- arg_params : list of NDArray Target parameter arrays. aux_params : list of NDArray Target aux arrays. Notes ...
def get_params(self, arg_params, aux_params): """ Copy data from each executor to `arg_params` and `aux_params`. Parameters ---------- arg_params : list of NDArray Target parameter arrays. aux_params : list of NDArray Target aux arrays. Notes ...
[ "Copy", "data", "from", "each", "executor", "to", "arg_params", "and", "aux_params", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L415-L434
[ "def", "get_params", "(", "self", ",", "arg_params", ",", "aux_params", ")", ":", "for", "name", ",", "block", "in", "zip", "(", "self", ".", "param_names", ",", "self", ".", "param_arrays", ")", ":", "weight", "=", "sum", "(", "w", ".", "copyto", "(...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup.forward
Split `data_batch` according to workload and run forward on each devices. Parameters ---------- data_batch : DataBatch Or could be any object implementing similar interface. is_train : bool The hint for the backend, indicating whether we are during training phase...
python/mxnet/module/executor_group.py
def forward(self, data_batch, is_train=None): """Split `data_batch` according to workload and run forward on each devices. Parameters ---------- data_batch : DataBatch Or could be any object implementing similar interface. is_train : bool The hint for the...
def forward(self, data_batch, is_train=None): """Split `data_batch` according to workload and run forward on each devices. Parameters ---------- data_batch : DataBatch Or could be any object implementing similar interface. is_train : bool The hint for the...
[ "Split", "data_batch", "according", "to", "workload", "and", "run", "forward", "on", "each", "devices", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L436-L462
[ "def", "forward", "(", "self", ",", "data_batch", ",", "is_train", "=", "None", ")", ":", "_load_data", "(", "data_batch", ",", "self", ".", "data_arrays", ",", "self", ".", "data_layouts", ")", "if", "is_train", "is", "None", ":", "is_train", "=", "self...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup.get_output_shapes
Get the shapes of the outputs.
python/mxnet/module/executor_group.py
def get_output_shapes(self): """Get the shapes of the outputs.""" outputs = self.execs[0].outputs shapes = [out.shape for out in outputs] concat_shapes = [] for key, the_shape, axis in zip(self.symbol.list_outputs(), shapes, self.output_layouts): the_shape = list(the...
def get_output_shapes(self): """Get the shapes of the outputs.""" outputs = self.execs[0].outputs shapes = [out.shape for out in outputs] concat_shapes = [] for key, the_shape, axis in zip(self.symbol.list_outputs(), shapes, self.output_layouts): the_shape = list(the...
[ "Get", "the", "shapes", "of", "the", "outputs", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L464-L475
[ "def", "get_output_shapes", "(", "self", ")", ":", "outputs", "=", "self", ".", "execs", "[", "0", "]", ".", "outputs", "shapes", "=", "[", "out", ".", "shape", "for", "out", "in", "outputs", "]", "concat_shapes", "=", "[", "]", "for", "key", ",", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup.get_outputs
Get outputs of the previous forward computation. If begin or end is specified, return [begin, end)-th outputs, otherwise return all outputs. Parameters ---------- merge_multi_context : bool Default is `True`. In the case when data-parallelism is used, the outputs ...
python/mxnet/module/executor_group.py
def get_outputs(self, merge_multi_context=True, begin=0, end=None): """Get outputs of the previous forward computation. If begin or end is specified, return [begin, end)-th outputs, otherwise return all outputs. Parameters ---------- merge_multi_context : bool ...
def get_outputs(self, merge_multi_context=True, begin=0, end=None): """Get outputs of the previous forward computation. If begin or end is specified, return [begin, end)-th outputs, otherwise return all outputs. Parameters ---------- merge_multi_context : bool ...
[ "Get", "outputs", "of", "the", "previous", "forward", "computation", ".", "If", "begin", "or", "end", "is", "specified", "return", "[", "begin", "end", ")", "-", "th", "outputs", "otherwise", "return", "all", "outputs", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L477-L506
[ "def", "get_outputs", "(", "self", ",", "merge_multi_context", "=", "True", ",", "begin", "=", "0", ",", "end", "=", "None", ")", ":", "if", "end", "is", "None", ":", "end", "=", "self", ".", "num_outputs", "outputs", "=", "[", "[", "exec_", ".", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup.set_states
Set value for states. Only one of states & value can be specified. Parameters ---------- states : list of list of NDArrays source states arrays formatted like [[state1_dev1, state1_dev2], [state2_dev1, state2_dev2]]. value : number a single scalar val...
python/mxnet/module/executor_group.py
def set_states(self, states=None, value=None): """Set value for states. Only one of states & value can be specified. Parameters ---------- states : list of list of NDArrays source states arrays formatted like [[state1_dev1, state1_dev2], [state2_dev1, state2_dev2...
def set_states(self, states=None, value=None): """Set value for states. Only one of states & value can be specified. Parameters ---------- states : list of list of NDArrays source states arrays formatted like [[state1_dev1, state1_dev2], [state2_dev1, state2_dev2...
[ "Set", "value", "for", "states", ".", "Only", "one", "of", "states", "&", "value", "can", "be", "specified", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L529-L548
[ "def", "set_states", "(", "self", ",", "states", "=", "None", ",", "value", "=", "None", ")", ":", "if", "states", "is", "not", "None", ":", "assert", "value", "is", "None", ",", "\"Only one of states & value can be specified.\"", "_load_general", "(", "states...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup.get_input_grads
Get the gradients with respect to the inputs of the module. Parameters ---------- merge_multi_context : bool Defaults to ``True``. In the case when data-parallelism is used, the outputs will be collected from multiple devices. A `True` value indicate that we ...
python/mxnet/module/executor_group.py
def get_input_grads(self, merge_multi_context=True): """Get the gradients with respect to the inputs of the module. Parameters ---------- merge_multi_context : bool Defaults to ``True``. In the case when data-parallelism is used, the outputs will be collected fro...
def get_input_grads(self, merge_multi_context=True): """Get the gradients with respect to the inputs of the module. Parameters ---------- merge_multi_context : bool Defaults to ``True``. In the case when data-parallelism is used, the outputs will be collected fro...
[ "Get", "the", "gradients", "with", "respect", "to", "the", "inputs", "of", "the", "module", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L550-L570
[ "def", "get_input_grads", "(", "self", ",", "merge_multi_context", "=", "True", ")", ":", "assert", "self", ".", "inputs_need_grad", "if", "merge_multi_context", ":", "return", "_merge_multi_context", "(", "self", ".", "input_grad_arrays", ",", "self", ".", "data_...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup.backward
Run backward on all devices. A backward should be called after a call to the forward function. Backward cannot be called unless ``self.for_training`` is ``True``. Parameters ---------- out_grads : NDArray or list of NDArray, optional Gradient on the outputs to be pro...
python/mxnet/module/executor_group.py
def backward(self, out_grads=None): """Run backward on all devices. A backward should be called after a call to the forward function. Backward cannot be called unless ``self.for_training`` is ``True``. Parameters ---------- out_grads : NDArray or list of NDArray, optiona...
def backward(self, out_grads=None): """Run backward on all devices. A backward should be called after a call to the forward function. Backward cannot be called unless ``self.for_training`` is ``True``. Parameters ---------- out_grads : NDArray or list of NDArray, optiona...
[ "Run", "backward", "on", "all", "devices", ".", "A", "backward", "should", "be", "called", "after", "a", "call", "to", "the", "forward", "function", ".", "Backward", "cannot", "be", "called", "unless", "self", ".", "for_training", "is", "True", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L572-L599
[ "def", "backward", "(", "self", ",", "out_grads", "=", "None", ")", ":", "assert", "self", ".", "for_training", ",", "'re-bind with for_training=True to run backward'", "if", "out_grads", "is", "None", ":", "out_grads", "=", "[", "]", "for", "i", ",", "(", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup.update_metric
Accumulate the performance according to `eval_metric` on all devices by comparing outputs from [begin, end) to labels. By default use all outputs. Parameters ---------- eval_metric : EvalMetric The metric used for evaluation. labels : list of NDArray ...
python/mxnet/module/executor_group.py
def update_metric(self, eval_metric, labels, pre_sliced): """Accumulate the performance according to `eval_metric` on all devices by comparing outputs from [begin, end) to labels. By default use all outputs. Parameters ---------- eval_metric : EvalMetric The ...
def update_metric(self, eval_metric, labels, pre_sliced): """Accumulate the performance according to `eval_metric` on all devices by comparing outputs from [begin, end) to labels. By default use all outputs. Parameters ---------- eval_metric : EvalMetric The ...
[ "Accumulate", "the", "performance", "according", "to", "eval_metric", "on", "all", "devices", "by", "comparing", "outputs", "from", "[", "begin", "end", ")", "to", "labels", ".", "By", "default", "use", "all", "outputs", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L601-L639
[ "def", "update_metric", "(", "self", ",", "eval_metric", ",", "labels", ",", "pre_sliced", ")", ":", "for", "current_exec", ",", "(", "texec", ",", "islice", ")", "in", "enumerate", "(", "zip", "(", "self", ".", "execs", ",", "self", ".", "slices", ")"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup._bind_ith_exec
Internal utility function to bind the i-th executor. This function utilizes simple_bind python interface.
python/mxnet/module/executor_group.py
def _bind_ith_exec(self, i, data_shapes, label_shapes, shared_group): """Internal utility function to bind the i-th executor. This function utilizes simple_bind python interface. """ shared_exec = None if shared_group is None else shared_group.execs[i] context = self.contexts[i] ...
def _bind_ith_exec(self, i, data_shapes, label_shapes, shared_group): """Internal utility function to bind the i-th executor. This function utilizes simple_bind python interface. """ shared_exec = None if shared_group is None else shared_group.execs[i] context = self.contexts[i] ...
[ "Internal", "utility", "function", "to", "bind", "the", "i", "-", "th", "executor", ".", "This", "function", "utilizes", "simple_bind", "python", "interface", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L641-L664
[ "def", "_bind_ith_exec", "(", "self", ",", "i", ",", "data_shapes", ",", "label_shapes", ",", "shared_group", ")", ":", "shared_exec", "=", "None", "if", "shared_group", "is", "None", "else", "shared_group", ".", "execs", "[", "i", "]", "context", "=", "se...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DataParallelExecutorGroup._sliced_shape
Get the sliced shapes for the i-th executor. Parameters ---------- shapes : list of (str, tuple) The original (name, shape) pairs. i : int Which executor we are dealing with.
python/mxnet/module/executor_group.py
def _sliced_shape(self, shapes, i, major_axis): """Get the sliced shapes for the i-th executor. Parameters ---------- shapes : list of (str, tuple) The original (name, shape) pairs. i : int Which executor we are dealing with. """ sliced_sh...
def _sliced_shape(self, shapes, i, major_axis): """Get the sliced shapes for the i-th executor. Parameters ---------- shapes : list of (str, tuple) The original (name, shape) pairs. i : int Which executor we are dealing with. """ sliced_sh...
[ "Get", "the", "sliced", "shapes", "for", "the", "i", "-", "th", "executor", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/executor_group.py#L666-L682
[ "def", "_sliced_shape", "(", "self", ",", "shapes", ",", "i", ",", "major_axis", ")", ":", "sliced_shapes", "=", "[", "]", "for", "desc", ",", "axis", "in", "zip", "(", "shapes", ",", "major_axis", ")", ":", "shape", "=", "list", "(", "desc", ".", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
parse_class_names
parse # classes and class_names if applicable
example/ssd/train.py
def parse_class_names(args): """ parse # classes and class_names if applicable """ num_class = args.num_class if len(args.class_names) > 0: if os.path.isfile(args.class_names): # try to open it to read class names with open(args.class_names, 'r') as f: class_n...
def parse_class_names(args): """ parse # classes and class_names if applicable """ num_class = args.num_class if len(args.class_names) > 0: if os.path.isfile(args.class_names): # try to open it to read class names with open(args.class_names, 'r') as f: class_n...
[ "parse", "#", "classes", "and", "class_names", "if", "applicable" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ssd/train.py#L111-L126
[ "def", "parse_class_names", "(", "args", ")", ":", "num_class", "=", "args", ".", "num_class", "if", "len", "(", "args", ".", "class_names", ")", ">", "0", ":", "if", "os", ".", "path", ".", "isfile", "(", "args", ".", "class_names", ")", ":", "# try...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_has_instance
Return True if ``data`` has instance of ``dtype``. This function is called after _init_data. ``data`` is a list of (str, NDArray)
python/mxnet/io/utils.py
def _has_instance(data, dtype): """Return True if ``data`` has instance of ``dtype``. This function is called after _init_data. ``data`` is a list of (str, NDArray)""" for item in data: _, arr = item if isinstance(arr, dtype): return True return False
def _has_instance(data, dtype): """Return True if ``data`` has instance of ``dtype``. This function is called after _init_data. ``data`` is a list of (str, NDArray)""" for item in data: _, arr = item if isinstance(arr, dtype): return True return False
[ "Return", "True", "if", "data", "has", "instance", "of", "dtype", ".", "This", "function", "is", "called", "after", "_init_data", ".", "data", "is", "a", "list", "of", "(", "str", "NDArray", ")" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/utils.py#L63-L71
[ "def", "_has_instance", "(", "data", ",", "dtype", ")", ":", "for", "item", "in", "data", ":", "_", ",", "arr", "=", "item", "if", "isinstance", "(", "arr", ",", "dtype", ")", ":", "return", "True", "return", "False" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_getdata_by_idx
Shuffle the data.
python/mxnet/io/utils.py
def _getdata_by_idx(data, idx): """Shuffle the data.""" shuffle_data = [] for k, v in data: if (isinstance(v, h5py.Dataset) if h5py else False): shuffle_data.append((k, v)) elif isinstance(v, CSRNDArray): shuffle_data.append((k, sparse_array(v.asscipy()[idx], v.conte...
def _getdata_by_idx(data, idx): """Shuffle the data.""" shuffle_data = [] for k, v in data: if (isinstance(v, h5py.Dataset) if h5py else False): shuffle_data.append((k, v)) elif isinstance(v, CSRNDArray): shuffle_data.append((k, sparse_array(v.asscipy()[idx], v.conte...
[ "Shuffle", "the", "data", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/io/utils.py#L74-L86
[ "def", "_getdata_by_idx", "(", "data", ",", "idx", ")", ":", "shuffle_data", "=", "[", "]", "for", "k", ",", "v", "in", "data", ":", "if", "(", "isinstance", "(", "v", ",", "h5py", ".", "Dataset", ")", "if", "h5py", "else", "False", ")", ":", "sh...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_mobilenet
r"""MobileNet model from the `"MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications" <https://arxiv.org/abs/1704.04861>`_ paper. Parameters ---------- multiplier : float The width multiplier for controling the model size. Only multipliers that are no le...
python/mxnet/gluon/model_zoo/vision/mobilenet.py
def get_mobilenet(multiplier, pretrained=False, ctx=cpu(), root=os.path.join(base.data_dir(), 'models'), **kwargs): r"""MobileNet model from the `"MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications" <https://arxiv.org/abs/1704.04861>`_ paper. Parameters...
def get_mobilenet(multiplier, pretrained=False, ctx=cpu(), root=os.path.join(base.data_dir(), 'models'), **kwargs): r"""MobileNet model from the `"MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications" <https://arxiv.org/abs/1704.04861>`_ paper. Parameters...
[ "r", "MobileNet", "model", "from", "the", "MobileNets", ":", "Efficient", "Convolutional", "Neural", "Networks", "for", "Mobile", "Vision", "Applications", "<https", ":", "//", "arxiv", ".", "org", "/", "abs", "/", "1704", ".", "04861", ">", "_", "paper", ...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/model_zoo/vision/mobilenet.py#L191-L219
[ "def", "get_mobilenet", "(", "multiplier", ",", "pretrained", "=", "False", ",", "ctx", "=", "cpu", "(", ")", ",", "root", "=", "os", ".", "path", ".", "join", "(", "base", ".", "data_dir", "(", ")", ",", "'models'", ")", ",", "*", "*", "kwargs", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
NameManager.get
Get the canonical name for a symbol. This is the default implementation. If the user specifies a name, the user-specified name will be used. When user does not specify a name, we automatically generate a name based on the hint string. Parameters ---------- ...
python/mxnet/name.py
def get(self, name, hint): """Get the canonical name for a symbol. This is the default implementation. If the user specifies a name, the user-specified name will be used. When user does not specify a name, we automatically generate a name based on the hint string. ...
def get(self, name, hint): """Get the canonical name for a symbol. This is the default implementation. If the user specifies a name, the user-specified name will be used. When user does not specify a name, we automatically generate a name based on the hint string. ...
[ "Get", "the", "canonical", "name", "for", "a", "symbol", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/name.py#L36-L65
[ "def", "get", "(", "self", ",", "name", ",", "hint", ")", ":", "if", "name", ":", "return", "name", "if", "hint", "not", "in", "self", ".", "_counter", ":", "self", ".", "_counter", "[", "hint", "]", "=", "0", "name", "=", "'%s%d'", "%", "(", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
LogUniformSampler.draw
Draw samples from log uniform distribution and returns sampled candidates, expected count for true classes and sampled classes.
example/rnn/large_word_lm/sampler.py
def draw(self, true_classes): """Draw samples from log uniform distribution and returns sampled candidates, expected count for true classes and sampled classes.""" range_max = self.range_max num_sampled = self.num_sampled ctx = true_classes.context log_range = math.log(ra...
def draw(self, true_classes): """Draw samples from log uniform distribution and returns sampled candidates, expected count for true classes and sampled classes.""" range_max = self.range_max num_sampled = self.num_sampled ctx = true_classes.context log_range = math.log(ra...
[ "Draw", "samples", "from", "log", "uniform", "distribution", "and", "returns", "sampled", "candidates", "expected", "count", "for", "true", "classes", "and", "sampled", "classes", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rnn/large_word_lm/sampler.py#L36-L55
[ "def", "draw", "(", "self", ",", "true_classes", ")", ":", "range_max", "=", "self", ".", "range_max", "num_sampled", "=", "self", ".", "num_sampled", "ctx", "=", "true_classes", ".", "context", "log_range", "=", "math", ".", "log", "(", "range_max", "+", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
get_inception_score
Inception_score function. The images will be divided into 'splits' parts, and calculate each inception_score separately, then return the mean and std of inception_scores of these parts. :param images: Images(num x c x w x h) that needs to calculate inception_score. :param splits: :return: me...
example/gluon/dc_gan/inception_score.py
def get_inception_score(images, splits=10): """ Inception_score function. The images will be divided into 'splits' parts, and calculate each inception_score separately, then return the mean and std of inception_scores of these parts. :param images: Images(num x c x w x h) that needs to calcu...
def get_inception_score(images, splits=10): """ Inception_score function. The images will be divided into 'splits' parts, and calculate each inception_score separately, then return the mean and std of inception_scores of these parts. :param images: Images(num x c x w x h) that needs to calcu...
[ "Inception_score", "function", ".", "The", "images", "will", "be", "divided", "into", "splits", "parts", "and", "calculate", "each", "inception_score", "separately", "then", "return", "the", "mean", "and", "std", "of", "inception_scores", "of", "these", "parts", ...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/dc_gan/inception_score.py#L31-L76
[ "def", "get_inception_score", "(", "images", ",", "splits", "=", "10", ")", ":", "assert", "(", "images", ".", "shape", "[", "1", "]", "==", "3", ")", "# load inception model", "if", "inception_model", "is", "None", ":", "_init_inception", "(", ")", "# res...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
load_param
same as mx.model.load_checkpoint, but do not load symnet and will convert context
example/rcnn/symnet/model.py
def load_param(params, ctx=None): """same as mx.model.load_checkpoint, but do not load symnet and will convert context""" if ctx is None: ctx = mx.cpu() save_dict = mx.nd.load(params) arg_params = {} aux_params = {} for k, v in save_dict.items(): tp, name = k.split(':', 1) ...
def load_param(params, ctx=None): """same as mx.model.load_checkpoint, but do not load symnet and will convert context""" if ctx is None: ctx = mx.cpu() save_dict = mx.nd.load(params) arg_params = {} aux_params = {} for k, v in save_dict.items(): tp, name = k.split(':', 1) ...
[ "same", "as", "mx", ".", "model", ".", "load_checkpoint", "but", "do", "not", "load", "symnet", "and", "will", "convert", "context" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rcnn/symnet/model.py#L21-L34
[ "def", "load_param", "(", "params", ",", "ctx", "=", "None", ")", ":", "if", "ctx", "is", "None", ":", "ctx", "=", "mx", ".", "cpu", "(", ")", "save_dict", "=", "mx", ".", "nd", ".", "load", "(", "params", ")", "arg_params", "=", "{", "}", "aux...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
rnn_unroll
Deprecated. Please use cell.unroll instead
python/mxnet/rnn/rnn.py
def rnn_unroll(cell, length, inputs=None, begin_state=None, input_prefix='', layout='NTC'): """Deprecated. Please use cell.unroll instead""" warnings.warn('rnn_unroll is deprecated. Please call cell.unroll directly.') return cell.unroll(length=length, inputs=inputs, begin_state=begin_state, ...
def rnn_unroll(cell, length, inputs=None, begin_state=None, input_prefix='', layout='NTC'): """Deprecated. Please use cell.unroll instead""" warnings.warn('rnn_unroll is deprecated. Please call cell.unroll directly.') return cell.unroll(length=length, inputs=inputs, begin_state=begin_state, ...
[ "Deprecated", ".", "Please", "use", "cell", ".", "unroll", "instead" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn.py#L26-L30
[ "def", "rnn_unroll", "(", "cell", ",", "length", ",", "inputs", "=", "None", ",", "begin_state", "=", "None", ",", "input_prefix", "=", "''", ",", "layout", "=", "'NTC'", ")", ":", "warnings", ".", "warn", "(", "'rnn_unroll is deprecated. Please call cell.unro...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
save_rnn_checkpoint
Save checkpoint for model using RNN cells. Unpacks weight before saving. Parameters ---------- cells : mxnet.rnn.RNNCell or list of RNNCells The RNN cells used by this symbol. prefix : str Prefix of model name. epoch : int The epoch number of the model. symbol : Symb...
python/mxnet/rnn/rnn.py
def save_rnn_checkpoint(cells, prefix, epoch, symbol, arg_params, aux_params): """Save checkpoint for model using RNN cells. Unpacks weight before saving. Parameters ---------- cells : mxnet.rnn.RNNCell or list of RNNCells The RNN cells used by this symbol. prefix : str Prefix o...
def save_rnn_checkpoint(cells, prefix, epoch, symbol, arg_params, aux_params): """Save checkpoint for model using RNN cells. Unpacks weight before saving. Parameters ---------- cells : mxnet.rnn.RNNCell or list of RNNCells The RNN cells used by this symbol. prefix : str Prefix o...
[ "Save", "checkpoint", "for", "model", "using", "RNN", "cells", ".", "Unpacks", "weight", "before", "saving", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn.py#L32-L60
[ "def", "save_rnn_checkpoint", "(", "cells", ",", "prefix", ",", "epoch", ",", "symbol", ",", "arg_params", ",", "aux_params", ")", ":", "if", "isinstance", "(", "cells", ",", "BaseRNNCell", ")", ":", "cells", "=", "[", "cells", "]", "for", "cell", "in", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
load_rnn_checkpoint
Load model checkpoint from file. Pack weights after loading. Parameters ---------- cells : mxnet.rnn.RNNCell or list of RNNCells The RNN cells used by this symbol. prefix : str Prefix of model name. epoch : int Epoch number of model we would like to load. Returns ...
python/mxnet/rnn/rnn.py
def load_rnn_checkpoint(cells, prefix, epoch): """Load model checkpoint from file. Pack weights after loading. Parameters ---------- cells : mxnet.rnn.RNNCell or list of RNNCells The RNN cells used by this symbol. prefix : str Prefix of model name. epoch : int Epoch ...
def load_rnn_checkpoint(cells, prefix, epoch): """Load model checkpoint from file. Pack weights after loading. Parameters ---------- cells : mxnet.rnn.RNNCell or list of RNNCells The RNN cells used by this symbol. prefix : str Prefix of model name. epoch : int Epoch ...
[ "Load", "model", "checkpoint", "from", "file", ".", "Pack", "weights", "after", "loading", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn.py#L62-L95
[ "def", "load_rnn_checkpoint", "(", "cells", ",", "prefix", ",", "epoch", ")", ":", "sym", ",", "arg", ",", "aux", "=", "load_checkpoint", "(", "prefix", ",", "epoch", ")", "if", "isinstance", "(", "cells", ",", "BaseRNNCell", ")", ":", "cells", "=", "[...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
do_rnn_checkpoint
Make a callback to checkpoint Module to prefix every epoch. unpacks weights used by cells before saving. Parameters ---------- cells : mxnet.rnn.RNNCell or list of RNNCells The RNN cells used by this symbol. prefix : str The file prefix to checkpoint to period : int How ...
python/mxnet/rnn/rnn.py
def do_rnn_checkpoint(cells, prefix, period=1): """Make a callback to checkpoint Module to prefix every epoch. unpacks weights used by cells before saving. Parameters ---------- cells : mxnet.rnn.RNNCell or list of RNNCells The RNN cells used by this symbol. prefix : str The fil...
def do_rnn_checkpoint(cells, prefix, period=1): """Make a callback to checkpoint Module to prefix every epoch. unpacks weights used by cells before saving. Parameters ---------- cells : mxnet.rnn.RNNCell or list of RNNCells The RNN cells used by this symbol. prefix : str The fil...
[ "Make", "a", "callback", "to", "checkpoint", "Module", "to", "prefix", "every", "epoch", ".", "unpacks", "weights", "used", "by", "cells", "before", "saving", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/rnn/rnn.py#L97-L121
[ "def", "do_rnn_checkpoint", "(", "cells", ",", "prefix", ",", "period", "=", "1", ")", ":", "period", "=", "int", "(", "max", "(", "1", ",", "period", ")", ")", "# pylint: disable=unused-argument", "def", "_callback", "(", "iter_no", ",", "sym", "=", "No...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Sequential.hybridize
Activates or deactivates `HybridBlock` s recursively. Has no effect on non-hybrid children. Parameters ---------- active : bool, default True Whether to turn hybrid on or off. **kwargs : string Additional flags for hybridized operator.
python/mxnet/gluon/nn/basic_layers.py
def hybridize(self, active=True, **kwargs): """Activates or deactivates `HybridBlock` s recursively. Has no effect on non-hybrid children. Parameters ---------- active : bool, default True Whether to turn hybrid on or off. **kwargs : string Additi...
def hybridize(self, active=True, **kwargs): """Activates or deactivates `HybridBlock` s recursively. Has no effect on non-hybrid children. Parameters ---------- active : bool, default True Whether to turn hybrid on or off. **kwargs : string Additi...
[ "Activates", "or", "deactivates", "HybridBlock", "s", "recursively", ".", "Has", "no", "effect", "on", "non", "-", "hybrid", "children", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/nn/basic_layers.py#L77-L92
[ "def", "hybridize", "(", "self", ",", "active", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_children", "and", "all", "(", "isinstance", "(", "c", ",", "HybridBlock", ")", "for", "c", "in", "self", ".", "_children", ".", "va...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
read_img
Reads image specified by path into numpy.ndarray
example/ctc/lstm_ocr_infer.py
def read_img(path): """ Reads image specified by path into numpy.ndarray""" img = cv2.resize(cv2.imread(path, 0), (80, 30)).astype(np.float32) / 255 img = np.expand_dims(img.transpose(1, 0), 0) return img
def read_img(path): """ Reads image specified by path into numpy.ndarray""" img = cv2.resize(cv2.imread(path, 0), (80, 30)).astype(np.float32) / 255 img = np.expand_dims(img.transpose(1, 0), 0) return img
[ "Reads", "image", "specified", "by", "path", "into", "numpy", ".", "ndarray" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/lstm_ocr_infer.py#L32-L36
[ "def", "read_img", "(", "path", ")", ":", "img", "=", "cv2", ".", "resize", "(", "cv2", ".", "imread", "(", "path", ",", "0", ")", ",", "(", "80", ",", "30", ")", ")", ".", "astype", "(", "np", ".", "float32", ")", "/", "255", "img", "=", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
lstm_init_states
Returns a tuple of names and zero arrays for LSTM init states
example/ctc/lstm_ocr_infer.py
def lstm_init_states(batch_size): """ Returns a tuple of names and zero arrays for LSTM init states""" hp = Hyperparams() init_shapes = lstm.init_states(batch_size=batch_size, num_lstm_layer=hp.num_lstm_layer, num_hidden=hp.num_hidden) init_names = [s[0] for s in init_shapes] init_arrays = [mx.nd.ze...
def lstm_init_states(batch_size): """ Returns a tuple of names and zero arrays for LSTM init states""" hp = Hyperparams() init_shapes = lstm.init_states(batch_size=batch_size, num_lstm_layer=hp.num_lstm_layer, num_hidden=hp.num_hidden) init_names = [s[0] for s in init_shapes] init_arrays = [mx.nd.ze...
[ "Returns", "a", "tuple", "of", "names", "and", "zero", "arrays", "for", "LSTM", "init", "states" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/lstm_ocr_infer.py#L39-L45
[ "def", "lstm_init_states", "(", "batch_size", ")", ":", "hp", "=", "Hyperparams", "(", ")", "init_shapes", "=", "lstm", ".", "init_states", "(", "batch_size", "=", "batch_size", ",", "num_lstm_layer", "=", "hp", ".", "num_lstm_layer", ",", "num_hidden", "=", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
load_module
Loads the model from checkpoint specified by prefix and epoch, binds it to an executor, and sets its parameters and returns a mx.mod.Module
example/ctc/lstm_ocr_infer.py
def load_module(prefix, epoch, data_names, data_shapes): """Loads the model from checkpoint specified by prefix and epoch, binds it to an executor, and sets its parameters and returns a mx.mod.Module """ sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) # We don't need CTC loss ...
def load_module(prefix, epoch, data_names, data_shapes): """Loads the model from checkpoint specified by prefix and epoch, binds it to an executor, and sets its parameters and returns a mx.mod.Module """ sym, arg_params, aux_params = mx.model.load_checkpoint(prefix, epoch) # We don't need CTC loss ...
[ "Loads", "the", "model", "from", "checkpoint", "specified", "by", "prefix", "and", "epoch", "binds", "it", "to", "an", "executor", "and", "sets", "its", "parameters", "and", "returns", "a", "mx", ".", "mod", ".", "Module" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/lstm_ocr_infer.py#L48-L62
[ "def", "load_module", "(", "prefix", ",", "epoch", ",", "data_names", ",", "data_shapes", ")", ":", "sym", ",", "arg_params", ",", "aux_params", "=", "mx", ".", "model", ".", "load_checkpoint", "(", "prefix", ",", "epoch", ")", "# We don't need CTC loss for pr...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
main
Program entry point
example/ctc/lstm_ocr_infer.py
def main(): """Program entry point""" parser = argparse.ArgumentParser() parser.add_argument("path", help="Path to the CAPTCHA image file") parser.add_argument("--prefix", help="Checkpoint prefix [Default 'ocr']", default='ocr') parser.add_argument("--epoch", help="Checkpoint epoch [Default 100]", t...
def main(): """Program entry point""" parser = argparse.ArgumentParser() parser.add_argument("path", help="Path to the CAPTCHA image file") parser.add_argument("--prefix", help="Checkpoint prefix [Default 'ocr']", default='ocr') parser.add_argument("--epoch", help="Checkpoint epoch [Default 100]", t...
[ "Program", "entry", "point" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/lstm_ocr_infer.py#L65-L88
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "\"path\"", ",", "help", "=", "\"Path to the CAPTCHA image file\"", ")", "parser", ".", "add_argument", "(", "\"--prefix\"", ",", "hel...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
bbox_flip
invalid value in bbox_transform if this wrong (no overlap), note index 0 and 2 also note need to save before assignment :param bbox: [n][x1, y1, x2, y2] :param width: cv2 (height, width, channel) :param flip_x: will flip x1 and x2 :return: flipped box
example/rcnn/symdata/bbox.py
def bbox_flip(bbox, width, flip_x=False): """ invalid value in bbox_transform if this wrong (no overlap), note index 0 and 2 also note need to save before assignment :param bbox: [n][x1, y1, x2, y2] :param width: cv2 (height, width, channel) :param flip_x: will flip x1 and x2 :return: flippe...
def bbox_flip(bbox, width, flip_x=False): """ invalid value in bbox_transform if this wrong (no overlap), note index 0 and 2 also note need to save before assignment :param bbox: [n][x1, y1, x2, y2] :param width: cv2 (height, width, channel) :param flip_x: will flip x1 and x2 :return: flippe...
[ "invalid", "value", "in", "bbox_transform", "if", "this", "wrong", "(", "no", "overlap", ")", "note", "index", "0", "and", "2", "also", "note", "need", "to", "save", "before", "assignment", ":", "param", "bbox", ":", "[", "n", "]", "[", "x1", "y1", "...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rcnn/symdata/bbox.py#L21-L35
[ "def", "bbox_flip", "(", "bbox", ",", "width", ",", "flip_x", "=", "False", ")", ":", "if", "flip_x", ":", "xmax", "=", "width", "-", "bbox", "[", ":", ",", "0", "]", "xmin", "=", "width", "-", "bbox", "[", ":", ",", "2", "]", "bbox", "[", ":...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
bbox_overlaps
determine overlaps between boxes and query_boxes :param boxes: n * 4 bounding boxes :param query_boxes: k * 4 bounding boxes :return: overlaps: n * k overlaps
example/rcnn/symdata/bbox.py
def bbox_overlaps(boxes, query_boxes): """ determine overlaps between boxes and query_boxes :param boxes: n * 4 bounding boxes :param query_boxes: k * 4 bounding boxes :return: overlaps: n * k overlaps """ n_ = boxes.shape[0] k_ = query_boxes.shape[0] overlaps = np.zeros((n_, k_), dt...
def bbox_overlaps(boxes, query_boxes): """ determine overlaps between boxes and query_boxes :param boxes: n * 4 bounding boxes :param query_boxes: k * 4 bounding boxes :return: overlaps: n * k overlaps """ n_ = boxes.shape[0] k_ = query_boxes.shape[0] overlaps = np.zeros((n_, k_), dt...
[ "determine", "overlaps", "between", "boxes", "and", "query_boxes", ":", "param", "boxes", ":", "n", "*", "4", "bounding", "boxes", ":", "param", "query_boxes", ":", "k", "*", "4", "bounding", "boxes", ":", "return", ":", "overlaps", ":", "n", "*", "k", ...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rcnn/symdata/bbox.py#L38-L58
[ "def", "bbox_overlaps", "(", "boxes", ",", "query_boxes", ")", ":", "n_", "=", "boxes", ".", "shape", "[", "0", "]", "k_", "=", "query_boxes", ".", "shape", "[", "0", "]", "overlaps", "=", "np", ".", "zeros", "(", "(", "n_", ",", "k_", ")", ",", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
clip_boxes
Clip boxes to image boundaries. :param boxes: [N, 4* num_classes] :param im_shape: tuple of 2 :return: [N, 4* num_classes]
example/rcnn/symdata/bbox.py
def clip_boxes(boxes, im_shape): """ Clip boxes to image boundaries. :param boxes: [N, 4* num_classes] :param im_shape: tuple of 2 :return: [N, 4* num_classes] """ # x1 >= 0 boxes[:, 0::4] = np.maximum(np.minimum(boxes[:, 0::4], im_shape[1] - 1), 0) # y1 >= 0 boxes[:, 1::4] = np....
def clip_boxes(boxes, im_shape): """ Clip boxes to image boundaries. :param boxes: [N, 4* num_classes] :param im_shape: tuple of 2 :return: [N, 4* num_classes] """ # x1 >= 0 boxes[:, 0::4] = np.maximum(np.minimum(boxes[:, 0::4], im_shape[1] - 1), 0) # y1 >= 0 boxes[:, 1::4] = np....
[ "Clip", "boxes", "to", "image", "boundaries", ".", ":", "param", "boxes", ":", "[", "N", "4", "*", "num_classes", "]", ":", "param", "im_shape", ":", "tuple", "of", "2", ":", "return", ":", "[", "N", "4", "*", "num_classes", "]" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rcnn/symdata/bbox.py#L61-L76
[ "def", "clip_boxes", "(", "boxes", ",", "im_shape", ")", ":", "# x1 >= 0", "boxes", "[", ":", ",", "0", ":", ":", "4", "]", "=", "np", ".", "maximum", "(", "np", ".", "minimum", "(", "boxes", "[", ":", ",", "0", ":", ":", "4", "]", ",", "im_s...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
bbox_transform
compute bounding box regression targets from ex_rois to gt_rois :param ex_rois: [N, 4] :param gt_rois: [N, 4] :return: [N, 4]
example/rcnn/symdata/bbox.py
def bbox_transform(ex_rois, gt_rois, box_stds): """ compute bounding box regression targets from ex_rois to gt_rois :param ex_rois: [N, 4] :param gt_rois: [N, 4] :return: [N, 4] """ assert ex_rois.shape[0] == gt_rois.shape[0], 'inconsistent rois number' ex_widths = ex_rois[:, 2] - ex_ro...
def bbox_transform(ex_rois, gt_rois, box_stds): """ compute bounding box regression targets from ex_rois to gt_rois :param ex_rois: [N, 4] :param gt_rois: [N, 4] :return: [N, 4] """ assert ex_rois.shape[0] == gt_rois.shape[0], 'inconsistent rois number' ex_widths = ex_rois[:, 2] - ex_ro...
[ "compute", "bounding", "box", "regression", "targets", "from", "ex_rois", "to", "gt_rois", ":", "param", "ex_rois", ":", "[", "N", "4", "]", ":", "param", "gt_rois", ":", "[", "N", "4", "]", ":", "return", ":", "[", "N", "4", "]" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rcnn/symdata/bbox.py#L79-L104
[ "def", "bbox_transform", "(", "ex_rois", ",", "gt_rois", ",", "box_stds", ")", ":", "assert", "ex_rois", ".", "shape", "[", "0", "]", "==", "gt_rois", ".", "shape", "[", "0", "]", ",", "'inconsistent rois number'", "ex_widths", "=", "ex_rois", "[", ":", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
bbox_pred
Transform the set of class-agnostic boxes into class-specific boxes by applying the predicted offsets (box_deltas) :param boxes: !important [N 4] :param box_deltas: [N, 4 * num_classes] :return: [N 4 * num_classes]
example/rcnn/symdata/bbox.py
def bbox_pred(boxes, box_deltas, box_stds): """ Transform the set of class-agnostic boxes into class-specific boxes by applying the predicted offsets (box_deltas) :param boxes: !important [N 4] :param box_deltas: [N, 4 * num_classes] :return: [N 4 * num_classes] """ if boxes.shape[0] == ...
def bbox_pred(boxes, box_deltas, box_stds): """ Transform the set of class-agnostic boxes into class-specific boxes by applying the predicted offsets (box_deltas) :param boxes: !important [N 4] :param box_deltas: [N, 4 * num_classes] :return: [N 4 * num_classes] """ if boxes.shape[0] == ...
[ "Transform", "the", "set", "of", "class", "-", "agnostic", "boxes", "into", "class", "-", "specific", "boxes", "by", "applying", "the", "predicted", "offsets", "(", "box_deltas", ")", ":", "param", "boxes", ":", "!important", "[", "N", "4", "]", ":", "pa...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rcnn/symdata/bbox.py#L107-L143
[ "def", "bbox_pred", "(", "boxes", ",", "box_deltas", ",", "box_stds", ")", ":", "if", "boxes", ".", "shape", "[", "0", "]", "==", "0", ":", "return", "np", ".", "zeros", "(", "(", "0", ",", "box_deltas", ".", "shape", "[", "1", "]", ")", ")", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
nms
greedily select boxes with high confidence and overlap with current maximum <= thresh rule out overlap >= thresh :param dets: [[x1, y1, x2, y2 score]] :param thresh: retain overlap < thresh :return: indexes to keep
example/rcnn/symdata/bbox.py
def nms(dets, thresh): """ greedily select boxes with high confidence and overlap with current maximum <= thresh rule out overlap >= thresh :param dets: [[x1, y1, x2, y2 score]] :param thresh: retain overlap < thresh :return: indexes to keep """ x1 = dets[:, 0] y1 = dets[:, 1] x2...
def nms(dets, thresh): """ greedily select boxes with high confidence and overlap with current maximum <= thresh rule out overlap >= thresh :param dets: [[x1, y1, x2, y2 score]] :param thresh: retain overlap < thresh :return: indexes to keep """ x1 = dets[:, 0] y1 = dets[:, 1] x2...
[ "greedily", "select", "boxes", "with", "high", "confidence", "and", "overlap", "with", "current", "maximum", "<", "=", "thresh", "rule", "out", "overlap", ">", "=", "thresh", ":", "param", "dets", ":", "[[", "x1", "y1", "x2", "y2", "score", "]]", ":", ...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rcnn/symdata/bbox.py#L146-L180
[ "def", "nms", "(", "dets", ",", "thresh", ")", ":", "x1", "=", "dets", "[", ":", ",", "0", "]", "y1", "=", "dets", "[", ":", ",", "1", "]", "x2", "=", "dets", "[", ":", ",", "2", "]", "y2", "=", "dets", "[", ":", ",", "3", "]", "scores"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
im_detect
rois (nroi, 4), scores (nrois, nclasses), bbox_deltas (nrois, 4 * nclasses), im_info (3)
example/rcnn/symdata/bbox.py
def im_detect(rois, scores, bbox_deltas, im_info, bbox_stds, nms_thresh, conf_thresh): """rois (nroi, 4), scores (nrois, nclasses), bbox_deltas (nrois, 4 * nclasses), im_info (3)""" rois = rois.asnumpy() scores = scores.asnumpy() bbox_deltas = bbox_deltas.asnumpy() im_info = im_info.a...
def im_detect(rois, scores, bbox_deltas, im_info, bbox_stds, nms_thresh, conf_thresh): """rois (nroi, 4), scores (nrois, nclasses), bbox_deltas (nrois, 4 * nclasses), im_info (3)""" rois = rois.asnumpy() scores = scores.asnumpy() bbox_deltas = bbox_deltas.asnumpy() im_info = im_info.a...
[ "rois", "(", "nroi", "4", ")", "scores", "(", "nrois", "nclasses", ")", "bbox_deltas", "(", "nrois", "4", "*", "nclasses", ")", "im_info", "(", "3", ")" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/rcnn/symdata/bbox.py#L183-L214
[ "def", "im_detect", "(", "rois", ",", "scores", ",", "bbox_deltas", ",", "im_info", ",", "bbox_stds", ",", "nms_thresh", ",", "conf_thresh", ")", ":", "rois", "=", "rois", ".", "asnumpy", "(", ")", "scores", "=", "scores", ".", "asnumpy", "(", ")", "bb...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
c_str
Convert a python string to C string.
amalgamation/python/mxnet_predict.py
def c_str(string): """"Convert a python string to C string.""" if not isinstance(string, str): string = string.decode('ascii') return ctypes.c_char_p(string.encode('utf-8'))
def c_str(string): """"Convert a python string to C string.""" if not isinstance(string, str): string = string.decode('ascii') return ctypes.c_char_p(string.encode('utf-8'))
[ "Convert", "a", "python", "string", "to", "C", "string", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/amalgamation/python/mxnet_predict.py#L40-L44
[ "def", "c_str", "(", "string", ")", ":", "if", "not", "isinstance", "(", "string", ",", "str", ")", ":", "string", "=", "string", ".", "decode", "(", "'ascii'", ")", "return", "ctypes", ".", "c_char_p", "(", "string", ".", "encode", "(", "'utf-8'", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_find_lib_path
Find mxnet library.
amalgamation/python/mxnet_predict.py
def _find_lib_path(): """Find mxnet library.""" curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) amalgamation_lib_path = os.path.join(curr_path, '../../lib/libmxnet_predict.so') if os.path.exists(amalgamation_lib_path) and os.path.isfile(amalgamation_lib_path): lib_path...
def _find_lib_path(): """Find mxnet library.""" curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__))) amalgamation_lib_path = os.path.join(curr_path, '../../lib/libmxnet_predict.so') if os.path.exists(amalgamation_lib_path) and os.path.isfile(amalgamation_lib_path): lib_path...
[ "Find", "mxnet", "library", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/amalgamation/python/mxnet_predict.py#L52-L73
[ "def", "_find_lib_path", "(", ")", ":", "curr_path", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "expanduser", "(", "__file__", ")", ")", ")", "amalgamation_lib_path", "=", "os", ".", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_load_lib
Load libary by searching possible path.
amalgamation/python/mxnet_predict.py
def _load_lib(): """Load libary by searching possible path.""" lib_path = _find_lib_path() lib = ctypes.cdll.LoadLibrary(lib_path[0]) # DMatrix functions lib.MXGetLastError.restype = ctypes.c_char_p return lib
def _load_lib(): """Load libary by searching possible path.""" lib_path = _find_lib_path() lib = ctypes.cdll.LoadLibrary(lib_path[0]) # DMatrix functions lib.MXGetLastError.restype = ctypes.c_char_p return lib
[ "Load", "libary", "by", "searching", "possible", "path", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/amalgamation/python/mxnet_predict.py#L76-L82
[ "def", "_load_lib", "(", ")", ":", "lib_path", "=", "_find_lib_path", "(", ")", "lib", "=", "ctypes", ".", "cdll", ".", "LoadLibrary", "(", "lib_path", "[", "0", "]", ")", "# DMatrix functions", "lib", ".", "MXGetLastError", ".", "restype", "=", "ctypes", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
load_ndarray_file
Load ndarray file and return as list of numpy array. Parameters ---------- nd_bytes : str or bytes The internal ndarray bytes Returns ------- out : dict of str to numpy array or list of numpy array The output list or dict, depending on whether the saved type is list or dict.
amalgamation/python/mxnet_predict.py
def load_ndarray_file(nd_bytes): """Load ndarray file and return as list of numpy array. Parameters ---------- nd_bytes : str or bytes The internal ndarray bytes Returns ------- out : dict of str to numpy array or list of numpy array The output list or dict, depending on wh...
def load_ndarray_file(nd_bytes): """Load ndarray file and return as list of numpy array. Parameters ---------- nd_bytes : str or bytes The internal ndarray bytes Returns ------- out : dict of str to numpy array or list of numpy array The output list or dict, depending on wh...
[ "Load", "ndarray", "file", "and", "return", "as", "list", "of", "numpy", "array", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/amalgamation/python/mxnet_predict.py#L234-L276
[ "def", "load_ndarray_file", "(", "nd_bytes", ")", ":", "handle", "=", "NDListHandle", "(", ")", "olen", "=", "mx_uint", "(", ")", "nd_bytes", "=", "bytearray", "(", "nd_bytes", ")", "ptr", "=", "(", "ctypes", ".", "c_char", "*", "len", "(", "nd_bytes", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Predictor.forward
Perform forward to get the output. Parameters ---------- **kwargs Keyword arguments of input variable name to data. Examples -------- >>> predictor.forward(data=mydata) >>> out = predictor.get_output(0)
amalgamation/python/mxnet_predict.py
def forward(self, **kwargs): """Perform forward to get the output. Parameters ---------- **kwargs Keyword arguments of input variable name to data. Examples -------- >>> predictor.forward(data=mydata) >>> out = predictor.get_output(0) ...
def forward(self, **kwargs): """Perform forward to get the output. Parameters ---------- **kwargs Keyword arguments of input variable name to data. Examples -------- >>> predictor.forward(data=mydata) >>> out = predictor.get_output(0) ...
[ "Perform", "forward", "to", "get", "the", "output", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/amalgamation/python/mxnet_predict.py#L150-L171
[ "def", "forward", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "if", "not", "isinstance", "(", "v", ",", "np", ".", "ndarray", ")", ":", "raise", "ValueError", "(", "\"Expect n...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Predictor.reshape
Change the input shape of the predictor. Parameters ---------- input_shapes : dict of str to tuple The new shape of input data. Examples -------- >>> predictor.reshape({'data':data_shape_tuple})
amalgamation/python/mxnet_predict.py
def reshape(self, input_shapes): """Change the input shape of the predictor. Parameters ---------- input_shapes : dict of str to tuple The new shape of input data. Examples -------- >>> predictor.reshape({'data':data_shape_tuple}) """ ...
def reshape(self, input_shapes): """Change the input shape of the predictor. Parameters ---------- input_shapes : dict of str to tuple The new shape of input data. Examples -------- >>> predictor.reshape({'data':data_shape_tuple}) """ ...
[ "Change", "the", "input", "shape", "of", "the", "predictor", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/amalgamation/python/mxnet_predict.py#L173-L204
[ "def", "reshape", "(", "self", ",", "input_shapes", ")", ":", "indptr", "=", "[", "0", "]", "sdata", "=", "[", "]", "keys", "=", "[", "]", "for", "k", ",", "v", "in", "input_shapes", ".", "items", "(", ")", ":", "if", "not", "isinstance", "(", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Predictor.get_output
Get the index-th output. Parameters ---------- index : int The index of output. Returns ------- out : numpy array. The output array.
amalgamation/python/mxnet_predict.py
def get_output(self, index): """Get the index-th output. Parameters ---------- index : int The index of output. Returns ------- out : numpy array. The output array. """ pdata = ctypes.POINTER(mx_uint)() ndim = mx_u...
def get_output(self, index): """Get the index-th output. Parameters ---------- index : int The index of output. Returns ------- out : numpy array. The output array. """ pdata = ctypes.POINTER(mx_uint)() ndim = mx_u...
[ "Get", "the", "index", "-", "th", "output", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/amalgamation/python/mxnet_predict.py#L206-L231
[ "def", "get_output", "(", "self", ",", "index", ")", ":", "pdata", "=", "ctypes", ".", "POINTER", "(", "mx_uint", ")", "(", ")", "ndim", "=", "mx_uint", "(", ")", "_check_call", "(", "_LIB", ".", "MXPredGetOutputShape", "(", "self", ".", "handle", ",",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
AtariGame.begin_episode
Begin an episode of a game instance. We can play the game for a maximum of `max_episode_step` and after that, we are forced to restart
example/reinforcement-learning/dqn/atari_game.py
def begin_episode(self, max_episode_step=DEFAULT_MAX_EPISODE_STEP): """ Begin an episode of a game instance. We can play the game for a maximum of `max_episode_step` and after that, we are forced to restart """ if self.episode_step > self.max_episode_step or self.ale.game...
def begin_episode(self, max_episode_step=DEFAULT_MAX_EPISODE_STEP): """ Begin an episode of a game instance. We can play the game for a maximum of `max_episode_step` and after that, we are forced to restart """ if self.episode_step > self.max_episode_step or self.ale.game...
[ "Begin", "an", "episode", "of", "a", "game", "instance", ".", "We", "can", "play", "the", "game", "for", "a", "maximum", "of", "max_episode_step", "and", "after", "that", "we", "are", "forced", "to", "restart" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/reinforcement-learning/dqn/atari_game.py#L112-L126
[ "def", "begin_episode", "(", "self", ",", "max_episode_step", "=", "DEFAULT_MAX_EPISODE_STEP", ")", ":", "if", "self", ".", "episode_step", ">", "self", ".", "max_episode_step", "or", "self", ".", "ale", ".", "game_over", "(", ")", ":", "self", ".", "start",...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
RecurrentCell.reset
Reset before re-using the cell for another graph.
python/mxnet/gluon/rnn/rnn_cell.py
def reset(self): """Reset before re-using the cell for another graph.""" self._init_counter = -1 self._counter = -1 for cell in self._children.values(): cell.reset()
def reset(self): """Reset before re-using the cell for another graph.""" self._init_counter = -1 self._counter = -1 for cell in self._children.values(): cell.reset()
[ "Reset", "before", "re", "-", "using", "the", "cell", "for", "another", "graph", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/rnn/rnn_cell.py#L140-L145
[ "def", "reset", "(", "self", ")", ":", "self", ".", "_init_counter", "=", "-", "1", "self", ".", "_counter", "=", "-", "1", "for", "cell", "in", "self", ".", "_children", ".", "values", "(", ")", ":", "cell", ".", "reset", "(", ")" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
RecurrentCell.begin_state
Initial state for this cell. Parameters ---------- func : callable, default symbol.zeros Function for creating initial state. For Symbol API, func can be `symbol.zeros`, `symbol.uniform`, `symbol.var etc`. Use `symbol.var` if you want to directly ...
python/mxnet/gluon/rnn/rnn_cell.py
def begin_state(self, batch_size=0, func=ndarray.zeros, **kwargs): """Initial state for this cell. Parameters ---------- func : callable, default symbol.zeros Function for creating initial state. For Symbol API, func can be `symbol.zeros`, `symbol.uniform`, ...
def begin_state(self, batch_size=0, func=ndarray.zeros, **kwargs): """Initial state for this cell. Parameters ---------- func : callable, default symbol.zeros Function for creating initial state. For Symbol API, func can be `symbol.zeros`, `symbol.uniform`, ...
[ "Initial", "state", "for", "this", "cell", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/rnn/rnn_cell.py#L151-L190
[ "def", "begin_state", "(", "self", ",", "batch_size", "=", "0", ",", "func", "=", "ndarray", ".", "zeros", ",", "*", "*", "kwargs", ")", ":", "assert", "not", "self", ".", "_modified", ",", "\"After applying modifier cells (e.g. ZoneoutCell) the base \"", "\"cel...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
RecurrentCell.unroll
Unrolls an RNN cell across time steps. Parameters ---------- length : int Number of steps to unroll. inputs : Symbol, list of Symbol, or None If `inputs` is a single Symbol (usually the output of Embedding symbol), it should have shape (ba...
python/mxnet/gluon/rnn/rnn_cell.py
def unroll(self, length, inputs, begin_state=None, layout='NTC', merge_outputs=None, valid_length=None): """Unrolls an RNN cell across time steps. Parameters ---------- length : int Number of steps to unroll. inputs : Symbol, list of Symbol, or None ...
def unroll(self, length, inputs, begin_state=None, layout='NTC', merge_outputs=None, valid_length=None): """Unrolls an RNN cell across time steps. Parameters ---------- length : int Number of steps to unroll. inputs : Symbol, list of Symbol, or None ...
[ "Unrolls", "an", "RNN", "cell", "across", "time", "steps", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/rnn/rnn_cell.py#L192-L267
[ "def", "unroll", "(", "self", ",", "length", ",", "inputs", ",", "begin_state", "=", "None", ",", "layout", "=", "'NTC'", ",", "merge_outputs", "=", "None", ",", "valid_length", "=", "None", ")", ":", "# pylint: disable=too-many-locals", "self", ".", "reset"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
RecurrentCell._get_activation
Get activation function. Convert if is string
python/mxnet/gluon/rnn/rnn_cell.py
def _get_activation(self, F, inputs, activation, **kwargs): """Get activation function. Convert if is string""" func = {'tanh': F.tanh, 'relu': F.relu, 'sigmoid': F.sigmoid, 'softsign': F.softsign}.get(activation) if func: return func(i...
def _get_activation(self, F, inputs, activation, **kwargs): """Get activation function. Convert if is string""" func = {'tanh': F.tanh, 'relu': F.relu, 'sigmoid': F.sigmoid, 'softsign': F.softsign}.get(activation) if func: return func(i...
[ "Get", "activation", "function", ".", "Convert", "if", "is", "string" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/rnn/rnn_cell.py#L270-L282
[ "def", "_get_activation", "(", "self", ",", "F", ",", "inputs", ",", "activation", ",", "*", "*", "kwargs", ")", ":", "func", "=", "{", "'tanh'", ":", "F", ".", "tanh", ",", "'relu'", ":", "F", ".", "relu", ",", "'sigmoid'", ":", "F", ".", "sigmo...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
RecurrentCell.forward
Unrolls the recurrent cell for one time step. Parameters ---------- inputs : sym.Variable Input symbol, 2D, of shape (batch_size * num_units). states : list of sym.Variable RNN state from previous step or the output of begin_state(). Returns ----...
python/mxnet/gluon/rnn/rnn_cell.py
def forward(self, inputs, states): """Unrolls the recurrent cell for one time step. Parameters ---------- inputs : sym.Variable Input symbol, 2D, of shape (batch_size * num_units). states : list of sym.Variable RNN state from previous step or the output o...
def forward(self, inputs, states): """Unrolls the recurrent cell for one time step. Parameters ---------- inputs : sym.Variable Input symbol, 2D, of shape (batch_size * num_units). states : list of sym.Variable RNN state from previous step or the output o...
[ "Unrolls", "the", "recurrent", "cell", "for", "one", "time", "step", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/gluon/rnn/rnn_cell.py#L284-L312
[ "def", "forward", "(", "self", ",", "inputs", ",", "states", ")", ":", "# pylint: disable= arguments-differ", "self", ".", "_counter", "+=", "1", "return", "super", "(", "RecurrentCell", ",", "self", ")", ".", "forward", "(", "inputs", ",", "states", ")" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_check_input_names
Check that all input names are in symbol's arguments.
python/mxnet/module/base_module.py
def _check_input_names(symbol, names, typename, throw): """Check that all input names are in symbol's arguments.""" args = symbol.list_arguments() for name in names: if name in args: continue candidates = [arg for arg in args if not arg.endswith('_weight') a...
def _check_input_names(symbol, names, typename, throw): """Check that all input names are in symbol's arguments.""" args = symbol.list_arguments() for name in names: if name in args: continue candidates = [arg for arg in args if not arg.endswith('_weight') a...
[ "Check", "that", "all", "input", "names", "are", "in", "symbol", "s", "arguments", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/base_module.py#L37-L55
[ "def", "_check_input_names", "(", "symbol", ",", "names", ",", "typename", ",", "throw", ")", ":", "args", "=", "symbol", ".", "list_arguments", "(", ")", "for", "name", "in", "names", ":", "if", "name", "in", "args", ":", "continue", "candidates", "=", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_check_names_match
Check that input names matches input data descriptors.
python/mxnet/module/base_module.py
def _check_names_match(data_names, data_shapes, name, throw): """Check that input names matches input data descriptors.""" actual = [x[0] for x in data_shapes] if sorted(data_names) != sorted(actual): msg = "Data provided by %s_shapes don't match names specified by %s_names (%s vs. %s)"%( ...
def _check_names_match(data_names, data_shapes, name, throw): """Check that input names matches input data descriptors.""" actual = [x[0] for x in data_shapes] if sorted(data_names) != sorted(actual): msg = "Data provided by %s_shapes don't match names specified by %s_names (%s vs. %s)"%( ...
[ "Check", "that", "input", "names", "matches", "input", "data", "descriptors", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/base_module.py#L58-L67
[ "def", "_check_names_match", "(", "data_names", ",", "data_shapes", ",", "name", ",", "throw", ")", ":", "actual", "=", "[", "x", "[", "0", "]", "for", "x", "in", "data_shapes", "]", "if", "sorted", "(", "data_names", ")", "!=", "sorted", "(", "actual"...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
_parse_data_desc
parse data_attrs into DataDesc format and check that names match
python/mxnet/module/base_module.py
def _parse_data_desc(data_names, label_names, data_shapes, label_shapes): """parse data_attrs into DataDesc format and check that names match""" data_shapes = [x if isinstance(x, DataDesc) else DataDesc(*x) for x in data_shapes] _check_names_match(data_names, data_shapes, 'data', True) if label_shapes i...
def _parse_data_desc(data_names, label_names, data_shapes, label_shapes): """parse data_attrs into DataDesc format and check that names match""" data_shapes = [x if isinstance(x, DataDesc) else DataDesc(*x) for x in data_shapes] _check_names_match(data_names, data_shapes, 'data', True) if label_shapes i...
[ "parse", "data_attrs", "into", "DataDesc", "format", "and", "check", "that", "names", "match" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/base_module.py#L70-L79
[ "def", "_parse_data_desc", "(", "data_names", ",", "label_names", ",", "data_shapes", ",", "label_shapes", ")", ":", "data_shapes", "=", "[", "x", "if", "isinstance", "(", "x", ",", "DataDesc", ")", "else", "DataDesc", "(", "*", "x", ")", "for", "x", "in...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BaseModule.forward_backward
A convenient function that calls both ``forward`` and ``backward``.
python/mxnet/module/base_module.py
def forward_backward(self, data_batch): """A convenient function that calls both ``forward`` and ``backward``.""" self.forward(data_batch, is_train=True) self.backward()
def forward_backward(self, data_batch): """A convenient function that calls both ``forward`` and ``backward``.""" self.forward(data_batch, is_train=True) self.backward()
[ "A", "convenient", "function", "that", "calls", "both", "forward", "and", "backward", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/base_module.py#L193-L196
[ "def", "forward_backward", "(", "self", ",", "data_batch", ")", ":", "self", ".", "forward", "(", "data_batch", ",", "is_train", "=", "True", ")", "self", ".", "backward", "(", ")" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BaseModule.score
Runs prediction on ``eval_data`` and evaluates the performance according to the given ``eval_metric``. Checkout `Module Tutorial <http://mxnet.io/tutorials/basic/module.html>`_ to see a end-to-end use-case. Parameters ---------- eval_data : DataIter Evaluati...
python/mxnet/module/base_module.py
def score(self, eval_data, eval_metric, num_batch=None, batch_end_callback=None, score_end_callback=None, reset=True, epoch=0, sparse_row_id_fn=None): """Runs prediction on ``eval_data`` and evaluates the performance according to the given ``eval_metric``. Checkout `...
def score(self, eval_data, eval_metric, num_batch=None, batch_end_callback=None, score_end_callback=None, reset=True, epoch=0, sparse_row_id_fn=None): """Runs prediction on ``eval_data`` and evaluates the performance according to the given ``eval_metric``. Checkout `...
[ "Runs", "prediction", "on", "eval_data", "and", "evaluates", "the", "performance", "according", "to", "the", "given", "eval_metric", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/base_module.py#L198-L276
[ "def", "score", "(", "self", ",", "eval_data", ",", "eval_metric", ",", "num_batch", "=", "None", ",", "batch_end_callback", "=", "None", ",", "score_end_callback", "=", "None", ",", "reset", "=", "True", ",", "epoch", "=", "0", ",", "sparse_row_id_fn", "=...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BaseModule.iter_predict
Iterates over predictions. Examples -------- >>> for pred, i_batch, batch in module.iter_predict(eval_data): ... # pred is a list of outputs from the module ... # i_batch is a integer ... # batch is the data batch from the data iterator Parameters ...
python/mxnet/module/base_module.py
def iter_predict(self, eval_data, num_batch=None, reset=True, sparse_row_id_fn=None): """Iterates over predictions. Examples -------- >>> for pred, i_batch, batch in module.iter_predict(eval_data): ... # pred is a list of outputs from the module ... # i_batch is ...
def iter_predict(self, eval_data, num_batch=None, reset=True, sparse_row_id_fn=None): """Iterates over predictions. Examples -------- >>> for pred, i_batch, batch in module.iter_predict(eval_data): ... # pred is a list of outputs from the module ... # i_batch is ...
[ "Iterates", "over", "predictions", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/base_module.py#L278-L316
[ "def", "iter_predict", "(", "self", ",", "eval_data", ",", "num_batch", "=", "None", ",", "reset", "=", "True", ",", "sparse_row_id_fn", "=", "None", ")", ":", "assert", "self", ".", "binded", "and", "self", ".", "params_initialized", "if", "reset", ":", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BaseModule.predict
Runs prediction and collects the outputs. When `merge_batches` is ``True`` (by default), the return value will be a list ``[out1, out2, out3]``, where each element is formed by concatenating the outputs for all the mini-batches. When `always_output_list` is ``False`` (as by default), th...
python/mxnet/module/base_module.py
def predict(self, eval_data, num_batch=None, merge_batches=True, reset=True, always_output_list=False, sparse_row_id_fn=None): """Runs prediction and collects the outputs. When `merge_batches` is ``True`` (by default), the return value will be a list ``[out1, out2, out3]``, wher...
def predict(self, eval_data, num_batch=None, merge_batches=True, reset=True, always_output_list=False, sparse_row_id_fn=None): """Runs prediction and collects the outputs. When `merge_batches` is ``True`` (by default), the return value will be a list ``[out1, out2, out3]``, wher...
[ "Runs", "prediction", "and", "collects", "the", "outputs", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/base_module.py#L318-L407
[ "def", "predict", "(", "self", ",", "eval_data", ",", "num_batch", "=", "None", ",", "merge_batches", "=", "True", ",", "reset", "=", "True", ",", "always_output_list", "=", "False", ",", "sparse_row_id_fn", "=", "None", ")", ":", "assert", "self", ".", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BaseModule.set_params
Assigns parameter and aux state values. Parameters ---------- arg_params : dict Dictionary of name to value (`NDArray`) mapping. aux_params : dict Dictionary of name to value (`NDArray`) mapping. allow_missing : bool If ``True``, params could ...
python/mxnet/module/base_module.py
def set_params(self, arg_params, aux_params, allow_missing=False, force_init=True, allow_extra=False): """Assigns parameter and aux state values. Parameters ---------- arg_params : dict Dictionary of name to value (`NDArray`) mapping. aux_params : ...
def set_params(self, arg_params, aux_params, allow_missing=False, force_init=True, allow_extra=False): """Assigns parameter and aux state values. Parameters ---------- arg_params : dict Dictionary of name to value (`NDArray`) mapping. aux_params : ...
[ "Assigns", "parameter", "and", "aux", "state", "values", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/base_module.py#L671-L699
[ "def", "set_params", "(", "self", ",", "arg_params", ",", "aux_params", ",", "allow_missing", "=", "False", ",", "force_init", "=", "True", ",", "allow_extra", "=", "False", ")", ":", "self", ".", "init_params", "(", "initializer", "=", "None", ",", "arg_p...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BaseModule.save_params
Saves model parameters to file. Parameters ---------- fname : str Path to output param file. Examples -------- >>> # An example of saving module parameters. >>> mod.save_params('myfile')
python/mxnet/module/base_module.py
def save_params(self, fname): """Saves model parameters to file. Parameters ---------- fname : str Path to output param file. Examples -------- >>> # An example of saving module parameters. >>> mod.save_params('myfile') """ ar...
def save_params(self, fname): """Saves model parameters to file. Parameters ---------- fname : str Path to output param file. Examples -------- >>> # An example of saving module parameters. >>> mod.save_params('myfile') """ ar...
[ "Saves", "model", "parameters", "to", "file", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/base_module.py#L701-L717
[ "def", "save_params", "(", "self", ",", "fname", ")", ":", "arg_params", ",", "aux_params", "=", "self", ".", "get_params", "(", ")", "save_dict", "=", "{", "(", "'arg:%s'", "%", "k", ")", ":", "v", ".", "as_in_context", "(", "cpu", "(", ")", ")", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BaseModule.load_params
Loads model parameters from file. Parameters ---------- fname : str Path to input param file. Examples -------- >>> # An example of loading module parameters. >>> mod.load_params('myfile')
python/mxnet/module/base_module.py
def load_params(self, fname): """Loads model parameters from file. Parameters ---------- fname : str Path to input param file. Examples -------- >>> # An example of loading module parameters. >>> mod.load_params('myfile') """ ...
def load_params(self, fname): """Loads model parameters from file. Parameters ---------- fname : str Path to input param file. Examples -------- >>> # An example of loading module parameters. >>> mod.load_params('myfile') """ ...
[ "Loads", "model", "parameters", "from", "file", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/base_module.py#L719-L743
[ "def", "load_params", "(", "self", ",", "fname", ")", ":", "save_dict", "=", "ndarray", ".", "load", "(", "fname", ")", "arg_params", "=", "{", "}", "aux_params", "=", "{", "}", "for", "k", ",", "value", "in", "save_dict", ".", "items", "(", ")", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
BaseModule.bind
Binds the symbols to construct executors. This is necessary before one can perform computation with the module. Parameters ---------- data_shapes : list of (str, tuple) or DataDesc objects Typically is ``data_iter.provide_data``. Can also be a list of (data name,...
python/mxnet/module/base_module.py
def bind(self, data_shapes, label_shapes=None, for_training=True, inputs_need_grad=False, force_rebind=False, shared_module=None, grad_req='write'): """Binds the symbols to construct executors. This is necessary before one can perform computation with the module. Param...
def bind(self, data_shapes, label_shapes=None, for_training=True, inputs_need_grad=False, force_rebind=False, shared_module=None, grad_req='write'): """Binds the symbols to construct executors. This is necessary before one can perform computation with the module. Param...
[ "Binds", "the", "symbols", "to", "construct", "executors", ".", "This", "is", "necessary", "before", "one", "can", "perform", "computation", "with", "the", "module", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/module/base_module.py#L990-L1029
[ "def", "bind", "(", "self", ",", "data_shapes", ",", "label_shapes", "=", "None", ",", "for_training", "=", "True", ",", "inputs_need_grad", "=", "False", ",", "force_rebind", "=", "False", ",", "shared_module", "=", "None", ",", "grad_req", "=", "'write'", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
find_lib_path
Find MXNet dynamic library files. Returns ------- lib_path : list(string) List of all found path to the libraries.
python/mxnet/libinfo.py
def find_lib_path(): """Find MXNet dynamic library files. Returns ------- lib_path : list(string) List of all found path to the libraries. """ lib_from_env = os.environ.get('MXNET_LIBRARY_PATH') if lib_from_env: if os.path.isfile(lib_from_env): if not os.path.isa...
def find_lib_path(): """Find MXNet dynamic library files. Returns ------- lib_path : list(string) List of all found path to the libraries. """ lib_from_env = os.environ.get('MXNET_LIBRARY_PATH') if lib_from_env: if os.path.isfile(lib_from_env): if not os.path.isa...
[ "Find", "MXNet", "dynamic", "library", "files", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/libinfo.py#L26-L77
[ "def", "find_lib_path", "(", ")", ":", "lib_from_env", "=", "os", ".", "environ", ".", "get", "(", "'MXNET_LIBRARY_PATH'", ")", "if", "lib_from_env", ":", "if", "os", ".", "path", ".", "isfile", "(", "lib_from_env", ")", ":", "if", "not", "os", ".", "p...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
find_include_path
Find MXNet included header files. Returns ------- incl_path : string Path to the header files.
python/mxnet/libinfo.py
def find_include_path(): """Find MXNet included header files. Returns ------- incl_path : string Path to the header files. """ incl_from_env = os.environ.get('MXNET_INCLUDE_PATH') if incl_from_env: if os.path.isdir(incl_from_env): if not os.path.isabs(incl_from_e...
def find_include_path(): """Find MXNet included header files. Returns ------- incl_path : string Path to the header files. """ incl_from_env = os.environ.get('MXNET_INCLUDE_PATH') if incl_from_env: if os.path.isdir(incl_from_env): if not os.path.isabs(incl_from_e...
[ "Find", "MXNet", "included", "header", "files", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/libinfo.py#L79-L110
[ "def", "find_include_path", "(", ")", ":", "incl_from_env", "=", "os", ".", "environ", ".", "get", "(", "'MXNET_INCLUDE_PATH'", ")", "if", "incl_from_env", ":", "if", "os", ".", "path", ".", "isdir", "(", "incl_from_env", ")", ":", "if", "not", "os", "."...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
CaptchaGen.image
Generate a greyscale captcha image representing number string Parameters ---------- captcha_str: str string a characters for captcha image Returns ------- numpy.ndarray Generated greyscale image in np.ndarray float type with values normalized to ...
example/ctc/captcha_generator.py
def image(self, captcha_str): """Generate a greyscale captcha image representing number string Parameters ---------- captcha_str: str string a characters for captcha image Returns ------- numpy.ndarray Generated greyscale image in np.ndar...
def image(self, captcha_str): """Generate a greyscale captcha image representing number string Parameters ---------- captcha_str: str string a characters for captcha image Returns ------- numpy.ndarray Generated greyscale image in np.ndar...
[ "Generate", "a", "greyscale", "captcha", "image", "representing", "number", "string" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/captcha_generator.py#L48-L67
[ "def", "image", "(", "self", ",", "captcha_str", ")", ":", "img", "=", "self", ".", "captcha", ".", "generate", "(", "captcha_str", ")", "img", "=", "np", ".", "fromstring", "(", "img", ".", "getvalue", "(", ")", ",", "dtype", "=", "'uint8'", ")", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DigitCaptcha.get_rand
Generates a character string of digits. Number of digits are between self.num_digit_min and self.num_digit_max Returns ------- str
example/ctc/captcha_generator.py
def get_rand(num_digit_min, num_digit_max): """Generates a character string of digits. Number of digits are between self.num_digit_min and self.num_digit_max Returns ------- str """ buf = "" max_len = random.randint(num_digit_min, num_digit_max) fo...
def get_rand(num_digit_min, num_digit_max): """Generates a character string of digits. Number of digits are between self.num_digit_min and self.num_digit_max Returns ------- str """ buf = "" max_len = random.randint(num_digit_min, num_digit_max) fo...
[ "Generates", "a", "character", "string", "of", "digits", ".", "Number", "of", "digits", "are", "between", "self", ".", "num_digit_min", "and", "self", ".", "num_digit_max", "Returns", "-------", "str" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/captcha_generator.py#L113-L124
[ "def", "get_rand", "(", "num_digit_min", ",", "num_digit_max", ")", ":", "buf", "=", "\"\"", "max_len", "=", "random", ".", "randint", "(", "num_digit_min", ",", "num_digit_max", ")", "for", "i", "in", "range", "(", "max_len", ")", ":", "buf", "+=", "str...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
DigitCaptcha._gen_sample
Generate a random captcha image sample Returns ------- (numpy.ndarray, str) Tuple of image (numpy ndarray) and character string of digits used to generate the image
example/ctc/captcha_generator.py
def _gen_sample(self): """Generate a random captcha image sample Returns ------- (numpy.ndarray, str) Tuple of image (numpy ndarray) and character string of digits used to generate the image """ num_str = self.get_rand(self.num_digit_min, self.num_digit_max) ...
def _gen_sample(self): """Generate a random captcha image sample Returns ------- (numpy.ndarray, str) Tuple of image (numpy ndarray) and character string of digits used to generate the image """ num_str = self.get_rand(self.num_digit_min, self.num_digit_max) ...
[ "Generate", "a", "random", "captcha", "image", "sample", "Returns", "-------", "(", "numpy", ".", "ndarray", "str", ")", "Tuple", "of", "image", "(", "numpy", "ndarray", ")", "and", "character", "string", "of", "digits", "used", "to", "generate", "the", "i...
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/ctc/captcha_generator.py#L126-L134
[ "def", "_gen_sample", "(", "self", ")", ":", "num_str", "=", "self", ".", "get_rand", "(", "self", ".", "num_digit_min", ",", "self", ".", "num_digit_max", ")", "return", "self", ".", "captcha", ".", "image", "(", "num_str", ")", ",", "num_str" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Optimizer.register
Registers a new optimizer. Once an optimizer is registered, we can create an instance of this optimizer with `create_optimizer` later. Examples -------- >>> @mx.optimizer.Optimizer.register ... class MyOptimizer(mx.optimizer.Optimizer): ... pass >>>...
python/mxnet/optimizer/optimizer.py
def register(klass): """Registers a new optimizer. Once an optimizer is registered, we can create an instance of this optimizer with `create_optimizer` later. Examples -------- >>> @mx.optimizer.Optimizer.register ... class MyOptimizer(mx.optimizer.Optimizer): ...
def register(klass): """Registers a new optimizer. Once an optimizer is registered, we can create an instance of this optimizer with `create_optimizer` later. Examples -------- >>> @mx.optimizer.Optimizer.register ... class MyOptimizer(mx.optimizer.Optimizer): ...
[ "Registers", "a", "new", "optimizer", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L129-L154
[ "def", "register", "(", "klass", ")", ":", "assert", "(", "isinstance", "(", "klass", ",", "type", ")", ")", "name", "=", "klass", ".", "__name__", ".", "lower", "(", ")", "if", "name", "in", "Optimizer", ".", "opt_registry", ":", "warnings", ".", "w...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Optimizer.create_optimizer
Instantiates an optimizer with a given name and kwargs. .. note:: We can use the alias `create` for ``Optimizer.create_optimizer``. Parameters ---------- name: str Name of the optimizer. Should be the name of a subclass of Optimizer. Case insensitive. k...
python/mxnet/optimizer/optimizer.py
def create_optimizer(name, **kwargs): """Instantiates an optimizer with a given name and kwargs. .. note:: We can use the alias `create` for ``Optimizer.create_optimizer``. Parameters ---------- name: str Name of the optimizer. Should be the name of a su...
def create_optimizer(name, **kwargs): """Instantiates an optimizer with a given name and kwargs. .. note:: We can use the alias `create` for ``Optimizer.create_optimizer``. Parameters ---------- name: str Name of the optimizer. Should be the name of a su...
[ "Instantiates", "an", "optimizer", "with", "a", "given", "name", "and", "kwargs", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L157-L188
[ "def", "create_optimizer", "(", "name", ",", "*", "*", "kwargs", ")", ":", "if", "name", ".", "lower", "(", ")", "in", "Optimizer", ".", "opt_registry", ":", "return", "Optimizer", ".", "opt_registry", "[", "name", ".", "lower", "(", ")", "]", "(", "...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Optimizer.create_state_multi_precision
Creates auxiliary state for a given weight, including FP32 high precision copy if original weight is FP16. This method is provided to perform automatic mixed precision training for optimizers that do not support it themselves. Parameters ---------- index : int ...
python/mxnet/optimizer/optimizer.py
def create_state_multi_precision(self, index, weight): """Creates auxiliary state for a given weight, including FP32 high precision copy if original weight is FP16. This method is provided to perform automatic mixed precision training for optimizers that do not support it themselves. ...
def create_state_multi_precision(self, index, weight): """Creates auxiliary state for a given weight, including FP32 high precision copy if original weight is FP16. This method is provided to perform automatic mixed precision training for optimizers that do not support it themselves. ...
[ "Creates", "auxiliary", "state", "for", "a", "given", "weight", "including", "FP32", "high", "precision", "copy", "if", "original", "weight", "is", "FP16", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L218-L246
[ "def", "create_state_multi_precision", "(", "self", ",", "index", ",", "weight", ")", ":", "weight_master_copy", "=", "None", "if", "self", ".", "multi_precision", "and", "weight", ".", "dtype", "==", "numpy", ".", "float16", ":", "weight_master_copy", "=", "w...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Optimizer.update_multi_precision
Updates the given parameter using the corresponding gradient and state. Mixed precision version. Parameters ---------- index : int The unique index of the parameter into the individual learning rates and weight decays. Learning rates and weight decay ...
python/mxnet/optimizer/optimizer.py
def update_multi_precision(self, index, weight, grad, state): """Updates the given parameter using the corresponding gradient and state. Mixed precision version. Parameters ---------- index : int The unique index of the parameter into the individual learning ...
def update_multi_precision(self, index, weight, grad, state): """Updates the given parameter using the corresponding gradient and state. Mixed precision version. Parameters ---------- index : int The unique index of the parameter into the individual learning ...
[ "Updates", "the", "given", "parameter", "using", "the", "corresponding", "gradient", "and", "state", ".", "Mixed", "precision", "version", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L266-L291
[ "def", "update_multi_precision", "(", "self", ",", "index", ",", "weight", ",", "grad", ",", "state", ")", ":", "if", "self", ".", "multi_precision", "and", "weight", ".", "dtype", "==", "numpy", ".", "float16", ":", "# Wrapper for mixed precision", "weight_ma...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Optimizer.set_lr_mult
Sets an individual learning rate multiplier for each parameter. If you specify a learning rate multiplier for a parameter, then the learning rate for the parameter will be set as the product of the global learning rate `self.lr` and its multiplier. .. note:: The default learning rate m...
python/mxnet/optimizer/optimizer.py
def set_lr_mult(self, args_lr_mult): """Sets an individual learning rate multiplier for each parameter. If you specify a learning rate multiplier for a parameter, then the learning rate for the parameter will be set as the product of the global learning rate `self.lr` and its multiplier...
def set_lr_mult(self, args_lr_mult): """Sets an individual learning rate multiplier for each parameter. If you specify a learning rate multiplier for a parameter, then the learning rate for the parameter will be set as the product of the global learning rate `self.lr` and its multiplier...
[ "Sets", "an", "individual", "learning", "rate", "multiplier", "for", "each", "parameter", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L314-L345
[ "def", "set_lr_mult", "(", "self", ",", "args_lr_mult", ")", ":", "self", ".", "lr_mult", "=", "{", "}", "if", "self", ".", "sym_info", ":", "attr", ",", "arg_names", "=", "self", ".", "sym_info", "for", "name", "in", "arg_names", ":", "if", "name", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Optimizer.set_wd_mult
Sets an individual weight decay multiplier for each parameter. By default, if `param_idx2name` was provided in the constructor, the weight decay multipler is set as 0 for all parameters whose name don't end with ``_weight`` or ``_gamma``. .. note:: The default weight decay mult...
python/mxnet/optimizer/optimizer.py
def set_wd_mult(self, args_wd_mult): """Sets an individual weight decay multiplier for each parameter. By default, if `param_idx2name` was provided in the constructor, the weight decay multipler is set as 0 for all parameters whose name don't end with ``_weight`` or ``_gamma``. ...
def set_wd_mult(self, args_wd_mult): """Sets an individual weight decay multiplier for each parameter. By default, if `param_idx2name` was provided in the constructor, the weight decay multipler is set as 0 for all parameters whose name don't end with ``_weight`` or ``_gamma``. ...
[ "Sets", "an", "individual", "weight", "decay", "multiplier", "for", "each", "parameter", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L347-L382
[ "def", "set_wd_mult", "(", "self", ",", "args_wd_mult", ")", ":", "self", ".", "wd_mult", "=", "{", "}", "for", "n", "in", "self", ".", "idx2name", ".", "values", "(", ")", ":", "if", "not", "(", "n", ".", "endswith", "(", "'_weight'", ")", "or", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Optimizer._set_current_context
Sets the number of the currently handled device. Parameters ---------- device_id : int The number of current device.
python/mxnet/optimizer/optimizer.py
def _set_current_context(self, device_id): """Sets the number of the currently handled device. Parameters ---------- device_id : int The number of current device. """ if device_id not in self._all_index_update_counts: self._all_index_update_counts...
def _set_current_context(self, device_id): """Sets the number of the currently handled device. Parameters ---------- device_id : int The number of current device. """ if device_id not in self._all_index_update_counts: self._all_index_update_counts...
[ "Sets", "the", "number", "of", "the", "currently", "handled", "device", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L384-L394
[ "def", "_set_current_context", "(", "self", ",", "device_id", ")", ":", "if", "device_id", "not", "in", "self", ".", "_all_index_update_counts", ":", "self", ".", "_all_index_update_counts", "[", "device_id", "]", "=", "{", "}", "self", ".", "_index_update_count...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Optimizer._update_count
Updates num_update. Parameters ---------- index : int or list of int The index to be updated.
python/mxnet/optimizer/optimizer.py
def _update_count(self, index): """Updates num_update. Parameters ---------- index : int or list of int The index to be updated. """ if not isinstance(index, (list, tuple)): index = [index] for idx in index: if idx not in self....
def _update_count(self, index): """Updates num_update. Parameters ---------- index : int or list of int The index to be updated. """ if not isinstance(index, (list, tuple)): index = [index] for idx in index: if idx not in self....
[ "Updates", "num_update", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L396-L410
[ "def", "_update_count", "(", "self", ",", "index", ")", ":", "if", "not", "isinstance", "(", "index", ",", "(", "list", ",", "tuple", ")", ")", ":", "index", "=", "[", "index", "]", "for", "idx", "in", "index", ":", "if", "idx", "not", "in", "sel...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Optimizer._get_lrs
Gets the learning rates given the indices of the weights. Parameters ---------- indices : list of int Indices corresponding to weights. Returns ------- lrs : list of float Learning rates for those indices.
python/mxnet/optimizer/optimizer.py
def _get_lrs(self, indices): """Gets the learning rates given the indices of the weights. Parameters ---------- indices : list of int Indices corresponding to weights. Returns ------- lrs : list of float Learning rates for those indices. ...
def _get_lrs(self, indices): """Gets the learning rates given the indices of the weights. Parameters ---------- indices : list of int Indices corresponding to weights. Returns ------- lrs : list of float Learning rates for those indices. ...
[ "Gets", "the", "learning", "rates", "given", "the", "indices", "of", "the", "weights", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L412-L438
[ "def", "_get_lrs", "(", "self", ",", "indices", ")", ":", "if", "self", ".", "lr_scheduler", "is", "not", "None", ":", "lr", "=", "self", ".", "lr_scheduler", "(", "self", ".", "num_update", ")", "else", ":", "lr", "=", "self", ".", "lr", "lrs", "=...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Optimizer._get_wds
Gets weight decays for indices. Returns 0 for non-weights if the name of weights are provided for `__init__`. Parameters ---------- indices : list of int Indices of weights. Returns ------- wds : list of float Weight decays for those indi...
python/mxnet/optimizer/optimizer.py
def _get_wds(self, indices): """Gets weight decays for indices. Returns 0 for non-weights if the name of weights are provided for `__init__`. Parameters ---------- indices : list of int Indices of weights. Returns ------- wds : list of float ...
def _get_wds(self, indices): """Gets weight decays for indices. Returns 0 for non-weights if the name of weights are provided for `__init__`. Parameters ---------- indices : list of int Indices of weights. Returns ------- wds : list of float ...
[ "Gets", "weight", "decays", "for", "indices", ".", "Returns", "0", "for", "non", "-", "weights", "if", "the", "name", "of", "weights", "are", "provided", "for", "__init__", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L455-L477
[ "def", "_get_wds", "(", "self", ",", "indices", ")", ":", "wds", "=", "[", "self", ".", "wd", "for", "_", "in", "indices", "]", "for", "i", ",", "index", "in", "enumerate", "(", "indices", ")", ":", "if", "index", "in", "self", ".", "param_dict", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Updater.sync_state_context
sync state context.
python/mxnet/optimizer/optimizer.py
def sync_state_context(self, state, context): """sync state context.""" if isinstance(state, NDArray): return state.as_in_context(context) elif isinstance(state, (tuple, list)): synced_state = (self.sync_state_context(i, context) for i in state) if isinstance(...
def sync_state_context(self, state, context): """sync state context.""" if isinstance(state, NDArray): return state.as_in_context(context) elif isinstance(state, (tuple, list)): synced_state = (self.sync_state_context(i, context) for i in state) if isinstance(...
[ "sync", "state", "context", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L1679-L1690
[ "def", "sync_state_context", "(", "self", ",", "state", ",", "context", ")", ":", "if", "isinstance", "(", "state", ",", "NDArray", ")", ":", "return", "state", ".", "as_in_context", "(", "context", ")", "elif", "isinstance", "(", "state", ",", "(", "tup...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Updater.set_states
Sets updater states.
python/mxnet/optimizer/optimizer.py
def set_states(self, states): """Sets updater states.""" states = pickle.loads(states) if isinstance(states, tuple) and len(states) == 2: self.states, self.optimizer = states else: self.states = states self.states_synced = dict.fromkeys(self.states.keys(),...
def set_states(self, states): """Sets updater states.""" states = pickle.loads(states) if isinstance(states, tuple) and len(states) == 2: self.states, self.optimizer = states else: self.states = states self.states_synced = dict.fromkeys(self.states.keys(),...
[ "Sets", "updater", "states", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L1692-L1699
[ "def", "set_states", "(", "self", ",", "states", ")", ":", "states", "=", "pickle", ".", "loads", "(", "states", ")", "if", "isinstance", "(", "states", ",", "tuple", ")", "and", "len", "(", "states", ")", "==", "2", ":", "self", ".", "states", ","...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Updater.get_states
Gets updater states. Parameters ---------- dump_optimizer : bool, default False Whether to also save the optimizer itself. This would also save optimizer information such as learning rate and weight decay schedules.
python/mxnet/optimizer/optimizer.py
def get_states(self, dump_optimizer=False): """Gets updater states. Parameters ---------- dump_optimizer : bool, default False Whether to also save the optimizer itself. This would also save optimizer information such as learning rate and weight decay schedules. ...
def get_states(self, dump_optimizer=False): """Gets updater states. Parameters ---------- dump_optimizer : bool, default False Whether to also save the optimizer itself. This would also save optimizer information such as learning rate and weight decay schedules. ...
[ "Gets", "updater", "states", "." ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/optimizer/optimizer.py#L1701-L1710
[ "def", "get_states", "(", "self", ",", "dump_optimizer", "=", "False", ")", ":", "return", "pickle", ".", "dumps", "(", "(", "self", ".", "states", ",", "self", ".", "optimizer", ")", "if", "dump_optimizer", "else", "self", ".", "states", ")" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
preprocess
Preprocess: Convert a video into the mouth images
example/gluon/lipnet/utils/preprocess_data.py
def preprocess(from_idx, to_idx, _params): """ Preprocess: Convert a video into the mouth images """ source_exts = '*.mpg' src_path = _params['src_path'] tgt_path = _params['tgt_path'] face_predictor_path = './shape_predictor_68_face_landmarks.dat' succ = set() fail = set() for ...
def preprocess(from_idx, to_idx, _params): """ Preprocess: Convert a video into the mouth images """ source_exts = '*.mpg' src_path = _params['src_path'] tgt_path = _params['tgt_path'] face_predictor_path = './shape_predictor_68_face_landmarks.dat' succ = set() fail = set() for ...
[ "Preprocess", ":", "Convert", "a", "video", "into", "the", "mouth", "images" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/utils/preprocess_data.py#L202-L243
[ "def", "preprocess", "(", "from_idx", ",", "to_idx", ",", "_params", ")", ":", "source_exts", "=", "'*.mpg'", "src_path", "=", "_params", "[", "'src_path'", "]", "tgt_path", "=", "_params", "[", "'tgt_path'", "]", "face_predictor_path", "=", "'./shape_predictor_...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Video.from_frames
Read from frames
example/gluon/lipnet/utils/preprocess_data.py
def from_frames(self, path): """ Read from frames """ frames_path = sorted([os.path.join(path, x) for x in os.listdir(path)]) frames = [ndimage.imread(frame_path) for frame_path in frames_path] self.handle_type(frames) return self
def from_frames(self, path): """ Read from frames """ frames_path = sorted([os.path.join(path, x) for x in os.listdir(path)]) frames = [ndimage.imread(frame_path) for frame_path in frames_path] self.handle_type(frames) return self
[ "Read", "from", "frames" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/utils/preprocess_data.py#L71-L78
[ "def", "from_frames", "(", "self", ",", "path", ")", ":", "frames_path", "=", "sorted", "(", "[", "os", ".", "path", ".", "join", "(", "path", ",", "x", ")", "for", "x", "in", "os", ".", "listdir", "(", "path", ")", "]", ")", "frames", "=", "["...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Video.from_video
Read from videos
example/gluon/lipnet/utils/preprocess_data.py
def from_video(self, path): """ Read from videos """ frames = self.get_video_frames(path) self.handle_type(frames) return self
def from_video(self, path): """ Read from videos """ frames = self.get_video_frames(path) self.handle_type(frames) return self
[ "Read", "from", "videos" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/utils/preprocess_data.py#L80-L86
[ "def", "from_video", "(", "self", ",", "path", ")", ":", "frames", "=", "self", ".", "get_video_frames", "(", "path", ")", "self", ".", "handle_type", "(", "frames", ")", "return", "self" ]
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Video.handle_type
Config video types
example/gluon/lipnet/utils/preprocess_data.py
def handle_type(self, frames): """ Config video types """ if self.vtype == 'mouth': self.process_frames_mouth(frames) elif self.vtype == 'face': self.process_frames_face(frames) else: raise Exception('Video type not found')
def handle_type(self, frames): """ Config video types """ if self.vtype == 'mouth': self.process_frames_mouth(frames) elif self.vtype == 'face': self.process_frames_face(frames) else: raise Exception('Video type not found')
[ "Config", "video", "types" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/utils/preprocess_data.py#L95-L104
[ "def", "handle_type", "(", "self", ",", "frames", ")", ":", "if", "self", ".", "vtype", "==", "'mouth'", ":", "self", ".", "process_frames_mouth", "(", "frames", ")", "elif", "self", ".", "vtype", "==", "'face'", ":", "self", ".", "process_frames_face", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7
train
Video.process_frames_face
Preprocess from frames using face detector
example/gluon/lipnet/utils/preprocess_data.py
def process_frames_face(self, frames): """ Preprocess from frames using face detector """ detector = dlib.get_frontal_face_detector() predictor = dlib.shape_predictor(self.face_predictor_path) mouth_frames = self.get_frames_mouth(detector, predictor, frames) self....
def process_frames_face(self, frames): """ Preprocess from frames using face detector """ detector = dlib.get_frontal_face_detector() predictor = dlib.shape_predictor(self.face_predictor_path) mouth_frames = self.get_frames_mouth(detector, predictor, frames) self....
[ "Preprocess", "from", "frames", "using", "face", "detector" ]
apache/incubator-mxnet
python
https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/example/gluon/lipnet/utils/preprocess_data.py#L106-L116
[ "def", "process_frames_face", "(", "self", ",", "frames", ")", ":", "detector", "=", "dlib", ".", "get_frontal_face_detector", "(", ")", "predictor", "=", "dlib", ".", "shape_predictor", "(", "self", ".", "face_predictor_path", ")", "mouth_frames", "=", "self", ...
1af29e9c060a4c7d60eeaacba32afdb9a7775ba7