repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
ray-project/ray
python/ray/utils.py
ensure_str
def ensure_str(s, encoding="utf-8", errors="strict"): """Coerce *s* to `str`. To keep six with lower version, see Issue 4169, we copy this function from six == 1.12.0. TODO(yuhguo): remove this function when six >= 1.12.0. For Python 2: - `unicode` -> encoded to `str` - `str` -> `str`...
python
def ensure_str(s, encoding="utf-8", errors="strict"): """Coerce *s* to `str`. To keep six with lower version, see Issue 4169, we copy this function from six == 1.12.0. TODO(yuhguo): remove this function when six >= 1.12.0. For Python 2: - `unicode` -> encoded to `str` - `str` -> `str`...
[ "def", "ensure_str", "(", "s", ",", "encoding", "=", "\"utf-8\"", ",", "errors", "=", "\"strict\"", ")", ":", "if", "six", ".", "PY3", ":", "text_type", "=", "str", "binary_type", "=", "bytes", "else", ":", "text_type", "=", "unicode", "# noqa: F821", "b...
Coerce *s* to `str`. To keep six with lower version, see Issue 4169, we copy this function from six == 1.12.0. TODO(yuhguo): remove this function when six >= 1.12.0. For Python 2: - `unicode` -> encoded to `str` - `str` -> `str` For Python 3: - `str` -> `str` - `bytes` ->...
[ "Coerce", "*", "s", "*", "to", "str", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L184-L212
train
ray-project/ray
python/ray/utils.py
get_cuda_visible_devices
def get_cuda_visible_devices(): """Get the device IDs in the CUDA_VISIBLE_DEVICES environment variable. Returns: if CUDA_VISIBLE_DEVICES is set, this returns a list of integers with the IDs of the GPUs. If it is not set, this returns None. """ gpu_ids_str = os.environ.get("CUDA_VISI...
python
def get_cuda_visible_devices(): """Get the device IDs in the CUDA_VISIBLE_DEVICES environment variable. Returns: if CUDA_VISIBLE_DEVICES is set, this returns a list of integers with the IDs of the GPUs. If it is not set, this returns None. """ gpu_ids_str = os.environ.get("CUDA_VISI...
[ "def", "get_cuda_visible_devices", "(", ")", ":", "gpu_ids_str", "=", "os", ".", "environ", ".", "get", "(", "\"CUDA_VISIBLE_DEVICES\"", ",", "None", ")", "if", "gpu_ids_str", "is", "None", ":", "return", "None", "if", "gpu_ids_str", "==", "\"\"", ":", "retu...
Get the device IDs in the CUDA_VISIBLE_DEVICES environment variable. Returns: if CUDA_VISIBLE_DEVICES is set, this returns a list of integers with the IDs of the GPUs. If it is not set, this returns None.
[ "Get", "the", "device", "IDs", "in", "the", "CUDA_VISIBLE_DEVICES", "environment", "variable", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L230-L245
train
ray-project/ray
python/ray/utils.py
resources_from_resource_arguments
def resources_from_resource_arguments(default_num_cpus, default_num_gpus, default_resources, runtime_num_cpus, runtime_num_gpus, runtime_resources): """Determine a task's resource requirements. Args: default_num_cpus: The defau...
python
def resources_from_resource_arguments(default_num_cpus, default_num_gpus, default_resources, runtime_num_cpus, runtime_num_gpus, runtime_resources): """Determine a task's resource requirements. Args: default_num_cpus: The defau...
[ "def", "resources_from_resource_arguments", "(", "default_num_cpus", ",", "default_num_gpus", ",", "default_resources", ",", "runtime_num_cpus", ",", "runtime_num_gpus", ",", "runtime_resources", ")", ":", "if", "runtime_resources", "is", "not", "None", ":", "resources", ...
Determine a task's resource requirements. Args: default_num_cpus: The default number of CPUs required by this function or actor method. default_num_gpus: The default number of GPUs required by this function or actor method. default_resources: The default custom resou...
[ "Determine", "a", "task", "s", "resource", "requirements", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L257-L299
train
ray-project/ray
python/ray/utils.py
setup_logger
def setup_logger(logging_level, logging_format): """Setup default logging for ray.""" logger = logging.getLogger("ray") if type(logging_level) is str: logging_level = logging.getLevelName(logging_level.upper()) logger.setLevel(logging_level) global _default_handler if _default_handler is...
python
def setup_logger(logging_level, logging_format): """Setup default logging for ray.""" logger = logging.getLogger("ray") if type(logging_level) is str: logging_level = logging.getLevelName(logging_level.upper()) logger.setLevel(logging_level) global _default_handler if _default_handler is...
[ "def", "setup_logger", "(", "logging_level", ",", "logging_format", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "\"ray\"", ")", "if", "type", "(", "logging_level", ")", "is", "str", ":", "logging_level", "=", "logging", ".", "getLevelName", "(...
Setup default logging for ray.
[ "Setup", "default", "logging", "for", "ray", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L305-L316
train
ray-project/ray
python/ray/utils.py
vmstat
def vmstat(stat): """Run vmstat and get a particular statistic. Args: stat: The statistic that we are interested in retrieving. Returns: The parsed output. """ out = subprocess.check_output(["vmstat", "-s"]) stat = stat.encode("ascii") for line in out.split(b"\n"): ...
python
def vmstat(stat): """Run vmstat and get a particular statistic. Args: stat: The statistic that we are interested in retrieving. Returns: The parsed output. """ out = subprocess.check_output(["vmstat", "-s"]) stat = stat.encode("ascii") for line in out.split(b"\n"): ...
[ "def", "vmstat", "(", "stat", ")", ":", "out", "=", "subprocess", ".", "check_output", "(", "[", "\"vmstat\"", ",", "\"-s\"", "]", ")", "stat", "=", "stat", ".", "encode", "(", "\"ascii\"", ")", "for", "line", "in", "out", ".", "split", "(", "b\"\\n\...
Run vmstat and get a particular statistic. Args: stat: The statistic that we are interested in retrieving. Returns: The parsed output.
[ "Run", "vmstat", "and", "get", "a", "particular", "statistic", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L321-L336
train
ray-project/ray
python/ray/utils.py
sysctl
def sysctl(command): """Run a sysctl command and parse the output. Args: command: A sysctl command with an argument, for example, ["sysctl", "hw.memsize"]. Returns: The parsed output. """ out = subprocess.check_output(command) result = out.split(b" ")[1] try: ...
python
def sysctl(command): """Run a sysctl command and parse the output. Args: command: A sysctl command with an argument, for example, ["sysctl", "hw.memsize"]. Returns: The parsed output. """ out = subprocess.check_output(command) result = out.split(b" ")[1] try: ...
[ "def", "sysctl", "(", "command", ")", ":", "out", "=", "subprocess", ".", "check_output", "(", "command", ")", "result", "=", "out", ".", "split", "(", "b\" \"", ")", "[", "1", "]", "try", ":", "return", "int", "(", "result", ")", "except", "ValueErr...
Run a sysctl command and parse the output. Args: command: A sysctl command with an argument, for example, ["sysctl", "hw.memsize"]. Returns: The parsed output.
[ "Run", "a", "sysctl", "command", "and", "parse", "the", "output", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L341-L356
train
ray-project/ray
python/ray/utils.py
get_system_memory
def get_system_memory(): """Return the total amount of system memory in bytes. Returns: The total amount of system memory in bytes. """ # Try to accurately figure out the memory limit if we are in a docker # container. Note that this file is not specific to Docker and its value is # oft...
python
def get_system_memory(): """Return the total amount of system memory in bytes. Returns: The total amount of system memory in bytes. """ # Try to accurately figure out the memory limit if we are in a docker # container. Note that this file is not specific to Docker and its value is # oft...
[ "def", "get_system_memory", "(", ")", ":", "# Try to accurately figure out the memory limit if we are in a docker", "# container. Note that this file is not specific to Docker and its value is", "# often much larger than the actual amount of memory.", "docker_limit", "=", "None", "memory_limit...
Return the total amount of system memory in bytes. Returns: The total amount of system memory in bytes.
[ "Return", "the", "total", "amount", "of", "system", "memory", "in", "bytes", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L359-L395
train
ray-project/ray
python/ray/utils.py
get_shared_memory_bytes
def get_shared_memory_bytes(): """Get the size of the shared memory file system. Returns: The size of the shared memory file system in bytes. """ # Make sure this is only called on Linux. assert sys.platform == "linux" or sys.platform == "linux2" shm_fd = os.open("/dev/shm", os.O_RDONL...
python
def get_shared_memory_bytes(): """Get the size of the shared memory file system. Returns: The size of the shared memory file system in bytes. """ # Make sure this is only called on Linux. assert sys.platform == "linux" or sys.platform == "linux2" shm_fd = os.open("/dev/shm", os.O_RDONL...
[ "def", "get_shared_memory_bytes", "(", ")", ":", "# Make sure this is only called on Linux.", "assert", "sys", ".", "platform", "==", "\"linux\"", "or", "sys", ".", "platform", "==", "\"linux2\"", "shm_fd", "=", "os", ".", "open", "(", "\"/dev/shm\"", ",", "os", ...
Get the size of the shared memory file system. Returns: The size of the shared memory file system in bytes.
[ "Get", "the", "size", "of", "the", "shared", "memory", "file", "system", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L398-L417
train
ray-project/ray
python/ray/utils.py
check_oversized_pickle
def check_oversized_pickle(pickled, name, obj_type, worker): """Send a warning message if the pickled object is too large. Args: pickled: the pickled object. name: name of the pickled object. obj_type: type of the pickled object, can be 'function', 'remote function', 'actor'...
python
def check_oversized_pickle(pickled, name, obj_type, worker): """Send a warning message if the pickled object is too large. Args: pickled: the pickled object. name: name of the pickled object. obj_type: type of the pickled object, can be 'function', 'remote function', 'actor'...
[ "def", "check_oversized_pickle", "(", "pickled", ",", "name", ",", "obj_type", ",", "worker", ")", ":", "length", "=", "len", "(", "pickled", ")", "if", "length", "<=", "ray_constants", ".", "PICKLE_OBJECT_WARNING_SIZE", ":", "return", "warning_message", "=", ...
Send a warning message if the pickled object is too large. Args: pickled: the pickled object. name: name of the pickled object. obj_type: type of the pickled object, can be 'function', 'remote function', 'actor', or 'object'. worker: the worker used to send warning messa...
[ "Send", "a", "warning", "message", "if", "the", "pickled", "object", "is", "too", "large", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L420-L442
train
ray-project/ray
python/ray/utils.py
thread_safe_client
def thread_safe_client(client, lock=None): """Create a thread-safe proxy which locks every method call for the given client. Args: client: the client object to be guarded. lock: the lock object that will be used to lock client's methods. If None, a new lock will be used. Re...
python
def thread_safe_client(client, lock=None): """Create a thread-safe proxy which locks every method call for the given client. Args: client: the client object to be guarded. lock: the lock object that will be used to lock client's methods. If None, a new lock will be used. Re...
[ "def", "thread_safe_client", "(", "client", ",", "lock", "=", "None", ")", ":", "if", "lock", "is", "None", ":", "lock", "=", "threading", ".", "Lock", "(", ")", "return", "_ThreadSafeProxy", "(", "client", ",", "lock", ")" ]
Create a thread-safe proxy which locks every method call for the given client. Args: client: the client object to be guarded. lock: the lock object that will be used to lock client's methods. If None, a new lock will be used. Returns: A thread-safe proxy for the given c...
[ "Create", "a", "thread", "-", "safe", "proxy", "which", "locks", "every", "method", "call", "for", "the", "given", "client", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L482-L496
train
ray-project/ray
python/ray/utils.py
try_to_create_directory
def try_to_create_directory(directory_path): """Attempt to create a directory that is globally readable/writable. Args: directory_path: The path of the directory to create. """ logger = logging.getLogger("ray") directory_path = os.path.expanduser(directory_path) if not os.path.exists(di...
python
def try_to_create_directory(directory_path): """Attempt to create a directory that is globally readable/writable. Args: directory_path: The path of the directory to create. """ logger = logging.getLogger("ray") directory_path = os.path.expanduser(directory_path) if not os.path.exists(di...
[ "def", "try_to_create_directory", "(", "directory_path", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "\"ray\"", ")", "directory_path", "=", "os", ".", "path", ".", "expanduser", "(", "directory_path", ")", "if", "not", "os", ".", "path", ".", ...
Attempt to create a directory that is globally readable/writable. Args: directory_path: The path of the directory to create.
[ "Attempt", "to", "create", "a", "directory", "that", "is", "globally", "readable", "/", "writable", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/utils.py#L503-L533
train
ray-project/ray
python/ray/experimental/array/distributed/core.py
subblocks
def subblocks(a, *ranges): """ This function produces a distributed array from a subset of the blocks in the `a`. The result and `a` will have the same number of dimensions. For example, subblocks(a, [0, 1], [2, 4]) will produce a DistArray whose objectids are [[a.objectids[0, 2], a....
python
def subblocks(a, *ranges): """ This function produces a distributed array from a subset of the blocks in the `a`. The result and `a` will have the same number of dimensions. For example, subblocks(a, [0, 1], [2, 4]) will produce a DistArray whose objectids are [[a.objectids[0, 2], a....
[ "def", "subblocks", "(", "a", ",", "*", "ranges", ")", ":", "ranges", "=", "list", "(", "ranges", ")", "if", "len", "(", "ranges", ")", "!=", "a", ".", "ndim", ":", "raise", "Exception", "(", "\"sub_blocks expects to receive a number of ranges \"", "\"equal ...
This function produces a distributed array from a subset of the blocks in the `a`. The result and `a` will have the same number of dimensions. For example, subblocks(a, [0, 1], [2, 4]) will produce a DistArray whose objectids are [[a.objectids[0, 2], a.objectids[0, 4]], [a.objectids...
[ "This", "function", "produces", "a", "distributed", "array", "from", "a", "subset", "of", "the", "blocks", "in", "the", "a", ".", "The", "result", "and", "a", "will", "have", "the", "same", "number", "of", "dimensions", ".", "For", "example", "subblocks", ...
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/array/distributed/core.py#L204-L245
train
ray-project/ray
python/ray/experimental/array/distributed/core.py
DistArray.assemble
def assemble(self): """Assemble an array from a distributed array of object IDs.""" first_block = ray.get(self.objectids[(0, ) * self.ndim]) dtype = first_block.dtype result = np.zeros(self.shape, dtype=dtype) for index in np.ndindex(*self.num_blocks): lower = DistArr...
python
def assemble(self): """Assemble an array from a distributed array of object IDs.""" first_block = ray.get(self.objectids[(0, ) * self.ndim]) dtype = first_block.dtype result = np.zeros(self.shape, dtype=dtype) for index in np.ndindex(*self.num_blocks): lower = DistArr...
[ "def", "assemble", "(", "self", ")", ":", "first_block", "=", "ray", ".", "get", "(", "self", ".", "objectids", "[", "(", "0", ",", ")", "*", "self", ".", "ndim", "]", ")", "dtype", "=", "first_block", ".", "dtype", "result", "=", "np", ".", "zer...
Assemble an array from a distributed array of object IDs.
[ "Assemble", "an", "array", "from", "a", "distributed", "array", "of", "object", "IDs", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/array/distributed/core.py#L58-L68
train
ray-project/ray
python/ray/rllib/agents/impala/vtrace.py
multi_log_probs_from_logits_and_actions
def multi_log_probs_from_logits_and_actions(policy_logits, actions): """Computes action log-probs from policy logits and actions. In the notation used throughout documentation and comments, T refers to the time dimension ranging from 0 to T-1. B refers to the batch size and ACTION_SPACE refers to the list of...
python
def multi_log_probs_from_logits_and_actions(policy_logits, actions): """Computes action log-probs from policy logits and actions. In the notation used throughout documentation and comments, T refers to the time dimension ranging from 0 to T-1. B refers to the batch size and ACTION_SPACE refers to the list of...
[ "def", "multi_log_probs_from_logits_and_actions", "(", "policy_logits", ",", "actions", ")", ":", "log_probs", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "policy_logits", ")", ")", ":", "log_probs", ".", "append", "(", "-", "tf", ".", "nn",...
Computes action log-probs from policy logits and actions. In the notation used throughout documentation and comments, T refers to the time dimension ranging from 0 to T-1. B refers to the batch size and ACTION_SPACE refers to the list of numbers each representing a number of actions. Args: policy_logits...
[ "Computes", "action", "log", "-", "probs", "from", "policy", "logits", "and", "actions", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/impala/vtrace.py#L54-L91
train
ray-project/ray
python/ray/rllib/agents/impala/vtrace.py
from_logits
def from_logits(behaviour_policy_logits, target_policy_logits, actions, discounts, rewards, values, bootstrap_value, clip_rho_threshold=1.0, clip_pg_rho_threshold=1.0, name="vt...
python
def from_logits(behaviour_policy_logits, target_policy_logits, actions, discounts, rewards, values, bootstrap_value, clip_rho_threshold=1.0, clip_pg_rho_threshold=1.0, name="vt...
[ "def", "from_logits", "(", "behaviour_policy_logits", ",", "target_policy_logits", ",", "actions", ",", "discounts", ",", "rewards", ",", "values", ",", "bootstrap_value", ",", "clip_rho_threshold", "=", "1.0", ",", "clip_pg_rho_threshold", "=", "1.0", ",", "name", ...
multi_from_logits wrapper used only for tests
[ "multi_from_logits", "wrapper", "used", "only", "for", "tests" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/impala/vtrace.py#L94-L124
train
ray-project/ray
python/ray/rllib/agents/impala/vtrace.py
multi_from_logits
def multi_from_logits(behaviour_policy_logits, target_policy_logits, actions, discounts, rewards, values, bootstrap_value, clip_rho_threshold=1.0, ...
python
def multi_from_logits(behaviour_policy_logits, target_policy_logits, actions, discounts, rewards, values, bootstrap_value, clip_rho_threshold=1.0, ...
[ "def", "multi_from_logits", "(", "behaviour_policy_logits", ",", "target_policy_logits", ",", "actions", ",", "discounts", ",", "rewards", ",", "values", ",", "bootstrap_value", ",", "clip_rho_threshold", "=", "1.0", ",", "clip_pg_rho_threshold", "=", "1.0", ",", "n...
r"""V-trace for softmax policies. Calculates V-trace actor critic targets for softmax polices as described in "IMPALA: Scalable Distributed Deep-RL with Importance Weighted Actor-Learner Architectures" by Espeholt, Soyer, Munos et al. Target policy refers to the policy we are interested in improving and ...
[ "r", "V", "-", "trace", "for", "softmax", "policies", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/impala/vtrace.py#L127-L244
train
ray-project/ray
python/ray/rllib/agents/impala/vtrace.py
from_importance_weights
def from_importance_weights(log_rhos, discounts, rewards, values, bootstrap_value, clip_rho_threshold=1.0, clip_pg_rho_threshold=1.0, ...
python
def from_importance_weights(log_rhos, discounts, rewards, values, bootstrap_value, clip_rho_threshold=1.0, clip_pg_rho_threshold=1.0, ...
[ "def", "from_importance_weights", "(", "log_rhos", ",", "discounts", ",", "rewards", ",", "values", ",", "bootstrap_value", ",", "clip_rho_threshold", "=", "1.0", ",", "clip_pg_rho_threshold", "=", "1.0", ",", "name", "=", "\"vtrace_from_importance_weights\"", ")", ...
r"""V-trace from log importance weights. Calculates V-trace actor critic targets as described in "IMPALA: Scalable Distributed Deep-RL with Importance Weighted Actor-Learner Architectures" by Espeholt, Soyer, Munos et al. In the notation used throughout documentation and comments, T refers to the time di...
[ "r", "V", "-", "trace", "from", "log", "importance", "weights", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/impala/vtrace.py#L247-L386
train
ray-project/ray
python/ray/rllib/agents/impala/vtrace.py
get_log_rhos
def get_log_rhos(target_action_log_probs, behaviour_action_log_probs): """With the selected log_probs for multi-discrete actions of behaviour and target policies we compute the log_rhos for calculating the vtrace.""" t = tf.stack(target_action_log_probs) b = tf.stack(behaviour_action_log_probs) log_...
python
def get_log_rhos(target_action_log_probs, behaviour_action_log_probs): """With the selected log_probs for multi-discrete actions of behaviour and target policies we compute the log_rhos for calculating the vtrace.""" t = tf.stack(target_action_log_probs) b = tf.stack(behaviour_action_log_probs) log_...
[ "def", "get_log_rhos", "(", "target_action_log_probs", ",", "behaviour_action_log_probs", ")", ":", "t", "=", "tf", ".", "stack", "(", "target_action_log_probs", ")", "b", "=", "tf", ".", "stack", "(", "behaviour_action_log_probs", ")", "log_rhos", "=", "tf", "....
With the selected log_probs for multi-discrete actions of behaviour and target policies we compute the log_rhos for calculating the vtrace.
[ "With", "the", "selected", "log_probs", "for", "multi", "-", "discrete", "actions", "of", "behaviour", "and", "target", "policies", "we", "compute", "the", "log_rhos", "for", "calculating", "the", "vtrace", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/impala/vtrace.py#L389-L395
train
ray-project/ray
python/ray/tune/examples/tune_mnist_async_hyperband.py
weight_variable
def weight_variable(shape): """weight_variable generates a weight variable of a given shape.""" initial = tf.truncated_normal(shape, stddev=0.1) return tf.Variable(initial)
python
def weight_variable(shape): """weight_variable generates a weight variable of a given shape.""" initial = tf.truncated_normal(shape, stddev=0.1) return tf.Variable(initial)
[ "def", "weight_variable", "(", "shape", ")", ":", "initial", "=", "tf", ".", "truncated_normal", "(", "shape", ",", "stddev", "=", "0.1", ")", "return", "tf", ".", "Variable", "(", "initial", ")" ]
weight_variable generates a weight variable of a given shape.
[ "weight_variable", "generates", "a", "weight", "variable", "of", "a", "given", "shape", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/examples/tune_mnist_async_hyperband.py#L121-L124
train
ray-project/ray
python/ray/tune/examples/tune_mnist_async_hyperband.py
bias_variable
def bias_variable(shape): """bias_variable generates a bias variable of a given shape.""" initial = tf.constant(0.1, shape=shape) return tf.Variable(initial)
python
def bias_variable(shape): """bias_variable generates a bias variable of a given shape.""" initial = tf.constant(0.1, shape=shape) return tf.Variable(initial)
[ "def", "bias_variable", "(", "shape", ")", ":", "initial", "=", "tf", ".", "constant", "(", "0.1", ",", "shape", "=", "shape", ")", "return", "tf", ".", "Variable", "(", "initial", ")" ]
bias_variable generates a bias variable of a given shape.
[ "bias_variable", "generates", "a", "bias", "variable", "of", "a", "given", "shape", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/examples/tune_mnist_async_hyperband.py#L127-L130
train
ray-project/ray
python/ray/tune/commands.py
print_format_output
def print_format_output(dataframe): """Prints output of given dataframe to fit into terminal. Returns: table (pd.DataFrame): Final outputted dataframe. dropped_cols (list): Columns dropped due to terminal size. empty_cols (list): Empty columns (dropped on default). """ print_df ...
python
def print_format_output(dataframe): """Prints output of given dataframe to fit into terminal. Returns: table (pd.DataFrame): Final outputted dataframe. dropped_cols (list): Columns dropped due to terminal size. empty_cols (list): Empty columns (dropped on default). """ print_df ...
[ "def", "print_format_output", "(", "dataframe", ")", ":", "print_df", "=", "pd", ".", "DataFrame", "(", ")", "dropped_cols", "=", "[", "]", "empty_cols", "=", "[", "]", "# column display priority is based on the info_keys passed in", "for", "i", ",", "col", "in", ...
Prints output of given dataframe to fit into terminal. Returns: table (pd.DataFrame): Final outputted dataframe. dropped_cols (list): Columns dropped due to terminal size. empty_cols (list): Empty columns (dropped on default).
[ "Prints", "output", "of", "given", "dataframe", "to", "fit", "into", "terminal", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/commands.py#L72-L108
train
ray-project/ray
python/ray/tune/commands.py
list_trials
def list_trials(experiment_path, sort=None, output=None, filter_op=None, info_keys=None, result_keys=None): """Lists trials in the directory subtree starting at the given path. Args: experiment_path (str): Directory where t...
python
def list_trials(experiment_path, sort=None, output=None, filter_op=None, info_keys=None, result_keys=None): """Lists trials in the directory subtree starting at the given path. Args: experiment_path (str): Directory where t...
[ "def", "list_trials", "(", "experiment_path", ",", "sort", "=", "None", ",", "output", "=", "None", ",", "filter_op", "=", "None", ",", "info_keys", "=", "None", ",", "result_keys", "=", "None", ")", ":", "_check_tabulate", "(", ")", "experiment_state", "=...
Lists trials in the directory subtree starting at the given path. Args: experiment_path (str): Directory where trials are located. Corresponds to Experiment.local_dir/Experiment.name. sort (str): Key to sort by. output (str): Name of file where output is saved. filter_op...
[ "Lists", "trials", "in", "the", "directory", "subtree", "starting", "at", "the", "given", "path", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/commands.py#L128-L208
train
ray-project/ray
python/ray/tune/commands.py
list_experiments
def list_experiments(project_path, sort=None, output=None, filter_op=None, info_keys=None): """Lists experiments in the directory subtree. Args: project_path (str): Directory where experiments are located. C...
python
def list_experiments(project_path, sort=None, output=None, filter_op=None, info_keys=None): """Lists experiments in the directory subtree. Args: project_path (str): Directory where experiments are located. C...
[ "def", "list_experiments", "(", "project_path", ",", "sort", "=", "None", ",", "output", "=", "None", ",", "filter_op", "=", "None", ",", "info_keys", "=", "None", ")", ":", "_check_tabulate", "(", ")", "base", ",", "experiment_folders", ",", "_", "=", "...
Lists experiments in the directory subtree. Args: project_path (str): Directory where experiments are located. Corresponds to Experiment.local_dir. sort (str): Key to sort by. output (str): Name of file where output is saved. filter_op (str): Filter operation in the form...
[ "Lists", "experiments", "in", "the", "directory", "subtree", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/commands.py#L211-L309
train
ray-project/ray
python/ray/tune/commands.py
add_note
def add_note(path, filename="note.txt"): """Opens a txt file at the given path where user can add and save notes. Args: path (str): Directory where note will be saved. filename (str): Name of note. Defaults to "note.txt" """ path = os.path.expanduser(path) assert os.path.isdir(path)...
python
def add_note(path, filename="note.txt"): """Opens a txt file at the given path where user can add and save notes. Args: path (str): Directory where note will be saved. filename (str): Name of note. Defaults to "note.txt" """ path = os.path.expanduser(path) assert os.path.isdir(path)...
[ "def", "add_note", "(", "path", ",", "filename", "=", "\"note.txt\"", ")", ":", "path", "=", "os", ".", "path", ".", "expanduser", "(", "path", ")", "assert", "os", ".", "path", ".", "isdir", "(", "path", ")", ",", "\"{} is not a valid directory.\"", "."...
Opens a txt file at the given path where user can add and save notes. Args: path (str): Directory where note will be saved. filename (str): Name of note. Defaults to "note.txt"
[ "Opens", "a", "txt", "file", "at", "the", "given", "path", "where", "user", "can", "add", "and", "save", "notes", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/commands.py#L312-L333
train
ray-project/ray
python/ray/tune/automlboard/frontend/query.py
query_job
def query_job(request): """Rest API to query the job info, with the given job_id. The url pattern should be like this: curl http://<server>:<port>/query_job?job_id=<job_id> The response may be: { "running_trials": 0, "start_time": "2018-07-19 20:49:40", "current_round": 1...
python
def query_job(request): """Rest API to query the job info, with the given job_id. The url pattern should be like this: curl http://<server>:<port>/query_job?job_id=<job_id> The response may be: { "running_trials": 0, "start_time": "2018-07-19 20:49:40", "current_round": 1...
[ "def", "query_job", "(", "request", ")", ":", "job_id", "=", "request", ".", "GET", ".", "get", "(", "\"job_id\"", ")", "jobs", "=", "JobRecord", ".", "objects", ".", "filter", "(", "job_id", "=", "job_id", ")", "trials", "=", "TrialRecord", ".", "obje...
Rest API to query the job info, with the given job_id. The url pattern should be like this: curl http://<server>:<port>/query_job?job_id=<job_id> The response may be: { "running_trials": 0, "start_time": "2018-07-19 20:49:40", "current_round": 1, "failed_trials": 0, ...
[ "Rest", "API", "to", "query", "the", "job", "info", "with", "the", "given", "job_id", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/query.py#L14-L71
train
ray-project/ray
python/ray/tune/automlboard/frontend/query.py
query_trial
def query_trial(request): """Rest API to query the trial info, with the given trial_id. The url pattern should be like this: curl http://<server>:<port>/query_trial?trial_id=<trial_id> The response may be: { "app_url": "None", "trial_status": "TERMINATED", "params": {'a':...
python
def query_trial(request): """Rest API to query the trial info, with the given trial_id. The url pattern should be like this: curl http://<server>:<port>/query_trial?trial_id=<trial_id> The response may be: { "app_url": "None", "trial_status": "TERMINATED", "params": {'a':...
[ "def", "query_trial", "(", "request", ")", ":", "trial_id", "=", "request", ".", "GET", ".", "get", "(", "\"trial_id\"", ")", "trials", "=", "TrialRecord", ".", "objects", ".", "filter", "(", "trial_id", "=", "trial_id", ")", ".", "order_by", "(", "\"-st...
Rest API to query the trial info, with the given trial_id. The url pattern should be like this: curl http://<server>:<port>/query_trial?trial_id=<trial_id> The response may be: { "app_url": "None", "trial_status": "TERMINATED", "params": {'a': 1, 'b': 2}, "job_id": "a...
[ "Rest", "API", "to", "query", "the", "trial", "info", "with", "the", "given", "trial_id", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/query.py#L74-L110
train
ray-project/ray
python/ray/tune/schedulers/median_stopping_rule.py
MedianStoppingRule.on_trial_result
def on_trial_result(self, trial_runner, trial, result): """Callback for early stopping. This stopping rule stops a running trial if the trial's best objective value by step `t` is strictly worse than the median of the running averages of all completed trials' objectives reported up to s...
python
def on_trial_result(self, trial_runner, trial, result): """Callback for early stopping. This stopping rule stops a running trial if the trial's best objective value by step `t` is strictly worse than the median of the running averages of all completed trials' objectives reported up to s...
[ "def", "on_trial_result", "(", "self", ",", "trial_runner", ",", "trial", ",", "result", ")", ":", "if", "trial", "in", "self", ".", "_stopped_trials", ":", "assert", "not", "self", ".", "_hard_stop", "return", "TrialScheduler", ".", "CONTINUE", "# fall back t...
Callback for early stopping. This stopping rule stops a running trial if the trial's best objective value by step `t` is strictly worse than the median of the running averages of all completed trials' objectives reported up to step `t`.
[ "Callback", "for", "early", "stopping", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/median_stopping_rule.py#L56-L85
train
ray-project/ray
python/ray/tune/schedulers/median_stopping_rule.py
MedianStoppingRule.on_trial_remove
def on_trial_remove(self, trial_runner, trial): """Marks trial as completed if it is paused and has previously ran.""" if trial.status is Trial.PAUSED and trial in self._results: self._completed_trials.add(trial)
python
def on_trial_remove(self, trial_runner, trial): """Marks trial as completed if it is paused and has previously ran.""" if trial.status is Trial.PAUSED and trial in self._results: self._completed_trials.add(trial)
[ "def", "on_trial_remove", "(", "self", ",", "trial_runner", ",", "trial", ")", ":", "if", "trial", ".", "status", "is", "Trial", ".", "PAUSED", "and", "trial", "in", "self", ".", "_results", ":", "self", ".", "_completed_trials", ".", "add", "(", "trial"...
Marks trial as completed if it is paused and has previously ran.
[ "Marks", "trial", "as", "completed", "if", "it", "is", "paused", "and", "has", "previously", "ran", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/median_stopping_rule.py#L91-L94
train
ray-project/ray
python/ray/tune/automlboard/models/models.py
JobRecord.from_json
def from_json(cls, json_info): """Build a Job instance from a json string.""" if json_info is None: return None return JobRecord( job_id=json_info["job_id"], name=json_info["job_name"], user=json_info["user"], type=json_info["type"], ...
python
def from_json(cls, json_info): """Build a Job instance from a json string.""" if json_info is None: return None return JobRecord( job_id=json_info["job_id"], name=json_info["job_name"], user=json_info["user"], type=json_info["type"], ...
[ "def", "from_json", "(", "cls", ",", "json_info", ")", ":", "if", "json_info", "is", "None", ":", "return", "None", "return", "JobRecord", "(", "job_id", "=", "json_info", "[", "\"job_id\"", "]", ",", "name", "=", "json_info", "[", "\"job_name\"", "]", "...
Build a Job instance from a json string.
[ "Build", "a", "Job", "instance", "from", "a", "json", "string", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/models/models.py#L20-L29
train
ray-project/ray
python/ray/tune/automlboard/models/models.py
TrialRecord.from_json
def from_json(cls, json_info): """Build a Trial instance from a json string.""" if json_info is None: return None return TrialRecord( trial_id=json_info["trial_id"], job_id=json_info["job_id"], trial_status=json_info["status"], start_ti...
python
def from_json(cls, json_info): """Build a Trial instance from a json string.""" if json_info is None: return None return TrialRecord( trial_id=json_info["trial_id"], job_id=json_info["job_id"], trial_status=json_info["status"], start_ti...
[ "def", "from_json", "(", "cls", ",", "json_info", ")", ":", "if", "json_info", "is", "None", ":", "return", "None", "return", "TrialRecord", "(", "trial_id", "=", "json_info", "[", "\"trial_id\"", "]", ",", "job_id", "=", "json_info", "[", "\"job_id\"", "]...
Build a Trial instance from a json string.
[ "Build", "a", "Trial", "instance", "from", "a", "json", "string", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/models/models.py#L48-L57
train
ray-project/ray
python/ray/tune/automlboard/models/models.py
ResultRecord.from_json
def from_json(cls, json_info): """Build a Result instance from a json string.""" if json_info is None: return None return ResultRecord( trial_id=json_info["trial_id"], timesteps_total=json_info["timesteps_total"], done=json_info.get("done", None), ...
python
def from_json(cls, json_info): """Build a Result instance from a json string.""" if json_info is None: return None return ResultRecord( trial_id=json_info["trial_id"], timesteps_total=json_info["timesteps_total"], done=json_info.get("done", None), ...
[ "def", "from_json", "(", "cls", ",", "json_info", ")", ":", "if", "json_info", "is", "None", ":", "return", "None", "return", "ResultRecord", "(", "trial_id", "=", "json_info", "[", "\"trial_id\"", "]", ",", "timesteps_total", "=", "json_info", "[", "\"times...
Build a Result instance from a json string.
[ "Build", "a", "Result", "instance", "from", "a", "json", "string", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/models/models.py#L80-L98
train
ray-project/ray
python/ray/rllib/evaluation/postprocessing.py
compute_advantages
def compute_advantages(rollout, last_r, gamma=0.9, lambda_=1.0, use_gae=True): """Given a rollout, compute its value targets and the advantage. Args: rollout (SampleBatch): SampleBatch of a single trajectory last_r (float): Value estimation for last observation gamma (float): Discount f...
python
def compute_advantages(rollout, last_r, gamma=0.9, lambda_=1.0, use_gae=True): """Given a rollout, compute its value targets and the advantage. Args: rollout (SampleBatch): SampleBatch of a single trajectory last_r (float): Value estimation for last observation gamma (float): Discount f...
[ "def", "compute_advantages", "(", "rollout", ",", "last_r", ",", "gamma", "=", "0.9", ",", "lambda_", "=", "1.0", ",", "use_gae", "=", "True", ")", ":", "traj", "=", "{", "}", "trajsize", "=", "len", "(", "rollout", "[", "SampleBatch", ".", "ACTIONS", ...
Given a rollout, compute its value targets and the advantage. Args: rollout (SampleBatch): SampleBatch of a single trajectory last_r (float): Value estimation for last observation gamma (float): Discount factor. lambda_ (float): Parameter for GAE use_gae (bool): Using Genera...
[ "Given", "a", "rollout", "compute", "its", "value", "targets", "and", "the", "advantage", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/evaluation/postprocessing.py#L23-L70
train
ray-project/ray
python/ray/monitor.py
Monitor.xray_heartbeat_batch_handler
def xray_heartbeat_batch_handler(self, unused_channel, data): """Handle an xray heartbeat batch message from Redis.""" gcs_entries = ray.gcs_utils.GcsTableEntry.GetRootAsGcsTableEntry( data, 0) heartbeat_data = gcs_entries.Entries(0) message = (ray.gcs_utils.HeartbeatBatchT...
python
def xray_heartbeat_batch_handler(self, unused_channel, data): """Handle an xray heartbeat batch message from Redis.""" gcs_entries = ray.gcs_utils.GcsTableEntry.GetRootAsGcsTableEntry( data, 0) heartbeat_data = gcs_entries.Entries(0) message = (ray.gcs_utils.HeartbeatBatchT...
[ "def", "xray_heartbeat_batch_handler", "(", "self", ",", "unused_channel", ",", "data", ")", ":", "gcs_entries", "=", "ray", ".", "gcs_utils", ".", "GcsTableEntry", ".", "GetRootAsGcsTableEntry", "(", "data", ",", "0", ")", "heartbeat_data", "=", "gcs_entries", ...
Handle an xray heartbeat batch message from Redis.
[ "Handle", "an", "xray", "heartbeat", "batch", "message", "from", "Redis", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/monitor.py#L102-L135
train
ray-project/ray
python/ray/monitor.py
Monitor._xray_clean_up_entries_for_driver
def _xray_clean_up_entries_for_driver(self, driver_id): """Remove this driver's object/task entries from redis. Removes control-state entries of all tasks and task return objects belonging to the driver. Args: driver_id: The driver id. """ xray_task_table_p...
python
def _xray_clean_up_entries_for_driver(self, driver_id): """Remove this driver's object/task entries from redis. Removes control-state entries of all tasks and task return objects belonging to the driver. Args: driver_id: The driver id. """ xray_task_table_p...
[ "def", "_xray_clean_up_entries_for_driver", "(", "self", ",", "driver_id", ")", ":", "xray_task_table_prefix", "=", "(", "ray", ".", "gcs_utils", ".", "TablePrefix_RAYLET_TASK_string", ".", "encode", "(", "\"ascii\"", ")", ")", "xray_object_table_prefix", "=", "(", ...
Remove this driver's object/task entries from redis. Removes control-state entries of all tasks and task return objects belonging to the driver. Args: driver_id: The driver id.
[ "Remove", "this", "driver", "s", "object", "/", "task", "entries", "from", "redis", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/monitor.py#L137-L199
train
ray-project/ray
python/ray/monitor.py
Monitor.xray_driver_removed_handler
def xray_driver_removed_handler(self, unused_channel, data): """Handle a notification that a driver has been removed. Args: unused_channel: The message channel. data: The message data. """ gcs_entries = ray.gcs_utils.GcsTableEntry.GetRootAsGcsTableEntry( ...
python
def xray_driver_removed_handler(self, unused_channel, data): """Handle a notification that a driver has been removed. Args: unused_channel: The message channel. data: The message data. """ gcs_entries = ray.gcs_utils.GcsTableEntry.GetRootAsGcsTableEntry( ...
[ "def", "xray_driver_removed_handler", "(", "self", ",", "unused_channel", ",", "data", ")", ":", "gcs_entries", "=", "ray", ".", "gcs_utils", ".", "GcsTableEntry", ".", "GetRootAsGcsTableEntry", "(", "data", ",", "0", ")", "driver_data", "=", "gcs_entries", ".",...
Handle a notification that a driver has been removed. Args: unused_channel: The message channel. data: The message data.
[ "Handle", "a", "notification", "that", "a", "driver", "has", "been", "removed", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/monitor.py#L201-L217
train
ray-project/ray
python/ray/monitor.py
Monitor.process_messages
def process_messages(self, max_messages=10000): """Process all messages ready in the subscription channels. This reads messages from the subscription channels and calls the appropriate handlers until there are no messages left. Args: max_messages: The maximum number of mess...
python
def process_messages(self, max_messages=10000): """Process all messages ready in the subscription channels. This reads messages from the subscription channels and calls the appropriate handlers until there are no messages left. Args: max_messages: The maximum number of mess...
[ "def", "process_messages", "(", "self", ",", "max_messages", "=", "10000", ")", ":", "subscribe_clients", "=", "[", "self", ".", "primary_subscribe_client", "]", "for", "subscribe_client", "in", "subscribe_clients", ":", "for", "_", "in", "range", "(", "max_mess...
Process all messages ready in the subscription channels. This reads messages from the subscription channels and calls the appropriate handlers until there are no messages left. Args: max_messages: The maximum number of messages to process before returning.
[ "Process", "all", "messages", "ready", "in", "the", "subscription", "channels", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/monitor.py#L219-L252
train
ray-project/ray
python/ray/monitor.py
Monitor._maybe_flush_gcs
def _maybe_flush_gcs(self): """Experimental: issue a flush request to the GCS. The purpose of this feature is to control GCS memory usage. To activate this feature, Ray must be compiled with the flag RAY_USE_NEW_GCS set, and Ray must be started at run time with the flag as well...
python
def _maybe_flush_gcs(self): """Experimental: issue a flush request to the GCS. The purpose of this feature is to control GCS memory usage. To activate this feature, Ray must be compiled with the flag RAY_USE_NEW_GCS set, and Ray must be started at run time with the flag as well...
[ "def", "_maybe_flush_gcs", "(", "self", ")", ":", "if", "not", "self", ".", "issue_gcs_flushes", ":", "return", "if", "self", ".", "gcs_flush_policy", "is", "None", ":", "serialized", "=", "self", ".", "redis", ".", "get", "(", "\"gcs_flushing_policy\"", ")"...
Experimental: issue a flush request to the GCS. The purpose of this feature is to control GCS memory usage. To activate this feature, Ray must be compiled with the flag RAY_USE_NEW_GCS set, and Ray must be started at run time with the flag as well.
[ "Experimental", ":", "issue", "a", "flush", "request", "to", "the", "GCS", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/monitor.py#L264-L293
train
ray-project/ray
python/ray/monitor.py
Monitor.run
def run(self): """Run the monitor. This function loops forever, checking for messages about dead database clients and cleaning up state accordingly. """ # Initialize the subscription channel. self.subscribe(ray.gcs_utils.XRAY_HEARTBEAT_BATCH_CHANNEL) self.subscri...
python
def run(self): """Run the monitor. This function loops forever, checking for messages about dead database clients and cleaning up state accordingly. """ # Initialize the subscription channel. self.subscribe(ray.gcs_utils.XRAY_HEARTBEAT_BATCH_CHANNEL) self.subscri...
[ "def", "run", "(", "self", ")", ":", "# Initialize the subscription channel.", "self", ".", "subscribe", "(", "ray", ".", "gcs_utils", ".", "XRAY_HEARTBEAT_BATCH_CHANNEL", ")", "self", ".", "subscribe", "(", "ray", ".", "gcs_utils", ".", "XRAY_DRIVER_CHANNEL", ")"...
Run the monitor. This function loops forever, checking for messages about dead database clients and cleaning up state accordingly.
[ "Run", "the", "monitor", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/monitor.py#L295-L325
train
ray-project/ray
python/ray/tune/automlboard/frontend/view.py
index
def index(request): """View for the home page.""" recent_jobs = JobRecord.objects.order_by("-start_time")[0:100] recent_trials = TrialRecord.objects.order_by("-start_time")[0:500] total_num = len(recent_trials) running_num = sum(t.trial_status == Trial.RUNNING for t in recent_trials) success_nu...
python
def index(request): """View for the home page.""" recent_jobs = JobRecord.objects.order_by("-start_time")[0:100] recent_trials = TrialRecord.objects.order_by("-start_time")[0:500] total_num = len(recent_trials) running_num = sum(t.trial_status == Trial.RUNNING for t in recent_trials) success_nu...
[ "def", "index", "(", "request", ")", ":", "recent_jobs", "=", "JobRecord", ".", "objects", ".", "order_by", "(", "\"-start_time\"", ")", "[", "0", ":", "100", "]", "recent_trials", "=", "TrialRecord", ".", "objects", ".", "order_by", "(", "\"-start_time\"", ...
View for the home page.
[ "View", "for", "the", "home", "page", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/view.py#L17-L41
train
ray-project/ray
python/ray/tune/automlboard/frontend/view.py
job
def job(request): """View for a single job.""" job_id = request.GET.get("job_id") recent_jobs = JobRecord.objects.order_by("-start_time")[0:100] recent_trials = TrialRecord.objects \ .filter(job_id=job_id) \ .order_by("-start_time") trial_records = [] for recent_trial in recent_t...
python
def job(request): """View for a single job.""" job_id = request.GET.get("job_id") recent_jobs = JobRecord.objects.order_by("-start_time")[0:100] recent_trials = TrialRecord.objects \ .filter(job_id=job_id) \ .order_by("-start_time") trial_records = [] for recent_trial in recent_t...
[ "def", "job", "(", "request", ")", ":", "job_id", "=", "request", ".", "GET", ".", "get", "(", "\"job_id\"", ")", "recent_jobs", "=", "JobRecord", ".", "objects", ".", "order_by", "(", "\"-start_time\"", ")", "[", "0", ":", "100", "]", "recent_trials", ...
View for a single job.
[ "View", "for", "a", "single", "job", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/view.py#L44-L74
train
ray-project/ray
python/ray/tune/automlboard/frontend/view.py
trial
def trial(request): """View for a single trial.""" job_id = request.GET.get("job_id") trial_id = request.GET.get("trial_id") recent_trials = TrialRecord.objects \ .filter(job_id=job_id) \ .order_by("-start_time") recent_results = ResultRecord.objects \ .filter(trial_id=trial_...
python
def trial(request): """View for a single trial.""" job_id = request.GET.get("job_id") trial_id = request.GET.get("trial_id") recent_trials = TrialRecord.objects \ .filter(job_id=job_id) \ .order_by("-start_time") recent_results = ResultRecord.objects \ .filter(trial_id=trial_...
[ "def", "trial", "(", "request", ")", ":", "job_id", "=", "request", ".", "GET", ".", "get", "(", "\"job_id\"", ")", "trial_id", "=", "request", ".", "GET", ".", "get", "(", "\"trial_id\"", ")", "recent_trials", "=", "TrialRecord", ".", "objects", ".", ...
View for a single trial.
[ "View", "for", "a", "single", "trial", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/view.py#L77-L97
train
ray-project/ray
python/ray/tune/automlboard/frontend/view.py
get_job_info
def get_job_info(current_job): """Get job information for current job.""" trials = TrialRecord.objects.filter(job_id=current_job.job_id) total_num = len(trials) running_num = sum(t.trial_status == Trial.RUNNING for t in trials) success_num = sum(t.trial_status == Trial.TERMINATED for t in trials) ...
python
def get_job_info(current_job): """Get job information for current job.""" trials = TrialRecord.objects.filter(job_id=current_job.job_id) total_num = len(trials) running_num = sum(t.trial_status == Trial.RUNNING for t in trials) success_num = sum(t.trial_status == Trial.TERMINATED for t in trials) ...
[ "def", "get_job_info", "(", "current_job", ")", ":", "trials", "=", "TrialRecord", ".", "objects", ".", "filter", "(", "job_id", "=", "current_job", ".", "job_id", ")", "total_num", "=", "len", "(", "trials", ")", "running_num", "=", "sum", "(", "t", "."...
Get job information for current job.
[ "Get", "job", "information", "for", "current", "job", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/view.py#L100-L131
train
ray-project/ray
python/ray/tune/automlboard/frontend/view.py
get_trial_info
def get_trial_info(current_trial): """Get job information for current trial.""" if current_trial.end_time and ("_" in current_trial.end_time): # end time is parsed from result.json and the format # is like: yyyy-mm-dd_hh-MM-ss, which will be converted # to yyyy-mm-dd hh:MM:ss here ...
python
def get_trial_info(current_trial): """Get job information for current trial.""" if current_trial.end_time and ("_" in current_trial.end_time): # end time is parsed from result.json and the format # is like: yyyy-mm-dd_hh-MM-ss, which will be converted # to yyyy-mm-dd hh:MM:ss here ...
[ "def", "get_trial_info", "(", "current_trial", ")", ":", "if", "current_trial", ".", "end_time", "and", "(", "\"_\"", "in", "current_trial", ".", "end_time", ")", ":", "# end time is parsed from result.json and the format", "# is like: yyyy-mm-dd_hh-MM-ss, which will be conve...
Get job information for current trial.
[ "Get", "job", "information", "for", "current", "trial", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/view.py#L134-L161
train
ray-project/ray
python/ray/tune/automlboard/frontend/view.py
get_winner
def get_winner(trials): """Get winner trial of a job.""" winner = {} # TODO: sort_key should be customized here sort_key = "accuracy" if trials and len(trials) > 0: first_metrics = get_trial_info(trials[0])["metrics"] if first_metrics and not first_metrics.get("accuracy", None): ...
python
def get_winner(trials): """Get winner trial of a job.""" winner = {} # TODO: sort_key should be customized here sort_key = "accuracy" if trials and len(trials) > 0: first_metrics = get_trial_info(trials[0])["metrics"] if first_metrics and not first_metrics.get("accuracy", None): ...
[ "def", "get_winner", "(", "trials", ")", ":", "winner", "=", "{", "}", "# TODO: sort_key should be customized here", "sort_key", "=", "\"accuracy\"", "if", "trials", "and", "len", "(", "trials", ")", ">", "0", ":", "first_metrics", "=", "get_trial_info", "(", ...
Get winner trial of a job.
[ "Get", "winner", "trial", "of", "a", "job", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/view.py#L164-L182
train
ray-project/ray
python/ray/tune/config_parser.py
make_parser
def make_parser(parser_creator=None, **kwargs): """Returns a base argument parser for the ray.tune tool. Args: parser_creator: A constructor for the parser class. kwargs: Non-positional args to be passed into the parser class constructor. """ if parser_creator: pars...
python
def make_parser(parser_creator=None, **kwargs): """Returns a base argument parser for the ray.tune tool. Args: parser_creator: A constructor for the parser class. kwargs: Non-positional args to be passed into the parser class constructor. """ if parser_creator: pars...
[ "def", "make_parser", "(", "parser_creator", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "parser_creator", ":", "parser", "=", "parser_creator", "(", "*", "*", "kwargs", ")", "else", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "...
Returns a base argument parser for the ray.tune tool. Args: parser_creator: A constructor for the parser class. kwargs: Non-positional args to be passed into the parser class constructor.
[ "Returns", "a", "base", "argument", "parser", "for", "the", "ray", ".", "tune", "tool", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/config_parser.py#L18-L151
train
ray-project/ray
python/ray/tune/config_parser.py
to_argv
def to_argv(config): """Converts configuration to a command line argument format.""" argv = [] for k, v in config.items(): if "-" in k: raise ValueError("Use '_' instead of '-' in `{}`".format(k)) if v is None: continue if not isinstance(v, bool) or v: # for ...
python
def to_argv(config): """Converts configuration to a command line argument format.""" argv = [] for k, v in config.items(): if "-" in k: raise ValueError("Use '_' instead of '-' in `{}`".format(k)) if v is None: continue if not isinstance(v, bool) or v: # for ...
[ "def", "to_argv", "(", "config", ")", ":", "argv", "=", "[", "]", "for", "k", ",", "v", "in", "config", ".", "items", "(", ")", ":", "if", "\"-\"", "in", "k", ":", "raise", "ValueError", "(", "\"Use '_' instead of '-' in `{}`\"", ".", "format", "(", ...
Converts configuration to a command line argument format.
[ "Converts", "configuration", "to", "a", "command", "line", "argument", "format", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/config_parser.py#L154-L170
train
ray-project/ray
python/ray/tune/config_parser.py
create_trial_from_spec
def create_trial_from_spec(spec, output_path, parser, **trial_kwargs): """Creates a Trial object from parsing the spec. Arguments: spec (dict): A resolved experiment specification. Arguments should The args here should correspond to the command line flags in ray.tune.config_pars...
python
def create_trial_from_spec(spec, output_path, parser, **trial_kwargs): """Creates a Trial object from parsing the spec. Arguments: spec (dict): A resolved experiment specification. Arguments should The args here should correspond to the command line flags in ray.tune.config_pars...
[ "def", "create_trial_from_spec", "(", "spec", ",", "output_path", ",", "parser", ",", "*", "*", "trial_kwargs", ")", ":", "try", ":", "args", "=", "parser", ".", "parse_args", "(", "to_argv", "(", "spec", ")", ")", "except", "SystemExit", ":", "raise", "...
Creates a Trial object from parsing the spec. Arguments: spec (dict): A resolved experiment specification. Arguments should The args here should correspond to the command line flags in ray.tune.config_parser. output_path (str); A specific output path within the local_dir. ...
[ "Creates", "a", "Trial", "object", "from", "parsing", "the", "spec", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/config_parser.py#L173-L218
train
ray-project/ray
python/ray/autoscaler/gcp/node_provider.py
wait_for_compute_zone_operation
def wait_for_compute_zone_operation(compute, project_name, operation, zone): """Poll for compute zone operation until finished.""" logger.info("wait_for_compute_zone_operation: " "Waiting for operation {} to finish...".format( operation["name"])) for _ in range(MAX_POLLS...
python
def wait_for_compute_zone_operation(compute, project_name, operation, zone): """Poll for compute zone operation until finished.""" logger.info("wait_for_compute_zone_operation: " "Waiting for operation {} to finish...".format( operation["name"])) for _ in range(MAX_POLLS...
[ "def", "wait_for_compute_zone_operation", "(", "compute", ",", "project_name", ",", "operation", ",", "zone", ")", ":", "logger", ".", "info", "(", "\"wait_for_compute_zone_operation: \"", "\"Waiting for operation {} to finish...\"", ".", "format", "(", "operation", "[", ...
Poll for compute zone operation until finished.
[ "Poll", "for", "compute", "zone", "operation", "until", "finished", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/node_provider.py#L22-L42
train
ray-project/ray
python/ray/experimental/signal.py
_get_task_id
def _get_task_id(source): """Return the task id associated to the generic source of the signal. Args: source: source of the signal, it can be either an object id returned by a task, a task id, or an actor handle. Returns: - If source is an object id, return id of task which cre...
python
def _get_task_id(source): """Return the task id associated to the generic source of the signal. Args: source: source of the signal, it can be either an object id returned by a task, a task id, or an actor handle. Returns: - If source is an object id, return id of task which cre...
[ "def", "_get_task_id", "(", "source", ")", ":", "if", "type", "(", "source", ")", "is", "ray", ".", "actor", ".", "ActorHandle", ":", "return", "source", ".", "_ray_actor_id", "else", ":", "if", "type", "(", "source", ")", "is", "ray", ".", "TaskID", ...
Return the task id associated to the generic source of the signal. Args: source: source of the signal, it can be either an object id returned by a task, a task id, or an actor handle. Returns: - If source is an object id, return id of task which creted object. - If source i...
[ "Return", "the", "task", "id", "associated", "to", "the", "generic", "source", "of", "the", "signal", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/signal.py#L36-L54
train
ray-project/ray
python/ray/experimental/signal.py
send
def send(signal): """Send signal. The signal has a unique identifier that is computed from (1) the id of the actor or task sending this signal (i.e., the actor or task calling this function), and (2) an index that is incremented every time this source sends a signal. This index starts from 1. ...
python
def send(signal): """Send signal. The signal has a unique identifier that is computed from (1) the id of the actor or task sending this signal (i.e., the actor or task calling this function), and (2) an index that is incremented every time this source sends a signal. This index starts from 1. ...
[ "def", "send", "(", "signal", ")", ":", "if", "hasattr", "(", "ray", ".", "worker", ".", "global_worker", ",", "\"actor_creation_task_id\"", ")", ":", "source_key", "=", "ray", ".", "worker", ".", "global_worker", ".", "actor_id", ".", "hex", "(", ")", "...
Send signal. The signal has a unique identifier that is computed from (1) the id of the actor or task sending this signal (i.e., the actor or task calling this function), and (2) an index that is incremented every time this source sends a signal. This index starts from 1. Args: signal: Sig...
[ "Send", "signal", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/signal.py#L57-L76
train
ray-project/ray
python/ray/experimental/signal.py
receive
def receive(sources, timeout=None): """Get all outstanding signals from sources. A source can be either (1) an object ID returned by the task (we want to receive signals from), or (2) an actor handle. When invoked by the same entity E (where E can be an actor, task or driver), for each source S in...
python
def receive(sources, timeout=None): """Get all outstanding signals from sources. A source can be either (1) an object ID returned by the task (we want to receive signals from), or (2) an actor handle. When invoked by the same entity E (where E can be an actor, task or driver), for each source S in...
[ "def", "receive", "(", "sources", ",", "timeout", "=", "None", ")", ":", "# If None, initialize the timeout to a huge value (i.e., over 30,000 years", "# in this case) to \"approximate\" infinity.", "if", "timeout", "is", "None", ":", "timeout", "=", "10", "**", "12", "if...
Get all outstanding signals from sources. A source can be either (1) an object ID returned by the task (we want to receive signals from), or (2) an actor handle. When invoked by the same entity E (where E can be an actor, task or driver), for each source S in sources, this function returns all signals...
[ "Get", "all", "outstanding", "signals", "from", "sources", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/signal.py#L79-L166
train
ray-project/ray
python/ray/experimental/signal.py
reset
def reset(): """ Reset the worker state associated with any signals that this worker has received so far. If the worker calls receive() on a source next, it will get all the signals generated by that source starting with index = 1. """ if hasattr(ray.worker.global_worker, "signal_counters")...
python
def reset(): """ Reset the worker state associated with any signals that this worker has received so far. If the worker calls receive() on a source next, it will get all the signals generated by that source starting with index = 1. """ if hasattr(ray.worker.global_worker, "signal_counters")...
[ "def", "reset", "(", ")", ":", "if", "hasattr", "(", "ray", ".", "worker", ".", "global_worker", ",", "\"signal_counters\"", ")", ":", "ray", ".", "worker", ".", "global_worker", ".", "signal_counters", "=", "defaultdict", "(", "lambda", ":", "b\"0\"", ")"...
Reset the worker state associated with any signals that this worker has received so far. If the worker calls receive() on a source next, it will get all the signals generated by that source starting with index = 1.
[ "Reset", "the", "worker", "state", "associated", "with", "any", "signals", "that", "this", "worker", "has", "received", "so", "far", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/signal.py#L184-L193
train
ray-project/ray
python/ray/rllib/utils/debug.py
log_once
def log_once(key): """Returns True if this is the "first" call for a given key. Various logging settings can adjust the definition of "first". Example: >>> if log_once("some_key"): ... logger.info("Some verbose logging statement") """ global _last_logged if _disabled: ...
python
def log_once(key): """Returns True if this is the "first" call for a given key. Various logging settings can adjust the definition of "first". Example: >>> if log_once("some_key"): ... logger.info("Some verbose logging statement") """ global _last_logged if _disabled: ...
[ "def", "log_once", "(", "key", ")", ":", "global", "_last_logged", "if", "_disabled", ":", "return", "False", "elif", "key", "not", "in", "_logged", ":", "_logged", ".", "add", "(", "key", ")", "_last_logged", "=", "time", ".", "time", "(", ")", "retur...
Returns True if this is the "first" call for a given key. Various logging settings can adjust the definition of "first". Example: >>> if log_once("some_key"): ... logger.info("Some verbose logging statement")
[ "Returns", "True", "if", "this", "is", "the", "first", "call", "for", "a", "given", "key", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/debug.py#L18-L41
train
ray-project/ray
python/ray/experimental/api.py
get
def get(object_ids): """Get a single or a collection of remote objects from the object store. This method is identical to `ray.get` except it adds support for tuples, ndarrays and dictionaries. Args: object_ids: Object ID of the object to get, a list, tuple, ndarray of object IDs t...
python
def get(object_ids): """Get a single or a collection of remote objects from the object store. This method is identical to `ray.get` except it adds support for tuples, ndarrays and dictionaries. Args: object_ids: Object ID of the object to get, a list, tuple, ndarray of object IDs t...
[ "def", "get", "(", "object_ids", ")", ":", "if", "isinstance", "(", "object_ids", ",", "(", "tuple", ",", "np", ".", "ndarray", ")", ")", ":", "return", "ray", ".", "get", "(", "list", "(", "object_ids", ")", ")", "elif", "isinstance", "(", "object_i...
Get a single or a collection of remote objects from the object store. This method is identical to `ray.get` except it adds support for tuples, ndarrays and dictionaries. Args: object_ids: Object ID of the object to get, a list, tuple, ndarray of object IDs to get or a dict of {key: obj...
[ "Get", "a", "single", "or", "a", "collection", "of", "remote", "objects", "from", "the", "object", "store", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/api.py#L9-L38
train
ray-project/ray
python/ray/experimental/api.py
wait
def wait(object_ids, num_returns=1, timeout=None): """Return a list of IDs that are ready and a list of IDs that are not. This method is identical to `ray.wait` except it adds support for tuples and ndarrays. Args: object_ids (List[ObjectID], Tuple(ObjectID), np.array(ObjectID)): L...
python
def wait(object_ids, num_returns=1, timeout=None): """Return a list of IDs that are ready and a list of IDs that are not. This method is identical to `ray.wait` except it adds support for tuples and ndarrays. Args: object_ids (List[ObjectID], Tuple(ObjectID), np.array(ObjectID)): L...
[ "def", "wait", "(", "object_ids", ",", "num_returns", "=", "1", ",", "timeout", "=", "None", ")", ":", "if", "isinstance", "(", "object_ids", ",", "(", "tuple", ",", "np", ".", "ndarray", ")", ")", ":", "return", "ray", ".", "wait", "(", "list", "(...
Return a list of IDs that are ready and a list of IDs that are not. This method is identical to `ray.wait` except it adds support for tuples and ndarrays. Args: object_ids (List[ObjectID], Tuple(ObjectID), np.array(ObjectID)): List like of object IDs for objects that may or may not be ...
[ "Return", "a", "list", "of", "IDs", "that", "are", "ready", "and", "a", "list", "of", "IDs", "that", "are", "not", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/api.py#L41-L63
train
ray-project/ray
python/ray/tune/experiment.py
_raise_deprecation_note
def _raise_deprecation_note(deprecated, replacement, soft=False): """User notification for deprecated parameter. Arguments: deprecated (str): Deprecated parameter. replacement (str): Replacement parameter to use instead. soft (bool): Fatal if True. """ error_msg = ("`{deprecated...
python
def _raise_deprecation_note(deprecated, replacement, soft=False): """User notification for deprecated parameter. Arguments: deprecated (str): Deprecated parameter. replacement (str): Replacement parameter to use instead. soft (bool): Fatal if True. """ error_msg = ("`{deprecated...
[ "def", "_raise_deprecation_note", "(", "deprecated", ",", "replacement", ",", "soft", "=", "False", ")", ":", "error_msg", "=", "(", "\"`{deprecated}` is deprecated. Please use `{replacement}`. \"", "\"`{deprecated}` will be removed in future versions of \"", "\"Ray.\"", ".", "...
User notification for deprecated parameter. Arguments: deprecated (str): Deprecated parameter. replacement (str): Replacement parameter to use instead. soft (bool): Fatal if True.
[ "User", "notification", "for", "deprecated", "parameter", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/experiment.py#L18-L32
train
ray-project/ray
python/ray/tune/experiment.py
convert_to_experiment_list
def convert_to_experiment_list(experiments): """Produces a list of Experiment objects. Converts input from dict, single experiment, or list of experiments to list of experiments. If input is None, will return an empty list. Arguments: experiments (Experiment | list | dict): Experiments to ...
python
def convert_to_experiment_list(experiments): """Produces a list of Experiment objects. Converts input from dict, single experiment, or list of experiments to list of experiments. If input is None, will return an empty list. Arguments: experiments (Experiment | list | dict): Experiments to ...
[ "def", "convert_to_experiment_list", "(", "experiments", ")", ":", "exp_list", "=", "experiments", "# Transform list if necessary", "if", "experiments", "is", "None", ":", "exp_list", "=", "[", "]", "elif", "isinstance", "(", "experiments", ",", "Experiment", ")", ...
Produces a list of Experiment objects. Converts input from dict, single experiment, or list of experiments to list of experiments. If input is None, will return an empty list. Arguments: experiments (Experiment | list | dict): Experiments to run. Returns: List of experiments.
[ "Produces", "a", "list", "of", "Experiment", "objects", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/experiment.py#L180-L215
train
ray-project/ray
python/ray/tune/experiment.py
Experiment.from_json
def from_json(cls, name, spec): """Generates an Experiment object from JSON. Args: name (str): Name of Experiment. spec (dict): JSON configuration of experiment. """ if "run" not in spec: raise TuneError("No trainable specified!") # Special c...
python
def from_json(cls, name, spec): """Generates an Experiment object from JSON. Args: name (str): Name of Experiment. spec (dict): JSON configuration of experiment. """ if "run" not in spec: raise TuneError("No trainable specified!") # Special c...
[ "def", "from_json", "(", "cls", ",", "name", ",", "spec", ")", ":", "if", "\"run\"", "not", "in", "spec", ":", "raise", "TuneError", "(", "\"No trainable specified!\"", ")", "# Special case the `env` param for RLlib by automatically", "# moving it into the `config` sectio...
Generates an Experiment object from JSON. Args: name (str): Name of Experiment. spec (dict): JSON configuration of experiment.
[ "Generates", "an", "Experiment", "object", "from", "JSON", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/experiment.py#L118-L142
train
ray-project/ray
python/ray/tune/experiment.py
Experiment._register_if_needed
def _register_if_needed(cls, run_object): """Registers Trainable or Function at runtime. Assumes already registered if run_object is a string. Does not register lambdas because they could be part of variant generation. Also, does not inspect interface of given run_object. Argum...
python
def _register_if_needed(cls, run_object): """Registers Trainable or Function at runtime. Assumes already registered if run_object is a string. Does not register lambdas because they could be part of variant generation. Also, does not inspect interface of given run_object. Argum...
[ "def", "_register_if_needed", "(", "cls", ",", "run_object", ")", ":", "if", "isinstance", "(", "run_object", ",", "six", ".", "string_types", ")", ":", "return", "run_object", "elif", "isinstance", "(", "run_object", ",", "types", ".", "FunctionType", ")", ...
Registers Trainable or Function at runtime. Assumes already registered if run_object is a string. Does not register lambdas because they could be part of variant generation. Also, does not inspect interface of given run_object. Arguments: run_object (str|function|class): Tr...
[ "Registers", "Trainable", "or", "Function", "at", "runtime", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/experiment.py#L145-L177
train
ray-project/ray
python/ray/experimental/array/distributed/linalg.py
tsqr
def tsqr(a): """Perform a QR decomposition of a tall-skinny matrix. Args: a: A distributed matrix with shape MxN (suppose K = min(M, N)). Returns: A tuple of q (a DistArray) and r (a numpy array) satisfying the following. - If q_full = ray.get(DistArray, q).assemble...
python
def tsqr(a): """Perform a QR decomposition of a tall-skinny matrix. Args: a: A distributed matrix with shape MxN (suppose K = min(M, N)). Returns: A tuple of q (a DistArray) and r (a numpy array) satisfying the following. - If q_full = ray.get(DistArray, q).assemble...
[ "def", "tsqr", "(", "a", ")", ":", "if", "len", "(", "a", ".", "shape", ")", "!=", "2", ":", "raise", "Exception", "(", "\"tsqr requires len(a.shape) == 2, but a.shape is \"", "\"{}\"", ".", "format", "(", "a", ".", "shape", ")", ")", "if", "a", ".", "...
Perform a QR decomposition of a tall-skinny matrix. Args: a: A distributed matrix with shape MxN (suppose K = min(M, N)). Returns: A tuple of q (a DistArray) and r (a numpy array) satisfying the following. - If q_full = ray.get(DistArray, q).assemble(), then ...
[ "Perform", "a", "QR", "decomposition", "of", "a", "tall", "-", "skinny", "matrix", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/array/distributed/linalg.py#L15-L84
train
ray-project/ray
python/ray/experimental/array/distributed/linalg.py
modified_lu
def modified_lu(q): """Perform a modified LU decomposition of a matrix. This takes a matrix q with orthonormal columns, returns l, u, s such that q - s = l * u. Args: q: A two dimensional orthonormal matrix q. Returns: A tuple of a lower triangular matrix l, an upper triangular ma...
python
def modified_lu(q): """Perform a modified LU decomposition of a matrix. This takes a matrix q with orthonormal columns, returns l, u, s such that q - s = l * u. Args: q: A two dimensional orthonormal matrix q. Returns: A tuple of a lower triangular matrix l, an upper triangular ma...
[ "def", "modified_lu", "(", "q", ")", ":", "q", "=", "q", ".", "assemble", "(", ")", "m", ",", "b", "=", "q", ".", "shape", "[", "0", "]", ",", "q", ".", "shape", "[", "1", "]", "S", "=", "np", ".", "zeros", "(", "b", ")", "q_work", "=", ...
Perform a modified LU decomposition of a matrix. This takes a matrix q with orthonormal columns, returns l, u, s such that q - s = l * u. Args: q: A two dimensional orthonormal matrix q. Returns: A tuple of a lower triangular matrix l, an upper triangular matrix u, and a a...
[ "Perform", "a", "modified", "LU", "decomposition", "of", "a", "matrix", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/array/distributed/linalg.py#L91-L125
train
ray-project/ray
python/ray/tune/trial_runner.py
_naturalize
def _naturalize(string): """Provides a natural representation for string for nice sorting.""" splits = re.split("([0-9]+)", string) return [int(text) if text.isdigit() else text.lower() for text in splits]
python
def _naturalize(string): """Provides a natural representation for string for nice sorting.""" splits = re.split("([0-9]+)", string) return [int(text) if text.isdigit() else text.lower() for text in splits]
[ "def", "_naturalize", "(", "string", ")", ":", "splits", "=", "re", ".", "split", "(", "\"([0-9]+)\"", ",", "string", ")", "return", "[", "int", "(", "text", ")", "if", "text", ".", "isdigit", "(", ")", "else", "text", ".", "lower", "(", ")", "for"...
Provides a natural representation for string for nice sorting.
[ "Provides", "a", "natural", "representation", "for", "string", "for", "nice", "sorting", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L30-L33
train
ray-project/ray
python/ray/tune/trial_runner.py
_find_newest_ckpt
def _find_newest_ckpt(ckpt_dir): """Returns path to most recently modified checkpoint.""" full_paths = [ os.path.join(ckpt_dir, fname) for fname in os.listdir(ckpt_dir) if fname.startswith("experiment_state") and fname.endswith(".json") ] return max(full_paths)
python
def _find_newest_ckpt(ckpt_dir): """Returns path to most recently modified checkpoint.""" full_paths = [ os.path.join(ckpt_dir, fname) for fname in os.listdir(ckpt_dir) if fname.startswith("experiment_state") and fname.endswith(".json") ] return max(full_paths)
[ "def", "_find_newest_ckpt", "(", "ckpt_dir", ")", ":", "full_paths", "=", "[", "os", ".", "path", ".", "join", "(", "ckpt_dir", ",", "fname", ")", "for", "fname", "in", "os", ".", "listdir", "(", "ckpt_dir", ")", "if", "fname", ".", "startswith", "(", ...
Returns path to most recently modified checkpoint.
[ "Returns", "path", "to", "most", "recently", "modified", "checkpoint", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L36-L42
train
ray-project/ray
python/ray/tune/trial_runner.py
TrialRunner.checkpoint
def checkpoint(self): """Saves execution state to `self._metadata_checkpoint_dir`. Overwrites the current session checkpoint, which starts when self is instantiated. """ if not self._metadata_checkpoint_dir: return metadata_checkpoint_dir = self._metadata_che...
python
def checkpoint(self): """Saves execution state to `self._metadata_checkpoint_dir`. Overwrites the current session checkpoint, which starts when self is instantiated. """ if not self._metadata_checkpoint_dir: return metadata_checkpoint_dir = self._metadata_che...
[ "def", "checkpoint", "(", "self", ")", ":", "if", "not", "self", ".", "_metadata_checkpoint_dir", ":", "return", "metadata_checkpoint_dir", "=", "self", ".", "_metadata_checkpoint_dir", "if", "not", "os", ".", "path", ".", "exists", "(", "metadata_checkpoint_dir",...
Saves execution state to `self._metadata_checkpoint_dir`. Overwrites the current session checkpoint, which starts when self is instantiated.
[ "Saves", "execution", "state", "to", "self", ".", "_metadata_checkpoint_dir", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L167-L193
train
ray-project/ray
python/ray/tune/trial_runner.py
TrialRunner.restore
def restore(cls, metadata_checkpoint_dir, search_alg=None, scheduler=None, trial_executor=None): """Restores all checkpointed trials from previous run. Requires user to manually re-register their objects. Also stops all ongoing tri...
python
def restore(cls, metadata_checkpoint_dir, search_alg=None, scheduler=None, trial_executor=None): """Restores all checkpointed trials from previous run. Requires user to manually re-register their objects. Also stops all ongoing tri...
[ "def", "restore", "(", "cls", ",", "metadata_checkpoint_dir", ",", "search_alg", "=", "None", ",", "scheduler", "=", "None", ",", "trial_executor", "=", "None", ")", ":", "newest_ckpt_path", "=", "_find_newest_ckpt", "(", "metadata_checkpoint_dir", ")", "with", ...
Restores all checkpointed trials from previous run. Requires user to manually re-register their objects. Also stops all ongoing trials. Args: metadata_checkpoint_dir (str): Path to metadata checkpoints. search_alg (SearchAlgorithm): Search Algorithm. Defaults to ...
[ "Restores", "all", "checkpointed", "trials", "from", "previous", "run", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L196-L245
train
ray-project/ray
python/ray/tune/trial_runner.py
TrialRunner.is_finished
def is_finished(self): """Returns whether all trials have finished running.""" if self._total_time > self._global_time_limit: logger.warning("Exceeded global time limit {} / {}".format( self._total_time, self._global_time_limit)) return True trials_done ...
python
def is_finished(self): """Returns whether all trials have finished running.""" if self._total_time > self._global_time_limit: logger.warning("Exceeded global time limit {} / {}".format( self._total_time, self._global_time_limit)) return True trials_done ...
[ "def", "is_finished", "(", "self", ")", ":", "if", "self", ".", "_total_time", ">", "self", ".", "_global_time_limit", ":", "logger", ".", "warning", "(", "\"Exceeded global time limit {} / {}\"", ".", "format", "(", "self", ".", "_total_time", ",", "self", "....
Returns whether all trials have finished running.
[ "Returns", "whether", "all", "trials", "have", "finished", "running", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L247-L256
train
ray-project/ray
python/ray/tune/trial_runner.py
TrialRunner.step
def step(self): """Runs one step of the trial event loop. Callers should typically run this method repeatedly in a loop. They may inspect or modify the runner's state in between calls to step(). """ if self.is_finished(): raise TuneError("Called step when all trials ...
python
def step(self): """Runs one step of the trial event loop. Callers should typically run this method repeatedly in a loop. They may inspect or modify the runner's state in between calls to step(). """ if self.is_finished(): raise TuneError("Called step when all trials ...
[ "def", "step", "(", "self", ")", ":", "if", "self", ".", "is_finished", "(", ")", ":", "raise", "TuneError", "(", "\"Called step when all trials finished?\"", ")", "with", "warn_if_slow", "(", "\"on_step_begin\"", ")", ":", "self", ".", "trial_executor", ".", ...
Runs one step of the trial event loop. Callers should typically run this method repeatedly in a loop. They may inspect or modify the runner's state in between calls to step().
[ "Runs", "one", "step", "of", "the", "trial", "event", "loop", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L258-L308
train
ray-project/ray
python/ray/tune/trial_runner.py
TrialRunner.add_trial
def add_trial(self, trial): """Adds a new trial to this TrialRunner. Trials may be added at any time. Args: trial (Trial): Trial to queue. """ trial.set_verbose(self._verbose) self._trials.append(trial) with warn_if_slow("scheduler.on_trial_add"): ...
python
def add_trial(self, trial): """Adds a new trial to this TrialRunner. Trials may be added at any time. Args: trial (Trial): Trial to queue. """ trial.set_verbose(self._verbose) self._trials.append(trial) with warn_if_slow("scheduler.on_trial_add"): ...
[ "def", "add_trial", "(", "self", ",", "trial", ")", ":", "trial", ".", "set_verbose", "(", "self", ".", "_verbose", ")", "self", ".", "_trials", ".", "append", "(", "trial", ")", "with", "warn_if_slow", "(", "\"scheduler.on_trial_add\"", ")", ":", "self", ...
Adds a new trial to this TrialRunner. Trials may be added at any time. Args: trial (Trial): Trial to queue.
[ "Adds", "a", "new", "trial", "to", "this", "TrialRunner", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L322-L334
train
ray-project/ray
python/ray/tune/trial_runner.py
TrialRunner.debug_string
def debug_string(self, max_debug=MAX_DEBUG_TRIALS): """Returns a human readable message for printing to the console.""" messages = self._debug_messages() states = collections.defaultdict(set) limit_per_state = collections.Counter() for t in self._trials: states[t.stat...
python
def debug_string(self, max_debug=MAX_DEBUG_TRIALS): """Returns a human readable message for printing to the console.""" messages = self._debug_messages() states = collections.defaultdict(set) limit_per_state = collections.Counter() for t in self._trials: states[t.stat...
[ "def", "debug_string", "(", "self", ",", "max_debug", "=", "MAX_DEBUG_TRIALS", ")", ":", "messages", "=", "self", ".", "_debug_messages", "(", ")", "states", "=", "collections", ".", "defaultdict", "(", "set", ")", "limit_per_state", "=", "collections", ".", ...
Returns a human readable message for printing to the console.
[ "Returns", "a", "human", "readable", "message", "for", "printing", "to", "the", "console", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L336-L390
train
ray-project/ray
python/ray/tune/trial_runner.py
TrialRunner._get_next_trial
def _get_next_trial(self): """Replenishes queue. Blocks if all trials queued have finished, but search algorithm is still not finished. """ trials_done = all(trial.is_finished() for trial in self._trials) wait_for_trial = trials_done and not self._search_alg.is_finished(...
python
def _get_next_trial(self): """Replenishes queue. Blocks if all trials queued have finished, but search algorithm is still not finished. """ trials_done = all(trial.is_finished() for trial in self._trials) wait_for_trial = trials_done and not self._search_alg.is_finished(...
[ "def", "_get_next_trial", "(", "self", ")", ":", "trials_done", "=", "all", "(", "trial", ".", "is_finished", "(", ")", "for", "trial", "in", "self", ".", "_trials", ")", "wait_for_trial", "=", "trials_done", "and", "not", "self", ".", "_search_alg", ".", ...
Replenishes queue. Blocks if all trials queued have finished, but search algorithm is still not finished.
[ "Replenishes", "queue", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L423-L434
train
ray-project/ray
python/ray/tune/trial_runner.py
TrialRunner._checkpoint_trial_if_needed
def _checkpoint_trial_if_needed(self, trial): """Checkpoints trial based off trial.last_result.""" if trial.should_checkpoint(): # Save trial runtime if possible if hasattr(trial, "runner") and trial.runner: self.trial_executor.save(trial, storage=Checkpoint.DISK)...
python
def _checkpoint_trial_if_needed(self, trial): """Checkpoints trial based off trial.last_result.""" if trial.should_checkpoint(): # Save trial runtime if possible if hasattr(trial, "runner") and trial.runner: self.trial_executor.save(trial, storage=Checkpoint.DISK)...
[ "def", "_checkpoint_trial_if_needed", "(", "self", ",", "trial", ")", ":", "if", "trial", ".", "should_checkpoint", "(", ")", ":", "# Save trial runtime if possible", "if", "hasattr", "(", "trial", ",", "\"runner\"", ")", "and", "trial", ".", "runner", ":", "s...
Checkpoints trial based off trial.last_result.
[ "Checkpoints", "trial", "based", "off", "trial", ".", "last_result", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L506-L512
train
ray-project/ray
python/ray/tune/trial_runner.py
TrialRunner._try_recover
def _try_recover(self, trial, error_msg): """Tries to recover trial. Notifies SearchAlgorithm and Scheduler if failure to recover. Args: trial (Trial): Trial to recover. error_msg (str): Error message from prior to invoking this method. """ try: ...
python
def _try_recover(self, trial, error_msg): """Tries to recover trial. Notifies SearchAlgorithm and Scheduler if failure to recover. Args: trial (Trial): Trial to recover. error_msg (str): Error message from prior to invoking this method. """ try: ...
[ "def", "_try_recover", "(", "self", ",", "trial", ",", "error_msg", ")", ":", "try", ":", "self", ".", "trial_executor", ".", "stop_trial", "(", "trial", ",", "error", "=", "error_msg", "is", "not", "None", ",", "error_msg", "=", "error_msg", ",", "stop_...
Tries to recover trial. Notifies SearchAlgorithm and Scheduler if failure to recover. Args: trial (Trial): Trial to recover. error_msg (str): Error message from prior to invoking this method.
[ "Tries", "to", "recover", "trial", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L514-L542
train
ray-project/ray
python/ray/tune/trial_runner.py
TrialRunner._requeue_trial
def _requeue_trial(self, trial): """Notification to TrialScheduler and requeue trial. This does not notify the SearchAlgorithm because the function evaluation is still in progress. """ self._scheduler_alg.on_trial_error(self, trial) self.trial_executor.set_status(trial, ...
python
def _requeue_trial(self, trial): """Notification to TrialScheduler and requeue trial. This does not notify the SearchAlgorithm because the function evaluation is still in progress. """ self._scheduler_alg.on_trial_error(self, trial) self.trial_executor.set_status(trial, ...
[ "def", "_requeue_trial", "(", "self", ",", "trial", ")", ":", "self", ".", "_scheduler_alg", ".", "on_trial_error", "(", "self", ",", "trial", ")", "self", ".", "trial_executor", ".", "set_status", "(", "trial", ",", "Trial", ".", "PENDING", ")", "with", ...
Notification to TrialScheduler and requeue trial. This does not notify the SearchAlgorithm because the function evaluation is still in progress.
[ "Notification", "to", "TrialScheduler", "and", "requeue", "trial", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L544-L553
train
ray-project/ray
python/ray/tune/trial_runner.py
TrialRunner._update_trial_queue
def _update_trial_queue(self, blocking=False, timeout=600): """Adds next trials to queue if possible. Note that the timeout is currently unexposed to the user. Args: blocking (bool): Blocks until either a trial is available or is_finished (timeout or search algorith...
python
def _update_trial_queue(self, blocking=False, timeout=600): """Adds next trials to queue if possible. Note that the timeout is currently unexposed to the user. Args: blocking (bool): Blocks until either a trial is available or is_finished (timeout or search algorith...
[ "def", "_update_trial_queue", "(", "self", ",", "blocking", "=", "False", ",", "timeout", "=", "600", ")", ":", "trials", "=", "self", ".", "_search_alg", ".", "next_trials", "(", ")", "if", "blocking", "and", "not", "trials", ":", "start", "=", "time", ...
Adds next trials to queue if possible. Note that the timeout is currently unexposed to the user. Args: blocking (bool): Blocks until either a trial is available or is_finished (timeout or search algorithm finishes). timeout (int): Seconds before blocking times o...
[ "Adds", "next", "trials", "to", "queue", "if", "possible", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L555-L578
train
ray-project/ray
python/ray/tune/trial_runner.py
TrialRunner.stop_trial
def stop_trial(self, trial): """Stops trial. Trials may be stopped at any time. If trial is in state PENDING or PAUSED, calls `on_trial_remove` for scheduler and `on_trial_complete(..., early_terminated=True) for search_alg. Otherwise waits for result for the trial and calls ...
python
def stop_trial(self, trial): """Stops trial. Trials may be stopped at any time. If trial is in state PENDING or PAUSED, calls `on_trial_remove` for scheduler and `on_trial_complete(..., early_terminated=True) for search_alg. Otherwise waits for result for the trial and calls ...
[ "def", "stop_trial", "(", "self", ",", "trial", ")", ":", "error", "=", "False", "error_msg", "=", "None", "if", "trial", ".", "status", "in", "[", "Trial", ".", "ERROR", ",", "Trial", ".", "TERMINATED", "]", ":", "return", "elif", "trial", ".", "sta...
Stops trial. Trials may be stopped at any time. If trial is in state PENDING or PAUSED, calls `on_trial_remove` for scheduler and `on_trial_complete(..., early_terminated=True) for search_alg. Otherwise waits for result for the trial and calls `on_trial_complete` for scheduler ...
[ "Stops", "trial", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L588-L620
train
ray-project/ray
examples/cython/cython_main.py
run_func
def run_func(func, *args, **kwargs): """Helper function for running examples""" ray.init() func = ray.remote(func) # NOTE: kwargs not allowed for now result = ray.get(func.remote(*args)) # Inspect the stack to get calling example caller = inspect.stack()[1][3] print("%s: %s" % (caller...
python
def run_func(func, *args, **kwargs): """Helper function for running examples""" ray.init() func = ray.remote(func) # NOTE: kwargs not allowed for now result = ray.get(func.remote(*args)) # Inspect the stack to get calling example caller = inspect.stack()[1][3] print("%s: %s" % (caller...
[ "def", "run_func", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ray", ".", "init", "(", ")", "func", "=", "ray", ".", "remote", "(", "func", ")", "# NOTE: kwargs not allowed for now", "result", "=", "ray", ".", "get", "(", "func...
Helper function for running examples
[ "Helper", "function", "for", "running", "examples" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/cython/cython_main.py#L13-L26
train
ray-project/ray
examples/cython/cython_main.py
example6
def example6(): """Cython simple class""" ray.init() cls = ray.remote(cyth.simple_class) a1 = cls.remote() a2 = cls.remote() result1 = ray.get(a1.increment.remote()) result2 = ray.get(a2.increment.remote()) print(result1, result2)
python
def example6(): """Cython simple class""" ray.init() cls = ray.remote(cyth.simple_class) a1 = cls.remote() a2 = cls.remote() result1 = ray.get(a1.increment.remote()) result2 = ray.get(a2.increment.remote()) print(result1, result2)
[ "def", "example6", "(", ")", ":", "ray", ".", "init", "(", ")", "cls", "=", "ray", ".", "remote", "(", "cyth", ".", "simple_class", ")", "a1", "=", "cls", ".", "remote", "(", ")", "a2", "=", "cls", ".", "remote", "(", ")", "result1", "=", "ray"...
Cython simple class
[ "Cython", "simple", "class" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/cython/cython_main.py#L73-L85
train
ray-project/ray
examples/cython/cython_main.py
example8
def example8(): """Cython with blas. NOTE: requires scipy""" # See cython_blas.pyx for argument documentation mat = np.array([[[2.0, 2.0], [2.0, 2.0]], [[2.0, 2.0], [2.0, 2.0]]], dtype=np.float32) result = np.zeros((2, 2), np.float32, order="C") run_func(cyth.compute_kernel_matr...
python
def example8(): """Cython with blas. NOTE: requires scipy""" # See cython_blas.pyx for argument documentation mat = np.array([[[2.0, 2.0], [2.0, 2.0]], [[2.0, 2.0], [2.0, 2.0]]], dtype=np.float32) result = np.zeros((2, 2), np.float32, order="C") run_func(cyth.compute_kernel_matr...
[ "def", "example8", "(", ")", ":", "# See cython_blas.pyx for argument documentation", "mat", "=", "np", ".", "array", "(", "[", "[", "[", "2.0", ",", "2.0", "]", ",", "[", "2.0", ",", "2.0", "]", "]", ",", "[", "[", "2.0", ",", "2.0", "]", ",", "["...
Cython with blas. NOTE: requires scipy
[ "Cython", "with", "blas", ".", "NOTE", ":", "requires", "scipy" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/cython/cython_main.py#L96-L116
train
ray-project/ray
python/ray/rllib/agents/dqn/dqn_policy_graph.py
_adjust_nstep
def _adjust_nstep(n_step, gamma, obs, actions, rewards, new_obs, dones): """Rewrites the given trajectory fragments to encode n-step rewards. reward[i] = ( reward[i] * gamma**0 + reward[i+1] * gamma**1 + ... + reward[i+n_step-1] * gamma**(n_step-1)) The ith new_obs is also ...
python
def _adjust_nstep(n_step, gamma, obs, actions, rewards, new_obs, dones): """Rewrites the given trajectory fragments to encode n-step rewards. reward[i] = ( reward[i] * gamma**0 + reward[i+1] * gamma**1 + ... + reward[i+n_step-1] * gamma**(n_step-1)) The ith new_obs is also ...
[ "def", "_adjust_nstep", "(", "n_step", ",", "gamma", ",", "obs", ",", "actions", ",", "rewards", ",", "new_obs", ",", "dones", ")", ":", "assert", "not", "any", "(", "dones", "[", ":", "-", "1", "]", ")", ",", "\"Unexpected done in middle of trajectory\"",...
Rewrites the given trajectory fragments to encode n-step rewards. reward[i] = ( reward[i] * gamma**0 + reward[i+1] * gamma**1 + ... + reward[i+n_step-1] * gamma**(n_step-1)) The ith new_obs is also adjusted to point to the (i+n_step-1)'th new obs. At the end of the traject...
[ "Rewrites", "the", "given", "trajectory", "fragments", "to", "encode", "n", "-", "step", "rewards", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/dqn/dqn_policy_graph.py#L603-L625
train
ray-project/ray
python/ray/rllib/agents/dqn/dqn_policy_graph.py
_reduce_mean_ignore_inf
def _reduce_mean_ignore_inf(x, axis): """Same as tf.reduce_mean() but ignores -inf values.""" mask = tf.not_equal(x, tf.float32.min) x_zeroed = tf.where(mask, x, tf.zeros_like(x)) return (tf.reduce_sum(x_zeroed, axis) / tf.reduce_sum( tf.cast(mask, tf.float32), axis))
python
def _reduce_mean_ignore_inf(x, axis): """Same as tf.reduce_mean() but ignores -inf values.""" mask = tf.not_equal(x, tf.float32.min) x_zeroed = tf.where(mask, x, tf.zeros_like(x)) return (tf.reduce_sum(x_zeroed, axis) / tf.reduce_sum( tf.cast(mask, tf.float32), axis))
[ "def", "_reduce_mean_ignore_inf", "(", "x", ",", "axis", ")", ":", "mask", "=", "tf", ".", "not_equal", "(", "x", ",", "tf", ".", "float32", ".", "min", ")", "x_zeroed", "=", "tf", ".", "where", "(", "mask", ",", "x", ",", "tf", ".", "zeros_like", ...
Same as tf.reduce_mean() but ignores -inf values.
[ "Same", "as", "tf", ".", "reduce_mean", "()", "but", "ignores", "-", "inf", "values", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/dqn/dqn_policy_graph.py#L652-L657
train
ray-project/ray
python/ray/rllib/agents/dqn/dqn_policy_graph.py
_huber_loss
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))
python
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", ")", ":", "return", "tf", ".", "where", "(", "tf", ".", "abs", "(", "x", ")", "<", "delta", ",", "tf", ".", "square", "(", "x", ")", "*", "0.5", ",", "delta", "*", "(", "tf", ".", "a...
Reference: https://en.wikipedia.org/wiki/Huber_loss
[ "Reference", ":", "https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Huber_loss" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/dqn/dqn_policy_graph.py#L660-L664
train
ray-project/ray
python/ray/rllib/agents/dqn/dqn_policy_graph.py
_minimize_and_clip
def _minimize_and_clip(optimizer, objective, var_list, clip_val=10): """Minimized `objective` using `optimizer` w.r.t. variables in `var_list` while ensure the norm of the gradients for each variable is clipped to `clip_val` """ gradients = optimizer.compute_gradients(objective, var_list=var_list) ...
python
def _minimize_and_clip(optimizer, objective, var_list, clip_val=10): """Minimized `objective` using `optimizer` w.r.t. variables in `var_list` while ensure the norm of the gradients for each variable is clipped to `clip_val` """ gradients = optimizer.compute_gradients(objective, var_list=var_list) ...
[ "def", "_minimize_and_clip", "(", "optimizer", ",", "objective", ",", "var_list", ",", "clip_val", "=", "10", ")", ":", "gradients", "=", "optimizer", ".", "compute_gradients", "(", "objective", ",", "var_list", "=", "var_list", ")", "for", "i", ",", "(", ...
Minimized `objective` using `optimizer` w.r.t. variables in `var_list` while ensure the norm of the gradients for each variable is clipped to `clip_val`
[ "Minimized", "objective", "using", "optimizer", "w", ".", "r", ".", "t", ".", "variables", "in", "var_list", "while", "ensure", "the", "norm", "of", "the", "gradients", "for", "each", "variable", "is", "clipped", "to", "clip_val" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/dqn/dqn_policy_graph.py#L667-L676
train
ray-project/ray
python/ray/rllib/agents/dqn/dqn_policy_graph.py
_scope_vars
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 were...
python
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 were...
[ "def", "_scope_vars", "(", "scope", ",", "trainable_only", "=", "False", ")", ":", "return", "tf", ".", "get_collection", "(", "tf", ".", "GraphKeys", ".", "TRAINABLE_VARIABLES", "if", "trainable_only", "else", "tf", ".", "GraphKeys", ".", "VARIABLES", ",", ...
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 ------- v...
[ "Get", "variables", "inside", "a", "scope", "The", "scope", "can", "be", "specified", "as", "a", "string" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/dqn/dqn_policy_graph.py#L679-L700
train
ray-project/ray
python/ray/rllib/agents/dqn/dqn_policy_graph.py
QNetwork.noisy_layer
def noisy_layer(self, prefix, action_in, out_size, sigma0, non_linear=True): """ a common dense layer: y = w^{T}x + b a noisy layer: y = (w + \epsilon_w*\sigma_w)^{T}x + (b+\epsilon_b*\sigma_b) where \epsilon are random variables sampled from factorized no...
python
def noisy_layer(self, prefix, action_in, out_size, sigma0, non_linear=True): """ a common dense layer: y = w^{T}x + b a noisy layer: y = (w + \epsilon_w*\sigma_w)^{T}x + (b+\epsilon_b*\sigma_b) where \epsilon are random variables sampled from factorized no...
[ "def", "noisy_layer", "(", "self", ",", "prefix", ",", "action_in", ",", "out_size", ",", "sigma0", ",", "non_linear", "=", "True", ")", ":", "in_size", "=", "int", "(", "action_in", ".", "shape", "[", "1", "]", ")", "epsilon_in", "=", "tf", ".", "ra...
a common dense layer: y = w^{T}x + b a noisy layer: y = (w + \epsilon_w*\sigma_w)^{T}x + (b+\epsilon_b*\sigma_b) where \epsilon are random variables sampled from factorized normal distributions and \sigma are trainable variables which are expected to vanish along the training...
[ "a", "common", "dense", "layer", ":", "y", "=", "w^", "{", "T", "}", "x", "+", "b", "a", "noisy", "layer", ":", "y", "=", "(", "w", "+", "\\", "epsilon_w", "*", "\\", "sigma_w", ")", "^", "{", "T", "}", "x", "+", "(", "b", "+", "\\", "eps...
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/dqn/dqn_policy_graph.py#L256-L308
train
ray-project/ray
python/ray/experimental/sgd/tfbench/convnet_builder.py
ConvNetBuilder.get_custom_getter
def get_custom_getter(self): """Returns a custom getter that this class's methods must be called All methods of this class must be called under a variable scope that was passed this custom getter. Example: ```python network = ConvNetBuilder(...) with tf.variable_scope("cg", custom_getter=n...
python
def get_custom_getter(self): """Returns a custom getter that this class's methods must be called All methods of this class must be called under a variable scope that was passed this custom getter. Example: ```python network = ConvNetBuilder(...) with tf.variable_scope("cg", custom_getter=n...
[ "def", "get_custom_getter", "(", "self", ")", ":", "def", "inner_custom_getter", "(", "getter", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "use_tf_layers", ":", "return", "getter", "(", "*", "args", ",", "*", "*", ...
Returns a custom getter that this class's methods must be called All methods of this class must be called under a variable scope that was passed this custom getter. Example: ```python network = ConvNetBuilder(...) with tf.variable_scope("cg", custom_getter=network.get_custom_getter()): netwo...
[ "Returns", "a", "custom", "getter", "that", "this", "class", "s", "methods", "must", "be", "called" ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L58-L89
train
ray-project/ray
python/ray/experimental/sgd/tfbench/convnet_builder.py
ConvNetBuilder.switch_to_aux_top_layer
def switch_to_aux_top_layer(self): """Context that construct cnn in the auxiliary arm.""" if self.aux_top_layer is None: raise RuntimeError("Empty auxiliary top layer in the network.") saved_top_layer = self.top_layer saved_top_size = self.top_size self.top_layer = se...
python
def switch_to_aux_top_layer(self): """Context that construct cnn in the auxiliary arm.""" if self.aux_top_layer is None: raise RuntimeError("Empty auxiliary top layer in the network.") saved_top_layer = self.top_layer saved_top_size = self.top_size self.top_layer = se...
[ "def", "switch_to_aux_top_layer", "(", "self", ")", ":", "if", "self", ".", "aux_top_layer", "is", "None", ":", "raise", "RuntimeError", "(", "\"Empty auxiliary top layer in the network.\"", ")", "saved_top_layer", "=", "self", ".", "top_layer", "saved_top_size", "=",...
Context that construct cnn in the auxiliary arm.
[ "Context", "that", "construct", "cnn", "in", "the", "auxiliary", "arm", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L92-L104
train
ray-project/ray
python/ray/experimental/sgd/tfbench/convnet_builder.py
ConvNetBuilder.conv
def conv(self, num_out_channels, k_height, k_width, d_height=1, d_width=1, mode="SAME", input_layer=None, num_channels_in=None, use_batch_norm=None, stddev=None, activation="rel...
python
def conv(self, num_out_channels, k_height, k_width, d_height=1, d_width=1, mode="SAME", input_layer=None, num_channels_in=None, use_batch_norm=None, stddev=None, activation="rel...
[ "def", "conv", "(", "self", ",", "num_out_channels", ",", "k_height", ",", "k_width", ",", "d_height", "=", "1", ",", "d_width", "=", "1", ",", "mode", "=", "\"SAME\"", ",", "input_layer", "=", "None", ",", "num_channels_in", "=", "None", ",", "use_batch...
Construct a conv2d layer on top of cnn.
[ "Construct", "a", "conv2d", "layer", "on", "top", "of", "cnn", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L143-L243
train
ray-project/ray
python/ray/experimental/sgd/tfbench/convnet_builder.py
ConvNetBuilder._pool
def _pool(self, pool_name, pool_function, k_height, k_width, d_height, d_width, mode, input_layer, num_channels_in): """Construct a pooling layer.""" if input_layer is None: input_layer = self.top_layer else: self.top_size = num_channels_in name = po...
python
def _pool(self, pool_name, pool_function, k_height, k_width, d_height, d_width, mode, input_layer, num_channels_in): """Construct a pooling layer.""" if input_layer is None: input_layer = self.top_layer else: self.top_size = num_channels_in name = po...
[ "def", "_pool", "(", "self", ",", "pool_name", ",", "pool_function", ",", "k_height", ",", "k_width", ",", "d_height", ",", "d_width", ",", "mode", ",", "input_layer", ",", "num_channels_in", ")", ":", "if", "input_layer", "is", "None", ":", "input_layer", ...
Construct a pooling layer.
[ "Construct", "a", "pooling", "layer", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L245-L275
train
ray-project/ray
python/ray/experimental/sgd/tfbench/convnet_builder.py
ConvNetBuilder.mpool
def mpool(self, k_height, k_width, d_height=2, d_width=2, mode="VALID", input_layer=None, num_channels_in=None): """Construct a max pooling layer.""" return self._pool("mpool", pooling_layers.max_pooling2d,...
python
def mpool(self, k_height, k_width, d_height=2, d_width=2, mode="VALID", input_layer=None, num_channels_in=None): """Construct a max pooling layer.""" return self._pool("mpool", pooling_layers.max_pooling2d,...
[ "def", "mpool", "(", "self", ",", "k_height", ",", "k_width", ",", "d_height", "=", "2", ",", "d_width", "=", "2", ",", "mode", "=", "\"VALID\"", ",", "input_layer", "=", "None", ",", "num_channels_in", "=", "None", ")", ":", "return", "self", ".", "...
Construct a max pooling layer.
[ "Construct", "a", "max", "pooling", "layer", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L277-L288
train
ray-project/ray
python/ray/experimental/sgd/tfbench/convnet_builder.py
ConvNetBuilder.apool
def apool(self, k_height, k_width, d_height=2, d_width=2, mode="VALID", input_layer=None, num_channels_in=None): """Construct an average pooling layer.""" return self._pool("apool", pooling_layers.average_p...
python
def apool(self, k_height, k_width, d_height=2, d_width=2, mode="VALID", input_layer=None, num_channels_in=None): """Construct an average pooling layer.""" return self._pool("apool", pooling_layers.average_p...
[ "def", "apool", "(", "self", ",", "k_height", ",", "k_width", ",", "d_height", "=", "2", ",", "d_width", "=", "2", ",", "mode", "=", "\"VALID\"", ",", "input_layer", "=", "None", ",", "num_channels_in", "=", "None", ")", ":", "return", "self", ".", "...
Construct an average pooling layer.
[ "Construct", "an", "average", "pooling", "layer", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L290-L301
train
ray-project/ray
python/ray/experimental/sgd/tfbench/convnet_builder.py
ConvNetBuilder._batch_norm_without_layers
def _batch_norm_without_layers(self, input_layer, decay, use_scale, epsilon): """Batch normalization on `input_layer` without tf.layers.""" shape = input_layer.shape num_channels = shape[3] if self.data_format == "NHWC" else shape[1] beta = self.get_var...
python
def _batch_norm_without_layers(self, input_layer, decay, use_scale, epsilon): """Batch normalization on `input_layer` without tf.layers.""" shape = input_layer.shape num_channels = shape[3] if self.data_format == "NHWC" else shape[1] beta = self.get_var...
[ "def", "_batch_norm_without_layers", "(", "self", ",", "input_layer", ",", "decay", ",", "use_scale", ",", "epsilon", ")", ":", "shape", "=", "input_layer", ".", "shape", "num_channels", "=", "shape", "[", "3", "]", "if", "self", ".", "data_format", "==", ...
Batch normalization on `input_layer` without tf.layers.
[ "Batch", "normalization", "on", "input_layer", "without", "tf", ".", "layers", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L411-L466
train
ray-project/ray
python/ray/experimental/sgd/tfbench/convnet_builder.py
ConvNetBuilder.batch_norm
def batch_norm(self, input_layer=None, decay=0.999, scale=False, epsilon=0.001): """Adds a Batch Normalization layer.""" if input_layer is None: input_layer = self.top_layer else: self.top_size = ...
python
def batch_norm(self, input_layer=None, decay=0.999, scale=False, epsilon=0.001): """Adds a Batch Normalization layer.""" if input_layer is None: input_layer = self.top_layer else: self.top_size = ...
[ "def", "batch_norm", "(", "self", ",", "input_layer", "=", "None", ",", "decay", "=", "0.999", ",", "scale", "=", "False", ",", "epsilon", "=", "0.001", ")", ":", "if", "input_layer", "is", "None", ":", "input_layer", "=", "self", ".", "top_layer", "el...
Adds a Batch Normalization layer.
[ "Adds", "a", "Batch", "Normalization", "layer", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L468-L499
train
ray-project/ray
python/ray/experimental/sgd/tfbench/convnet_builder.py
ConvNetBuilder.lrn
def lrn(self, depth_radius, bias, alpha, beta): """Adds a local response normalization layer.""" name = "lrn" + str(self.counts["lrn"]) self.counts["lrn"] += 1 self.top_layer = tf.nn.lrn( self.top_layer, depth_radius, bias, alpha, beta, name=name) return self.top_laye...
python
def lrn(self, depth_radius, bias, alpha, beta): """Adds a local response normalization layer.""" name = "lrn" + str(self.counts["lrn"]) self.counts["lrn"] += 1 self.top_layer = tf.nn.lrn( self.top_layer, depth_radius, bias, alpha, beta, name=name) return self.top_laye...
[ "def", "lrn", "(", "self", ",", "depth_radius", ",", "bias", ",", "alpha", ",", "beta", ")", ":", "name", "=", "\"lrn\"", "+", "str", "(", "self", ".", "counts", "[", "\"lrn\"", "]", ")", "self", ".", "counts", "[", "\"lrn\"", "]", "+=", "1", "se...
Adds a local response normalization layer.
[ "Adds", "a", "local", "response", "normalization", "layer", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L501-L507
train
ray-project/ray
python/ray/experimental/internal_kv.py
_internal_kv_get
def _internal_kv_get(key): """Fetch the value of a binary key.""" worker = ray.worker.get_global_worker() if worker.mode == ray.worker.LOCAL_MODE: return _local.get(key) return worker.redis_client.hget(key, "value")
python
def _internal_kv_get(key): """Fetch the value of a binary key.""" worker = ray.worker.get_global_worker() if worker.mode == ray.worker.LOCAL_MODE: return _local.get(key) return worker.redis_client.hget(key, "value")
[ "def", "_internal_kv_get", "(", "key", ")", ":", "worker", "=", "ray", ".", "worker", ".", "get_global_worker", "(", ")", "if", "worker", ".", "mode", "==", "ray", ".", "worker", ".", "LOCAL_MODE", ":", "return", "_local", ".", "get", "(", "key", ")", ...
Fetch the value of a binary key.
[ "Fetch", "the", "value", "of", "a", "binary", "key", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/internal_kv.py#L15-L22
train
ray-project/ray
python/ray/experimental/internal_kv.py
_internal_kv_put
def _internal_kv_put(key, value, overwrite=False): """Globally associates a value with a given binary key. This only has an effect if the key does not already have a value. Returns: already_exists (bool): whether the value already exists. """ worker = ray.worker.get_global_worker() if...
python
def _internal_kv_put(key, value, overwrite=False): """Globally associates a value with a given binary key. This only has an effect if the key does not already have a value. Returns: already_exists (bool): whether the value already exists. """ worker = ray.worker.get_global_worker() if...
[ "def", "_internal_kv_put", "(", "key", ",", "value", ",", "overwrite", "=", "False", ")", ":", "worker", "=", "ray", ".", "worker", ".", "get_global_worker", "(", ")", "if", "worker", ".", "mode", "==", "ray", ".", "worker", ".", "LOCAL_MODE", ":", "ex...
Globally associates a value with a given binary key. This only has an effect if the key does not already have a value. Returns: already_exists (bool): whether the value already exists.
[ "Globally", "associates", "a", "value", "with", "a", "given", "binary", "key", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/internal_kv.py#L25-L45
train
ray-project/ray
python/ray/rllib/optimizers/aso_tree_aggregator.py
TreeAggregator.init
def init(self, aggregators): """Deferred init so that we can pass in previously created workers.""" assert len(aggregators) == self.num_aggregation_workers, aggregators if len(self.remote_evaluators) < self.num_aggregation_workers: raise ValueError( "The number of ag...
python
def init(self, aggregators): """Deferred init so that we can pass in previously created workers.""" assert len(aggregators) == self.num_aggregation_workers, aggregators if len(self.remote_evaluators) < self.num_aggregation_workers: raise ValueError( "The number of ag...
[ "def", "init", "(", "self", ",", "aggregators", ")", ":", "assert", "len", "(", "aggregators", ")", "==", "self", ".", "num_aggregation_workers", ",", "aggregators", "if", "len", "(", "self", ".", "remote_evaluators", ")", "<", "self", ".", "num_aggregation_...
Deferred init so that we can pass in previously created workers.
[ "Deferred", "init", "so", "that", "we", "can", "pass", "in", "previously", "created", "workers", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/aso_tree_aggregator.py#L57-L84
train
ray-project/ray
python/ray/internal/internal_api.py
free
def free(object_ids, local_only=False, delete_creating_tasks=False): """Free a list of IDs from object stores. This function is a low-level API which should be used in restricted scenarios. If local_only is false, the request will be send to all object stores. This method will not return any valu...
python
def free(object_ids, local_only=False, delete_creating_tasks=False): """Free a list of IDs from object stores. This function is a low-level API which should be used in restricted scenarios. If local_only is false, the request will be send to all object stores. This method will not return any valu...
[ "def", "free", "(", "object_ids", ",", "local_only", "=", "False", ",", "delete_creating_tasks", "=", "False", ")", ":", "worker", "=", "ray", ".", "worker", ".", "get_global_worker", "(", ")", "if", "ray", ".", "worker", ".", "_mode", "(", ")", "==", ...
Free a list of IDs from object stores. This function is a low-level API which should be used in restricted scenarios. If local_only is false, the request will be send to all object stores. This method will not return any value to indicate whether the deletion is successful or not. This function i...
[ "Free", "a", "list", "of", "IDs", "from", "object", "stores", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/internal/internal_api.py#L11-L55
train
ray-project/ray
python/ray/tune/automlboard/backend/collector.py
CollectorService.run
def run(self): """Start the collector worker thread. If running in standalone mode, the current thread will wait until the collector thread ends. """ self.collector.start() if self.standalone: self.collector.join()
python
def run(self): """Start the collector worker thread. If running in standalone mode, the current thread will wait until the collector thread ends. """ self.collector.start() if self.standalone: self.collector.join()
[ "def", "run", "(", "self", ")", ":", "self", ".", "collector", ".", "start", "(", ")", "if", "self", ".", "standalone", ":", "self", ".", "collector", ".", "join", "(", ")" ]
Start the collector worker thread. If running in standalone mode, the current thread will wait until the collector thread ends.
[ "Start", "the", "collector", "worker", "thread", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L47-L55
train
ray-project/ray
python/ray/tune/automlboard/backend/collector.py
CollectorService.init_logger
def init_logger(cls, log_level): """Initialize logger settings.""" logger = logging.getLogger("AutoMLBoard") handler = logging.StreamHandler() formatter = logging.Formatter("[%(levelname)s %(asctime)s] " "%(filename)s: %(lineno)d " ...
python
def init_logger(cls, log_level): """Initialize logger settings.""" logger = logging.getLogger("AutoMLBoard") handler = logging.StreamHandler() formatter = logging.Formatter("[%(levelname)s %(asctime)s] " "%(filename)s: %(lineno)d " ...
[ "def", "init_logger", "(", "cls", ",", "log_level", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "\"AutoMLBoard\"", ")", "handler", "=", "logging", ".", "StreamHandler", "(", ")", "formatter", "=", "logging", ".", "Formatter", "(", "\"[%(leveln...
Initialize logger settings.
[ "Initialize", "logger", "settings", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L62-L72
train
ray-project/ray
python/ray/tune/automlboard/backend/collector.py
Collector.run
def run(self): """Run the main event loop for collector thread. In each round the collector traverse the results log directory and reload trial information from the status files. """ self._initialize() self._do_collect() while not self._is_finished: ...
python
def run(self): """Run the main event loop for collector thread. In each round the collector traverse the results log directory and reload trial information from the status files. """ self._initialize() self._do_collect() while not self._is_finished: ...
[ "def", "run", "(", "self", ")", ":", "self", ".", "_initialize", "(", ")", "self", ".", "_do_collect", "(", ")", "while", "not", "self", ".", "_is_finished", ":", "time", ".", "sleep", "(", "self", ".", "_reload_interval", ")", "self", ".", "_do_collec...
Run the main event loop for collector thread. In each round the collector traverse the results log directory and reload trial information from the status files.
[ "Run", "the", "main", "event", "loop", "for", "collector", "thread", "." ]
4eade036a0505e244c976f36aaa2d64386b5129b
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L98-L111
train