-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve ray.tune
usage example.
#209
Changes from 11 commits
b14fd61
d56893e
50780d1
a9a4fbe
140f5b0
93255f2
0845f64
d64895b
3d72df8
56761bb
9eed66b
b2aa9dc
0e9bf5b
32dd02b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
+1,296 −0 | notebooks/deconv_tv_admm_tune.ipynb | |
+456 −318 | notebooks/sparsecode_poisson_pgm.ipynb | |
+108 −234 | notebooks/video_rpca_admm.ipynb |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
# Copyright (C) 2021 by SCICO Developers | ||
# Copyright (C) 2021-2022 by SCICO Developers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For other files, should the end year be the current year or the year the file was last edited on? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding is that the end year should correspond to the year of most recent edit. I think we can live with manual updates for now. |
||
# All rights reserved. BSD 3-clause License. | ||
# This file is part of the SCICO package. Details of the copyright and | ||
# user license can be found in the 'LICENSE' file distributed with the | ||
|
@@ -8,6 +8,8 @@ | |
"""Parameter tuning using :doc:`ray.tune <ray:tune/index>`.""" | ||
|
||
import datetime | ||
import os | ||
import tempfile | ||
from typing import Any, Callable, Dict, List, Mapping, Optional, Type, Union | ||
|
||
import ray | ||
|
@@ -71,6 +73,7 @@ def run( | |
config: Optional[Dict[str, Any]] = None, | ||
hyperopt: bool = True, | ||
verbose: bool = True, | ||
local_dir: Optional[str] = None, | ||
) -> ray.tune.ExperimentAnalysis: | ||
"""Simplified wrapper for :func:`ray.tune.run`. | ||
|
||
|
@@ -97,6 +100,10 @@ def run( | |
running, and terminated trials are indicated by "P:", "R:", | ||
and "T:" respectively, followed by the current best metric | ||
value and the parameters at which it was reported. | ||
local_dir: Directory in which to save tuning results. Defaults to | ||
a subdirectory "ray_results" within the path returned by | ||
`tempfile.gettempdir()`, corresponding e.g. to | ||
"/tmp/ray_results" under Linux. | ||
|
||
Returns: | ||
Result of parameter search. | ||
|
@@ -114,15 +121,23 @@ def run( | |
else: | ||
kwargs.update({"verbose": 0}) | ||
|
||
def _run(config, checkpoint_dir=None): | ||
run_or_experiment(config) | ||
if isinstance(run_or_experiment, str): | ||
name = run_or_experiment | ||
else: | ||
name = run_or_experiment.__name__ | ||
name += "_" + datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S") | ||
|
||
if local_dir is None: | ||
local_dir = os.path.join(tempfile.gettempdir(), "ray_results") | ||
|
||
return ray.tune.run( | ||
_run, | ||
run_or_experiment, | ||
metric=metric, | ||
mode=mode, | ||
name=name, | ||
time_budget_s=time_budget_s, | ||
num_samples=num_samples, | ||
local_dir=local_dir, | ||
resources_per_trial=resources_per_trial, | ||
max_concurrent_trials=max_concurrent_trials, | ||
reuse_actors=True, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you remove the example related dependencies? I don't think these are there anywhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be a continual pain until #195 is addressed. I'll fix manually for now.