partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
query_job
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, ...
python/ray/tune/automlboard/frontend/query.py
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): """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...
[ "Rest", "API", "to", "query", "the", "job", "info", "with", "the", "given", "job_id", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/query.py#L14-L71
[ "def", "query_job", "(", "request", ")", ":", "job_id", "=", "request", ".", "GET", ".", "get", "(", "\"job_id\"", ")", "jobs", "=", "JobRecord", ".", "objects", ".", "filter", "(", "job_id", "=", "job_id", ")", "trials", "=", "TrialRecord", ".", "obje...
4eade036a0505e244c976f36aaa2d64386b5129b
train
query_trial
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...
python/ray/tune/automlboard/frontend/query.py
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): """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':...
[ "Rest", "API", "to", "query", "the", "trial", "info", "with", "the", "given", "trial_id", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/query.py#L74-L110
[ "def", "query_trial", "(", "request", ")", ":", "trial_id", "=", "request", ".", "GET", ".", "get", "(", "\"trial_id\"", ")", "trials", "=", "TrialRecord", ".", "objects", ".", "filter", "(", "trial_id", "=", "trial_id", ")", ".", "order_by", "(", "\"-st...
4eade036a0505e244c976f36aaa2d64386b5129b
train
MedianStoppingRule.on_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 step `t`.
python/ray/tune/schedulers/median_stopping_rule.py
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): """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...
[ "Callback", "for", "early", "stopping", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/median_stopping_rule.py#L56-L85
[ "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...
4eade036a0505e244c976f36aaa2d64386b5129b
train
MedianStoppingRule.on_trial_remove
Marks trial as completed if it is paused and has previously ran.
python/ray/tune/schedulers/median_stopping_rule.py
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): """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)
[ "Marks", "trial", "as", "completed", "if", "it", "is", "paused", "and", "has", "previously", "ran", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/median_stopping_rule.py#L91-L94
[ "def", "on_trial_remove", "(", "self", ",", "trial_runner", ",", "trial", ")", ":", "if", "trial", ".", "status", "is", "Trial", ".", "PAUSED", "and", "trial", "in", "self", ".", "_results", ":", "self", ".", "_completed_trials", ".", "add", "(", "trial"...
4eade036a0505e244c976f36aaa2d64386b5129b
train
JobRecord.from_json
Build a Job instance from a json string.
python/ray/tune/automlboard/models/models.py
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): """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"], ...
[ "Build", "a", "Job", "instance", "from", "a", "json", "string", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/models/models.py#L20-L29
[ "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\"", "]", "...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TrialRecord.from_json
Build a Trial instance from a json string.
python/ray/tune/automlboard/models/models.py
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): """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...
[ "Build", "a", "Trial", "instance", "from", "a", "json", "string", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/models/models.py#L48-L57
[ "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\"", "]...
4eade036a0505e244c976f36aaa2d64386b5129b
train
ResultRecord.from_json
Build a Result instance from a json string.
python/ray/tune/automlboard/models/models.py
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): """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), ...
[ "Build", "a", "Result", "instance", "from", "a", "json", "string", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/models/models.py#L80-L98
[ "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...
4eade036a0505e244c976f36aaa2d64386b5129b
train
compute_advantages
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...
python/ray/rllib/evaluation/postprocessing.py
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): """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...
[ "Given", "a", "rollout", "compute", "its", "value", "targets", "and", "the", "advantage", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/evaluation/postprocessing.py#L23-L70
[ "def", "compute_advantages", "(", "rollout", ",", "last_r", ",", "gamma", "=", "0.9", ",", "lambda_", "=", "1.0", ",", "use_gae", "=", "True", ")", ":", "traj", "=", "{", "}", "trajsize", "=", "len", "(", "rollout", "[", "SampleBatch", ".", "ACTIONS", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Monitor.xray_heartbeat_batch_handler
Handle an xray heartbeat batch message from Redis.
python/ray/monitor.py
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): """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...
[ "Handle", "an", "xray", "heartbeat", "batch", "message", "from", "Redis", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/monitor.py#L102-L135
[ "def", "xray_heartbeat_batch_handler", "(", "self", ",", "unused_channel", ",", "data", ")", ":", "gcs_entries", "=", "ray", ".", "gcs_utils", ".", "GcsTableEntry", ".", "GetRootAsGcsTableEntry", "(", "data", ",", "0", ")", "heartbeat_data", "=", "gcs_entries", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Monitor._xray_clean_up_entries_for_driver
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.
python/ray/monitor.py
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): """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...
[ "Remove", "this", "driver", "s", "object", "/", "task", "entries", "from", "redis", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/monitor.py#L137-L199
[ "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", "=", "(", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Monitor.xray_driver_removed_handler
Handle a notification that a driver has been removed. Args: unused_channel: The message channel. data: The message data.
python/ray/monitor.py
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): """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( ...
[ "Handle", "a", "notification", "that", "a", "driver", "has", "been", "removed", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/monitor.py#L201-L217
[ "def", "xray_driver_removed_handler", "(", "self", ",", "unused_channel", ",", "data", ")", ":", "gcs_entries", "=", "ray", ".", "gcs_utils", ".", "GcsTableEntry", ".", "GetRootAsGcsTableEntry", "(", "data", ",", "0", ")", "driver_data", "=", "gcs_entries", ".",...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Monitor.process_messages
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.
python/ray/monitor.py
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): """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...
[ "Process", "all", "messages", "ready", "in", "the", "subscription", "channels", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/monitor.py#L219-L252
[ "def", "process_messages", "(", "self", ",", "max_messages", "=", "10000", ")", ":", "subscribe_clients", "=", "[", "self", ".", "primary_subscribe_client", "]", "for", "subscribe_client", "in", "subscribe_clients", ":", "for", "_", "in", "range", "(", "max_mess...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Monitor._maybe_flush_gcs
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/ray/monitor.py
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): """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", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/monitor.py#L264-L293
[ "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\"", ")"...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Monitor.run
Run the monitor. This function loops forever, checking for messages about dead database clients and cleaning up state accordingly.
python/ray/monitor.py
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): """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...
[ "Run", "the", "monitor", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/monitor.py#L295-L325
[ "def", "run", "(", "self", ")", ":", "# Initialize the subscription channel.", "self", ".", "subscribe", "(", "ray", ".", "gcs_utils", ".", "XRAY_HEARTBEAT_BATCH_CHANNEL", ")", "self", ".", "subscribe", "(", "ray", ".", "gcs_utils", ".", "XRAY_DRIVER_CHANNEL", ")"...
4eade036a0505e244c976f36aaa2d64386b5129b
train
index
View for the home page.
python/ray/tune/automlboard/frontend/view.py
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): """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...
[ "View", "for", "the", "home", "page", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/view.py#L17-L41
[ "def", "index", "(", "request", ")", ":", "recent_jobs", "=", "JobRecord", ".", "objects", ".", "order_by", "(", "\"-start_time\"", ")", "[", "0", ":", "100", "]", "recent_trials", "=", "TrialRecord", ".", "objects", ".", "order_by", "(", "\"-start_time\"", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
job
View for a single job.
python/ray/tune/automlboard/frontend/view.py
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): """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...
[ "View", "for", "a", "single", "job", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/view.py#L44-L74
[ "def", "job", "(", "request", ")", ":", "job_id", "=", "request", ".", "GET", ".", "get", "(", "\"job_id\"", ")", "recent_jobs", "=", "JobRecord", ".", "objects", ".", "order_by", "(", "\"-start_time\"", ")", "[", "0", ":", "100", "]", "recent_trials", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
trial
View for a single trial.
python/ray/tune/automlboard/frontend/view.py
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): """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_...
[ "View", "for", "a", "single", "trial", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/view.py#L77-L97
[ "def", "trial", "(", "request", ")", ":", "job_id", "=", "request", ".", "GET", ".", "get", "(", "\"job_id\"", ")", "trial_id", "=", "request", ".", "GET", ".", "get", "(", "\"trial_id\"", ")", "recent_trials", "=", "TrialRecord", ".", "objects", ".", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
get_job_info
Get job information for current job.
python/ray/tune/automlboard/frontend/view.py
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): """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) ...
[ "Get", "job", "information", "for", "current", "job", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/view.py#L100-L131
[ "def", "get_job_info", "(", "current_job", ")", ":", "trials", "=", "TrialRecord", ".", "objects", ".", "filter", "(", "job_id", "=", "current_job", ".", "job_id", ")", "total_num", "=", "len", "(", "trials", ")", "running_num", "=", "sum", "(", "t", "."...
4eade036a0505e244c976f36aaa2d64386b5129b
train
get_trial_info
Get job information for current trial.
python/ray/tune/automlboard/frontend/view.py
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): """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 ...
[ "Get", "job", "information", "for", "current", "trial", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/view.py#L134-L161
[ "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...
4eade036a0505e244c976f36aaa2d64386b5129b
train
get_winner
Get winner trial of a job.
python/ray/tune/automlboard/frontend/view.py
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): """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): ...
[ "Get", "winner", "trial", "of", "a", "job", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/frontend/view.py#L164-L182
[ "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", "(", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
make_parser
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.
python/ray/tune/config_parser.py
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): """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...
[ "Returns", "a", "base", "argument", "parser", "for", "the", "ray", ".", "tune", "tool", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/config_parser.py#L18-L151
[ "def", "make_parser", "(", "parser_creator", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "parser_creator", ":", "parser", "=", "parser_creator", "(", "*", "*", "kwargs", ")", "else", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "...
4eade036a0505e244c976f36aaa2d64386b5129b
train
to_argv
Converts configuration to a command line argument format.
python/ray/tune/config_parser.py
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): """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 ...
[ "Converts", "configuration", "to", "a", "command", "line", "argument", "format", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/config_parser.py#L154-L170
[ "def", "to_argv", "(", "config", ")", ":", "argv", "=", "[", "]", "for", "k", ",", "v", "in", "config", ".", "items", "(", ")", ":", "if", "\"-\"", "in", "k", ":", "raise", "ValueError", "(", "\"Use '_' instead of '-' in `{}`\"", ".", "format", "(", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
create_trial_from_spec
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. ...
python/ray/tune/config_parser.py
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): """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...
[ "Creates", "a", "Trial", "object", "from", "parsing", "the", "spec", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/config_parser.py#L173-L218
[ "def", "create_trial_from_spec", "(", "spec", ",", "output_path", ",", "parser", ",", "*", "*", "trial_kwargs", ")", ":", "try", ":", "args", "=", "parser", ".", "parse_args", "(", "to_argv", "(", "spec", ")", ")", "except", "SystemExit", ":", "raise", "...
4eade036a0505e244c976f36aaa2d64386b5129b
train
wait_for_compute_zone_operation
Poll for compute zone operation until finished.
python/ray/autoscaler/gcp/node_provider.py
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): """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...
[ "Poll", "for", "compute", "zone", "operation", "until", "finished", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/gcp/node_provider.py#L22-L42
[ "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", "[", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_get_task_id
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...
python/ray/experimental/signal.py
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): """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...
[ "Return", "the", "task", "id", "associated", "to", "the", "generic", "source", "of", "the", "signal", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/signal.py#L36-L54
[ "def", "_get_task_id", "(", "source", ")", ":", "if", "type", "(", "source", ")", "is", "ray", ".", "actor", ".", "ActorHandle", ":", "return", "source", ".", "_ray_actor_id", "else", ":", "if", "type", "(", "source", ")", "is", "ray", ".", "TaskID", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
send
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...
python/ray/experimental/signal.py
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): """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. ...
[ "Send", "signal", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/signal.py#L57-L76
[ "def", "send", "(", "signal", ")", ":", "if", "hasattr", "(", "ray", ".", "worker", ".", "global_worker", ",", "\"actor_creation_task_id\"", ")", ":", "source_key", "=", "ray", ".", "worker", ".", "global_worker", ".", "actor_id", ".", "hex", "(", ")", "...
4eade036a0505e244c976f36aaa2d64386b5129b
train
receive
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...
python/ray/experimental/signal.py
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): """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...
[ "Get", "all", "outstanding", "signals", "from", "sources", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/signal.py#L79-L166
[ "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...
4eade036a0505e244c976f36aaa2d64386b5129b
train
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.
python/ray/experimental/signal.py
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(): """ 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")...
[ "Reset", "the", "worker", "state", "associated", "with", "any", "signals", "that", "this", "worker", "has", "received", "so", "far", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/signal.py#L184-L193
[ "def", "reset", "(", ")", ":", "if", "hasattr", "(", "ray", ".", "worker", ".", "global_worker", ",", "\"signal_counters\"", ")", ":", "ray", ".", "worker", ".", "global_worker", ".", "signal_counters", "=", "defaultdict", "(", "lambda", ":", "b\"0\"", ")"...
4eade036a0505e244c976f36aaa2d64386b5129b
train
log_once
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")
python/ray/rllib/utils/debug.py
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): """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: ...
[ "Returns", "True", "if", "this", "is", "the", "first", "call", "for", "a", "given", "key", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/utils/debug.py#L18-L41
[ "def", "log_once", "(", "key", ")", ":", "global", "_last_logged", "if", "_disabled", ":", "return", "False", "elif", "key", "not", "in", "_logged", ":", "_logged", ".", "add", "(", "key", ")", "_last_logged", "=", "time", ".", "time", "(", ")", "retur...
4eade036a0505e244c976f36aaa2d64386b5129b
train
get
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...
python/ray/experimental/api.py
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): """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...
[ "Get", "a", "single", "or", "a", "collection", "of", "remote", "objects", "from", "the", "object", "store", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/api.py#L9-L38
[ "def", "get", "(", "object_ids", ")", ":", "if", "isinstance", "(", "object_ids", ",", "(", "tuple", ",", "np", ".", "ndarray", ")", ")", ":", "return", "ray", ".", "get", "(", "list", "(", "object_ids", ")", ")", "elif", "isinstance", "(", "object_i...
4eade036a0505e244c976f36aaa2d64386b5129b
train
wait
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 ...
python/ray/experimental/api.py
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): """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...
[ "Return", "a", "list", "of", "IDs", "that", "are", "ready", "and", "a", "list", "of", "IDs", "that", "are", "not", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/api.py#L41-L63
[ "def", "wait", "(", "object_ids", ",", "num_returns", "=", "1", ",", "timeout", "=", "None", ")", ":", "if", "isinstance", "(", "object_ids", ",", "(", "tuple", ",", "np", ".", "ndarray", ")", ")", ":", "return", "ray", ".", "wait", "(", "list", "(...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_raise_deprecation_note
User notification for deprecated parameter. Arguments: deprecated (str): Deprecated parameter. replacement (str): Replacement parameter to use instead. soft (bool): Fatal if True.
python/ray/tune/experiment.py
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): """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...
[ "User", "notification", "for", "deprecated", "parameter", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/experiment.py#L18-L32
[ "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.\"", ".", "...
4eade036a0505e244c976f36aaa2d64386b5129b
train
convert_to_experiment_list
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.
python/ray/tune/experiment.py
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): """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 ...
[ "Produces", "a", "list", "of", "Experiment", "objects", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/experiment.py#L180-L215
[ "def", "convert_to_experiment_list", "(", "experiments", ")", ":", "exp_list", "=", "experiments", "# Transform list if necessary", "if", "experiments", "is", "None", ":", "exp_list", "=", "[", "]", "elif", "isinstance", "(", "experiments", ",", "Experiment", ")", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Experiment.from_json
Generates an Experiment object from JSON. Args: name (str): Name of Experiment. spec (dict): JSON configuration of experiment.
python/ray/tune/experiment.py
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): """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...
[ "Generates", "an", "Experiment", "object", "from", "JSON", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/experiment.py#L118-L142
[ "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...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Experiment._register_if_needed
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...
python/ray/tune/experiment.py
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): """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...
[ "Registers", "Trainable", "or", "Function", "at", "runtime", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/experiment.py#L145-L177
[ "def", "_register_if_needed", "(", "cls", ",", "run_object", ")", ":", "if", "isinstance", "(", "run_object", ",", "six", ".", "string_types", ")", ":", "return", "run_object", "elif", "isinstance", "(", "run_object", ",", "types", ".", "FunctionType", ")", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
tsqr
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 ...
python/ray/experimental/array/distributed/linalg.py
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): """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...
[ "Perform", "a", "QR", "decomposition", "of", "a", "tall", "-", "skinny", "matrix", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/array/distributed/linalg.py#L15-L84
[ "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", ".", "...
4eade036a0505e244c976f36aaa2d64386b5129b
train
modified_lu
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...
python/ray/experimental/array/distributed/linalg.py
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): """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...
[ "Perform", "a", "modified", "LU", "decomposition", "of", "a", "matrix", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/array/distributed/linalg.py#L91-L125
[ "def", "modified_lu", "(", "q", ")", ":", "q", "=", "q", ".", "assemble", "(", ")", "m", ",", "b", "=", "q", ".", "shape", "[", "0", "]", ",", "q", ".", "shape", "[", "1", "]", "S", "=", "np", ".", "zeros", "(", "b", ")", "q_work", "=", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_naturalize
Provides a natural representation for string for nice sorting.
python/ray/tune/trial_runner.py
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): """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]
[ "Provides", "a", "natural", "representation", "for", "string", "for", "nice", "sorting", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L30-L33
[ "def", "_naturalize", "(", "string", ")", ":", "splits", "=", "re", ".", "split", "(", "\"([0-9]+)\"", ",", "string", ")", "return", "[", "int", "(", "text", ")", "if", "text", ".", "isdigit", "(", ")", "else", "text", ".", "lower", "(", ")", "for"...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_find_newest_ckpt
Returns path to most recently modified checkpoint.
python/ray/tune/trial_runner.py
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): """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)
[ "Returns", "path", "to", "most", "recently", "modified", "checkpoint", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L36-L42
[ "def", "_find_newest_ckpt", "(", "ckpt_dir", ")", ":", "full_paths", "=", "[", "os", ".", "path", ".", "join", "(", "ckpt_dir", ",", "fname", ")", "for", "fname", "in", "os", ".", "listdir", "(", "ckpt_dir", ")", "if", "fname", ".", "startswith", "(", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TrialRunner.checkpoint
Saves execution state to `self._metadata_checkpoint_dir`. Overwrites the current session checkpoint, which starts when self is instantiated.
python/ray/tune/trial_runner.py
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): """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...
[ "Saves", "execution", "state", "to", "self", ".", "_metadata_checkpoint_dir", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L167-L193
[ "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",...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TrialRunner.restore
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 ...
python/ray/tune/trial_runner.py
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): """Restores all checkpointed trials from previous run. Requires user to manually re-register their objects. Also stops all ongoing tri...
[ "Restores", "all", "checkpointed", "trials", "from", "previous", "run", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L196-L245
[ "def", "restore", "(", "cls", ",", "metadata_checkpoint_dir", ",", "search_alg", "=", "None", ",", "scheduler", "=", "None", ",", "trial_executor", "=", "None", ")", ":", "newest_ckpt_path", "=", "_find_newest_ckpt", "(", "metadata_checkpoint_dir", ")", "with", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TrialRunner.is_finished
Returns whether all trials have finished running.
python/ray/tune/trial_runner.py
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): """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 ...
[ "Returns", "whether", "all", "trials", "have", "finished", "running", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L247-L256
[ "def", "is_finished", "(", "self", ")", ":", "if", "self", ".", "_total_time", ">", "self", ".", "_global_time_limit", ":", "logger", ".", "warning", "(", "\"Exceeded global time limit {} / {}\"", ".", "format", "(", "self", ".", "_total_time", ",", "self", "....
4eade036a0505e244c976f36aaa2d64386b5129b
train
TrialRunner.step
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().
python/ray/tune/trial_runner.py
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): """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 ...
[ "Runs", "one", "step", "of", "the", "trial", "event", "loop", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L258-L308
[ "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", ".", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TrialRunner.add_trial
Adds a new trial to this TrialRunner. Trials may be added at any time. Args: trial (Trial): Trial to queue.
python/ray/tune/trial_runner.py
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): """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"): ...
[ "Adds", "a", "new", "trial", "to", "this", "TrialRunner", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L322-L334
[ "def", "add_trial", "(", "self", ",", "trial", ")", ":", "trial", ".", "set_verbose", "(", "self", ".", "_verbose", ")", "self", ".", "_trials", ".", "append", "(", "trial", ")", "with", "warn_if_slow", "(", "\"scheduler.on_trial_add\"", ")", ":", "self", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TrialRunner.debug_string
Returns a human readable message for printing to the console.
python/ray/tune/trial_runner.py
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): """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...
[ "Returns", "a", "human", "readable", "message", "for", "printing", "to", "the", "console", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L336-L390
[ "def", "debug_string", "(", "self", ",", "max_debug", "=", "MAX_DEBUG_TRIALS", ")", ":", "messages", "=", "self", ".", "_debug_messages", "(", ")", "states", "=", "collections", ".", "defaultdict", "(", "set", ")", "limit_per_state", "=", "collections", ".", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TrialRunner._get_next_trial
Replenishes queue. Blocks if all trials queued have finished, but search algorithm is still not finished.
python/ray/tune/trial_runner.py
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): """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(...
[ "Replenishes", "queue", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L423-L434
[ "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", ".", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TrialRunner._checkpoint_trial_if_needed
Checkpoints trial based off trial.last_result.
python/ray/tune/trial_runner.py
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): """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)...
[ "Checkpoints", "trial", "based", "off", "trial", ".", "last_result", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L506-L512
[ "def", "_checkpoint_trial_if_needed", "(", "self", ",", "trial", ")", ":", "if", "trial", ".", "should_checkpoint", "(", ")", ":", "# Save trial runtime if possible", "if", "hasattr", "(", "trial", ",", "\"runner\"", ")", "and", "trial", ".", "runner", ":", "s...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TrialRunner._try_recover
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.
python/ray/tune/trial_runner.py
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): """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: ...
[ "Tries", "to", "recover", "trial", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L514-L542
[ "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_...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TrialRunner._requeue_trial
Notification to TrialScheduler and requeue trial. This does not notify the SearchAlgorithm because the function evaluation is still in progress.
python/ray/tune/trial_runner.py
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): """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, ...
[ "Notification", "to", "TrialScheduler", "and", "requeue", "trial", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L544-L553
[ "def", "_requeue_trial", "(", "self", ",", "trial", ")", ":", "self", ".", "_scheduler_alg", ".", "on_trial_error", "(", "self", ",", "trial", ")", "self", ".", "trial_executor", ".", "set_status", "(", "trial", ",", "Trial", ".", "PENDING", ")", "with", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TrialRunner._update_trial_queue
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...
python/ray/tune/trial_runner.py
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): """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...
[ "Adds", "next", "trials", "to", "queue", "if", "possible", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L555-L578
[ "def", "_update_trial_queue", "(", "self", ",", "blocking", "=", "False", ",", "timeout", "=", "600", ")", ":", "trials", "=", "self", ".", "_search_alg", ".", "next_trials", "(", ")", "if", "blocking", "and", "not", "trials", ":", "start", "=", "time", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TrialRunner.stop_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 `on_trial_complete` for scheduler ...
python/ray/tune/trial_runner.py
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): """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 ...
[ "Stops", "trial", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/trial_runner.py#L588-L620
[ "def", "stop_trial", "(", "self", ",", "trial", ")", ":", "error", "=", "False", "error_msg", "=", "None", "if", "trial", ".", "status", "in", "[", "Trial", ".", "ERROR", ",", "Trial", ".", "TERMINATED", "]", ":", "return", "elif", "trial", ".", "sta...
4eade036a0505e244c976f36aaa2d64386b5129b
train
run_func
Helper function for running examples
examples/cython/cython_main.py
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): """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...
[ "Helper", "function", "for", "running", "examples" ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/cython/cython_main.py#L13-L26
[ "def", "run_func", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "ray", ".", "init", "(", ")", "func", "=", "ray", ".", "remote", "(", "func", ")", "# NOTE: kwargs not allowed for now", "result", "=", "ray", ".", "get", "(", "func...
4eade036a0505e244c976f36aaa2d64386b5129b
train
example6
Cython simple class
examples/cython/cython_main.py
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(): """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)
[ "Cython", "simple", "class" ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/cython/cython_main.py#L73-L85
[ "def", "example6", "(", ")", ":", "ray", ".", "init", "(", ")", "cls", "=", "ray", ".", "remote", "(", "cyth", ".", "simple_class", ")", "a1", "=", "cls", ".", "remote", "(", ")", "a2", "=", "cls", ".", "remote", "(", ")", "result1", "=", "ray"...
4eade036a0505e244c976f36aaa2d64386b5129b
train
example8
Cython with blas. NOTE: requires scipy
examples/cython/cython_main.py
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(): """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...
[ "Cython", "with", "blas", ".", "NOTE", ":", "requires", "scipy" ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/examples/cython/cython_main.py#L96-L116
[ "def", "example8", "(", ")", ":", "# See cython_blas.pyx for argument documentation", "mat", "=", "np", ".", "array", "(", "[", "[", "[", "2.0", ",", "2.0", "]", ",", "[", "2.0", ",", "2.0", "]", "]", ",", "[", "[", "2.0", ",", "2.0", "]", ",", "["...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_adjust_nstep
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...
python/ray/rllib/agents/dqn/dqn_policy_graph.py
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): """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 ...
[ "Rewrites", "the", "given", "trajectory", "fragments", "to", "encode", "n", "-", "step", "rewards", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/dqn/dqn_policy_graph.py#L603-L625
[ "def", "_adjust_nstep", "(", "n_step", ",", "gamma", ",", "obs", ",", "actions", ",", "rewards", ",", "new_obs", ",", "dones", ")", ":", "assert", "not", "any", "(", "dones", "[", ":", "-", "1", "]", ")", ",", "\"Unexpected done in middle of trajectory\"",...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_reduce_mean_ignore_inf
Same as tf.reduce_mean() but ignores -inf values.
python/ray/rllib/agents/dqn/dqn_policy_graph.py
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): """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))
[ "Same", "as", "tf", ".", "reduce_mean", "()", "but", "ignores", "-", "inf", "values", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/dqn/dqn_policy_graph.py#L652-L657
[ "def", "_reduce_mean_ignore_inf", "(", "x", ",", "axis", ")", ":", "mask", "=", "tf", ".", "not_equal", "(", "x", ",", "tf", ".", "float32", ".", "min", ")", "x_zeroed", "=", "tf", ".", "where", "(", "mask", ",", "x", ",", "tf", ".", "zeros_like", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_huber_loss
Reference: https://en.wikipedia.org/wiki/Huber_loss
python/ray/rllib/agents/dqn/dqn_policy_graph.py
def _huber_loss(x, delta=1.0): """Reference: https://en.wikipedia.org/wiki/Huber_loss""" return tf.where( tf.abs(x) < delta, tf.square(x) * 0.5, delta * (tf.abs(x) - 0.5 * delta))
def _huber_loss(x, delta=1.0): """Reference: https://en.wikipedia.org/wiki/Huber_loss""" return tf.where( tf.abs(x) < delta, tf.square(x) * 0.5, delta * (tf.abs(x) - 0.5 * delta))
[ "Reference", ":", "https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Huber_loss" ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/dqn/dqn_policy_graph.py#L660-L664
[ "def", "_huber_loss", "(", "x", ",", "delta", "=", "1.0", ")", ":", "return", "tf", ".", "where", "(", "tf", ".", "abs", "(", "x", ")", "<", "delta", ",", "tf", ".", "square", "(", "x", ")", "*", "0.5", ",", "delta", "*", "(", "tf", ".", "a...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_minimize_and_clip
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`
python/ray/rllib/agents/dqn/dqn_policy_graph.py
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): """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) ...
[ "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" ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/dqn/dqn_policy_graph.py#L667-L676
[ "def", "_minimize_and_clip", "(", "optimizer", ",", "objective", ",", "var_list", ",", "clip_val", "=", "10", ")", ":", "gradients", "=", "optimizer", ".", "compute_gradients", "(", "objective", ",", "var_list", "=", "var_list", ")", "for", "i", ",", "(", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_scope_vars
Get variables inside a scope The scope can be specified as a string Parameters ---------- scope: str or VariableScope scope in which the variables reside. trainable_only: bool whether or not to return only the variables that were marked as trainable. Returns ------- v...
python/ray/rllib/agents/dqn/dqn_policy_graph.py
def _scope_vars(scope, trainable_only=False): """ Get variables inside a scope The scope can be specified as a string Parameters ---------- scope: str or VariableScope scope in which the variables reside. trainable_only: bool whether or not to return only the variables that were...
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...
[ "Get", "variables", "inside", "a", "scope", "The", "scope", "can", "be", "specified", "as", "a", "string" ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/dqn/dqn_policy_graph.py#L679-L700
[ "def", "_scope_vars", "(", "scope", ",", "trainable_only", "=", "False", ")", ":", "return", "tf", ".", "get_collection", "(", "tf", ".", "GraphKeys", ".", "TRAINABLE_VARIABLES", "if", "trainable_only", "else", "tf", ".", "GraphKeys", ".", "VARIABLES", ",", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
QNetwork.noisy_layer
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...
python/ray/rllib/agents/dqn/dqn_policy_graph.py
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): """ 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...
[ "a", "common", "dense", "layer", ":", "y", "=", "w^", "{", "T", "}", "x", "+", "b", "a", "noisy", "layer", ":", "y", "=", "(", "w", "+", "\\", "epsilon_w", "*", "\\", "sigma_w", ")", "^", "{", "T", "}", "x", "+", "(", "b", "+", "\\", "eps...
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/dqn/dqn_policy_graph.py#L256-L308
[ "def", "noisy_layer", "(", "self", ",", "prefix", ",", "action_in", ",", "out_size", ",", "sigma0", ",", "non_linear", "=", "True", ")", ":", "in_size", "=", "int", "(", "action_in", ".", "shape", "[", "1", "]", ")", "epsilon_in", "=", "tf", ".", "ra...
4eade036a0505e244c976f36aaa2d64386b5129b
train
ConvNetBuilder.get_custom_getter
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...
python/ray/experimental/sgd/tfbench/convnet_builder.py
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): """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...
[ "Returns", "a", "custom", "getter", "that", "this", "class", "s", "methods", "must", "be", "called" ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L58-L89
[ "def", "get_custom_getter", "(", "self", ")", ":", "def", "inner_custom_getter", "(", "getter", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "use_tf_layers", ":", "return", "getter", "(", "*", "args", ",", "*", "*", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
ConvNetBuilder.switch_to_aux_top_layer
Context that construct cnn in the auxiliary arm.
python/ray/experimental/sgd/tfbench/convnet_builder.py
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): """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...
[ "Context", "that", "construct", "cnn", "in", "the", "auxiliary", "arm", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L92-L104
[ "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", "=",...
4eade036a0505e244c976f36aaa2d64386b5129b
train
ConvNetBuilder.conv
Construct a conv2d layer on top of cnn.
python/ray/experimental/sgd/tfbench/convnet_builder.py
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_norm=None, stddev=None, activation="rel...
[ "Construct", "a", "conv2d", "layer", "on", "top", "of", "cnn", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L143-L243
[ "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...
4eade036a0505e244c976f36aaa2d64386b5129b
train
ConvNetBuilder._pool
Construct a pooling layer.
python/ray/experimental/sgd/tfbench/convnet_builder.py
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): """Construct a pooling layer.""" if input_layer is None: input_layer = self.top_layer else: self.top_size = num_channels_in name = po...
[ "Construct", "a", "pooling", "layer", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L245-L275
[ "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", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
ConvNetBuilder.mpool
Construct a max pooling layer.
python/ray/experimental/sgd/tfbench/convnet_builder.py
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): """Construct a max pooling layer.""" return self._pool("mpool", pooling_layers.max_pooling2d,...
[ "Construct", "a", "max", "pooling", "layer", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L277-L288
[ "def", "mpool", "(", "self", ",", "k_height", ",", "k_width", ",", "d_height", "=", "2", ",", "d_width", "=", "2", ",", "mode", "=", "\"VALID\"", ",", "input_layer", "=", "None", ",", "num_channels_in", "=", "None", ")", ":", "return", "self", ".", "...
4eade036a0505e244c976f36aaa2d64386b5129b
train
ConvNetBuilder.apool
Construct an average pooling layer.
python/ray/experimental/sgd/tfbench/convnet_builder.py
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): """Construct an average pooling layer.""" return self._pool("apool", pooling_layers.average_p...
[ "Construct", "an", "average", "pooling", "layer", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L290-L301
[ "def", "apool", "(", "self", ",", "k_height", ",", "k_width", ",", "d_height", "=", "2", ",", "d_width", "=", "2", ",", "mode", "=", "\"VALID\"", ",", "input_layer", "=", "None", ",", "num_channels_in", "=", "None", ")", ":", "return", "self", ".", "...
4eade036a0505e244c976f36aaa2d64386b5129b
train
ConvNetBuilder._batch_norm_without_layers
Batch normalization on `input_layer` without tf.layers.
python/ray/experimental/sgd/tfbench/convnet_builder.py
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): """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...
[ "Batch", "normalization", "on", "input_layer", "without", "tf", ".", "layers", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L411-L466
[ "def", "_batch_norm_without_layers", "(", "self", ",", "input_layer", ",", "decay", ",", "use_scale", ",", "epsilon", ")", ":", "shape", "=", "input_layer", ".", "shape", "num_channels", "=", "shape", "[", "3", "]", "if", "self", ".", "data_format", "==", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
ConvNetBuilder.batch_norm
Adds a Batch Normalization layer.
python/ray/experimental/sgd/tfbench/convnet_builder.py
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): """Adds a Batch Normalization layer.""" if input_layer is None: input_layer = self.top_layer else: self.top_size = ...
[ "Adds", "a", "Batch", "Normalization", "layer", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L468-L499
[ "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...
4eade036a0505e244c976f36aaa2d64386b5129b
train
ConvNetBuilder.lrn
Adds a local response normalization layer.
python/ray/experimental/sgd/tfbench/convnet_builder.py
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): """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...
[ "Adds", "a", "local", "response", "normalization", "layer", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/sgd/tfbench/convnet_builder.py#L501-L507
[ "def", "lrn", "(", "self", ",", "depth_radius", ",", "bias", ",", "alpha", ",", "beta", ")", ":", "name", "=", "\"lrn\"", "+", "str", "(", "self", ".", "counts", "[", "\"lrn\"", "]", ")", "self", ".", "counts", "[", "\"lrn\"", "]", "+=", "1", "se...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_internal_kv_get
Fetch the value of a binary key.
python/ray/experimental/internal_kv.py
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): """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")
[ "Fetch", "the", "value", "of", "a", "binary", "key", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/internal_kv.py#L15-L22
[ "def", "_internal_kv_get", "(", "key", ")", ":", "worker", "=", "ray", ".", "worker", ".", "get_global_worker", "(", ")", "if", "worker", ".", "mode", "==", "ray", ".", "worker", ".", "LOCAL_MODE", ":", "return", "_local", ".", "get", "(", "key", ")", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
_internal_kv_put
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.
python/ray/experimental/internal_kv.py
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): """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...
[ "Globally", "associates", "a", "value", "with", "a", "given", "binary", "key", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/internal_kv.py#L25-L45
[ "def", "_internal_kv_put", "(", "key", ",", "value", ",", "overwrite", "=", "False", ")", ":", "worker", "=", "ray", ".", "worker", ".", "get_global_worker", "(", ")", "if", "worker", ".", "mode", "==", "ray", ".", "worker", ".", "LOCAL_MODE", ":", "ex...
4eade036a0505e244c976f36aaa2d64386b5129b
train
TreeAggregator.init
Deferred init so that we can pass in previously created workers.
python/ray/rllib/optimizers/aso_tree_aggregator.py
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): """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...
[ "Deferred", "init", "so", "that", "we", "can", "pass", "in", "previously", "created", "workers", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/aso_tree_aggregator.py#L57-L84
[ "def", "init", "(", "self", ",", "aggregators", ")", ":", "assert", "len", "(", "aggregators", ")", "==", "self", ".", "num_aggregation_workers", ",", "aggregators", "if", "len", "(", "self", ".", "remote_evaluators", ")", "<", "self", ".", "num_aggregation_...
4eade036a0505e244c976f36aaa2d64386b5129b
train
free
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...
python/ray/internal/internal_api.py
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): """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...
[ "Free", "a", "list", "of", "IDs", "from", "object", "stores", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/internal/internal_api.py#L11-L55
[ "def", "free", "(", "object_ids", ",", "local_only", "=", "False", ",", "delete_creating_tasks", "=", "False", ")", ":", "worker", "=", "ray", ".", "worker", ".", "get_global_worker", "(", ")", "if", "ray", ".", "worker", ".", "_mode", "(", ")", "==", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
CollectorService.run
Start the collector worker thread. If running in standalone mode, the current thread will wait until the collector thread ends.
python/ray/tune/automlboard/backend/collector.py
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): """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()
[ "Start", "the", "collector", "worker", "thread", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L47-L55
[ "def", "run", "(", "self", ")", ":", "self", ".", "collector", ".", "start", "(", ")", "if", "self", ".", "standalone", ":", "self", ".", "collector", ".", "join", "(", ")" ]
4eade036a0505e244c976f36aaa2d64386b5129b
train
CollectorService.init_logger
Initialize logger settings.
python/ray/tune/automlboard/backend/collector.py
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): """Initialize logger settings.""" logger = logging.getLogger("AutoMLBoard") handler = logging.StreamHandler() formatter = logging.Formatter("[%(levelname)s %(asctime)s] " "%(filename)s: %(lineno)d " ...
[ "Initialize", "logger", "settings", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L62-L72
[ "def", "init_logger", "(", "cls", ",", "log_level", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "\"AutoMLBoard\"", ")", "handler", "=", "logging", ".", "StreamHandler", "(", ")", "formatter", "=", "logging", ".", "Formatter", "(", "\"[%(leveln...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Collector.run
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.
python/ray/tune/automlboard/backend/collector.py
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): """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: ...
[ "Run", "the", "main", "event", "loop", "for", "collector", "thread", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L98-L111
[ "def", "run", "(", "self", ")", ":", "self", ".", "_initialize", "(", ")", "self", ".", "_do_collect", "(", ")", "while", "not", "self", ".", "_is_finished", ":", "time", ".", "sleep", "(", "self", ".", "_reload_interval", ")", "self", ".", "_do_collec...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Collector._initialize
Initialize collector worker thread, Log path will be checked first. Records in DB backend will be cleared.
python/ray/tune/automlboard/backend/collector.py
def _initialize(self): """Initialize collector worker thread, Log path will be checked first. Records in DB backend will be cleared. """ if not os.path.exists(self._logdir): raise CollectorError("Log directory %s not exists" % self._logdir) self.logger.info("Collect...
def _initialize(self): """Initialize collector worker thread, Log path will be checked first. Records in DB backend will be cleared. """ if not os.path.exists(self._logdir): raise CollectorError("Log directory %s not exists" % self._logdir) self.logger.info("Collect...
[ "Initialize", "collector", "worker", "thread", "Log", "path", "will", "be", "checked", "first", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L117-L131
[ "def", "_initialize", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "_logdir", ")", ":", "raise", "CollectorError", "(", "\"Log directory %s not exists\"", "%", "self", ".", "_logdir", ")", "self", ".", "logger", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Collector.sync_job_info
Load information of the job with the given job name. 1. Traverse each experiment sub-directory and sync information for each trial. 2. Create or update the job information, together with the job meta file. Args: job_name (str) name of the Tune experiment
python/ray/tune/automlboard/backend/collector.py
def sync_job_info(self, job_name): """Load information of the job with the given job name. 1. Traverse each experiment sub-directory and sync information for each trial. 2. Create or update the job information, together with the job meta file. Args: jo...
def sync_job_info(self, job_name): """Load information of the job with the given job name. 1. Traverse each experiment sub-directory and sync information for each trial. 2. Create or update the job information, together with the job meta file. Args: jo...
[ "Load", "information", "of", "the", "job", "with", "the", "given", "job", "name", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L140-L165
[ "def", "sync_job_info", "(", "self", ",", "job_name", ")", ":", "job_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_logdir", ",", "job_name", ")", "if", "job_name", "not", "in", "self", ".", "_monitored_jobs", ":", "self", ".", "_creat...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Collector.sync_trial_info
Load information of the trial from the given experiment directory. Create or update the trial information, together with the trial meta file. Args: job_path(str) expr_dir_name(str)
python/ray/tune/automlboard/backend/collector.py
def sync_trial_info(self, job_path, expr_dir_name): """Load information of the trial from the given experiment directory. Create or update the trial information, together with the trial meta file. Args: job_path(str) expr_dir_name(str) """ expr_...
def sync_trial_info(self, job_path, expr_dir_name): """Load information of the trial from the given experiment directory. Create or update the trial information, together with the trial meta file. Args: job_path(str) expr_dir_name(str) """ expr_...
[ "Load", "information", "of", "the", "trial", "from", "the", "given", "experiment", "directory", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L167-L185
[ "def", "sync_trial_info", "(", "self", ",", "job_path", ",", "expr_dir_name", ")", ":", "expr_name", "=", "expr_dir_name", "[", "-", "8", ":", "]", "expr_path", "=", "os", ".", "path", ".", "join", "(", "job_path", ",", "expr_dir_name", ")", "if", "expr_...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Collector._create_job_info
Create information for given job. Meta file will be loaded if exists, and the job information will be saved in db backend. Args: job_dir (str): Directory path of the job.
python/ray/tune/automlboard/backend/collector.py
def _create_job_info(self, job_dir): """Create information for given job. Meta file will be loaded if exists, and the job information will be saved in db backend. Args: job_dir (str): Directory path of the job. """ meta = self._build_job_meta(job_dir) ...
def _create_job_info(self, job_dir): """Create information for given job. Meta file will be loaded if exists, and the job information will be saved in db backend. Args: job_dir (str): Directory path of the job. """ meta = self._build_job_meta(job_dir) ...
[ "Create", "information", "for", "given", "job", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L187-L201
[ "def", "_create_job_info", "(", "self", ",", "job_dir", ")", ":", "meta", "=", "self", ".", "_build_job_meta", "(", "job_dir", ")", "self", ".", "logger", ".", "debug", "(", "\"Create job: %s\"", "%", "meta", ")", "job_record", "=", "JobRecord", ".", "from...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Collector._update_job_info
Update information for given job. Meta file will be loaded if exists, and the job information in in db backend will be updated. Args: job_dir (str): Directory path of the job. Return: Updated dict of job meta info
python/ray/tune/automlboard/backend/collector.py
def _update_job_info(cls, job_dir): """Update information for given job. Meta file will be loaded if exists, and the job information in in db backend will be updated. Args: job_dir (str): Directory path of the job. Return: Updated dict of job meta info ...
def _update_job_info(cls, job_dir): """Update information for given job. Meta file will be loaded if exists, and the job information in in db backend will be updated. Args: job_dir (str): Directory path of the job. Return: Updated dict of job meta info ...
[ "Update", "information", "for", "given", "job", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L204-L223
[ "def", "_update_job_info", "(", "cls", ",", "job_dir", ")", ":", "meta_file", "=", "os", ".", "path", ".", "join", "(", "job_dir", ",", "JOB_META_FILE", ")", "meta", "=", "parse_json", "(", "meta_file", ")", "if", "meta", ":", "logging", ".", "debug", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Collector._create_trial_info
Create information for given trial. Meta file will be loaded if exists, and the trial information will be saved in db backend. Args: expr_dir (str): Directory path of the experiment.
python/ray/tune/automlboard/backend/collector.py
def _create_trial_info(self, expr_dir): """Create information for given trial. Meta file will be loaded if exists, and the trial information will be saved in db backend. Args: expr_dir (str): Directory path of the experiment. """ meta = self._build_trial_met...
def _create_trial_info(self, expr_dir): """Create information for given trial. Meta file will be loaded if exists, and the trial information will be saved in db backend. Args: expr_dir (str): Directory path of the experiment. """ meta = self._build_trial_met...
[ "Create", "information", "for", "given", "trial", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L225-L239
[ "def", "_create_trial_info", "(", "self", ",", "expr_dir", ")", ":", "meta", "=", "self", ".", "_build_trial_meta", "(", "expr_dir", ")", "self", ".", "logger", ".", "debug", "(", "\"Create trial for %s\"", "%", "meta", ")", "trial_record", "=", "TrialRecord",...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Collector._update_trial_info
Update information for given trial. Meta file will be loaded if exists, and the trial information in db backend will be updated. Args: expr_dir(str)
python/ray/tune/automlboard/backend/collector.py
def _update_trial_info(self, expr_dir): """Update information for given trial. Meta file will be loaded if exists, and the trial information in db backend will be updated. Args: expr_dir(str) """ trial_id = expr_dir[-8:] meta_file = os.path.join(exp...
def _update_trial_info(self, expr_dir): """Update information for given trial. Meta file will be loaded if exists, and the trial information in db backend will be updated. Args: expr_dir(str) """ trial_id = expr_dir[-8:] meta_file = os.path.join(exp...
[ "Update", "information", "for", "given", "trial", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L241-L281
[ "def", "_update_trial_info", "(", "self", ",", "expr_dir", ")", ":", "trial_id", "=", "expr_dir", "[", "-", "8", ":", "]", "meta_file", "=", "os", ".", "path", ".", "join", "(", "expr_dir", ",", "EXPR_META_FILE", ")", "meta", "=", "parse_json", "(", "m...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Collector._build_job_meta
Build meta file for job. Args: job_dir (str): Directory path of the job. Return: A dict of job meta info.
python/ray/tune/automlboard/backend/collector.py
def _build_job_meta(cls, job_dir): """Build meta file for job. Args: job_dir (str): Directory path of the job. Return: A dict of job meta info. """ meta_file = os.path.join(job_dir, JOB_META_FILE) meta = parse_json(meta_file) if not meta...
def _build_job_meta(cls, job_dir): """Build meta file for job. Args: job_dir (str): Directory path of the job. Return: A dict of job meta info. """ meta_file = os.path.join(job_dir, JOB_META_FILE) meta = parse_json(meta_file) if not meta...
[ "Build", "meta", "file", "for", "job", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L284-L312
[ "def", "_build_job_meta", "(", "cls", ",", "job_dir", ")", ":", "meta_file", "=", "os", ".", "path", ".", "join", "(", "job_dir", ",", "JOB_META_FILE", ")", "meta", "=", "parse_json", "(", "meta_file", ")", "if", "not", "meta", ":", "job_name", "=", "j...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Collector._build_trial_meta
Build meta file for trial. Args: expr_dir (str): Directory path of the experiment. Return: A dict of trial meta info.
python/ray/tune/automlboard/backend/collector.py
def _build_trial_meta(cls, expr_dir): """Build meta file for trial. Args: expr_dir (str): Directory path of the experiment. Return: A dict of trial meta info. """ meta_file = os.path.join(expr_dir, EXPR_META_FILE) meta = parse_json(meta_file) ...
def _build_trial_meta(cls, expr_dir): """Build meta file for trial. Args: expr_dir (str): Directory path of the experiment. Return: A dict of trial meta info. """ meta_file = os.path.join(expr_dir, EXPR_META_FILE) meta = parse_json(meta_file) ...
[ "Build", "meta", "file", "for", "trial", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L315-L354
[ "def", "_build_trial_meta", "(", "cls", ",", "expr_dir", ")", ":", "meta_file", "=", "os", ".", "path", ".", "join", "(", "expr_dir", ",", "EXPR_META_FILE", ")", "meta", "=", "parse_json", "(", "meta_file", ")", "if", "not", "meta", ":", "job_id", "=", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Collector._add_results
Add a list of results into db. Args: results (list): A list of json results. trial_id (str): Id of the trial.
python/ray/tune/automlboard/backend/collector.py
def _add_results(self, results, trial_id): """Add a list of results into db. Args: results (list): A list of json results. trial_id (str): Id of the trial. """ for result in results: self.logger.debug("Appending result: %s" % result) resul...
def _add_results(self, results, trial_id): """Add a list of results into db. Args: results (list): A list of json results. trial_id (str): Id of the trial. """ for result in results: self.logger.debug("Appending result: %s" % result) resul...
[ "Add", "a", "list", "of", "results", "into", "db", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/automlboard/backend/collector.py#L356-L367
[ "def", "_add_results", "(", "self", ",", "results", ",", "trial_id", ")", ":", "for", "result", "in", "results", ":", "self", ".", "logger", ".", "debug", "(", "\"Appending result: %s\"", "%", "result", ")", "result", "[", "\"trial_id\"", "]", "=", "trial_...
4eade036a0505e244c976f36aaa2d64386b5129b
train
add_time_dimension
Adds a time dimension to padded inputs. Arguments: padded_inputs (Tensor): a padded batch of sequences. That is, for seq_lens=[1, 2, 2], then inputs=[A, *, B, B, C, C], where A, B, C are sequence elements and * denotes padding. seq_lens (Tensor): the sequence lengths within ...
python/ray/rllib/models/lstm.py
def add_time_dimension(padded_inputs, seq_lens): """Adds a time dimension to padded inputs. Arguments: padded_inputs (Tensor): a padded batch of sequences. That is, for seq_lens=[1, 2, 2], then inputs=[A, *, B, B, C, C], where A, B, C are sequence elements and * denotes padding....
def add_time_dimension(padded_inputs, seq_lens): """Adds a time dimension to padded inputs. Arguments: padded_inputs (Tensor): a padded batch of sequences. That is, for seq_lens=[1, 2, 2], then inputs=[A, *, B, B, C, C], where A, B, C are sequence elements and * denotes padding....
[ "Adds", "a", "time", "dimension", "to", "padded", "inputs", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/models/lstm.py#L95-L119
[ "def", "add_time_dimension", "(", "padded_inputs", ",", "seq_lens", ")", ":", "# Sequence lengths have to be specified for LSTM batch inputs. The", "# input batch must be padded to the max seq length given here. That is,", "# batch_size == len(seq_lens) * max(seq_lens)", "padded_batch_size", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
chop_into_sequences
Truncate and pad experiences into fixed-length sequences. Arguments: episode_ids (list): List of episode ids for each step. unroll_ids (list): List of identifiers for the sample batch. This is used to make sure sequences are cut between sample batches. agent_indices (list): List...
python/ray/rllib/models/lstm.py
def chop_into_sequences(episode_ids, unroll_ids, agent_indices, feature_columns, state_columns, max_seq_len, dynamic_max=True, _extra_padding=0): ""...
def chop_into_sequences(episode_ids, unroll_ids, agent_indices, feature_columns, state_columns, max_seq_len, dynamic_max=True, _extra_padding=0): ""...
[ "Truncate", "and", "pad", "experiences", "into", "fixed", "-", "length", "sequences", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/models/lstm.py#L123-L217
[ "def", "chop_into_sequences", "(", "episode_ids", ",", "unroll_ids", ",", "agent_indices", ",", "feature_columns", ",", "state_columns", ",", "max_seq_len", ",", "dynamic_max", "=", "True", ",", "_extra_padding", "=", "0", ")", ":", "prev_id", "=", "None", "seq_...
4eade036a0505e244c976f36aaa2d64386b5129b
train
explore
Return a config perturbed as specified. Args: config (dict): Original hyperparameter configuration. mutations (dict): Specification of mutations to perform as documented in the PopulationBasedTraining scheduler. resample_probability (float): Probability of allowing resampling of...
python/ray/tune/schedulers/pbt.py
def explore(config, mutations, resample_probability, custom_explore_fn): """Return a config perturbed as specified. Args: config (dict): Original hyperparameter configuration. mutations (dict): Specification of mutations to perform as documented in the PopulationBasedTraining schedu...
def explore(config, mutations, resample_probability, custom_explore_fn): """Return a config perturbed as specified. Args: config (dict): Original hyperparameter configuration. mutations (dict): Specification of mutations to perform as documented in the PopulationBasedTraining schedu...
[ "Return", "a", "config", "perturbed", "as", "specified", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/pbt.py#L41-L87
[ "def", "explore", "(", "config", ",", "mutations", ",", "resample_probability", ",", "custom_explore_fn", ")", ":", "new_config", "=", "copy", ".", "deepcopy", "(", "config", ")", "for", "key", ",", "distribution", "in", "mutations", ".", "items", "(", ")", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
make_experiment_tag
Appends perturbed params to the trial name to show in the console.
python/ray/tune/schedulers/pbt.py
def make_experiment_tag(orig_tag, config, mutations): """Appends perturbed params to the trial name to show in the console.""" resolved_vars = {} for k in mutations.keys(): resolved_vars[("config", k)] = config[k] return "{}@perturbed[{}]".format(orig_tag, format_vars(resolved_vars))
def make_experiment_tag(orig_tag, config, mutations): """Appends perturbed params to the trial name to show in the console.""" resolved_vars = {} for k in mutations.keys(): resolved_vars[("config", k)] = config[k] return "{}@perturbed[{}]".format(orig_tag, format_vars(resolved_vars))
[ "Appends", "perturbed", "params", "to", "the", "trial", "name", "to", "show", "in", "the", "console", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/pbt.py#L90-L96
[ "def", "make_experiment_tag", "(", "orig_tag", ",", "config", ",", "mutations", ")", ":", "resolved_vars", "=", "{", "}", "for", "k", "in", "mutations", ".", "keys", "(", ")", ":", "resolved_vars", "[", "(", "\"config\"", ",", "k", ")", "]", "=", "conf...
4eade036a0505e244c976f36aaa2d64386b5129b
train
PopulationBasedTraining._log_config_on_step
Logs transition during exploit/exploit step. For each step, logs: [target trial tag, clone trial tag, target trial iteration, clone trial iteration, old config, new config].
python/ray/tune/schedulers/pbt.py
def _log_config_on_step(self, trial_state, new_state, trial, trial_to_clone, new_config): """Logs transition during exploit/exploit step. For each step, logs: [target trial tag, clone trial tag, target trial iteration, clone trial iteration, old config, new config]. ...
def _log_config_on_step(self, trial_state, new_state, trial, trial_to_clone, new_config): """Logs transition during exploit/exploit step. For each step, logs: [target trial tag, clone trial tag, target trial iteration, clone trial iteration, old config, new config]. ...
[ "Logs", "transition", "during", "exploit", "/", "exploit", "step", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/pbt.py#L225-L256
[ "def", "_log_config_on_step", "(", "self", ",", "trial_state", ",", "new_state", ",", "trial", ",", "trial_to_clone", ",", "new_config", ")", ":", "trial_name", ",", "trial_to_clone_name", "=", "(", "trial_state", ".", "orig_tag", ",", "new_state", ".", "orig_ta...
4eade036a0505e244c976f36aaa2d64386b5129b
train
PopulationBasedTraining._exploit
Transfers perturbed state from trial_to_clone -> trial. If specified, also logs the updated hyperparam state.
python/ray/tune/schedulers/pbt.py
def _exploit(self, trial_executor, trial, trial_to_clone): """Transfers perturbed state from trial_to_clone -> trial. If specified, also logs the updated hyperparam state.""" trial_state = self._trial_state[trial] new_state = self._trial_state[trial_to_clone] if not new_state.l...
def _exploit(self, trial_executor, trial, trial_to_clone): """Transfers perturbed state from trial_to_clone -> trial. If specified, also logs the updated hyperparam state.""" trial_state = self._trial_state[trial] new_state = self._trial_state[trial_to_clone] if not new_state.l...
[ "Transfers", "perturbed", "state", "from", "trial_to_clone", "-", ">", "trial", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/pbt.py#L258-L297
[ "def", "_exploit", "(", "self", ",", "trial_executor", ",", "trial", ",", "trial_to_clone", ")", ":", "trial_state", "=", "self", ".", "_trial_state", "[", "trial", "]", "new_state", "=", "self", ".", "_trial_state", "[", "trial_to_clone", "]", "if", "not", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
PopulationBasedTraining._quantiles
Returns trials in the lower and upper `quantile` of the population. If there is not enough data to compute this, returns empty lists.
python/ray/tune/schedulers/pbt.py
def _quantiles(self): """Returns trials in the lower and upper `quantile` of the population. If there is not enough data to compute this, returns empty lists.""" trials = [] for trial, state in self._trial_state.items(): if state.last_score is not None and not trial.is_fini...
def _quantiles(self): """Returns trials in the lower and upper `quantile` of the population. If there is not enough data to compute this, returns empty lists.""" trials = [] for trial, state in self._trial_state.items(): if state.last_score is not None and not trial.is_fini...
[ "Returns", "trials", "in", "the", "lower", "and", "upper", "quantile", "of", "the", "population", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/pbt.py#L299-L314
[ "def", "_quantiles", "(", "self", ")", ":", "trials", "=", "[", "]", "for", "trial", ",", "state", "in", "self", ".", "_trial_state", ".", "items", "(", ")", ":", "if", "state", ".", "last_score", "is", "not", "None", "and", "not", "trial", ".", "i...
4eade036a0505e244c976f36aaa2d64386b5129b
train
PopulationBasedTraining.choose_trial_to_run
Ensures all trials get fair share of time (as defined by time_attr). This enables the PBT scheduler to support a greater number of concurrent trials than can fit in the cluster at any given time.
python/ray/tune/schedulers/pbt.py
def choose_trial_to_run(self, trial_runner): """Ensures all trials get fair share of time (as defined by time_attr). This enables the PBT scheduler to support a greater number of concurrent trials than can fit in the cluster at any given time. """ candidates = [] for tr...
def choose_trial_to_run(self, trial_runner): """Ensures all trials get fair share of time (as defined by time_attr). This enables the PBT scheduler to support a greater number of concurrent trials than can fit in the cluster at any given time. """ candidates = [] for tr...
[ "Ensures", "all", "trials", "get", "fair", "share", "of", "time", "(", "as", "defined", "by", "time_attr", ")", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/schedulers/pbt.py#L316-L330
[ "def", "choose_trial_to_run", "(", "self", ",", "trial_runner", ")", ":", "candidates", "=", "[", "]", "for", "trial", "in", "trial_runner", ".", "get_trials", "(", ")", ":", "if", "trial", ".", "status", "in", "[", "Trial", ".", "PENDING", ",", "Trial",...
4eade036a0505e244c976f36aaa2d64386b5129b
train
key_pair
Returns the ith default (aws_key_pair_name, key_pair_path).
python/ray/autoscaler/aws/config.py
def key_pair(i, region): """Returns the ith default (aws_key_pair_name, key_pair_path).""" if i == 0: return ("{}_{}".format(RAY, region), os.path.expanduser("~/.ssh/{}_{}.pem".format(RAY, region))) return ("{}_{}_{}".format(RAY, i, region), os.path.expanduser("~/.ssh/{}_...
def key_pair(i, region): """Returns the ith default (aws_key_pair_name, key_pair_path).""" if i == 0: return ("{}_{}".format(RAY, region), os.path.expanduser("~/.ssh/{}_{}.pem".format(RAY, region))) return ("{}_{}_{}".format(RAY, i, region), os.path.expanduser("~/.ssh/{}_...
[ "Returns", "the", "ith", "default", "(", "aws_key_pair_name", "key_pair_path", ")", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/autoscaler/aws/config.py#L28-L34
[ "def", "key_pair", "(", "i", ",", "region", ")", ":", "if", "i", "==", "0", ":", "return", "(", "\"{}_{}\"", ".", "format", "(", "RAY", ",", "region", ")", ",", "os", ".", "path", ".", "expanduser", "(", "\"~/.ssh/{}_{}.pem\"", ".", "format", "(", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
FullyConnectedNetwork._build_layers
Process the flattened inputs. Note that dict inputs will be flattened into a vector. To define a model that processes the components separately, use _build_layers_v2().
python/ray/rllib/models/fcnet.py
def _build_layers(self, inputs, num_outputs, options): """Process the flattened inputs. Note that dict inputs will be flattened into a vector. To define a model that processes the components separately, use _build_layers_v2(). """ hiddens = options.get("fcnet_hiddens") ...
def _build_layers(self, inputs, num_outputs, options): """Process the flattened inputs. Note that dict inputs will be flattened into a vector. To define a model that processes the components separately, use _build_layers_v2(). """ hiddens = options.get("fcnet_hiddens") ...
[ "Process", "the", "flattened", "inputs", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/models/fcnet.py#L17-L46
[ "def", "_build_layers", "(", "self", ",", "inputs", ",", "num_outputs", ",", "options", ")", ":", "hiddens", "=", "options", ".", "get", "(", "\"fcnet_hiddens\"", ")", "activation", "=", "get_activation_fn", "(", "options", ".", "get", "(", "\"fcnet_activation...
4eade036a0505e244c976f36aaa2d64386b5129b
train
with_base_config
Returns the given config dict merged with a base agent conf.
python/ray/rllib/agents/trainer.py
def with_base_config(base_config, extra_config): """Returns the given config dict merged with a base agent conf.""" config = copy.deepcopy(base_config) config.update(extra_config) return config
def with_base_config(base_config, extra_config): """Returns the given config dict merged with a base agent conf.""" config = copy.deepcopy(base_config) config.update(extra_config) return config
[ "Returns", "the", "given", "config", "dict", "merged", "with", "a", "base", "agent", "conf", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/trainer.py#L241-L246
[ "def", "with_base_config", "(", "base_config", ",", "extra_config", ")", ":", "config", "=", "copy", ".", "deepcopy", "(", "base_config", ")", "config", ".", "update", "(", "extra_config", ")", "return", "config" ]
4eade036a0505e244c976f36aaa2d64386b5129b
train
get_agent_class
Returns the class of a known agent given its name.
python/ray/rllib/agents/registry.py
def get_agent_class(alg): """Returns the class of a known agent given its name.""" try: return _get_agent_class(alg) except ImportError: from ray.rllib.agents.mock import _agent_import_failed return _agent_import_failed(traceback.format_exc())
def get_agent_class(alg): """Returns the class of a known agent given its name.""" try: return _get_agent_class(alg) except ImportError: from ray.rllib.agents.mock import _agent_import_failed return _agent_import_failed(traceback.format_exc())
[ "Returns", "the", "class", "of", "a", "known", "agent", "given", "its", "name", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/registry.py#L112-L119
[ "def", "get_agent_class", "(", "alg", ")", ":", "try", ":", "return", "_get_agent_class", "(", "alg", ")", "except", "ImportError", ":", "from", "ray", ".", "rllib", ".", "agents", ".", "mock", "import", "_agent_import_failed", "return", "_agent_import_failed", ...
4eade036a0505e244c976f36aaa2d64386b5129b
train
determine_ip_address
Return the first IP address for an ethernet interface on the system.
python/ray/reporter.py
def determine_ip_address(): """Return the first IP address for an ethernet interface on the system.""" addrs = [ x.address for k, v in psutil.net_if_addrs().items() if k[0] == "e" for x in v if x.family == AddressFamily.AF_INET ] return addrs[0]
def determine_ip_address(): """Return the first IP address for an ethernet interface on the system.""" addrs = [ x.address for k, v in psutil.net_if_addrs().items() if k[0] == "e" for x in v if x.family == AddressFamily.AF_INET ] return addrs[0]
[ "Return", "the", "first", "IP", "address", "for", "an", "ethernet", "interface", "on", "the", "system", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/reporter.py#L61-L67
[ "def", "determine_ip_address", "(", ")", ":", "addrs", "=", "[", "x", ".", "address", "for", "k", ",", "v", "in", "psutil", ".", "net_if_addrs", "(", ")", ".", "items", "(", ")", "if", "k", "[", "0", "]", "==", "\"e\"", "for", "x", "in", "v", "...
4eade036a0505e244c976f36aaa2d64386b5129b
train
Reporter.perform_iteration
Get any changes to the log files and push updates to Redis.
python/ray/reporter.py
def perform_iteration(self): """Get any changes to the log files and push updates to Redis.""" stats = self.get_all_stats() self.redis_client.publish( self.redis_key, jsonify_asdict(stats), )
def perform_iteration(self): """Get any changes to the log files and push updates to Redis.""" stats = self.get_all_stats() self.redis_client.publish( self.redis_key, jsonify_asdict(stats), )
[ "Get", "any", "changes", "to", "the", "log", "files", "and", "push", "updates", "to", "Redis", "." ]
ray-project/ray
python
https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/reporter.py#L163-L170
[ "def", "perform_iteration", "(", "self", ")", ":", "stats", "=", "self", ".", "get_all_stats", "(", ")", "self", ".", "redis_client", ".", "publish", "(", "self", ".", "redis_key", ",", "jsonify_asdict", "(", "stats", ")", ",", ")" ]
4eade036a0505e244c976f36aaa2d64386b5129b