示例#1
0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
from __future__ import division

import itertools

from guild import batch_util


def gen_trials(flags, _batch=None):
    flag_list = [
        _trial_flags(name, val) for name, val in sorted(flags.items())
    ]
    return [dict(trial) for trial in itertools.product(*flag_list)]


def _trial_flags(flag_name, flag_val):
    if isinstance(flag_val, list):
        return [(flag_name, trial_val) for trial_val in flag_val]
    return [(flag_name, flag_val)]


if __name__ == "__main__":
    batch_util.default_main(gen_trials)
示例#2
0
def _validate_min_max(val, dist_name, flag_name):
    if dist_name not in (None, "uniform"):
        raise batch_util.BatchError(
            "unsupported distribution %r for flag %s - must be 'uniform'" %
            (dist_name, flag_name))
    if len(val) != 2:
        raise batch_util.BatchError(
            "unexpected arguemt list %r for flag %s - expected 2 arguments" %
            (val, flag_name))


def _gen_trial_vals(dims, num_trials, random_seed):
    import skopt
    res = skopt.dummy_minimize(lambda *args: 0,
                               dims,
                               n_calls=num_trials,
                               random_state=random_seed)
    return res.x_iters


def _patch_numpy_deprecation_warnings():
    warnings.filterwarnings("ignore", category=Warning)
    # pylint: disable=unused-variable
    import numpy.core.umath_tests


if __name__ == "__main__":
    _patch_numpy_deprecation_warnings()
    batch_util.default_main(_gen_batch_trials)
示例#3
0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import absolute_import
from __future__ import division

import itertools

from guild import batch_util


def gen_trials(flags, _batch=None):
    flag_list = [
        _trial_flags(name, val) for name, val in sorted(flags.items())
    ]
    return [dict(trial) for trial in itertools.product(*flag_list)]


def _trial_flags(flag_name, flag_val):
    if isinstance(flag_val, list):
        return [(flag_name, trial_val) for trial_val in flag_val]
    return [(flag_name, flag_val)]


if __name__ == "__main__":
    batch_util.default_main(gen_trials, default_max_trials=None)