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
valid
boolean_flag
Add a boolean flag to argparse parser. Parameters ---------- parser: argparse.Parser parser to add the flag to name: str --<name> will enable the flag, while --no-<name> will disable it default: bool or None default value of the flag help: str help string for the...
baselines/common/misc_util.py
def boolean_flag(parser, name, default=False, help=None): """Add a boolean flag to argparse parser. Parameters ---------- parser: argparse.Parser parser to add the flag to name: str --<name> will enable the flag, while --no-<name> will disable it default: bool or None de...
def boolean_flag(parser, name, default=False, help=None): """Add a boolean flag to argparse parser. Parameters ---------- parser: argparse.Parser parser to add the flag to name: str --<name> will enable the flag, while --no-<name> will disable it default: bool or None de...
[ "Add", "a", "boolean", "flag", "to", "argparse", "parser", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/misc_util.py#L140-L156
[ "def", "boolean_flag", "(", "parser", ",", "name", ",", "default", "=", "False", ",", "help", "=", "None", ")", ":", "dest", "=", "name", ".", "replace", "(", "'-'", ",", "'_'", ")", "parser", ".", "add_argument", "(", "\"--\"", "+", "name", ",", "...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
get_wrapper_by_name
Given an a gym environment possibly wrapped multiple times, returns a wrapper of class named classname or raises ValueError if no such wrapper was applied Parameters ---------- env: gym.Env of gym.Wrapper gym environment classname: str name of the wrapper Returns ------- ...
baselines/common/misc_util.py
def get_wrapper_by_name(env, classname): """Given an a gym environment possibly wrapped multiple times, returns a wrapper of class named classname or raises ValueError if no such wrapper was applied Parameters ---------- env: gym.Env of gym.Wrapper gym environment classname: str ...
def get_wrapper_by_name(env, classname): """Given an a gym environment possibly wrapped multiple times, returns a wrapper of class named classname or raises ValueError if no such wrapper was applied Parameters ---------- env: gym.Env of gym.Wrapper gym environment classname: str ...
[ "Given", "an", "a", "gym", "environment", "possibly", "wrapped", "multiple", "times", "returns", "a", "wrapper", "of", "class", "named", "classname", "or", "raises", "ValueError", "if", "no", "such", "wrapper", "was", "applied" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/misc_util.py#L159-L182
[ "def", "get_wrapper_by_name", "(", "env", ",", "classname", ")", ":", "currentenv", "=", "env", "while", "True", ":", "if", "classname", "==", "currentenv", ".", "class_name", "(", ")", ":", "return", "currentenv", "elif", "isinstance", "(", "currentenv", ",...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
relatively_safe_pickle_dump
This is just like regular pickle dump, except from the fact that failure cases are different: - It's never possible that we end up with a pickle in corrupted state. - If a there was a different file at the path, that file will remain unchanged in the even of failure (provided that filesys...
baselines/common/misc_util.py
def relatively_safe_pickle_dump(obj, path, compression=False): """This is just like regular pickle dump, except from the fact that failure cases are different: - It's never possible that we end up with a pickle in corrupted state. - If a there was a different file at the path, that file will re...
def relatively_safe_pickle_dump(obj, path, compression=False): """This is just like regular pickle dump, except from the fact that failure cases are different: - It's never possible that we end up with a pickle in corrupted state. - If a there was a different file at the path, that file will re...
[ "This", "is", "just", "like", "regular", "pickle", "dump", "except", "from", "the", "fact", "that", "failure", "cases", "are", "different", ":" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/misc_util.py#L185-L218
[ "def", "relatively_safe_pickle_dump", "(", "obj", ",", "path", ",", "compression", "=", "False", ")", ":", "temp_storage", "=", "path", "+", "\".relatively_safe\"", "if", "compression", ":", "# Using gzip here would be simpler, but the size is limited to 2GB", "with", "te...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
pickle_load
Unpickle a possible compressed pickle. Parameters ---------- path: str path to the output file compression: bool if true assumes that pickle was compressed when created and attempts decompression. Returns ------- obj: object the unpickled object
baselines/common/misc_util.py
def pickle_load(path, compression=False): """Unpickle a possible compressed pickle. Parameters ---------- path: str path to the output file compression: bool if true assumes that pickle was compressed when created and attempts decompression. Returns ------- obj: object ...
def pickle_load(path, compression=False): """Unpickle a possible compressed pickle. Parameters ---------- path: str path to the output file compression: bool if true assumes that pickle was compressed when created and attempts decompression. Returns ------- obj: object ...
[ "Unpickle", "a", "possible", "compressed", "pickle", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/misc_util.py#L221-L243
[ "def", "pickle_load", "(", "path", ",", "compression", "=", "False", ")", ":", "if", "compression", ":", "with", "zipfile", ".", "ZipFile", "(", "path", ",", "\"r\"", ",", "compression", "=", "zipfile", ".", "ZIP_DEFLATED", ")", "as", "myzip", ":", "with...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
RunningAvg.update
Update the estimate. Parameters ---------- new_val: float new observated value of estimated quantity.
baselines/common/misc_util.py
def update(self, new_val): """Update the estimate. Parameters ---------- new_val: float new observated value of estimated quantity. """ if self._value is None: self._value = new_val else: self._value = self._gamma * self._value...
def update(self, new_val): """Update the estimate. Parameters ---------- new_val: float new observated value of estimated quantity. """ if self._value is None: self._value = new_val else: self._value = self._gamma * self._value...
[ "Update", "the", "estimate", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/misc_util.py#L123-L134
[ "def", "update", "(", "self", ",", "new_val", ")", ":", "if", "self", ".", "_value", "is", "None", ":", "self", ".", "_value", "=", "new_val", "else", ":", "self", ".", "_value", "=", "self", ".", "_gamma", "*", "self", ".", "_value", "+", "(", "...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
store_args
Stores provided method args as instance attributes.
baselines/her/util.py
def store_args(method): """Stores provided method args as instance attributes. """ argspec = inspect.getfullargspec(method) defaults = {} if argspec.defaults is not None: defaults = dict( zip(argspec.args[-len(argspec.defaults):], argspec.defaults)) if argspec.kwonlydefaults ...
def store_args(method): """Stores provided method args as instance attributes. """ argspec = inspect.getfullargspec(method) defaults = {} if argspec.defaults is not None: defaults = dict( zip(argspec.args[-len(argspec.defaults):], argspec.defaults)) if argspec.kwonlydefaults ...
[ "Stores", "provided", "method", "args", "as", "instance", "attributes", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/her/util.py#L14-L38
[ "def", "store_args", "(", "method", ")", ":", "argspec", "=", "inspect", ".", "getfullargspec", "(", "method", ")", "defaults", "=", "{", "}", "if", "argspec", ".", "defaults", "is", "not", "None", ":", "defaults", "=", "dict", "(", "zip", "(", "argspe...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
import_function
Import a function identified by a string like "pkg.module:fn_name".
baselines/her/util.py
def import_function(spec): """Import a function identified by a string like "pkg.module:fn_name". """ mod_name, fn_name = spec.split(':') module = importlib.import_module(mod_name) fn = getattr(module, fn_name) return fn
def import_function(spec): """Import a function identified by a string like "pkg.module:fn_name". """ mod_name, fn_name = spec.split(':') module = importlib.import_module(mod_name) fn = getattr(module, fn_name) return fn
[ "Import", "a", "function", "identified", "by", "a", "string", "like", "pkg", ".", "module", ":", "fn_name", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/her/util.py#L41-L47
[ "def", "import_function", "(", "spec", ")", ":", "mod_name", ",", "fn_name", "=", "spec", ".", "split", "(", "':'", ")", "module", "=", "importlib", ".", "import_module", "(", "mod_name", ")", "fn", "=", "getattr", "(", "module", ",", "fn_name", ")", "...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
flatten_grads
Flattens a variables and their gradients.
baselines/her/util.py
def flatten_grads(var_list, grads): """Flattens a variables and their gradients. """ return tf.concat([tf.reshape(grad, [U.numel(v)]) for (v, grad) in zip(var_list, grads)], 0)
def flatten_grads(var_list, grads): """Flattens a variables and their gradients. """ return tf.concat([tf.reshape(grad, [U.numel(v)]) for (v, grad) in zip(var_list, grads)], 0)
[ "Flattens", "a", "variables", "and", "their", "gradients", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/her/util.py#L50-L54
[ "def", "flatten_grads", "(", "var_list", ",", "grads", ")", ":", "return", "tf", ".", "concat", "(", "[", "tf", ".", "reshape", "(", "grad", ",", "[", "U", ".", "numel", "(", "v", ")", "]", ")", "for", "(", "v", ",", "grad", ")", "in", "zip", ...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
nn
Creates a simple neural network
baselines/her/util.py
def nn(input, layers_sizes, reuse=None, flatten=False, name=""): """Creates a simple neural network """ for i, size in enumerate(layers_sizes): activation = tf.nn.relu if i < len(layers_sizes) - 1 else None input = tf.layers.dense(inputs=input, units=size, ...
def nn(input, layers_sizes, reuse=None, flatten=False, name=""): """Creates a simple neural network """ for i, size in enumerate(layers_sizes): activation = tf.nn.relu if i < len(layers_sizes) - 1 else None input = tf.layers.dense(inputs=input, units=size, ...
[ "Creates", "a", "simple", "neural", "network" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/her/util.py#L57-L72
[ "def", "nn", "(", "input", ",", "layers_sizes", ",", "reuse", "=", "None", ",", "flatten", "=", "False", ",", "name", "=", "\"\"", ")", ":", "for", "i", ",", "size", "in", "enumerate", "(", "layers_sizes", ")", ":", "activation", "=", "tf", ".", "n...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
mpi_fork
Re-launches the current script with workers Returns "parent" for original parent, "child" for MPI children
baselines/her/util.py
def mpi_fork(n, extra_mpi_args=[]): """Re-launches the current script with workers Returns "parent" for original parent, "child" for MPI children """ if n <= 1: return "child" if os.getenv("IN_MPI") is None: env = os.environ.copy() env.update( MKL_NUM_THREADS="1",...
def mpi_fork(n, extra_mpi_args=[]): """Re-launches the current script with workers Returns "parent" for original parent, "child" for MPI children """ if n <= 1: return "child" if os.getenv("IN_MPI") is None: env = os.environ.copy() env.update( MKL_NUM_THREADS="1",...
[ "Re", "-", "launches", "the", "current", "script", "with", "workers", "Returns", "parent", "for", "original", "parent", "child", "for", "MPI", "children" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/her/util.py#L88-L111
[ "def", "mpi_fork", "(", "n", ",", "extra_mpi_args", "=", "[", "]", ")", ":", "if", "n", "<=", "1", ":", "return", "\"child\"", "if", "os", ".", "getenv", "(", "\"IN_MPI\"", ")", "is", "None", ":", "env", "=", "os", ".", "environ", ".", "copy", "(...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
convert_episode_to_batch_major
Converts an episode to have the batch dimension in the major (first) dimension.
baselines/her/util.py
def convert_episode_to_batch_major(episode): """Converts an episode to have the batch dimension in the major (first) dimension. """ episode_batch = {} for key in episode.keys(): val = np.array(episode[key]).copy() # make inputs batch-major instead of time-major episode_batch[...
def convert_episode_to_batch_major(episode): """Converts an episode to have the batch dimension in the major (first) dimension. """ episode_batch = {} for key in episode.keys(): val = np.array(episode[key]).copy() # make inputs batch-major instead of time-major episode_batch[...
[ "Converts", "an", "episode", "to", "have", "the", "batch", "dimension", "in", "the", "major", "(", "first", ")", "dimension", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/her/util.py#L114-L124
[ "def", "convert_episode_to_batch_major", "(", "episode", ")", ":", "episode_batch", "=", "{", "}", "for", "key", "in", "episode", ".", "keys", "(", ")", ":", "val", "=", "np", ".", "array", "(", "episode", "[", "key", "]", ")", ".", "copy", "(", ")",...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
reshape_for_broadcasting
Reshapes a tensor (source) to have the correct shape and dtype of the target before broadcasting it with MPI.
baselines/her/util.py
def reshape_for_broadcasting(source, target): """Reshapes a tensor (source) to have the correct shape and dtype of the target before broadcasting it with MPI. """ dim = len(target.get_shape()) shape = ([1] * (dim - 1)) + [-1] return tf.reshape(tf.cast(source, target.dtype), shape)
def reshape_for_broadcasting(source, target): """Reshapes a tensor (source) to have the correct shape and dtype of the target before broadcasting it with MPI. """ dim = len(target.get_shape()) shape = ([1] * (dim - 1)) + [-1] return tf.reshape(tf.cast(source, target.dtype), shape)
[ "Reshapes", "a", "tensor", "(", "source", ")", "to", "have", "the", "correct", "shape", "and", "dtype", "of", "the", "target", "before", "broadcasting", "it", "with", "MPI", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/her/util.py#L134-L140
[ "def", "reshape_for_broadcasting", "(", "source", ",", "target", ")", ":", "dim", "=", "len", "(", "target", ".", "get_shape", "(", ")", ")", "shape", "=", "(", "[", "1", "]", "*", "(", "dim", "-", "1", ")", ")", "+", "[", "-", "1", "]", "retur...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
add_vtarg_and_adv
Compute target value using TD(lambda) estimator, and advantage with GAE(lambda)
baselines/ppo1/pposgd_simple.py
def add_vtarg_and_adv(seg, gamma, lam): """ Compute target value using TD(lambda) estimator, and advantage with GAE(lambda) """ new = np.append(seg["new"], 0) # last element is only used for last vtarg, but we already zeroed it if last new = 1 vpred = np.append(seg["vpred"], seg["nextvpred"]) T ...
def add_vtarg_and_adv(seg, gamma, lam): """ Compute target value using TD(lambda) estimator, and advantage with GAE(lambda) """ new = np.append(seg["new"], 0) # last element is only used for last vtarg, but we already zeroed it if last new = 1 vpred = np.append(seg["vpred"], seg["nextvpred"]) T ...
[ "Compute", "target", "value", "using", "TD", "(", "lambda", ")", "estimator", "and", "advantage", "with", "GAE", "(", "lambda", ")" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/ppo1/pposgd_simple.py#L64-L78
[ "def", "add_vtarg_and_adv", "(", "seg", ",", "gamma", ",", "lam", ")", ":", "new", "=", "np", ".", "append", "(", "seg", "[", "\"new\"", "]", ",", "0", ")", "# last element is only used for last vtarg, but we already zeroed it if last new = 1", "vpred", "=", "np",...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
switch
Switches between two operations depending on a scalar value (int or bool). Note that both `then_expression` and `else_expression` should be symbolic tensors of the *same shape*. # Arguments condition: scalar tensor. then_expression: TensorFlow operation. else_expression: TensorFlow ...
baselines/common/tf_util.py
def switch(condition, then_expression, else_expression): """Switches between two operations depending on a scalar value (int or bool). Note that both `then_expression` and `else_expression` should be symbolic tensors of the *same shape*. # Arguments condition: scalar tensor. then_expres...
def switch(condition, then_expression, else_expression): """Switches between two operations depending on a scalar value (int or bool). Note that both `then_expression` and `else_expression` should be symbolic tensors of the *same shape*. # Arguments condition: scalar tensor. then_expres...
[ "Switches", "between", "two", "operations", "depending", "on", "a", "scalar", "value", "(", "int", "or", "bool", ")", ".", "Note", "that", "both", "then_expression", "and", "else_expression", "should", "be", "symbolic", "tensors", "of", "the", "*", "same", "...
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/tf_util.py#L9-L24
[ "def", "switch", "(", "condition", ",", "then_expression", ",", "else_expression", ")", ":", "x_shape", "=", "copy", ".", "copy", "(", "then_expression", ".", "get_shape", "(", ")", ")", "x", "=", "tf", ".", "cond", "(", "tf", ".", "cast", "(", "condit...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
huber_loss
Reference: https://en.wikipedia.org/wiki/Huber_loss
baselines/common/tf_util.py
def huber_loss(x, delta=1.0): """Reference: https://en.wikipedia.org/wiki/Huber_loss""" return tf.where( tf.abs(x) < delta, tf.square(x) * 0.5, delta * (tf.abs(x) - 0.5 * delta) )
def huber_loss(x, delta=1.0): """Reference: https://en.wikipedia.org/wiki/Huber_loss""" return tf.where( tf.abs(x) < delta, tf.square(x) * 0.5, delta * (tf.abs(x) - 0.5 * delta) )
[ "Reference", ":", "https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Huber_loss" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/tf_util.py#L39-L45
[ "def", "huber_loss", "(", "x", ",", "delta", "=", "1.0", ")", ":", "return", "tf", ".", "where", "(", "tf", ".", "abs", "(", "x", ")", "<", "delta", ",", "tf", ".", "square", "(", "x", ")", "*", "0.5", ",", "delta", "*", "(", "tf", ".", "ab...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
get_session
Get default session or create one with a given config
baselines/common/tf_util.py
def get_session(config=None): """Get default session or create one with a given config""" sess = tf.get_default_session() if sess is None: sess = make_session(config=config, make_default=True) return sess
def get_session(config=None): """Get default session or create one with a given config""" sess = tf.get_default_session() if sess is None: sess = make_session(config=config, make_default=True) return sess
[ "Get", "default", "session", "or", "create", "one", "with", "a", "given", "config" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/tf_util.py#L51-L56
[ "def", "get_session", "(", "config", "=", "None", ")", ":", "sess", "=", "tf", ".", "get_default_session", "(", ")", "if", "sess", "is", "None", ":", "sess", "=", "make_session", "(", "config", "=", "config", ",", "make_default", "=", "True", ")", "ret...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
make_session
Returns a session that will use <num_cpu> CPU's only
baselines/common/tf_util.py
def make_session(config=None, num_cpu=None, make_default=False, graph=None): """Returns a session that will use <num_cpu> CPU's only""" if num_cpu is None: num_cpu = int(os.getenv('RCALL_NUM_CPU', multiprocessing.cpu_count())) if config is None: config = tf.ConfigProto( allow_sof...
def make_session(config=None, num_cpu=None, make_default=False, graph=None): """Returns a session that will use <num_cpu> CPU's only""" if num_cpu is None: num_cpu = int(os.getenv('RCALL_NUM_CPU', multiprocessing.cpu_count())) if config is None: config = tf.ConfigProto( allow_sof...
[ "Returns", "a", "session", "that", "will", "use", "<num_cpu", ">", "CPU", "s", "only" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/tf_util.py#L58-L72
[ "def", "make_session", "(", "config", "=", "None", ",", "num_cpu", "=", "None", ",", "make_default", "=", "False", ",", "graph", "=", "None", ")", ":", "if", "num_cpu", "is", "None", ":", "num_cpu", "=", "int", "(", "os", ".", "getenv", "(", "'RCALL_...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
initialize
Initialize all the uninitialized variables in the global scope.
baselines/common/tf_util.py
def initialize(): """Initialize all the uninitialized variables in the global scope.""" new_variables = set(tf.global_variables()) - ALREADY_INITIALIZED get_session().run(tf.variables_initializer(new_variables)) ALREADY_INITIALIZED.update(new_variables)
def initialize(): """Initialize all the uninitialized variables in the global scope.""" new_variables = set(tf.global_variables()) - ALREADY_INITIALIZED get_session().run(tf.variables_initializer(new_variables)) ALREADY_INITIALIZED.update(new_variables)
[ "Initialize", "all", "the", "uninitialized", "variables", "in", "the", "global", "scope", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/tf_util.py#L87-L91
[ "def", "initialize", "(", ")", ":", "new_variables", "=", "set", "(", "tf", ".", "global_variables", "(", ")", ")", "-", "ALREADY_INITIALIZED", "get_session", "(", ")", ".", "run", "(", "tf", ".", "variables_initializer", "(", "new_variables", ")", ")", "A...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
function
Just like Theano function. Take a bunch of tensorflow placeholders and expressions computed based on those placeholders and produces f(inputs) -> outputs. Function f takes values to be fed to the input's placeholders and produces the values of the expressions in outputs. Input values can be passed in t...
baselines/common/tf_util.py
def function(inputs, outputs, updates=None, givens=None): """Just like Theano function. Take a bunch of tensorflow placeholders and expressions computed based on those placeholders and produces f(inputs) -> outputs. Function f takes values to be fed to the input's placeholders and produces the values of the...
def function(inputs, outputs, updates=None, givens=None): """Just like Theano function. Take a bunch of tensorflow placeholders and expressions computed based on those placeholders and produces f(inputs) -> outputs. Function f takes values to be fed to the input's placeholders and produces the values of the...
[ "Just", "like", "Theano", "function", ".", "Take", "a", "bunch", "of", "tensorflow", "placeholders", "and", "expressions", "computed", "based", "on", "those", "placeholders", "and", "produces", "f", "(", "inputs", ")", "-", ">", "outputs", ".", "Function", "...
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/tf_util.py#L137-L179
[ "def", "function", "(", "inputs", ",", "outputs", ",", "updates", "=", "None", ",", "givens", "=", "None", ")", ":", "if", "isinstance", "(", "outputs", ",", "list", ")", ":", "return", "_Function", "(", "inputs", ",", "outputs", ",", "updates", ",", ...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
adjust_shape
adjust shape of the data to the shape of the placeholder if possible. If shape is incompatible, AssertionError is thrown Parameters: placeholder tensorflow input placeholder data input data to be (potentially) reshaped to be fed into placeholder Returns: reshaped da...
baselines/common/tf_util.py
def adjust_shape(placeholder, data): ''' adjust shape of the data to the shape of the placeholder if possible. If shape is incompatible, AssertionError is thrown Parameters: placeholder tensorflow input placeholder data input data to be (potentially) reshaped to be fed i...
def adjust_shape(placeholder, data): ''' adjust shape of the data to the shape of the placeholder if possible. If shape is incompatible, AssertionError is thrown Parameters: placeholder tensorflow input placeholder data input data to be (potentially) reshaped to be fed i...
[ "adjust", "shape", "of", "the", "data", "to", "the", "shape", "of", "the", "placeholder", "if", "possible", ".", "If", "shape", "is", "incompatible", "AssertionError", "is", "thrown" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/tf_util.py#L377-L401
[ "def", "adjust_shape", "(", "placeholder", ",", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "np", ".", "ndarray", ")", "and", "not", "isinstance", "(", "data", ",", "list", ")", ":", "return", "data", "if", "isinstance", "(", "data",...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
_check_shape
check if two shapes are compatible (i.e. differ only by dimensions of size 1, or by the batch dimension)
baselines/common/tf_util.py
def _check_shape(placeholder_shape, data_shape): ''' check if two shapes are compatible (i.e. differ only by dimensions of size 1, or by the batch dimension)''' return True squeezed_placeholder_shape = _squeeze_shape(placeholder_shape) squeezed_data_shape = _squeeze_shape(data_shape) for i, s_data...
def _check_shape(placeholder_shape, data_shape): ''' check if two shapes are compatible (i.e. differ only by dimensions of size 1, or by the batch dimension)''' return True squeezed_placeholder_shape = _squeeze_shape(placeholder_shape) squeezed_data_shape = _squeeze_shape(data_shape) for i, s_data...
[ "check", "if", "two", "shapes", "are", "compatible", "(", "i", ".", "e", ".", "differ", "only", "by", "dimensions", "of", "size", "1", "or", "by", "the", "batch", "dimension", ")" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/tf_util.py#L404-L416
[ "def", "_check_shape", "(", "placeholder_shape", ",", "data_shape", ")", ":", "return", "True", "squeezed_placeholder_shape", "=", "_squeeze_shape", "(", "placeholder_shape", ")", "squeezed_data_shape", "=", "_squeeze_shape", "(", "data_shape", ")", "for", "i", ",", ...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
profile
Usage: @profile("my_func") def my_func(): code
baselines/logger.py
def profile(n): """ Usage: @profile("my_func") def my_func(): code """ def decorator_with_name(func): def func_wrapper(*args, **kwargs): with profile_kv(n): return func(*args, **kwargs) return func_wrapper return decorator_with_name
def profile(n): """ Usage: @profile("my_func") def my_func(): code """ def decorator_with_name(func): def func_wrapper(*args, **kwargs): with profile_kv(n): return func(*args, **kwargs) return func_wrapper return decorator_with_name
[ "Usage", ":" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/logger.py#L272-L283
[ "def", "profile", "(", "n", ")", ":", "def", "decorator_with_name", "(", "func", ")", ":", "def", "func_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "profile_kv", "(", "n", ")", ":", "return", "func", "(", "*", "args", ","...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
wrap_deepmind
Configure environment for DeepMind-style Atari.
baselines/common/atari_wrappers.py
def wrap_deepmind(env, episode_life=True, clip_rewards=True, frame_stack=False, scale=False): """Configure environment for DeepMind-style Atari. """ if episode_life: env = EpisodicLifeEnv(env) if 'FIRE' in env.unwrapped.get_action_meanings(): env = FireResetEnv(env) env = WarpFrame(e...
def wrap_deepmind(env, episode_life=True, clip_rewards=True, frame_stack=False, scale=False): """Configure environment for DeepMind-style Atari. """ if episode_life: env = EpisodicLifeEnv(env) if 'FIRE' in env.unwrapped.get_action_meanings(): env = FireResetEnv(env) env = WarpFrame(e...
[ "Configure", "environment", "for", "DeepMind", "-", "style", "Atari", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/atari_wrappers.py#L235-L249
[ "def", "wrap_deepmind", "(", "env", ",", "episode_life", "=", "True", ",", "clip_rewards", "=", "True", ",", "frame_stack", "=", "False", ",", "scale", "=", "False", ")", ":", "if", "episode_life", ":", "env", "=", "EpisodicLifeEnv", "(", "env", ")", "if...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
EpisodicLifeEnv.reset
Reset only when lives are exhausted. This way all states are still reachable even though lives are episodic, and the learner need not know about any of this behind-the-scenes.
baselines/common/atari_wrappers.py
def reset(self, **kwargs): """Reset only when lives are exhausted. This way all states are still reachable even though lives are episodic, and the learner need not know about any of this behind-the-scenes. """ if self.was_real_done: obs = self.env.reset(**kwargs) ...
def reset(self, **kwargs): """Reset only when lives are exhausted. This way all states are still reachable even though lives are episodic, and the learner need not know about any of this behind-the-scenes. """ if self.was_real_done: obs = self.env.reset(**kwargs) ...
[ "Reset", "only", "when", "lives", "are", "exhausted", ".", "This", "way", "all", "states", "are", "still", "reachable", "even", "though", "lives", "are", "episodic", "and", "the", "learner", "need", "not", "know", "about", "any", "of", "this", "behind", "-...
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/atari_wrappers.py#L84-L95
[ "def", "reset", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "was_real_done", ":", "obs", "=", "self", ".", "env", ".", "reset", "(", "*", "*", "kwargs", ")", "else", ":", "# no-op step to advance from terminal/lost life state", "obs"...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
sync_from_root
Send the root node's parameters to every worker. Arguments: sess: the TensorFlow session. variables: all parameter variables including optimizer's
baselines/common/mpi_util.py
def sync_from_root(sess, variables, comm=None): """ Send the root node's parameters to every worker. Arguments: sess: the TensorFlow session. variables: all parameter variables including optimizer's """ if comm is None: comm = MPI.COMM_WORLD import tensorflow as tf values = comm....
def sync_from_root(sess, variables, comm=None): """ Send the root node's parameters to every worker. Arguments: sess: the TensorFlow session. variables: all parameter variables including optimizer's """ if comm is None: comm = MPI.COMM_WORLD import tensorflow as tf values = comm....
[ "Send", "the", "root", "node", "s", "parameters", "to", "every", "worker", ".", "Arguments", ":", "sess", ":", "the", "TensorFlow", "session", ".", "variables", ":", "all", "parameter", "variables", "including", "optimizer", "s" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/mpi_util.py#L15-L26
[ "def", "sync_from_root", "(", "sess", ",", "variables", ",", "comm", "=", "None", ")", ":", "if", "comm", "is", "None", ":", "comm", "=", "MPI", ".", "COMM_WORLD", "import", "tensorflow", "as", "tf", "values", "=", "comm", ".", "bcast", "(", "sess", ...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
gpu_count
Count the GPUs on this machine.
baselines/common/mpi_util.py
def gpu_count(): """ Count the GPUs on this machine. """ if shutil.which('nvidia-smi') is None: return 0 output = subprocess.check_output(['nvidia-smi', '--query-gpu=gpu_name', '--format=csv']) return max(0, len(output.split(b'\n')) - 2)
def gpu_count(): """ Count the GPUs on this machine. """ if shutil.which('nvidia-smi') is None: return 0 output = subprocess.check_output(['nvidia-smi', '--query-gpu=gpu_name', '--format=csv']) return max(0, len(output.split(b'\n')) - 2)
[ "Count", "the", "GPUs", "on", "this", "machine", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/mpi_util.py#L28-L35
[ "def", "gpu_count", "(", ")", ":", "if", "shutil", ".", "which", "(", "'nvidia-smi'", ")", "is", "None", ":", "return", "0", "output", "=", "subprocess", ".", "check_output", "(", "[", "'nvidia-smi'", ",", "'--query-gpu=gpu_name'", ",", "'--format=csv'", "]"...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
setup_mpi_gpus
Set CUDA_VISIBLE_DEVICES to MPI rank if not already set
baselines/common/mpi_util.py
def setup_mpi_gpus(): """ Set CUDA_VISIBLE_DEVICES to MPI rank if not already set """ if 'CUDA_VISIBLE_DEVICES' not in os.environ: if sys.platform == 'darwin': # This Assumes if you're on OSX you're just ids = [] # doing a smoke test and don't want GPUs else: ...
def setup_mpi_gpus(): """ Set CUDA_VISIBLE_DEVICES to MPI rank if not already set """ if 'CUDA_VISIBLE_DEVICES' not in os.environ: if sys.platform == 'darwin': # This Assumes if you're on OSX you're just ids = [] # doing a smoke test and don't want GPUs else: ...
[ "Set", "CUDA_VISIBLE_DEVICES", "to", "MPI", "rank", "if", "not", "already", "set" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/mpi_util.py#L37-L47
[ "def", "setup_mpi_gpus", "(", ")", ":", "if", "'CUDA_VISIBLE_DEVICES'", "not", "in", "os", ".", "environ", ":", "if", "sys", ".", "platform", "==", "'darwin'", ":", "# This Assumes if you're on OSX you're just", "ids", "=", "[", "]", "# doing a smoke test and don't ...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
get_local_rank_size
Returns the rank of each process on its machine The processes on a given machine will be assigned ranks 0, 1, 2, ..., N-1, where N is the number of processes on this machine. Useful if you want to assign one gpu per machine
baselines/common/mpi_util.py
def get_local_rank_size(comm): """ Returns the rank of each process on its machine The processes on a given machine will be assigned ranks 0, 1, 2, ..., N-1, where N is the number of processes on this machine. Useful if you want to assign one gpu per machine """ this_node = platform...
def get_local_rank_size(comm): """ Returns the rank of each process on its machine The processes on a given machine will be assigned ranks 0, 1, 2, ..., N-1, where N is the number of processes on this machine. Useful if you want to assign one gpu per machine """ this_node = platform...
[ "Returns", "the", "rank", "of", "each", "process", "on", "its", "machine", "The", "processes", "on", "a", "given", "machine", "will", "be", "assigned", "ranks", "0", "1", "2", "...", "N", "-", "1", "where", "N", "is", "the", "number", "of", "processes"...
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/mpi_util.py#L49-L67
[ "def", "get_local_rank_size", "(", "comm", ")", ":", "this_node", "=", "platform", ".", "node", "(", ")", "ranks_nodes", "=", "comm", ".", "allgather", "(", "(", "comm", ".", "Get_rank", "(", ")", ",", "this_node", ")", ")", "node2rankssofar", "=", "defa...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
share_file
Copies the file from rank 0 to all other ranks Puts it in the same place on all machines
baselines/common/mpi_util.py
def share_file(comm, path): """ Copies the file from rank 0 to all other ranks Puts it in the same place on all machines """ localrank, _ = get_local_rank_size(comm) if comm.Get_rank() == 0: with open(path, 'rb') as fh: data = fh.read() comm.bcast(data) else: ...
def share_file(comm, path): """ Copies the file from rank 0 to all other ranks Puts it in the same place on all machines """ localrank, _ = get_local_rank_size(comm) if comm.Get_rank() == 0: with open(path, 'rb') as fh: data = fh.read() comm.bcast(data) else: ...
[ "Copies", "the", "file", "from", "rank", "0", "to", "all", "other", "ranks", "Puts", "it", "in", "the", "same", "place", "on", "all", "machines" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/mpi_util.py#L69-L85
[ "def", "share_file", "(", "comm", ",", "path", ")", ":", "localrank", ",", "_", "=", "get_local_rank_size", "(", "comm", ")", "if", "comm", ".", "Get_rank", "(", ")", "==", "0", ":", "with", "open", "(", "path", ",", "'rb'", ")", "as", "fh", ":", ...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
dict_gather
Perform a reduction operation over dicts
baselines/common/mpi_util.py
def dict_gather(comm, d, op='mean', assert_all_have_data=True): """ Perform a reduction operation over dicts """ if comm is None: return d alldicts = comm.allgather(d) size = comm.size k2li = defaultdict(list) for d in alldicts: for (k,v) in d.items(): k2li[k].append(...
def dict_gather(comm, d, op='mean', assert_all_have_data=True): """ Perform a reduction operation over dicts """ if comm is None: return d alldicts = comm.allgather(d) size = comm.size k2li = defaultdict(list) for d in alldicts: for (k,v) in d.items(): k2li[k].append(...
[ "Perform", "a", "reduction", "operation", "over", "dicts" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/mpi_util.py#L87-L108
[ "def", "dict_gather", "(", "comm", ",", "d", ",", "op", "=", "'mean'", ",", "assert_all_have_data", "=", "True", ")", ":", "if", "comm", "is", "None", ":", "return", "d", "alldicts", "=", "comm", ".", "allgather", "(", "d", ")", "size", "=", "comm", ...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
mpi_weighted_mean
Perform a weighted average over dicts that are each on a different node Input: local_name2valcount: dict mapping key -> (value, count) Returns: key -> mean
baselines/common/mpi_util.py
def mpi_weighted_mean(comm, local_name2valcount): """ Perform a weighted average over dicts that are each on a different node Input: local_name2valcount: dict mapping key -> (value, count) Returns: key -> mean """ all_name2valcount = comm.gather(local_name2valcount) if comm.rank == 0: ...
def mpi_weighted_mean(comm, local_name2valcount): """ Perform a weighted average over dicts that are each on a different node Input: local_name2valcount: dict mapping key -> (value, count) Returns: key -> mean """ all_name2valcount = comm.gather(local_name2valcount) if comm.rank == 0: ...
[ "Perform", "a", "weighted", "average", "over", "dicts", "that", "are", "each", "on", "a", "different", "node", "Input", ":", "local_name2valcount", ":", "dict", "mapping", "key", "-", ">", "(", "value", "count", ")", "Returns", ":", "key", "-", ">", "mea...
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/mpi_util.py#L110-L132
[ "def", "mpi_weighted_mean", "(", "comm", ",", "local_name2valcount", ")", ":", "all_name2valcount", "=", "comm", ".", "gather", "(", "local_name2valcount", ")", "if", "comm", ".", "rank", "==", "0", ":", "name2sum", "=", "defaultdict", "(", "float", ")", "na...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
learn
learn a policy function with TRPO algorithm Parameters: ---------- network neural network to learn. Can be either string ('mlp', 'cnn', 'lstm', 'lnlstm' for basic types) or function that takes input placeholder and returns tuple (output, None) for feedforward ne...
baselines/trpo_mpi/trpo_mpi.py
def learn(*, network, env, total_timesteps, timesteps_per_batch=1024, # what to train on max_kl=0.001, cg_iters=10, gamma=0.99, lam=1.0, # advantage estimation seed=None, ent_coef=0.0, cg_damping=1e-2, vf_stepsize=3e-4, ...
def learn(*, network, env, total_timesteps, timesteps_per_batch=1024, # what to train on max_kl=0.001, cg_iters=10, gamma=0.99, lam=1.0, # advantage estimation seed=None, ent_coef=0.0, cg_damping=1e-2, vf_stepsize=3e-4, ...
[ "learn", "a", "policy", "function", "with", "TRPO", "algorithm" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/trpo_mpi/trpo_mpi.py#L89-L392
[ "def", "learn", "(", "*", ",", "network", ",", "env", ",", "total_timesteps", ",", "timesteps_per_batch", "=", "1024", ",", "# what to train on", "max_kl", "=", "0.001", ",", "cg_iters", "=", "10", ",", "gamma", "=", "0.99", ",", "lam", "=", "1.0", ",", ...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
discount
computes discounted sums along 0th dimension of x. inputs ------ x: ndarray gamma: float outputs ------- y: ndarray with same shape as x, satisfying y[t] = x[t] + gamma*x[t+1] + gamma^2*x[t+2] + ... + gamma^k x[t+k], where k = len(x) - t - 1
baselines/common/math_util.py
def discount(x, gamma): """ computes discounted sums along 0th dimension of x. inputs ------ x: ndarray gamma: float outputs ------- y: ndarray with same shape as x, satisfying y[t] = x[t] + gamma*x[t+1] + gamma^2*x[t+2] + ... + gamma^k x[t+k], where k = le...
def discount(x, gamma): """ computes discounted sums along 0th dimension of x. inputs ------ x: ndarray gamma: float outputs ------- y: ndarray with same shape as x, satisfying y[t] = x[t] + gamma*x[t+1] + gamma^2*x[t+2] + ... + gamma^k x[t+k], where k = le...
[ "computes", "discounted", "sums", "along", "0th", "dimension", "of", "x", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/math_util.py#L5-L23
[ "def", "discount", "(", "x", ",", "gamma", ")", ":", "assert", "x", ".", "ndim", ">=", "1", "return", "scipy", ".", "signal", ".", "lfilter", "(", "[", "1", "]", ",", "[", "1", ",", "-", "gamma", "]", ",", "x", "[", ":", ":", "-", "1", "]",...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
explained_variance
Computes fraction of variance that ypred explains about y. Returns 1 - Var[y-ypred] / Var[y] interpretation: ev=0 => might as well have predicted zero ev=1 => perfect prediction ev<0 => worse than just predicting zero
baselines/common/math_util.py
def explained_variance(ypred,y): """ Computes fraction of variance that ypred explains about y. Returns 1 - Var[y-ypred] / Var[y] interpretation: ev=0 => might as well have predicted zero ev=1 => perfect prediction ev<0 => worse than just predicting zero """ asser...
def explained_variance(ypred,y): """ Computes fraction of variance that ypred explains about y. Returns 1 - Var[y-ypred] / Var[y] interpretation: ev=0 => might as well have predicted zero ev=1 => perfect prediction ev<0 => worse than just predicting zero """ asser...
[ "Computes", "fraction", "of", "variance", "that", "ypred", "explains", "about", "y", ".", "Returns", "1", "-", "Var", "[", "y", "-", "ypred", "]", "/", "Var", "[", "y", "]" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/math_util.py#L25-L38
[ "def", "explained_variance", "(", "ypred", ",", "y", ")", ":", "assert", "y", ".", "ndim", "==", "1", "and", "ypred", ".", "ndim", "==", "1", "vary", "=", "np", ".", "var", "(", "y", ")", "return", "np", ".", "nan", "if", "vary", "==", "0", "el...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
discount_with_boundaries
X: 2d array of floats, time x features New: 2d array of bools, indicating when a new episode has started
baselines/common/math_util.py
def discount_with_boundaries(X, New, gamma): """ X: 2d array of floats, time x features New: 2d array of bools, indicating when a new episode has started """ Y = np.zeros_like(X) T = X.shape[0] Y[T-1] = X[T-1] for t in range(T-2, -1, -1): Y[t] = X[t] + gamma * Y[t+1] * (1 - New[t...
def discount_with_boundaries(X, New, gamma): """ X: 2d array of floats, time x features New: 2d array of bools, indicating when a new episode has started """ Y = np.zeros_like(X) T = X.shape[0] Y[T-1] = X[T-1] for t in range(T-2, -1, -1): Y[t] = X[t] + gamma * Y[t+1] * (1 - New[t...
[ "X", ":", "2d", "array", "of", "floats", "time", "x", "features", "New", ":", "2d", "array", "of", "bools", "indicating", "when", "a", "new", "episode", "has", "started" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/math_util.py#L63-L73
[ "def", "discount_with_boundaries", "(", "X", ",", "New", ",", "gamma", ")", ":", "Y", "=", "np", ".", "zeros_like", "(", "X", ")", "T", "=", "X", ".", "shape", "[", "0", "]", "Y", "[", "T", "-", "1", "]", "=", "X", "[", "T", "-", "1", "]", ...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
ReplayBuffer.sample
Sample a batch of experiences. Parameters ---------- batch_size: int How many transitions to sample. Returns ------- obs_batch: np.array batch of observations act_batch: np.array batch of actions executed given obs_batch ...
baselines/deepq/replay_buffer.py
def sample(self, batch_size): """Sample a batch of experiences. Parameters ---------- batch_size: int How many transitions to sample. Returns ------- obs_batch: np.array batch of observations act_batch: np.array batch ...
def sample(self, batch_size): """Sample a batch of experiences. Parameters ---------- batch_size: int How many transitions to sample. Returns ------- obs_batch: np.array batch of observations act_batch: np.array batch ...
[ "Sample", "a", "batch", "of", "experiences", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/deepq/replay_buffer.py#L45-L68
[ "def", "sample", "(", "self", ",", "batch_size", ")", ":", "idxes", "=", "[", "random", ".", "randint", "(", "0", ",", "len", "(", "self", ".", "_storage", ")", "-", "1", ")", "for", "_", "in", "range", "(", "batch_size", ")", "]", "return", "sel...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
PrioritizedReplayBuffer.add
See ReplayBuffer.store_effect
baselines/deepq/replay_buffer.py
def add(self, *args, **kwargs): """See ReplayBuffer.store_effect""" idx = self._next_idx super().add(*args, **kwargs) self._it_sum[idx] = self._max_priority ** self._alpha self._it_min[idx] = self._max_priority ** self._alpha
def add(self, *args, **kwargs): """See ReplayBuffer.store_effect""" idx = self._next_idx super().add(*args, **kwargs) self._it_sum[idx] = self._max_priority ** self._alpha self._it_min[idx] = self._max_priority ** self._alpha
[ "See", "ReplayBuffer", ".", "store_effect" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/deepq/replay_buffer.py#L100-L105
[ "def", "add", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "idx", "=", "self", ".", "_next_idx", "super", "(", ")", ".", "add", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "_it_sum", "[", "idx", "]", "=",...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
PrioritizedReplayBuffer.sample
Sample a batch of experiences. compared to ReplayBuffer.sample it also returns importance weights and idxes of sampled experiences. Parameters ---------- batch_size: int How many transitions to sample. beta: float To what degree to use i...
baselines/deepq/replay_buffer.py
def sample(self, batch_size, beta): """Sample a batch of experiences. compared to ReplayBuffer.sample it also returns importance weights and idxes of sampled experiences. Parameters ---------- batch_size: int How many transitions to sample. ...
def sample(self, batch_size, beta): """Sample a batch of experiences. compared to ReplayBuffer.sample it also returns importance weights and idxes of sampled experiences. Parameters ---------- batch_size: int How many transitions to sample. ...
[ "Sample", "a", "batch", "of", "experiences", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/deepq/replay_buffer.py#L117-L167
[ "def", "sample", "(", "self", ",", "batch_size", ",", "beta", ")", ":", "assert", "beta", ">", "0", "idxes", "=", "self", ".", "_sample_proportional", "(", "batch_size", ")", "weights", "=", "[", "]", "p_min", "=", "self", ".", "_it_min", ".", "min", ...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
PrioritizedReplayBuffer.update_priorities
Update priorities of sampled transitions. sets priority of transition at index idxes[i] in buffer to priorities[i]. Parameters ---------- idxes: [int] List of idxes of sampled transitions priorities: [float] List of updated priorities correspondi...
baselines/deepq/replay_buffer.py
def update_priorities(self, idxes, priorities): """Update priorities of sampled transitions. sets priority of transition at index idxes[i] in buffer to priorities[i]. Parameters ---------- idxes: [int] List of idxes of sampled transitions priorities:...
def update_priorities(self, idxes, priorities): """Update priorities of sampled transitions. sets priority of transition at index idxes[i] in buffer to priorities[i]. Parameters ---------- idxes: [int] List of idxes of sampled transitions priorities:...
[ "Update", "priorities", "of", "sampled", "transitions", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/deepq/replay_buffer.py#L169-L191
[ "def", "update_priorities", "(", "self", ",", "idxes", ",", "priorities", ")", ":", "assert", "len", "(", "idxes", ")", "==", "len", "(", "priorities", ")", "for", "idx", ",", "priority", "in", "zip", "(", "idxes", ",", "priorities", ")", ":", "assert"...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
wrap_deepmind_retro
Configure environment for retro games, using config similar to DeepMind-style Atari in wrap_deepmind
baselines/common/retro_wrappers.py
def wrap_deepmind_retro(env, scale=True, frame_stack=4): """ Configure environment for retro games, using config similar to DeepMind-style Atari in wrap_deepmind """ env = WarpFrame(env) env = ClipRewardEnv(env) if frame_stack > 1: env = FrameStack(env, frame_stack) if scale: ...
def wrap_deepmind_retro(env, scale=True, frame_stack=4): """ Configure environment for retro games, using config similar to DeepMind-style Atari in wrap_deepmind """ env = WarpFrame(env) env = ClipRewardEnv(env) if frame_stack > 1: env = FrameStack(env, frame_stack) if scale: ...
[ "Configure", "environment", "for", "retro", "games", "using", "config", "similar", "to", "DeepMind", "-", "style", "Atari", "in", "wrap_deepmind" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/retro_wrappers.py#L212-L222
[ "def", "wrap_deepmind_retro", "(", "env", ",", "scale", "=", "True", ",", "frame_stack", "=", "4", ")", ":", "env", "=", "WarpFrame", "(", "env", ")", "env", "=", "ClipRewardEnv", "(", "env", ")", "if", "frame_stack", ">", "1", ":", "env", "=", "Fram...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
scope_vars
Get variables inside a scope The scope can be specified as a string Parameters ---------- scope: str or VariableScope scope in which the variables reside. trainable_only: bool whether or not to return only the variables that were marked as trainable. Returns ------- vars:...
baselines/deepq/build_graph.py
def scope_vars(scope, trainable_only=False): """ Get variables inside a scope The scope can be specified as a string Parameters ---------- scope: str or VariableScope scope in which the variables reside. trainable_only: bool whether or not to return only the variables that we...
def scope_vars(scope, trainable_only=False): """ Get variables inside a scope The scope can be specified as a string Parameters ---------- scope: str or VariableScope scope in which the variables reside. trainable_only: bool whether or not to return only the variables that we...
[ "Get", "variables", "inside", "a", "scope", "The", "scope", "can", "be", "specified", "as", "a", "string", "Parameters", "----------", "scope", ":", "str", "or", "VariableScope", "scope", "in", "which", "the", "variables", "reside", ".", "trainable_only", ":",...
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/deepq/build_graph.py#L100-L118
[ "def", "scope_vars", "(", "scope", ",", "trainable_only", "=", "False", ")", ":", "return", "tf", ".", "get_collection", "(", "tf", ".", "GraphKeys", ".", "TRAINABLE_VARIABLES", "if", "trainable_only", "else", "tf", ".", "GraphKeys", ".", "GLOBAL_VARIABLES", "...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
build_act
Creates the act function: Parameters ---------- make_obs_ph: str -> tf.placeholder or TfInput a function that take a name and creates a placeholder of input with that name q_func: (tf.Variable, int, str, bool) -> tf.Variable the model that takes the following inputs: observa...
baselines/deepq/build_graph.py
def build_act(make_obs_ph, q_func, num_actions, scope="deepq", reuse=None): """Creates the act function: Parameters ---------- make_obs_ph: str -> tf.placeholder or TfInput a function that take a name and creates a placeholder of input with that name q_func: (tf.Variable, int, str, bool) ->...
def build_act(make_obs_ph, q_func, num_actions, scope="deepq", reuse=None): """Creates the act function: Parameters ---------- make_obs_ph: str -> tf.placeholder or TfInput a function that take a name and creates a placeholder of input with that name q_func: (tf.Variable, int, str, bool) ->...
[ "Creates", "the", "act", "function", ":" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/deepq/build_graph.py#L146-L199
[ "def", "build_act", "(", "make_obs_ph", ",", "q_func", ",", "num_actions", ",", "scope", "=", "\"deepq\"", ",", "reuse", "=", "None", ")", ":", "with", "tf", ".", "variable_scope", "(", "scope", ",", "reuse", "=", "reuse", ")", ":", "observations_ph", "=...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
build_act_with_param_noise
Creates the act function with support for parameter space noise exploration (https://arxiv.org/abs/1706.01905): Parameters ---------- make_obs_ph: str -> tf.placeholder or TfInput a function that take a name and creates a placeholder of input with that name q_func: (tf.Variable, int, str, bool)...
baselines/deepq/build_graph.py
def build_act_with_param_noise(make_obs_ph, q_func, num_actions, scope="deepq", reuse=None, param_noise_filter_func=None): """Creates the act function with support for parameter space noise exploration (https://arxiv.org/abs/1706.01905): Parameters ---------- make_obs_ph: str -> tf.placeholder or TfInp...
def build_act_with_param_noise(make_obs_ph, q_func, num_actions, scope="deepq", reuse=None, param_noise_filter_func=None): """Creates the act function with support for parameter space noise exploration (https://arxiv.org/abs/1706.01905): Parameters ---------- make_obs_ph: str -> tf.placeholder or TfInp...
[ "Creates", "the", "act", "function", "with", "support", "for", "parameter", "space", "noise", "exploration", "(", "https", ":", "//", "arxiv", ".", "org", "/", "abs", "/", "1706", ".", "01905", ")", ":" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/deepq/build_graph.py#L202-L314
[ "def", "build_act_with_param_noise", "(", "make_obs_ph", ",", "q_func", ",", "num_actions", ",", "scope", "=", "\"deepq\"", ",", "reuse", "=", "None", ",", "param_noise_filter_func", "=", "None", ")", ":", "if", "param_noise_filter_func", "is", "None", ":", "par...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
build_train
Creates the train function: Parameters ---------- make_obs_ph: str -> tf.placeholder or TfInput a function that takes a name and creates a placeholder of input with that name q_func: (tf.Variable, int, str, bool) -> tf.Variable the model that takes the following inputs: obse...
baselines/deepq/build_graph.py
def build_train(make_obs_ph, q_func, num_actions, optimizer, grad_norm_clipping=None, gamma=1.0, double_q=True, scope="deepq", reuse=None, param_noise=False, param_noise_filter_func=None): """Creates the train function: Parameters ---------- make_obs_ph: str -> tf.placeholder or TfInput a f...
def build_train(make_obs_ph, q_func, num_actions, optimizer, grad_norm_clipping=None, gamma=1.0, double_q=True, scope="deepq", reuse=None, param_noise=False, param_noise_filter_func=None): """Creates the train function: Parameters ---------- make_obs_ph: str -> tf.placeholder or TfInput a f...
[ "Creates", "the", "train", "function", ":" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/deepq/build_graph.py#L317-L449
[ "def", "build_train", "(", "make_obs_ph", ",", "q_func", ",", "num_actions", ",", "optimizer", ",", "grad_norm_clipping", "=", "None", ",", "gamma", "=", "1.0", ",", "double_q", "=", "True", ",", "scope", "=", "\"deepq\"", ",", "reuse", "=", "None", ",", ...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
profile_tf_runningmeanstd
options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE) #pylint: disable=E1101 run_metadata = tf.RunMetadata() profile_opts = dict(options=options, run_metadata=run_metadata) from tensorflow.python.client import timeline fetched_timeline = timeline.Timeline(run_metadata.step_stats) #pylint: dis...
baselines/common/running_mean_std.py
def profile_tf_runningmeanstd(): import time from baselines.common import tf_util tf_util.get_session( config=tf.ConfigProto( inter_op_parallelism_threads=1, intra_op_parallelism_threads=1, allow_soft_placement=True )) x = np.random.random((376,)) n_trials = 10000 ...
def profile_tf_runningmeanstd(): import time from baselines.common import tf_util tf_util.get_session( config=tf.ConfigProto( inter_op_parallelism_threads=1, intra_op_parallelism_threads=1, allow_soft_placement=True )) x = np.random.random((376,)) n_trials = 10000 ...
[ "options", "=", "tf", ".", "RunOptions", "(", "trace_level", "=", "tf", ".", "RunOptions", ".", "FULL_TRACE", ")", "#pylint", ":", "disable", "=", "E1101", "run_metadata", "=", "tf", ".", "RunMetadata", "()", "profile_opts", "=", "dict", "(", "options", "=...
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/common/running_mean_std.py#L120-L182
[ "def", "profile_tf_runningmeanstd", "(", ")", ":", "import", "time", "from", "baselines", ".", "common", "import", "tf_util", "tf_util", ".", "get_session", "(", "config", "=", "tf", ".", "ConfigProto", "(", "inter_op_parallelism_threads", "=", "1", ",", "intra_...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
make_sample_her_transitions
Creates a sample function that can be used for HER experience replay. Args: replay_strategy (in ['future', 'none']): the HER replay strategy; if set to 'none', regular DDPG experience replay is used replay_k (int): the ratio between HER replays and regular replays (e.g. k = 4 -> 4 times...
baselines/her/her_sampler.py
def make_sample_her_transitions(replay_strategy, replay_k, reward_fun): """Creates a sample function that can be used for HER experience replay. Args: replay_strategy (in ['future', 'none']): the HER replay strategy; if set to 'none', regular DDPG experience replay is used replay_k ...
def make_sample_her_transitions(replay_strategy, replay_k, reward_fun): """Creates a sample function that can be used for HER experience replay. Args: replay_strategy (in ['future', 'none']): the HER replay strategy; if set to 'none', regular DDPG experience replay is used replay_k ...
[ "Creates", "a", "sample", "function", "that", "can", "be", "used", "for", "HER", "experience", "replay", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/her/her_sampler.py#L4-L63
[ "def", "make_sample_her_transitions", "(", "replay_strategy", ",", "replay_k", ",", "reward_fun", ")", ":", "if", "replay_strategy", "==", "'future'", ":", "future_p", "=", "1", "-", "(", "1.", "/", "(", "1", "+", "replay_k", ")", ")", "else", ":", "# 'rep...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
model
This model takes as input an observation and returns values of all actions.
baselines/deepq/experiments/custom_cartpole.py
def model(inpt, num_actions, scope, reuse=False): """This model takes as input an observation and returns values of all actions.""" with tf.variable_scope(scope, reuse=reuse): out = inpt out = layers.fully_connected(out, num_outputs=64, activation_fn=tf.nn.tanh) out = layers.fully_connec...
def model(inpt, num_actions, scope, reuse=False): """This model takes as input an observation and returns values of all actions.""" with tf.variable_scope(scope, reuse=reuse): out = inpt out = layers.fully_connected(out, num_outputs=64, activation_fn=tf.nn.tanh) out = layers.fully_connec...
[ "This", "model", "takes", "as", "input", "an", "observation", "and", "returns", "values", "of", "all", "actions", "." ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/deepq/experiments/custom_cartpole.py#L16-L22
[ "def", "model", "(", "inpt", ",", "num_actions", ",", "scope", ",", "reuse", "=", "False", ")", ":", "with", "tf", ".", "variable_scope", "(", "scope", ",", "reuse", "=", "reuse", ")", ":", "out", "=", "inpt", "out", "=", "layers", ".", "fully_connec...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
ReplayBuffer.sample
Returns a dict {key: array(batch_size x shapes[key])}
baselines/her/replay_buffer.py
def sample(self, batch_size): """Returns a dict {key: array(batch_size x shapes[key])} """ buffers = {} with self.lock: assert self.current_size > 0 for key in self.buffers.keys(): buffers[key] = self.buffers[key][:self.current_size] buff...
def sample(self, batch_size): """Returns a dict {key: array(batch_size x shapes[key])} """ buffers = {} with self.lock: assert self.current_size > 0 for key in self.buffers.keys(): buffers[key] = self.buffers[key][:self.current_size] buff...
[ "Returns", "a", "dict", "{", "key", ":", "array", "(", "batch_size", "x", "shapes", "[", "key", "]", ")", "}" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/her/replay_buffer.py#L37-L55
[ "def", "sample", "(", "self", ",", "batch_size", ")", ":", "buffers", "=", "{", "}", "with", "self", ".", "lock", ":", "assert", "self", ".", "current_size", ">", "0", "for", "key", "in", "self", ".", "buffers", ".", "keys", "(", ")", ":", "buffers...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
ReplayBuffer.store_episode
episode_batch: array(batch_size x (T or T+1) x dim_key)
baselines/her/replay_buffer.py
def store_episode(self, episode_batch): """episode_batch: array(batch_size x (T or T+1) x dim_key) """ batch_sizes = [len(episode_batch[key]) for key in episode_batch.keys()] assert np.all(np.array(batch_sizes) == batch_sizes[0]) batch_size = batch_sizes[0] with self.loc...
def store_episode(self, episode_batch): """episode_batch: array(batch_size x (T or T+1) x dim_key) """ batch_sizes = [len(episode_batch[key]) for key in episode_batch.keys()] assert np.all(np.array(batch_sizes) == batch_sizes[0]) batch_size = batch_sizes[0] with self.loc...
[ "episode_batch", ":", "array", "(", "batch_size", "x", "(", "T", "or", "T", "+", "1", ")", "x", "dim_key", ")" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/her/replay_buffer.py#L57-L71
[ "def", "store_episode", "(", "self", ",", "episode_batch", ")", ":", "batch_sizes", "=", "[", "len", "(", "episode_batch", "[", "key", "]", ")", "for", "key", "in", "episode_batch", ".", "keys", "(", ")", "]", "assert", "np", ".", "all", "(", "np", "...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
DDPG.store_episode
episode_batch: array of batch_size x (T or T+1) x dim_key 'o' is of size T+1, others are of size T
baselines/her/ddpg.py
def store_episode(self, episode_batch, update_stats=True): """ episode_batch: array of batch_size x (T or T+1) x dim_key 'o' is of size T+1, others are of size T """ self.buffer.store_episode(episode_batch) if update_stats: # add transitions t...
def store_episode(self, episode_batch, update_stats=True): """ episode_batch: array of batch_size x (T or T+1) x dim_key 'o' is of size T+1, others are of size T """ self.buffer.store_episode(episode_batch) if update_stats: # add transitions t...
[ "episode_batch", ":", "array", "of", "batch_size", "x", "(", "T", "or", "T", "+", "1", ")", "x", "dim_key", "o", "is", "of", "size", "T", "+", "1", "others", "are", "of", "size", "T" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/her/ddpg.py#L217-L240
[ "def", "store_episode", "(", "self", ",", "episode_batch", ",", "update_stats", "=", "True", ")", ":", "self", ".", "buffer", ".", "store_episode", "(", "episode_batch", ")", "if", "update_stats", ":", "# add transitions to normalizer", "episode_batch", "[", "'o_2...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
parse_cmdline_kwargs
convert a list of '='-spaced command-line arguments to a dictionary, evaluating python objects when possible
baselines/run.py
def parse_cmdline_kwargs(args): ''' convert a list of '='-spaced command-line arguments to a dictionary, evaluating python objects when possible ''' def parse(v): assert isinstance(v, str) try: return eval(v) except (NameError, SyntaxError): return v ...
def parse_cmdline_kwargs(args): ''' convert a list of '='-spaced command-line arguments to a dictionary, evaluating python objects when possible ''' def parse(v): assert isinstance(v, str) try: return eval(v) except (NameError, SyntaxError): return v ...
[ "convert", "a", "list", "of", "=", "-", "spaced", "command", "-", "line", "arguments", "to", "a", "dictionary", "evaluating", "python", "objects", "when", "possible" ]
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/run.py#L180-L192
[ "def", "parse_cmdline_kwargs", "(", "args", ")", ":", "def", "parse", "(", "v", ")", ":", "assert", "isinstance", "(", "v", ",", "str", ")", "try", ":", "return", "eval", "(", "v", ")", "except", "(", "NameError", ",", "SyntaxError", ")", ":", "retur...
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
cached_make_env
Only creates a new environment from the provided function if one has not yet already been created. This is useful here because we need to infer certain properties of the env, e.g. its observation and action spaces, without any intend of actually using it.
baselines/her/experiment/config.py
def cached_make_env(make_env): """ Only creates a new environment from the provided function if one has not yet already been created. This is useful here because we need to infer certain properties of the env, e.g. its observation and action spaces, without any intend of actually using it. """ i...
def cached_make_env(make_env): """ Only creates a new environment from the provided function if one has not yet already been created. This is useful here because we need to infer certain properties of the env, e.g. its observation and action spaces, without any intend of actually using it. """ i...
[ "Only", "creates", "a", "new", "environment", "from", "the", "provided", "function", "if", "one", "has", "not", "yet", "already", "been", "created", ".", "This", "is", "useful", "here", "because", "we", "need", "to", "infer", "certain", "properties", "of", ...
openai/baselines
python
https://github.com/openai/baselines/blob/3301089b48c42b87b396e246ea3f56fa4bfc9678/baselines/her/experiment/config.py#L61-L70
[ "def", "cached_make_env", "(", "make_env", ")", ":", "if", "make_env", "not", "in", "CACHED_ENVS", ":", "env", "=", "make_env", "(", ")", "CACHED_ENVS", "[", "make_env", "]", "=", "env", "return", "CACHED_ENVS", "[", "make_env", "]" ]
3301089b48c42b87b396e246ea3f56fa4bfc9678
valid
compute_geometric_median
Estimate the geometric median of points in 2D. Code from https://stackoverflow.com/a/30305181 Parameters ---------- X : (N,2) ndarray Points in 2D. Second axis must be given in xy-form. eps : float, optional Distance threshold when to return the median. Returns ------- ...
imgaug/augmentables/kps.py
def compute_geometric_median(X, eps=1e-5): """ Estimate the geometric median of points in 2D. Code from https://stackoverflow.com/a/30305181 Parameters ---------- X : (N,2) ndarray Points in 2D. Second axis must be given in xy-form. eps : float, optional Distance threshold...
def compute_geometric_median(X, eps=1e-5): """ Estimate the geometric median of points in 2D. Code from https://stackoverflow.com/a/30305181 Parameters ---------- X : (N,2) ndarray Points in 2D. Second axis must be given in xy-form. eps : float, optional Distance threshold...
[ "Estimate", "the", "geometric", "median", "of", "points", "in", "2D", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L13-L58
[ "def", "compute_geometric_median", "(", "X", ",", "eps", "=", "1e-5", ")", ":", "y", "=", "np", ".", "mean", "(", "X", ",", "0", ")", "while", "True", ":", "D", "=", "scipy", ".", "spatial", ".", "distance", ".", "cdist", "(", "X", ",", "[", "y...
786be74aa855513840113ea523c5df495dc6a8af
valid
Keypoint.project
Project the keypoint onto a new position on a new image. E.g. if the keypoint is on its original image at x=(10 of 100 pixels) and y=(20 of 100 pixels) and is projected onto a new image with size (width=200, height=200), its new position will be (20, 40). This is intended for cases whe...
imgaug/augmentables/kps.py
def project(self, from_shape, to_shape): """ Project the keypoint onto a new position on a new image. E.g. if the keypoint is on its original image at x=(10 of 100 pixels) and y=(20 of 100 pixels) and is projected onto a new image with size (width=200, height=200), its new posit...
def project(self, from_shape, to_shape): """ Project the keypoint onto a new position on a new image. E.g. if the keypoint is on its original image at x=(10 of 100 pixels) and y=(20 of 100 pixels) and is projected onto a new image with size (width=200, height=200), its new posit...
[ "Project", "the", "keypoint", "onto", "a", "new", "position", "on", "a", "new", "image", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L105-L131
[ "def", "project", "(", "self", ",", "from_shape", ",", "to_shape", ")", ":", "xy_proj", "=", "project_coords", "(", "[", "(", "self", ".", "x", ",", "self", ".", "y", ")", "]", ",", "from_shape", ",", "to_shape", ")", "return", "self", ".", "deepcopy...
786be74aa855513840113ea523c5df495dc6a8af
valid
Keypoint.shift
Move the keypoint around on an image. Parameters ---------- x : number, optional Move by this value on the x axis. y : number, optional Move by this value on the y axis. Returns ------- imgaug.Keypoint Keypoint object with ne...
imgaug/augmentables/kps.py
def shift(self, x=0, y=0): """ Move the keypoint around on an image. Parameters ---------- x : number, optional Move by this value on the x axis. y : number, optional Move by this value on the y axis. Returns ------- imga...
def shift(self, x=0, y=0): """ Move the keypoint around on an image. Parameters ---------- x : number, optional Move by this value on the x axis. y : number, optional Move by this value on the y axis. Returns ------- imga...
[ "Move", "the", "keypoint", "around", "on", "an", "image", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L133-L151
[ "def", "shift", "(", "self", ",", "x", "=", "0", ",", "y", "=", "0", ")", ":", "return", "self", ".", "deepcopy", "(", "self", ".", "x", "+", "x", ",", "self", ".", "y", "+", "y", ")" ]
786be74aa855513840113ea523c5df495dc6a8af
valid
Keypoint.draw_on_image
Draw the keypoint onto a given image. The keypoint is drawn as a square. Parameters ---------- image : (H,W,3) ndarray The image onto which to draw the keypoint. color : int or list of int or tuple of int or (3,) ndarray, optional The RGB color of the k...
imgaug/augmentables/kps.py
def draw_on_image(self, image, color=(0, 255, 0), alpha=1.0, size=3, copy=True, raise_if_out_of_image=False): """ Draw the keypoint onto a given image. The keypoint is drawn as a square. Parameters ---------- image : (H,W,3) ndarray The...
def draw_on_image(self, image, color=(0, 255, 0), alpha=1.0, size=3, copy=True, raise_if_out_of_image=False): """ Draw the keypoint onto a given image. The keypoint is drawn as a square. Parameters ---------- image : (H,W,3) ndarray The...
[ "Draw", "the", "keypoint", "onto", "a", "given", "image", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L153-L250
[ "def", "draw_on_image", "(", "self", ",", "image", ",", "color", "=", "(", "0", ",", "255", ",", "0", ")", ",", "alpha", "=", "1.0", ",", "size", "=", "3", ",", "copy", "=", "True", ",", "raise_if_out_of_image", "=", "False", ")", ":", "if", "cop...
786be74aa855513840113ea523c5df495dc6a8af
valid
Keypoint.generate_similar_points_manhattan
Generate nearby points to this keypoint based on manhattan distance. To generate the first neighbouring points, a distance of S (step size) is moved from the center point (this keypoint) to the top, right, bottom and left, resulting in four new points. From these new points, the pattern is repe...
imgaug/augmentables/kps.py
def generate_similar_points_manhattan(self, nb_steps, step_size, return_array=False): """ Generate nearby points to this keypoint based on manhattan distance. To generate the first neighbouring points, a distance of S (step size) is moved from the center point (this keypoint) to the top...
def generate_similar_points_manhattan(self, nb_steps, step_size, return_array=False): """ Generate nearby points to this keypoint based on manhattan distance. To generate the first neighbouring points, a distance of S (step size) is moved from the center point (this keypoint) to the top...
[ "Generate", "nearby", "points", "to", "this", "keypoint", "based", "on", "manhattan", "distance", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L252-L315
[ "def", "generate_similar_points_manhattan", "(", "self", ",", "nb_steps", ",", "step_size", ",", "return_array", "=", "False", ")", ":", "# TODO add test", "# Points generates in manhattan style with S steps have a shape similar to a 45deg rotated", "# square. The center line with th...
786be74aa855513840113ea523c5df495dc6a8af
valid
Keypoint.copy
Create a shallow copy of the Keypoint object. Parameters ---------- x : None or number, optional Coordinate of the keypoint on the x axis. If ``None``, the instance's value will be copied. y : None or number, optional Coordinate of the keypoint on th...
imgaug/augmentables/kps.py
def copy(self, x=None, y=None): """ Create a shallow copy of the Keypoint object. Parameters ---------- x : None or number, optional Coordinate of the keypoint on the x axis. If ``None``, the instance's value will be copied. y : None or number, o...
def copy(self, x=None, y=None): """ Create a shallow copy of the Keypoint object. Parameters ---------- x : None or number, optional Coordinate of the keypoint on the x axis. If ``None``, the instance's value will be copied. y : None or number, o...
[ "Create", "a", "shallow", "copy", "of", "the", "Keypoint", "object", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L317-L337
[ "def", "copy", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ")", ":", "return", "self", ".", "deepcopy", "(", "x", "=", "x", ",", "y", "=", "y", ")" ]
786be74aa855513840113ea523c5df495dc6a8af
valid
Keypoint.deepcopy
Create a deep copy of the Keypoint object. Parameters ---------- x : None or number, optional Coordinate of the keypoint on the x axis. If ``None``, the instance's value will be copied. y : None or number, optional Coordinate of the keypoint on the y...
imgaug/augmentables/kps.py
def deepcopy(self, x=None, y=None): """ Create a deep copy of the Keypoint object. Parameters ---------- x : None or number, optional Coordinate of the keypoint on the x axis. If ``None``, the instance's value will be copied. y : None or number, ...
def deepcopy(self, x=None, y=None): """ Create a deep copy of the Keypoint object. Parameters ---------- x : None or number, optional Coordinate of the keypoint on the x axis. If ``None``, the instance's value will be copied. y : None or number, ...
[ "Create", "a", "deep", "copy", "of", "the", "Keypoint", "object", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L339-L361
[ "def", "deepcopy", "(", "self", ",", "x", "=", "None", ",", "y", "=", "None", ")", ":", "x", "=", "self", ".", "x", "if", "x", "is", "None", "else", "x", "y", "=", "self", ".", "y", "if", "y", "is", "None", "else", "y", "return", "Keypoint", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
KeypointsOnImage.on
Project keypoints from one image to a new one. Parameters ---------- image : ndarray or tuple of int New image onto which the keypoints are to be projected. May also simply be that new image's shape tuple. Returns ------- keypoints : imgaug.Keypo...
imgaug/augmentables/kps.py
def on(self, image): """ Project keypoints from one image to a new one. Parameters ---------- image : ndarray or tuple of int New image onto which the keypoints are to be projected. May also simply be that new image's shape tuple. Returns ...
def on(self, image): """ Project keypoints from one image to a new one. Parameters ---------- image : ndarray or tuple of int New image onto which the keypoints are to be projected. May also simply be that new image's shape tuple. Returns ...
[ "Project", "keypoints", "from", "one", "image", "to", "a", "new", "one", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L414-L435
[ "def", "on", "(", "self", ",", "image", ")", ":", "shape", "=", "normalize_shape", "(", "image", ")", "if", "shape", "[", "0", ":", "2", "]", "==", "self", ".", "shape", "[", "0", ":", "2", "]", ":", "return", "self", ".", "deepcopy", "(", ")",...
786be74aa855513840113ea523c5df495dc6a8af
valid
KeypointsOnImage.draw_on_image
Draw all keypoints onto a given image. Each keypoint is marked by a square of a chosen color and size. Parameters ---------- image : (H,W,3) ndarray The image onto which to draw the keypoints. This image should usually have the same shape as set in K...
imgaug/augmentables/kps.py
def draw_on_image(self, image, color=(0, 255, 0), alpha=1.0, size=3, copy=True, raise_if_out_of_image=False): """ Draw all keypoints onto a given image. Each keypoint is marked by a square of a chosen color and size. Parameters ---------- image : (...
def draw_on_image(self, image, color=(0, 255, 0), alpha=1.0, size=3, copy=True, raise_if_out_of_image=False): """ Draw all keypoints onto a given image. Each keypoint is marked by a square of a chosen color and size. Parameters ---------- image : (...
[ "Draw", "all", "keypoints", "onto", "a", "given", "image", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L437-L480
[ "def", "draw_on_image", "(", "self", ",", "image", ",", "color", "=", "(", "0", ",", "255", ",", "0", ")", ",", "alpha", "=", "1.0", ",", "size", "=", "3", ",", "copy", "=", "True", ",", "raise_if_out_of_image", "=", "False", ")", ":", "image", "...
786be74aa855513840113ea523c5df495dc6a8af
valid
KeypointsOnImage.shift
Move the keypoints around on an image. Parameters ---------- x : number, optional Move each keypoint by this value on the x axis. y : number, optional Move each keypoint by this value on the y axis. Returns ------- out : KeypointsOnImage...
imgaug/augmentables/kps.py
def shift(self, x=0, y=0): """ Move the keypoints around on an image. Parameters ---------- x : number, optional Move each keypoint by this value on the x axis. y : number, optional Move each keypoint by this value on the y axis. Returns...
def shift(self, x=0, y=0): """ Move the keypoints around on an image. Parameters ---------- x : number, optional Move each keypoint by this value on the x axis. y : number, optional Move each keypoint by this value on the y axis. Returns...
[ "Move", "the", "keypoints", "around", "on", "an", "image", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L482-L501
[ "def", "shift", "(", "self", ",", "x", "=", "0", ",", "y", "=", "0", ")", ":", "keypoints", "=", "[", "keypoint", ".", "shift", "(", "x", "=", "x", ",", "y", "=", "y", ")", "for", "keypoint", "in", "self", ".", "keypoints", "]", "return", "se...
786be74aa855513840113ea523c5df495dc6a8af
valid
KeypointsOnImage.to_xy_array
Convert keypoint coordinates to ``(N,2)`` array. Returns ------- (N, 2) ndarray Array containing the coordinates of all keypoints. Shape is ``(N,2)`` with coordinates in xy-form.
imgaug/augmentables/kps.py
def to_xy_array(self): """ Convert keypoint coordinates to ``(N,2)`` array. Returns ------- (N, 2) ndarray Array containing the coordinates of all keypoints. Shape is ``(N,2)`` with coordinates in xy-form. """ result = np.zeros((len(self....
def to_xy_array(self): """ Convert keypoint coordinates to ``(N,2)`` array. Returns ------- (N, 2) ndarray Array containing the coordinates of all keypoints. Shape is ``(N,2)`` with coordinates in xy-form. """ result = np.zeros((len(self....
[ "Convert", "keypoint", "coordinates", "to", "(", "N", "2", ")", "array", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L517-L532
[ "def", "to_xy_array", "(", "self", ")", ":", "result", "=", "np", ".", "zeros", "(", "(", "len", "(", "self", ".", "keypoints", ")", ",", "2", ")", ",", "dtype", "=", "np", ".", "float32", ")", "for", "i", ",", "keypoint", "in", "enumerate", "(",...
786be74aa855513840113ea523c5df495dc6a8af
valid
KeypointsOnImage.from_xy_array
Convert an array (N,2) with a given image shape to a KeypointsOnImage object. Parameters ---------- xy : (N, 2) ndarray Coordinates of ``N`` keypoints on the original image, given as ``(N,2)`` array of xy-coordinates. shape : tuple of int or ndarray ...
imgaug/augmentables/kps.py
def from_xy_array(cls, xy, shape): """ Convert an array (N,2) with a given image shape to a KeypointsOnImage object. Parameters ---------- xy : (N, 2) ndarray Coordinates of ``N`` keypoints on the original image, given as ``(N,2)`` array of xy-coordinates...
def from_xy_array(cls, xy, shape): """ Convert an array (N,2) with a given image shape to a KeypointsOnImage object. Parameters ---------- xy : (N, 2) ndarray Coordinates of ``N`` keypoints on the original image, given as ``(N,2)`` array of xy-coordinates...
[ "Convert", "an", "array", "(", "N", "2", ")", "with", "a", "given", "image", "shape", "to", "a", "KeypointsOnImage", "object", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L559-L579
[ "def", "from_xy_array", "(", "cls", ",", "xy", ",", "shape", ")", ":", "keypoints", "=", "[", "Keypoint", "(", "x", "=", "coord", "[", "0", "]", ",", "y", "=", "coord", "[", "1", "]", ")", "for", "coord", "in", "xy", "]", "return", "KeypointsOnIm...
786be74aa855513840113ea523c5df495dc6a8af
valid
KeypointsOnImage.to_keypoint_image
Draws a new black image of shape ``(H,W,N)`` in which all keypoint coordinates are set to 255. (H=shape height, W=shape width, N=number of keypoints) This function can be used as a helper when augmenting keypoints with a method that only supports the augmentation of images. Parameters ...
imgaug/augmentables/kps.py
def to_keypoint_image(self, size=1): """ Draws a new black image of shape ``(H,W,N)`` in which all keypoint coordinates are set to 255. (H=shape height, W=shape width, N=number of keypoints) This function can be used as a helper when augmenting keypoints with a method that only supports...
def to_keypoint_image(self, size=1): """ Draws a new black image of shape ``(H,W,N)`` in which all keypoint coordinates are set to 255. (H=shape height, W=shape width, N=number of keypoints) This function can be used as a helper when augmenting keypoints with a method that only supports...
[ "Draws", "a", "new", "black", "image", "of", "shape", "(", "H", "W", "N", ")", "in", "which", "all", "keypoint", "coordinates", "are", "set", "to", "255", ".", "(", "H", "=", "shape", "height", "W", "=", "shape", "width", "N", "=", "number", "of", ...
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L582-L623
[ "def", "to_keypoint_image", "(", "self", ",", "size", "=", "1", ")", ":", "ia", ".", "do_assert", "(", "len", "(", "self", ".", "keypoints", ")", ">", "0", ")", "height", ",", "width", "=", "self", ".", "shape", "[", "0", ":", "2", "]", "image", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
KeypointsOnImage.from_keypoint_image
Converts an image generated by ``to_keypoint_image()`` back to a KeypointsOnImage object. Parameters ---------- image : (H,W,N) ndarray The keypoints image. N is the number of keypoints. if_not_found_coords : tuple or list or dict or None, optional Coordinates t...
imgaug/augmentables/kps.py
def from_keypoint_image(image, if_not_found_coords={"x": -1, "y": -1}, threshold=1, nb_channels=None): # pylint: disable=locally-disabled, dangerous-default-value, line-too-long """ Converts an image generated by ``to_keypoint_image()`` back to a KeypointsOnImage object. Parameters ----...
def from_keypoint_image(image, if_not_found_coords={"x": -1, "y": -1}, threshold=1, nb_channels=None): # pylint: disable=locally-disabled, dangerous-default-value, line-too-long """ Converts an image generated by ``to_keypoint_image()`` back to a KeypointsOnImage object. Parameters ----...
[ "Converts", "an", "image", "generated", "by", "to_keypoint_image", "()", "back", "to", "a", "KeypointsOnImage", "object", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L626-L695
[ "def", "from_keypoint_image", "(", "image", ",", "if_not_found_coords", "=", "{", "\"x\"", ":", "-", "1", ",", "\"y\"", ":", "-", "1", "}", ",", "threshold", "=", "1", ",", "nb_channels", "=", "None", ")", ":", "# pylint: disable=locally-disabled, dangerous-de...
786be74aa855513840113ea523c5df495dc6a8af
valid
KeypointsOnImage.to_distance_maps
Generates a ``(H,W,K)`` output containing ``K`` distance maps for ``K`` keypoints. The k-th distance map contains at every location ``(y, x)`` the euclidean distance to the k-th keypoint. This function can be used as a helper when augmenting keypoints with a method that only supports the augme...
imgaug/augmentables/kps.py
def to_distance_maps(self, inverted=False): """ Generates a ``(H,W,K)`` output containing ``K`` distance maps for ``K`` keypoints. The k-th distance map contains at every location ``(y, x)`` the euclidean distance to the k-th keypoint. This function can be used as a helper when augment...
def to_distance_maps(self, inverted=False): """ Generates a ``(H,W,K)`` output containing ``K`` distance maps for ``K`` keypoints. The k-th distance map contains at every location ``(y, x)`` the euclidean distance to the k-th keypoint. This function can be used as a helper when augment...
[ "Generates", "a", "(", "H", "W", "K", ")", "output", "containing", "K", "distance", "maps", "for", "K", "keypoints", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L697-L736
[ "def", "to_distance_maps", "(", "self", ",", "inverted", "=", "False", ")", ":", "ia", ".", "do_assert", "(", "len", "(", "self", ".", "keypoints", ")", ">", "0", ")", "height", ",", "width", "=", "self", ".", "shape", "[", "0", ":", "2", "]", "d...
786be74aa855513840113ea523c5df495dc6a8af
valid
KeypointsOnImage.from_distance_maps
Converts maps generated by ``to_distance_maps()`` back to a KeypointsOnImage object. Parameters ---------- distance_maps : (H,W,N) ndarray The distance maps. N is the number of keypoints. inverted : bool, optional Whether the given distance maps were generated i...
imgaug/augmentables/kps.py
def from_distance_maps(distance_maps, inverted=False, if_not_found_coords={"x": -1, "y": -1}, threshold=None, # pylint: disable=locally-disabled, dangerous-default-value, line-too-long nb_channels=None): """ Converts maps generated by ``to_distance_maps()`` back to a Keypoints...
def from_distance_maps(distance_maps, inverted=False, if_not_found_coords={"x": -1, "y": -1}, threshold=None, # pylint: disable=locally-disabled, dangerous-default-value, line-too-long nb_channels=None): """ Converts maps generated by ``to_distance_maps()`` back to a Keypoints...
[ "Converts", "maps", "generated", "by", "to_distance_maps", "()", "back", "to", "a", "KeypointsOnImage", "object", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L740-L823
[ "def", "from_distance_maps", "(", "distance_maps", ",", "inverted", "=", "False", ",", "if_not_found_coords", "=", "{", "\"x\"", ":", "-", "1", ",", "\"y\"", ":", "-", "1", "}", ",", "threshold", "=", "None", ",", "# pylint: disable=locally-disabled, dangerous-d...
786be74aa855513840113ea523c5df495dc6a8af
valid
KeypointsOnImage.copy
Create a shallow copy of the KeypointsOnImage object. Parameters ---------- keypoints : None or list of imgaug.Keypoint, optional List of keypoints on the image. If ``None``, the instance's keypoints will be copied. shape : tuple of int, optional The...
imgaug/augmentables/kps.py
def copy(self, keypoints=None, shape=None): """ Create a shallow copy of the KeypointsOnImage object. Parameters ---------- keypoints : None or list of imgaug.Keypoint, optional List of keypoints on the image. If ``None``, the instance's keypoints will be...
def copy(self, keypoints=None, shape=None): """ Create a shallow copy of the KeypointsOnImage object. Parameters ---------- keypoints : None or list of imgaug.Keypoint, optional List of keypoints on the image. If ``None``, the instance's keypoints will be...
[ "Create", "a", "shallow", "copy", "of", "the", "KeypointsOnImage", "object", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L825-L850
[ "def", "copy", "(", "self", ",", "keypoints", "=", "None", ",", "shape", "=", "None", ")", ":", "result", "=", "copy", ".", "copy", "(", "self", ")", "if", "keypoints", "is", "not", "None", ":", "result", ".", "keypoints", "=", "keypoints", "if", "...
786be74aa855513840113ea523c5df495dc6a8af
valid
KeypointsOnImage.deepcopy
Create a deep copy of the KeypointsOnImage object. Parameters ---------- keypoints : None or list of imgaug.Keypoint, optional List of keypoints on the image. If ``None``, the instance's keypoints will be copied. shape : tuple of int, optional The sh...
imgaug/augmentables/kps.py
def deepcopy(self, keypoints=None, shape=None): """ Create a deep copy of the KeypointsOnImage object. Parameters ---------- keypoints : None or list of imgaug.Keypoint, optional List of keypoints on the image. If ``None``, the instance's keypoints will b...
def deepcopy(self, keypoints=None, shape=None): """ Create a deep copy of the KeypointsOnImage object. Parameters ---------- keypoints : None or list of imgaug.Keypoint, optional List of keypoints on the image. If ``None``, the instance's keypoints will b...
[ "Create", "a", "deep", "copy", "of", "the", "KeypointsOnImage", "object", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/kps.py#L852-L877
[ "def", "deepcopy", "(", "self", ",", "keypoints", "=", "None", ",", "shape", "=", "None", ")", ":", "# for some reason deepcopy is way slower here than manual copy", "if", "keypoints", "is", "None", ":", "keypoints", "=", "[", "kp", ".", "deepcopy", "(", ")", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.contains
Estimate whether the bounding box contains a point. Parameters ---------- other : tuple of number or imgaug.Keypoint Point to check for. Returns ------- bool True if the point is contained in the bounding box, False otherwise.
imgaug/augmentables/bbs.py
def contains(self, other): """ Estimate whether the bounding box contains a point. Parameters ---------- other : tuple of number or imgaug.Keypoint Point to check for. Returns ------- bool True if the point is contained in the bou...
def contains(self, other): """ Estimate whether the bounding box contains a point. Parameters ---------- other : tuple of number or imgaug.Keypoint Point to check for. Returns ------- bool True if the point is contained in the bou...
[ "Estimate", "whether", "the", "bounding", "box", "contains", "a", "point", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L176-L195
[ "def", "contains", "(", "self", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "tuple", ")", ":", "x", ",", "y", "=", "other", "else", ":", "x", ",", "y", "=", "other", ".", "x", ",", "other", ".", "y", "return", "self", ".", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.project
Project the bounding box onto a differently shaped image. E.g. if the bounding box is on its original image at x1=(10 of 100 pixels) and y1=(20 of 100 pixels) and is projected onto a new image with size (width=200, height=200), its new position will be (x1=20, y1=40). (Analogous for x2/...
imgaug/augmentables/bbs.py
def project(self, from_shape, to_shape): """ Project the bounding box onto a differently shaped image. E.g. if the bounding box is on its original image at x1=(10 of 100 pixels) and y1=(20 of 100 pixels) and is projected onto a new image with size (width=200, height=200), its ne...
def project(self, from_shape, to_shape): """ Project the bounding box onto a differently shaped image. E.g. if the bounding box is on its original image at x1=(10 of 100 pixels) and y1=(20 of 100 pixels) and is projected onto a new image with size (width=200, height=200), its ne...
[ "Project", "the", "bounding", "box", "onto", "a", "differently", "shaped", "image", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L198-L231
[ "def", "project", "(", "self", ",", "from_shape", ",", "to_shape", ")", ":", "coords_proj", "=", "project_coords", "(", "[", "(", "self", ".", "x1", ",", "self", ".", "y1", ")", ",", "(", "self", ".", "x2", ",", "self", ".", "y2", ")", "]", ",", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.extend
Extend the size of the bounding box along its sides. Parameters ---------- all_sides : number, optional Value by which to extend the bounding box size along all sides. top : number, optional Value by which to extend the bounding box size along its top side. ...
imgaug/augmentables/bbs.py
def extend(self, all_sides=0, top=0, right=0, bottom=0, left=0): """ Extend the size of the bounding box along its sides. Parameters ---------- all_sides : number, optional Value by which to extend the bounding box size along all sides. top : number, optiona...
def extend(self, all_sides=0, top=0, right=0, bottom=0, left=0): """ Extend the size of the bounding box along its sides. Parameters ---------- all_sides : number, optional Value by which to extend the bounding box size along all sides. top : number, optiona...
[ "Extend", "the", "size", "of", "the", "bounding", "box", "along", "its", "sides", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L233-L265
[ "def", "extend", "(", "self", ",", "all_sides", "=", "0", ",", "top", "=", "0", ",", "right", "=", "0", ",", "bottom", "=", "0", ",", "left", "=", "0", ")", ":", "return", "BoundingBox", "(", "x1", "=", "self", ".", "x1", "-", "all_sides", "-",...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.intersection
Compute the intersection bounding box of this bounding box and another one. Note that in extreme cases, the intersection can be a single point, meaning that the intersection bounding box will exist, but then also has a height and width of zero. Parameters ---------- other : img...
imgaug/augmentables/bbs.py
def intersection(self, other, default=None): """ Compute the intersection bounding box of this bounding box and another one. Note that in extreme cases, the intersection can be a single point, meaning that the intersection bounding box will exist, but then also has a height and width of...
def intersection(self, other, default=None): """ Compute the intersection bounding box of this bounding box and another one. Note that in extreme cases, the intersection can be a single point, meaning that the intersection bounding box will exist, but then also has a height and width of...
[ "Compute", "the", "intersection", "bounding", "box", "of", "this", "bounding", "box", "and", "another", "one", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L267-L296
[ "def", "intersection", "(", "self", ",", "other", ",", "default", "=", "None", ")", ":", "x1_i", "=", "max", "(", "self", ".", "x1", ",", "other", ".", "x1", ")", "y1_i", "=", "max", "(", "self", ".", "y1", ",", "other", ".", "y1", ")", "x2_i",...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.union
Compute the union bounding box of this bounding box and another one. This is equivalent to drawing a bounding box around all corners points of both bounding boxes. Parameters ---------- other : imgaug.BoundingBox Other bounding box with which to generate the union. ...
imgaug/augmentables/bbs.py
def union(self, other): """ Compute the union bounding box of this bounding box and another one. This is equivalent to drawing a bounding box around all corners points of both bounding boxes. Parameters ---------- other : imgaug.BoundingBox Other bou...
def union(self, other): """ Compute the union bounding box of this bounding box and another one. This is equivalent to drawing a bounding box around all corners points of both bounding boxes. Parameters ---------- other : imgaug.BoundingBox Other bou...
[ "Compute", "the", "union", "bounding", "box", "of", "this", "bounding", "box", "and", "another", "one", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L298-L321
[ "def", "union", "(", "self", ",", "other", ")", ":", "return", "BoundingBox", "(", "x1", "=", "min", "(", "self", ".", "x1", ",", "other", ".", "x1", ")", ",", "y1", "=", "min", "(", "self", ".", "y1", ",", "other", ".", "y1", ")", ",", "x2",...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.iou
Compute the IoU of this bounding box with another one. IoU is the intersection over union, defined as:: ``area(intersection(A, B)) / area(union(A, B))`` ``= area(intersection(A, B)) / (area(A) + area(B) - area(intersection(A, B)))`` Parameters ---------- other ...
imgaug/augmentables/bbs.py
def iou(self, other): """ Compute the IoU of this bounding box with another one. IoU is the intersection over union, defined as:: ``area(intersection(A, B)) / area(union(A, B))`` ``= area(intersection(A, B)) / (area(A) + area(B) - area(intersection(A, B)))`` Pa...
def iou(self, other): """ Compute the IoU of this bounding box with another one. IoU is the intersection over union, defined as:: ``area(intersection(A, B)) / area(union(A, B))`` ``= area(intersection(A, B)) / (area(A) + area(B) - area(intersection(A, B)))`` Pa...
[ "Compute", "the", "IoU", "of", "this", "bounding", "box", "with", "another", "one", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L323-L348
[ "def", "iou", "(", "self", ",", "other", ")", ":", "inters", "=", "self", ".", "intersection", "(", "other", ")", "if", "inters", "is", "None", ":", "return", "0.0", "else", ":", "area_union", "=", "self", ".", "area", "+", "other", ".", "area", "-...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.is_fully_within_image
Estimate whether the bounding box is fully inside the image area. Parameters ---------- image : (H,W,...) ndarray or tuple of int Image dimensions to use. If an ndarray, its shape will be used. If a tuple, it is assumed to represent the image shape ...
imgaug/augmentables/bbs.py
def is_fully_within_image(self, image): """ Estimate whether the bounding box is fully inside the image area. Parameters ---------- image : (H,W,...) ndarray or tuple of int Image dimensions to use. If an ndarray, its shape will be used. If a ...
def is_fully_within_image(self, image): """ Estimate whether the bounding box is fully inside the image area. Parameters ---------- image : (H,W,...) ndarray or tuple of int Image dimensions to use. If an ndarray, its shape will be used. If a ...
[ "Estimate", "whether", "the", "bounding", "box", "is", "fully", "inside", "the", "image", "area", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L350-L370
[ "def", "is_fully_within_image", "(", "self", ",", "image", ")", ":", "shape", "=", "normalize_shape", "(", "image", ")", "height", ",", "width", "=", "shape", "[", "0", ":", "2", "]", "return", "self", ".", "x1", ">=", "0", "and", "self", ".", "x2", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.is_partly_within_image
Estimate whether the bounding box is at least partially inside the image area. Parameters ---------- image : (H,W,...) ndarray or tuple of int Image dimensions to use. If an ndarray, its shape will be used. If a tuple, it is assumed to represent the image sha...
imgaug/augmentables/bbs.py
def is_partly_within_image(self, image): """ Estimate whether the bounding box is at least partially inside the image area. Parameters ---------- image : (H,W,...) ndarray or tuple of int Image dimensions to use. If an ndarray, its shape will be used. ...
def is_partly_within_image(self, image): """ Estimate whether the bounding box is at least partially inside the image area. Parameters ---------- image : (H,W,...) ndarray or tuple of int Image dimensions to use. If an ndarray, its shape will be used. ...
[ "Estimate", "whether", "the", "bounding", "box", "is", "at", "least", "partially", "inside", "the", "image", "area", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L372-L394
[ "def", "is_partly_within_image", "(", "self", ",", "image", ")", ":", "shape", "=", "normalize_shape", "(", "image", ")", "height", ",", "width", "=", "shape", "[", "0", ":", "2", "]", "eps", "=", "np", ".", "finfo", "(", "np", ".", "float32", ")", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.is_out_of_image
Estimate whether the bounding box is partially or fully outside of the image area. Parameters ---------- image : (H,W,...) ndarray or tuple of int Image dimensions to use. If an ndarray, its shape will be used. If a tuple, it is assumed to represent the image shape and m...
imgaug/augmentables/bbs.py
def is_out_of_image(self, image, fully=True, partly=False): """ Estimate whether the bounding box is partially or fully outside of the image area. Parameters ---------- image : (H,W,...) ndarray or tuple of int Image dimensions to use. If an ndarray, its shape will b...
def is_out_of_image(self, image, fully=True, partly=False): """ Estimate whether the bounding box is partially or fully outside of the image area. Parameters ---------- image : (H,W,...) ndarray or tuple of int Image dimensions to use. If an ndarray, its shape will b...
[ "Estimate", "whether", "the", "bounding", "box", "is", "partially", "or", "fully", "outside", "of", "the", "image", "area", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L396-L425
[ "def", "is_out_of_image", "(", "self", ",", "image", ",", "fully", "=", "True", ",", "partly", "=", "False", ")", ":", "if", "self", ".", "is_fully_within_image", "(", "image", ")", ":", "return", "False", "elif", "self", ".", "is_partly_within_image", "("...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.clip_out_of_image
Clip off all parts of the bounding box that are outside of the image. Parameters ---------- image : (H,W,...) ndarray or tuple of int Image dimensions to use for the clipping of the bounding box. If an ndarray, its shape will be used. If a tuple, it is assume...
imgaug/augmentables/bbs.py
def clip_out_of_image(self, image): """ Clip off all parts of the bounding box that are outside of the image. Parameters ---------- image : (H,W,...) ndarray or tuple of int Image dimensions to use for the clipping of the bounding box. If an ndarray, its ...
def clip_out_of_image(self, image): """ Clip off all parts of the bounding box that are outside of the image. Parameters ---------- image : (H,W,...) ndarray or tuple of int Image dimensions to use for the clipping of the bounding box. If an ndarray, its ...
[ "Clip", "off", "all", "parts", "of", "the", "bounding", "box", "that", "are", "outside", "of", "the", "image", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L433-L468
[ "def", "clip_out_of_image", "(", "self", ",", "image", ")", ":", "shape", "=", "normalize_shape", "(", "image", ")", "height", ",", "width", "=", "shape", "[", "0", ":", "2", "]", "ia", ".", "do_assert", "(", "height", ">", "0", ")", "ia", ".", "do...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.shift
Shift the bounding box from one or more image sides, i.e. move it on the x/y-axis. Parameters ---------- top : None or int, optional Amount of pixels by which to shift the bounding box from the top. right : None or int, optional Amount of pixels by which to shif...
imgaug/augmentables/bbs.py
def shift(self, top=None, right=None, bottom=None, left=None): """ Shift the bounding box from one or more image sides, i.e. move it on the x/y-axis. Parameters ---------- top : None or int, optional Amount of pixels by which to shift the bounding box from the top. ...
def shift(self, top=None, right=None, bottom=None, left=None): """ Shift the bounding box from one or more image sides, i.e. move it on the x/y-axis. Parameters ---------- top : None or int, optional Amount of pixels by which to shift the bounding box from the top. ...
[ "Shift", "the", "bounding", "box", "from", "one", "or", "more", "image", "sides", "i", ".", "e", ".", "move", "it", "on", "the", "x", "/", "y", "-", "axis", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L471-L504
[ "def", "shift", "(", "self", ",", "top", "=", "None", ",", "right", "=", "None", ",", "bottom", "=", "None", ",", "left", "=", "None", ")", ":", "top", "=", "top", "if", "top", "is", "not", "None", "else", "0", "right", "=", "right", "if", "rig...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.draw_on_image
Draw the bounding box on an image. Parameters ---------- image : (H,W,C) ndarray(uint8) The image onto which to draw the bounding box. color : iterable of int, optional The color to use, corresponding to the channel layout of the image. Usually RGB. alp...
imgaug/augmentables/bbs.py
def draw_on_image(self, image, color=(0, 255, 0), alpha=1.0, size=1, copy=True, raise_if_out_of_image=False, thickness=None): """ Draw the bounding box on an image. Parameters ---------- image : (H,W,C) ndarray(uint8) The image onto which to dra...
def draw_on_image(self, image, color=(0, 255, 0), alpha=1.0, size=1, copy=True, raise_if_out_of_image=False, thickness=None): """ Draw the bounding box on an image. Parameters ---------- image : (H,W,C) ndarray(uint8) The image onto which to dra...
[ "Draw", "the", "bounding", "box", "on", "an", "image", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L507-L591
[ "def", "draw_on_image", "(", "self", ",", "image", ",", "color", "=", "(", "0", ",", "255", ",", "0", ")", ",", "alpha", "=", "1.0", ",", "size", "=", "1", ",", "copy", "=", "True", ",", "raise_if_out_of_image", "=", "False", ",", "thickness", "=",...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.extract_from_image
Extract the image pixels within the bounding box. This function will zero-pad the image if the bounding box is partially/fully outside of the image. Parameters ---------- image : (H,W) ndarray or (H,W,C) ndarray The image from which to extract the pixels within the ...
imgaug/augmentables/bbs.py
def extract_from_image(self, image, pad=True, pad_max=None, prevent_zero_size=True): """ Extract the image pixels within the bounding box. This function will zero-pad the image if the bounding box is partially/fully outside of the image. Parameters ...
def extract_from_image(self, image, pad=True, pad_max=None, prevent_zero_size=True): """ Extract the image pixels within the bounding box. This function will zero-pad the image if the bounding box is partially/fully outside of the image. Parameters ...
[ "Extract", "the", "image", "pixels", "within", "the", "bounding", "box", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L594-L714
[ "def", "extract_from_image", "(", "self", ",", "image", ",", "pad", "=", "True", ",", "pad_max", "=", "None", ",", "prevent_zero_size", "=", "True", ")", ":", "pad_top", "=", "0", "pad_right", "=", "0", "pad_bottom", "=", "0", "pad_left", "=", "0", "he...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.to_keypoints
Convert the corners of the bounding box to keypoints (clockwise, starting at top left). Returns ------- list of imgaug.Keypoint Corners of the bounding box as keypoints.
imgaug/augmentables/bbs.py
def to_keypoints(self): """ Convert the corners of the bounding box to keypoints (clockwise, starting at top left). Returns ------- list of imgaug.Keypoint Corners of the bounding box as keypoints. """ # TODO get rid of this deferred import f...
def to_keypoints(self): """ Convert the corners of the bounding box to keypoints (clockwise, starting at top left). Returns ------- list of imgaug.Keypoint Corners of the bounding box as keypoints. """ # TODO get rid of this deferred import f...
[ "Convert", "the", "corners", "of", "the", "bounding", "box", "to", "keypoints", "(", "clockwise", "starting", "at", "top", "left", ")", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L718-L736
[ "def", "to_keypoints", "(", "self", ")", ":", "# TODO get rid of this deferred import", "from", "imgaug", ".", "augmentables", ".", "kps", "import", "Keypoint", "return", "[", "Keypoint", "(", "x", "=", "self", ".", "x1", ",", "y", "=", "self", ".", "y1", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.copy
Create a shallow copy of the BoundingBox object. Parameters ---------- x1 : None or number If not None, then the x1 coordinate of the copied object will be set to this value. y1 : None or number If not None, then the y1 coordinate of the copied object will be se...
imgaug/augmentables/bbs.py
def copy(self, x1=None, y1=None, x2=None, y2=None, label=None): """ Create a shallow copy of the BoundingBox object. Parameters ---------- x1 : None or number If not None, then the x1 coordinate of the copied object will be set to this value. y1 : None or nu...
def copy(self, x1=None, y1=None, x2=None, y2=None, label=None): """ Create a shallow copy of the BoundingBox object. Parameters ---------- x1 : None or number If not None, then the x1 coordinate of the copied object will be set to this value. y1 : None or nu...
[ "Create", "a", "shallow", "copy", "of", "the", "BoundingBox", "object", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L738-L771
[ "def", "copy", "(", "self", ",", "x1", "=", "None", ",", "y1", "=", "None", ",", "x2", "=", "None", ",", "y2", "=", "None", ",", "label", "=", "None", ")", ":", "return", "BoundingBox", "(", "x1", "=", "self", ".", "x1", "if", "x1", "is", "No...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBox.deepcopy
Create a deep copy of the BoundingBox object. Parameters ---------- x1 : None or number If not None, then the x1 coordinate of the copied object will be set to this value. y1 : None or number If not None, then the y1 coordinate of the copied object will be set t...
imgaug/augmentables/bbs.py
def deepcopy(self, x1=None, y1=None, x2=None, y2=None, label=None): """ Create a deep copy of the BoundingBox object. Parameters ---------- x1 : None or number If not None, then the x1 coordinate of the copied object will be set to this value. y1 : None or n...
def deepcopy(self, x1=None, y1=None, x2=None, y2=None, label=None): """ Create a deep copy of the BoundingBox object. Parameters ---------- x1 : None or number If not None, then the x1 coordinate of the copied object will be set to this value. y1 : None or n...
[ "Create", "a", "deep", "copy", "of", "the", "BoundingBox", "object", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L773-L800
[ "def", "deepcopy", "(", "self", ",", "x1", "=", "None", ",", "y1", "=", "None", ",", "x2", "=", "None", ",", "y2", "=", "None", ",", "label", "=", "None", ")", ":", "return", "self", ".", "copy", "(", "x1", "=", "x1", ",", "y1", "=", "y1", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBoxesOnImage.on
Project bounding boxes from one image to a new one. Parameters ---------- image : ndarray or tuple of int New image onto which the bounding boxes are to be projected. May also simply be that new image's shape tuple. Returns ------- bounding_boxes...
imgaug/augmentables/bbs.py
def on(self, image): """ Project bounding boxes from one image to a new one. Parameters ---------- image : ndarray or tuple of int New image onto which the bounding boxes are to be projected. May also simply be that new image's shape tuple. Retur...
def on(self, image): """ Project bounding boxes from one image to a new one. Parameters ---------- image : ndarray or tuple of int New image onto which the bounding boxes are to be projected. May also simply be that new image's shape tuple. Retur...
[ "Project", "bounding", "boxes", "from", "one", "image", "to", "a", "new", "one", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L877-L898
[ "def", "on", "(", "self", ",", "image", ")", ":", "shape", "=", "normalize_shape", "(", "image", ")", "if", "shape", "[", "0", ":", "2", "]", "==", "self", ".", "shape", "[", "0", ":", "2", "]", ":", "return", "self", ".", "deepcopy", "(", ")",...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBoxesOnImage.from_xyxy_array
Convert an (N,4) ndarray to a BoundingBoxesOnImage object. This is the inverse of :func:`imgaug.BoundingBoxesOnImage.to_xyxy_array`. Parameters ---------- xyxy : (N,4) ndarray Array containing the corner coordinates (top-left, bottom-right) of ``N`` bounding boxes ...
imgaug/augmentables/bbs.py
def from_xyxy_array(cls, xyxy, shape): """ Convert an (N,4) ndarray to a BoundingBoxesOnImage object. This is the inverse of :func:`imgaug.BoundingBoxesOnImage.to_xyxy_array`. Parameters ---------- xyxy : (N,4) ndarray Array containing the corner coordinates...
def from_xyxy_array(cls, xyxy, shape): """ Convert an (N,4) ndarray to a BoundingBoxesOnImage object. This is the inverse of :func:`imgaug.BoundingBoxesOnImage.to_xyxy_array`. Parameters ---------- xyxy : (N,4) ndarray Array containing the corner coordinates...
[ "Convert", "an", "(", "N", "4", ")", "ndarray", "to", "a", "BoundingBoxesOnImage", "object", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L901-L927
[ "def", "from_xyxy_array", "(", "cls", ",", "xyxy", ",", "shape", ")", ":", "ia", ".", "do_assert", "(", "xyxy", ".", "shape", "[", "1", "]", "==", "4", ",", "\"Expected input array of shape (N, 4), got shape %s.\"", "%", "(", "xyxy", ".", "shape", ",", ")"...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBoxesOnImage.to_xyxy_array
Convert the BoundingBoxesOnImage object to an (N,4) ndarray. This is the inverse of :func:`imgaug.BoundingBoxesOnImage.from_xyxy_array`. Parameters ---------- dtype : numpy.dtype, optional Desired output datatype of the ndarray. Returns ------- ndar...
imgaug/augmentables/bbs.py
def to_xyxy_array(self, dtype=np.float32): """ Convert the BoundingBoxesOnImage object to an (N,4) ndarray. This is the inverse of :func:`imgaug.BoundingBoxesOnImage.from_xyxy_array`. Parameters ---------- dtype : numpy.dtype, optional Desired output datatyp...
def to_xyxy_array(self, dtype=np.float32): """ Convert the BoundingBoxesOnImage object to an (N,4) ndarray. This is the inverse of :func:`imgaug.BoundingBoxesOnImage.from_xyxy_array`. Parameters ---------- dtype : numpy.dtype, optional Desired output datatyp...
[ "Convert", "the", "BoundingBoxesOnImage", "object", "to", "an", "(", "N", "4", ")", "ndarray", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L929-L952
[ "def", "to_xyxy_array", "(", "self", ",", "dtype", "=", "np", ".", "float32", ")", ":", "xyxy_array", "=", "np", ".", "zeros", "(", "(", "len", "(", "self", ".", "bounding_boxes", ")", ",", "4", ")", ",", "dtype", "=", "np", ".", "float32", ")", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBoxesOnImage.draw_on_image
Draw all bounding boxes onto a given image. Parameters ---------- image : (H,W,3) ndarray The image onto which to draw the bounding boxes. This image should usually have the same shape as set in BoundingBoxesOnImage.shape. color : int or list of int ...
imgaug/augmentables/bbs.py
def draw_on_image(self, image, color=(0, 255, 0), alpha=1.0, size=1, copy=True, raise_if_out_of_image=False, thickness=None): """ Draw all bounding boxes onto a given image. Parameters ---------- image : (H,W,3) ndarray The image onto which to d...
def draw_on_image(self, image, color=(0, 255, 0), alpha=1.0, size=1, copy=True, raise_if_out_of_image=False, thickness=None): """ Draw all bounding boxes onto a given image. Parameters ---------- image : (H,W,3) ndarray The image onto which to d...
[ "Draw", "all", "bounding", "boxes", "onto", "a", "given", "image", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L954-L1005
[ "def", "draw_on_image", "(", "self", ",", "image", ",", "color", "=", "(", "0", ",", "255", ",", "0", ")", ",", "alpha", "=", "1.0", ",", "size", "=", "1", ",", "copy", "=", "True", ",", "raise_if_out_of_image", "=", "False", ",", "thickness", "=",...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBoxesOnImage.remove_out_of_image
Remove all bounding boxes that are fully or partially outside of the image. Parameters ---------- fully : bool, optional Whether to remove bounding boxes that are fully outside of the image. partly : bool, optional Whether to remove bounding boxes that are parti...
imgaug/augmentables/bbs.py
def remove_out_of_image(self, fully=True, partly=False): """ Remove all bounding boxes that are fully or partially outside of the image. Parameters ---------- fully : bool, optional Whether to remove bounding boxes that are fully outside of the image. partly...
def remove_out_of_image(self, fully=True, partly=False): """ Remove all bounding boxes that are fully or partially outside of the image. Parameters ---------- fully : bool, optional Whether to remove bounding boxes that are fully outside of the image. partly...
[ "Remove", "all", "bounding", "boxes", "that", "are", "fully", "or", "partially", "outside", "of", "the", "image", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L1007-L1028
[ "def", "remove_out_of_image", "(", "self", ",", "fully", "=", "True", ",", "partly", "=", "False", ")", ":", "bbs_clean", "=", "[", "bb", "for", "bb", "in", "self", ".", "bounding_boxes", "if", "not", "bb", ".", "is_out_of_image", "(", "self", ".", "sh...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBoxesOnImage.clip_out_of_image
Clip off all parts from all bounding boxes that are outside of the image. Returns ------- imgaug.BoundingBoxesOnImage Bounding boxes, clipped to fall within the image dimensions.
imgaug/augmentables/bbs.py
def clip_out_of_image(self): """ Clip off all parts from all bounding boxes that are outside of the image. Returns ------- imgaug.BoundingBoxesOnImage Bounding boxes, clipped to fall within the image dimensions. """ bbs_cut = [bb.clip_out_of_image(se...
def clip_out_of_image(self): """ Clip off all parts from all bounding boxes that are outside of the image. Returns ------- imgaug.BoundingBoxesOnImage Bounding boxes, clipped to fall within the image dimensions. """ bbs_cut = [bb.clip_out_of_image(se...
[ "Clip", "off", "all", "parts", "from", "all", "bounding", "boxes", "that", "are", "outside", "of", "the", "image", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L1036-L1048
[ "def", "clip_out_of_image", "(", "self", ")", ":", "bbs_cut", "=", "[", "bb", ".", "clip_out_of_image", "(", "self", ".", "shape", ")", "for", "bb", "in", "self", ".", "bounding_boxes", "if", "bb", ".", "is_partly_within_image", "(", "self", ".", "shape", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBoxesOnImage.shift
Shift all bounding boxes from one or more image sides, i.e. move them on the x/y-axis. Parameters ---------- top : None or int, optional Amount of pixels by which to shift all bounding boxes from the top. right : None or int, optional Amount of pixels by which t...
imgaug/augmentables/bbs.py
def shift(self, top=None, right=None, bottom=None, left=None): """ Shift all bounding boxes from one or more image sides, i.e. move them on the x/y-axis. Parameters ---------- top : None or int, optional Amount of pixels by which to shift all bounding boxes from the ...
def shift(self, top=None, right=None, bottom=None, left=None): """ Shift all bounding boxes from one or more image sides, i.e. move them on the x/y-axis. Parameters ---------- top : None or int, optional Amount of pixels by which to shift all bounding boxes from the ...
[ "Shift", "all", "bounding", "boxes", "from", "one", "or", "more", "image", "sides", "i", ".", "e", ".", "move", "them", "on", "the", "x", "/", "y", "-", "axis", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L1050-L1075
[ "def", "shift", "(", "self", ",", "top", "=", "None", ",", "right", "=", "None", ",", "bottom", "=", "None", ",", "left", "=", "None", ")", ":", "bbs_new", "=", "[", "bb", ".", "shift", "(", "top", "=", "top", ",", "right", "=", "right", ",", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
BoundingBoxesOnImage.deepcopy
Create a deep copy of the BoundingBoxesOnImage object. Returns ------- imgaug.BoundingBoxesOnImage Deep copy.
imgaug/augmentables/bbs.py
def deepcopy(self): """ Create a deep copy of the BoundingBoxesOnImage object. Returns ------- imgaug.BoundingBoxesOnImage Deep copy. """ # Manual copy is far faster than deepcopy for BoundingBoxesOnImage, # so use manual copy here too ...
def deepcopy(self): """ Create a deep copy of the BoundingBoxesOnImage object. Returns ------- imgaug.BoundingBoxesOnImage Deep copy. """ # Manual copy is far faster than deepcopy for BoundingBoxesOnImage, # so use manual copy here too ...
[ "Create", "a", "deep", "copy", "of", "the", "BoundingBoxesOnImage", "object", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/bbs.py#L1089-L1102
[ "def", "deepcopy", "(", "self", ")", ":", "# Manual copy is far faster than deepcopy for BoundingBoxesOnImage,", "# so use manual copy here too", "bbs", "=", "[", "bb", ".", "deepcopy", "(", ")", "for", "bb", "in", "self", ".", "bounding_boxes", "]", "return", "Boundi...
786be74aa855513840113ea523c5df495dc6a8af
valid
Emboss
Augmenter that embosses images and overlays the result with the original image. The embossed version pronounces highlights and shadows, letting the image look as if it was recreated on a metal plate ("embossed"). dtype support:: See ``imgaug.augmenters.convolutional.Convolve``. Parameter...
imgaug/augmenters/convolutional.py
def Emboss(alpha=0, strength=1, name=None, deterministic=False, random_state=None): """ Augmenter that embosses images and overlays the result with the original image. The embossed version pronounces highlights and shadows, letting the image look as if it was recreated on a metal plate ("embossed")...
def Emboss(alpha=0, strength=1, name=None, deterministic=False, random_state=None): """ Augmenter that embosses images and overlays the result with the original image. The embossed version pronounces highlights and shadows, letting the image look as if it was recreated on a metal plate ("embossed")...
[ "Augmenter", "that", "embosses", "images", "and", "overlays", "the", "result", "with", "the", "original", "image", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmenters/convolutional.py#L296-L378
[ "def", "Emboss", "(", "alpha", "=", "0", ",", "strength", "=", "1", ",", "name", "=", "None", ",", "deterministic", "=", "False", ",", "random_state", "=", "None", ")", ":", "alpha_param", "=", "iap", ".", "handle_continuous_param", "(", "alpha", ",", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
EdgeDetect
Augmenter that detects all edges in images, marks them in a black and white image and then overlays the result with the original image. dtype support:: See ``imgaug.augmenters.convolutional.Convolve``. Parameters ---------- alpha : number or tuple of number or list of number or imgaug...
imgaug/augmenters/convolutional.py
def EdgeDetect(alpha=0, name=None, deterministic=False, random_state=None): """ Augmenter that detects all edges in images, marks them in a black and white image and then overlays the result with the original image. dtype support:: See ``imgaug.augmenters.convolutional.Convolve``. Par...
def EdgeDetect(alpha=0, name=None, deterministic=False, random_state=None): """ Augmenter that detects all edges in images, marks them in a black and white image and then overlays the result with the original image. dtype support:: See ``imgaug.augmenters.convolutional.Convolve``. Par...
[ "Augmenter", "that", "detects", "all", "edges", "in", "images", "marks", "them", "in", "a", "black", "and", "white", "image", "and", "then", "overlays", "the", "result", "with", "the", "original", "image", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmenters/convolutional.py#L382-L445
[ "def", "EdgeDetect", "(", "alpha", "=", "0", ",", "name", "=", "None", ",", "deterministic", "=", "False", ",", "random_state", "=", "None", ")", ":", "alpha_param", "=", "iap", ".", "handle_continuous_param", "(", "alpha", ",", "\"alpha\"", ",", "value_ra...
786be74aa855513840113ea523c5df495dc6a8af
valid
DirectedEdgeDetect
Augmenter that detects edges that have certain directions and marks them in a black and white image and then overlays the result with the original image. dtype support:: See ``imgaug.augmenters.convolutional.Convolve``. Parameters ---------- alpha : number or tuple of number or list o...
imgaug/augmenters/convolutional.py
def DirectedEdgeDetect(alpha=0, direction=(0.0, 1.0), name=None, deterministic=False, random_state=None): """ Augmenter that detects edges that have certain directions and marks them in a black and white image and then overlays the result with the original image. dtype support:: See ``imga...
def DirectedEdgeDetect(alpha=0, direction=(0.0, 1.0), name=None, deterministic=False, random_state=None): """ Augmenter that detects edges that have certain directions and marks them in a black and white image and then overlays the result with the original image. dtype support:: See ``imga...
[ "Augmenter", "that", "detects", "edges", "that", "have", "certain", "directions", "and", "marks", "them", "in", "a", "black", "and", "white", "image", "and", "then", "overlays", "the", "result", "with", "the", "original", "image", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmenters/convolutional.py#L450-L568
[ "def", "DirectedEdgeDetect", "(", "alpha", "=", "0", ",", "direction", "=", "(", "0.0", ",", "1.0", ")", ",", "name", "=", "None", ",", "deterministic", "=", "False", ",", "random_state", "=", "None", ")", ":", "alpha_param", "=", "iap", ".", "handle_c...
786be74aa855513840113ea523c5df495dc6a8af
valid
normalize_shape
Normalize a shape tuple or array to a shape tuple. Parameters ---------- shape : tuple of int or ndarray The input to normalize. May optionally be an array. Returns ------- tuple of int Shape tuple.
imgaug/augmentables/utils.py
def normalize_shape(shape): """ Normalize a shape tuple or array to a shape tuple. Parameters ---------- shape : tuple of int or ndarray The input to normalize. May optionally be an array. Returns ------- tuple of int Shape tuple. """ if isinstance(shape, tuple...
def normalize_shape(shape): """ Normalize a shape tuple or array to a shape tuple. Parameters ---------- shape : tuple of int or ndarray The input to normalize. May optionally be an array. Returns ------- tuple of int Shape tuple. """ if isinstance(shape, tuple...
[ "Normalize", "a", "shape", "tuple", "or", "array", "to", "a", "shape", "tuple", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/utils.py#L8-L27
[ "def", "normalize_shape", "(", "shape", ")", ":", "if", "isinstance", "(", "shape", ",", "tuple", ")", ":", "return", "shape", "assert", "ia", ".", "is_np_array", "(", "shape", ")", ",", "(", "\"Expected tuple of ints or array, got %s.\"", "%", "(", "type", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
project_coords
Project coordinates from one image shape to another. This performs a relative projection, e.g. a point at 60% of the old image width will be at 60% of the new image width after projection. Parameters ---------- coords : ndarray or tuple of number Coordinates to project. Either a ``(N,2)`` ...
imgaug/augmentables/utils.py
def project_coords(coords, from_shape, to_shape): """ Project coordinates from one image shape to another. This performs a relative projection, e.g. a point at 60% of the old image width will be at 60% of the new image width after projection. Parameters ---------- coords : ndarray or tuple...
def project_coords(coords, from_shape, to_shape): """ Project coordinates from one image shape to another. This performs a relative projection, e.g. a point at 60% of the old image width will be at 60% of the new image width after projection. Parameters ---------- coords : ndarray or tuple...
[ "Project", "coordinates", "from", "one", "image", "shape", "to", "another", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmentables/utils.py#L31-L71
[ "def", "project_coords", "(", "coords", ",", "from_shape", ",", "to_shape", ")", ":", "from_shape", "=", "normalize_shape", "(", "from_shape", ")", "to_shape", "=", "normalize_shape", "(", "to_shape", ")", "if", "from_shape", "[", "0", ":", "2", "]", "==", ...
786be74aa855513840113ea523c5df495dc6a8af
valid
AdditiveGaussianNoise
Add gaussian noise (aka white noise) to images. dtype support:: See ``imgaug.augmenters.arithmetic.AddElementwise``. Parameters ---------- loc : number or tuple of number or list of number or imgaug.parameters.StochasticParameter, optional Mean of the normal distribution that generate...
imgaug/augmenters/arithmetic.py
def AdditiveGaussianNoise(loc=0, scale=0, per_channel=False, name=None, deterministic=False, random_state=None): """ Add gaussian noise (aka white noise) to images. dtype support:: See ``imgaug.augmenters.arithmetic.AddElementwise``. Parameters ---------- loc : number or tuple of numb...
def AdditiveGaussianNoise(loc=0, scale=0, per_channel=False, name=None, deterministic=False, random_state=None): """ Add gaussian noise (aka white noise) to images. dtype support:: See ``imgaug.augmenters.arithmetic.AddElementwise``. Parameters ---------- loc : number or tuple of numb...
[ "Add", "gaussian", "noise", "(", "aka", "white", "noise", ")", "to", "images", "." ]
aleju/imgaug
python
https://github.com/aleju/imgaug/blob/786be74aa855513840113ea523c5df495dc6a8af/imgaug/augmenters/arithmetic.py#L371-L451
[ "def", "AdditiveGaussianNoise", "(", "loc", "=", "0", ",", "scale", "=", "0", ",", "per_channel", "=", "False", ",", "name", "=", "None", ",", "deterministic", "=", "False", ",", "random_state", "=", "None", ")", ":", "loc2", "=", "iap", ".", "handle_c...
786be74aa855513840113ea523c5df495dc6a8af