repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
deephyper | deephyper-master/deephyper/skopt/acquisition.py | import numpy as np
import warnings
from scipy.stats import norm
def gaussian_acquisition_1D(
X, model, y_opt=None, acq_func="LCB", acq_func_kwargs=None, return_grad=True
):
"""
A wrapper around the acquisition function that is called by fmin_l_bfgs_b.
This is because lbfgs allows only 1-D input.
... | 10,975 | 32.160121 | 87 | py |
deephyper | deephyper-master/deephyper/skopt/benchmarks.py | # -*- coding: utf-8 -*-
"""A collection of benchmark problems."""
import numpy as np
def bench1(x):
"""A benchmark function for test purposes.
f(x) = x ** 2
It has a single minima with f(x*) = 0 at x* = 0.
"""
return x[0] ** 2
def bench1_with_time(x):
"""Same as bench1 but returns the... | 2,888 | 24.342105 | 87 | py |
deephyper | deephyper-master/deephyper/skopt/searchcv.py | import warnings
import numpy as np
from scipy.stats import rankdata
from sklearn.model_selection._search import BaseSearchCV
from sklearn.utils import check_random_state
from sklearn.utils.validation import check_is_fitted
from . import Optimizer
from .utils import point_asdict, dimensions_aslist, eval_callbacks
fr... | 20,969 | 38.269663 | 85 | py |
deephyper | deephyper-master/deephyper/skopt/utils.py | from copy import deepcopy
from functools import wraps
import numpy as np
from scipy.optimize import OptimizeResult
from scipy.optimize import minimize as sp_minimize
from sklearn.base import is_regressor
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.preprocessing import FunctionTransformer
from sk... | 28,832 | 32.881316 | 110 | py |
deephyper | deephyper-master/deephyper/skopt/plots.py | # -*- encoding: UTF-8 -*-
"""Plotting functions."""
import sys
import numpy as np
from itertools import count
from functools import partial
from scipy.optimize import OptimizeResult
from .acquisition import _gaussian_acquisition
from deephyper.skopt import expected_minimum, expected_minimum_random_sampling
from .space... | 51,772 | 34.076558 | 88 | py |
deephyper | deephyper-master/deephyper/skopt/__init__.py | """
Scikit-Optimize, or `skopt`, is a simple and efficient library to
minimize (very) expensive and noisy black-box functions. It implements
several methods for sequential model-based optimization. `skopt` is reusable
in many contexts and accessible.
"""
try:
# This variable is injected in the __builtins__ by the b... | 2,304 | 26.440476 | 76 | py |
deephyper | deephyper-master/deephyper/skopt/space/transformers.py | from __future__ import division
import numpy as np
from sklearn.preprocessing import LabelBinarizer
class Transformer(object):
"""Base class for all 1-D transformers."""
def fit(self, X):
return self
def transform(self, X):
raise NotImplementedError
def inverse_transform(self, X):
... | 8,914 | 26.600619 | 85 | py |
deephyper | deephyper-master/deephyper/skopt/space/space.py | import numbers
import numpy as np
import yaml
from scipy.stats.distributions import randint
from scipy.stats.distributions import rv_discrete
from scipy.stats.distributions import uniform, truncnorm
from sklearn.utils import check_random_state
from sklearn.utils.fixes import sp_version
if type(sp_version) is not tu... | 48,902 | 32.154576 | 131 | py |
deephyper | deephyper-master/deephyper/skopt/space/__init__.py | """
Utilities to define a search space.
"""
from .space import * # noqa: F401, F403
| 86 | 13.5 | 40 | py |
deephyper | deephyper-master/deephyper/skopt/sampler/base.py | class InitialPointGenerator(object):
def generate(self, dimensions, n_samples, random_state=None):
raise NotImplementedError
def set_params(self, **params):
"""
Set the parameters of this initial point generator.
Parameters
----------
**params : dict
... | 655 | 25.24 | 65 | py |
deephyper | deephyper-master/deephyper/skopt/sampler/lhs.py | """
Lhs functions are inspired by
https://github.com/clicumu/pyDOE2/blob/
master/pyDOE2/doe_lhs.py
"""
import numpy as np
from sklearn.utils import check_random_state
from scipy import spatial
from ..space import Space
from .base import InitialPointGenerator
def _random_permute_matrix(h, random_state=None):
rng =... | 5,671 | 37.585034 | 84 | py |
deephyper | deephyper-master/deephyper/skopt/sampler/hammersly.py | # -*- coding: utf-8 -*-
""" Inspired by https://github.com/jonathf/chaospy/blob/master/chaospy/
distributions/sampler/sequences/hammersley.py
"""
import numpy as np
from .halton import Halton
from ..space import Space
from .base import InitialPointGenerator
from sklearn.utils import check_random_state
class Hammersly... | 3,556 | 34.217822 | 78 | py |
deephyper | deephyper-master/deephyper/skopt/sampler/sobol.py | """
Authors:
Original FORTRAN77 version of i4_sobol by Bennett Fox.
MATLAB version by John Burkardt.
PYTHON version by Corrado Chisari
Original Python version of is_prime by Corrado Chisari
Original MATLAB versions of other functions by John Burkardt.
PYTHON versions by Corrado Chisari
... | 18,637 | 25.103641 | 79 | py |
deephyper | deephyper-master/deephyper/skopt/sampler/grid.py | """
Inspired by https://github.com/jonathf/chaospy/blob/master/chaospy/
distributions/sampler/sequences/grid.py
"""
import numpy as np
from .base import InitialPointGenerator
from ..space import Space
from sklearn.utils import check_random_state
def _quadrature_combine(args):
args = [np.asarray(arg).reshape(len(a... | 6,274 | 35.482558 | 85 | py |
deephyper | deephyper-master/deephyper/skopt/sampler/halton.py | """
Inspired by https://github.com/jonathf/chaospy/blob/master/chaospy/
distributions/sampler/sequences/halton.py
"""
import numpy as np
from .base import InitialPointGenerator
from ..space import Space
from sklearn.utils import check_random_state
class Halton(InitialPointGenerator):
"""Creates `Halton` sequence ... | 5,951 | 31.52459 | 82 | py |
deephyper | deephyper-master/deephyper/skopt/sampler/__init__.py | """
Utilities for generating initial sequences
"""
from .lhs import Lhs
from .sobol import Sobol
from .halton import Halton
from .hammersly import Hammersly
from .grid import Grid
from .base import InitialPointGenerator
__all__ = ["Lhs", "Sobol", "Halton", "Hammersly", "Grid", "InitialPointGenerator"]
| 305 | 22.538462 | 82 | py |
deephyper | deephyper-master/deephyper/skopt/learning/gbrt.py | import numpy as np
from sklearn.base import clone
from sklearn.base import BaseEstimator, RegressorMixin
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.utils import check_random_state
from joblib import Parallel, delayed
def _parallel_fit(regressor, X, y):
return regressor.fit(X, y)
class ... | 4,710 | 34.689394 | 86 | py |
deephyper | deephyper-master/deephyper/skopt/learning/__init__.py | """Machine learning extensions for model-based optimization."""
from .forest import RandomForestRegressor
from .forest import ExtraTreesRegressor
from .gaussian_process import GaussianProcessRegressor
from .gbrt import GradientBoostingQuantileRegressor
__all__ = [
"RandomForestRegressor",
"ExtraTreesRegresso... | 553 | 24.181818 | 71 | py |
deephyper | deephyper-master/deephyper/skopt/learning/forest.py | import numpy as np
from sklearn.ensemble import ExtraTreesRegressor as _sk_ExtraTreesRegressor
from sklearn.ensemble._forest import ForestRegressor, DecisionTreeRegressor
def _return_std(X, n_outputs, trees, predictions, min_variance):
"""
Returns `std(Y | X)`.
Can be calculated by E[Var(Y | Tree)] + Var... | 19,918 | 36.725379 | 82 | py |
deephyper | deephyper-master/deephyper/skopt/learning/gaussian_process/kernels.py | from math import sqrt
import numpy as np
from sklearn.gaussian_process.kernels import Kernel as sk_Kernel
from sklearn.gaussian_process.kernels import ConstantKernel as sk_ConstantKernel
from sklearn.gaussian_process.kernels import DotProduct as sk_DotProduct
from sklearn.gaussian_process.kernels import Exponentiation... | 14,672 | 34.442029 | 125 | py |
deephyper | deephyper-master/deephyper/skopt/learning/gaussian_process/gpr.py | import warnings
import numpy as np
import sklearn
from packaging import version
from scipy.linalg import cho_solve, solve_triangular
from sklearn.gaussian_process import (
GaussianProcessRegressor as sk_GaussianProcessRegressor,
)
from sklearn.utils import check_array
from .kernels import RBF, ConstantKernel, Sum... | 15,391 | 38.568123 | 88 | py |
deephyper | deephyper-master/deephyper/skopt/learning/gaussian_process/__init__.py | from .gpr import GaussianProcessRegressor # noqa: F401
__all__ = "GaussianProcessRegressor"
| 94 | 22.75 | 55 | py |
deephyper | deephyper-master/deephyper/skopt/learning/gaussian_process/tests/test_gpr.py | import numpy as np
import pytest
from scipy import optimize
from numpy.testing import assert_almost_equal
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert_array_equal
from deephyper.skopt.learning import GaussianProcessRegressor
from deephyper.skopt.learning.gaussian_process.kerne... | 3,818 | 29.552 | 88 | py |
deephyper | deephyper-master/deephyper/skopt/learning/gaussian_process/tests/test_kernels.py | import numpy as np
from scipy import optimize
from scipy.spatial.distance import pdist, squareform
try:
from sklearn.preprocessing import OrdinalEncoder
UseOrdinalEncoder = True
except ImportError:
UseOrdinalEncoder = False
from numpy.testing import assert_array_almost_equal
from numpy.testing import asse... | 7,824 | 29.928854 | 87 | py |
deephyper | deephyper-master/deephyper/skopt/learning/gaussian_process/tests/__init__.py | 0 | 0 | 0 | py | |
deephyper | deephyper-master/deephyper/skopt/learning/tests/test_gbrt.py | import numpy as np
import pytest
from scipy import stats
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.ensemble import RandomForestRegressor
from numpy.testing import assert_equal
from numpy.testing import assert_array_equal
from numpy.testing import assert_almost_equal
from deephyper.skopt.le... | 3,191 | 27 | 84 | py |
deephyper | deephyper-master/deephyper/skopt/learning/tests/test_forest.py | import numpy as np
import pytest
from numpy.testing import assert_array_equal
from deephyper.skopt.learning import ExtraTreesRegressor, RandomForestRegressor
def truth(X):
return 0.5 * np.sin(1.75 * X[:, 0])
@pytest.mark.hps
def test_random_forest():
# toy sample
X = [[-2, -1], [-1, -1], [-1, -2], [1,... | 3,034 | 24.940171 | 80 | py |
deephyper | deephyper-master/deephyper/skopt/learning/tests/__init__.py | 0 | 0 | 0 | py | |
deephyper | deephyper-master/deephyper/skopt/moo/_pf.py | import numpy as np
def is_pareto_efficient(new_obj, objvals):
"""Check if the new objective vector is pareto efficient with respect to previously computed values.
Args:
new_obj (array or list): Array or list of size (n_objectives, )
objvals (array or list): Array or list of size (n_points, n_... | 5,137 | 37.924242 | 269 | py |
deephyper | deephyper-master/deephyper/skopt/moo/_multiobjective.py | import abc
import numpy as np
from deephyper.skopt.utils import is_listlike
class MoScalarFunction(abc.ABC):
"""Abstract class representing a scalarizing function.
Args:
n_objectives (int, optional): Number of objective functions. Defaults to 1.
weight (float or 1-D array, optional): Array o... | 9,331 | 38.210084 | 255 | py |
deephyper | deephyper-master/deephyper/skopt/moo/_hv.py | # Copyright (C) 2010 Simon Wessing
# TU Dortmund University
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later v... | 10,912 | 35.376667 | 107 | py |
deephyper | deephyper-master/deephyper/skopt/moo/__init__.py | from ._hv import hypervolume
from ._multiobjective import (
MoAugmentedChebyshevFunction,
MoChebyshevFunction,
MoLinearFunction,
MoPBIFunction,
MoQuadraticFunction,
)
from ._pf import (
is_pareto_efficient,
non_dominated_set,
non_dominated_set_ranked,
pareto_front,
)
__all__ = [
... | 577 | 19.642857 | 35 | py |
deephyper | deephyper-master/deephyper/skopt/optimizer/base.py | """
Abstraction for optimizers.
It is sufficient that one re-implements the base estimator.
"""
import warnings
import numbers
try:
from collections.abc import Iterable
except ImportError:
from collections import Iterable
from ..callbacks import check_callback
from ..callbacks import VerboseCallback
from .o... | 12,427 | 36.433735 | 94 | py |
deephyper | deephyper-master/deephyper/skopt/optimizer/gp.py | """Gaussian process-based minimization algorithms."""
import numpy as np
from sklearn.utils import check_random_state
from .base import base_minimize
from ..utils import cook_estimator
from ..utils import normalize_dimensions
def gp_minimize(
func,
dimensions,
base_estimator=None,
n_calls=100,
... | 11,926 | 38.889632 | 94 | py |
deephyper | deephyper-master/deephyper/skopt/optimizer/gbrt.py | from sklearn.utils import check_random_state
from .base import base_minimize
from ..utils import cook_estimator
def gbrt_minimize(
func,
dimensions,
base_estimator=None,
n_calls=100,
n_random_starts=None,
n_initial_points=10,
initial_point_generator="random",
acq_func="EI",
acq_op... | 7,968 | 36.947619 | 94 | py |
deephyper | deephyper-master/deephyper/skopt/optimizer/__init__.py | from .base import base_minimize
from .dummy import dummy_minimize
from .forest import forest_minimize
from .gbrt import gbrt_minimize
from .gp import gp_minimize
from .optimizer import Optimizer, OBJECTIVE_VALUE_FAILURE
__all__ = [
"base_minimize",
"dummy_minimize",
"forest_minimize",
"gbrt_minimize",... | 390 | 20.722222 | 57 | py |
deephyper | deephyper-master/deephyper/skopt/optimizer/forest.py | """Forest based minimization algorithms."""
from .base import base_minimize
def forest_minimize(
func,
dimensions,
base_estimator="ET",
n_calls=100,
n_random_starts=None,
n_initial_points=10,
acq_func="EI",
initial_point_generator="random",
x0=None,
y0=None,
random_state=N... | 8,325 | 37.368664 | 94 | py |
deephyper | deephyper-master/deephyper/skopt/optimizer/optimizer.py | import sys
import warnings
from math import log
from numbers import Number
import ConfigSpace as CS
import numpy as np
import pandas as pd
from joblib import Parallel, delayed
from scipy.optimize import fmin_l_bfgs_b
from sklearn.base import clone, is_regressor
from sklearn.multioutput import MultiOutputRegressor
from... | 50,659 | 37.612805 | 161 | py |
deephyper | deephyper-master/deephyper/skopt/optimizer/dummy.py | """Random search."""
from .base import base_minimize
def dummy_minimize(
func,
dimensions,
n_calls=100,
initial_point_generator="random",
x0=None,
y0=None,
random_state=None,
verbose=False,
callback=None,
model_queue_size=None,
init_point_gen_kwargs=None,
):
"""Random ... | 5,020 | 35.384058 | 94 | py |
deephyper | deephyper-master/deephyper/evaluator/_encoder.py | import json
import re
import types
import uuid
from inspect import isclass
import ConfigSpace as cs
import ConfigSpace.hyperparameters as csh
import deephyper.skopt
import numpy as np
from ConfigSpace.read_and_write import json as cs_json
class Encoder(json.JSONEncoder):
"""
Enables JSON dump of numpy data, ... | 2,225 | 30.8 | 142 | py |
deephyper | deephyper-master/deephyper/evaluator/_process_pool.py | import asyncio
import functools
import logging
from concurrent.futures import ProcessPoolExecutor
from typing import Callable, Hashable
from deephyper.evaluator._evaluator import Evaluator
from deephyper.evaluator._job import Job
from deephyper.evaluator.storage import Storage
logger = logging.getLogger(__name__)
c... | 2,271 | 33.424242 | 138 | py |
deephyper | deephyper-master/deephyper/evaluator/_mpi_comm.py | import asyncio
import functools
import logging
import traceback
from typing import Callable, Hashable
from deephyper.core.exceptions import RunFunctionError
from deephyper.evaluator._evaluator import Evaluator
from deephyper.evaluator._job import Job
from deephyper.evaluator.storage import Storage
import mpi4py
# !... | 5,080 | 36.637037 | 188 | py |
deephyper | deephyper-master/deephyper/evaluator/_serial.py | import logging
from typing import Callable, Hashable
from deephyper.evaluator._evaluator import Evaluator
from deephyper.evaluator._job import Job
from deephyper.evaluator.storage import Storage
logger = logging.getLogger(__name__)
class SerialEvaluator(Evaluator):
"""This evaluator run evaluations one after t... | 2,238 | 36.316667 | 178 | py |
deephyper | deephyper-master/deephyper/evaluator/_evaluator.py | import asyncio
import copy
import csv
import functools
import importlib
import json
import logging
import os
import sys
import time
import warnings
from typing import Dict, List, Hashable
import numpy as np
from deephyper.evaluator._job import Job
from deephyper.skopt.optimizer import OBJECTIVE_VALUE_FAILURE
from deep... | 18,360 | 38.401288 | 263 | py |
deephyper | deephyper-master/deephyper/evaluator/_mochi_process_pool.py | import logging
import asyncio
import functools
import collections
import pymargo
import pymargo.core
from concurrent.futures import ProcessPoolExecutor
from deephyper.evaluator._evaluator import Evaluator
import mpi4py
# !To avoid initializing MPI when module is imported (MPI is optional)
mpi4py.rc.initialize = Fal... | 4,490 | 31.309353 | 138 | py |
deephyper | deephyper-master/deephyper/evaluator/_queued.py | import collections
def queued(evaluator_class):
"""Decorator transforming an Evaluator into a ``Queued{Evaluator}``. The ``run_function`` used with a ``Queued{Evaluator}`` needs to have a ``dequed`` keyword-argument where the dequed resources from the queue will be passed.
Args:
queue (list): A list ... | 1,285 | 31.974359 | 229 | py |
deephyper | deephyper-master/deephyper/evaluator/_distributed.py | import logging
import time
import pickle
from typing import List, Tuple
from deephyper.evaluator import Job
import mpi4py
# !To avoid initializing MPI when module is imported (MPI is optional)
mpi4py.rc.initialize = False
mpi4py.rc.finalize = True
from mpi4py import MPI # noqa: E402
TAG_INIT = 20
TAG_DATA = 30
... | 9,193 | 35.054902 | 114 | py |
deephyper | deephyper-master/deephyper/evaluator/_run_function_utils.py | from typing import Union
from numbers import Number
import numpy as np
def standardize_run_function_output(
output: Union[str, float, tuple, list, dict]
) -> dict:
"""Transform the output of the run-function to its standard form.
Possible return values of the run-function are:
>>> 0
>>> 0, 0
... | 1,592 | 26 | 124 | py |
deephyper | deephyper-master/deephyper/evaluator/_ray.py | import logging
import ray
from typing import Callable, Hashable
from deephyper.evaluator._evaluator import Evaluator
from deephyper.evaluator._job import Job
from deephyper.evaluator.storage import Storage
ray_initializer = None
logger = logging.getLogger(__name__)
class RayEvaluator(Evaluator):
"""This evalua... | 4,826 | 42.098214 | 236 | py |
deephyper | deephyper-master/deephyper/evaluator/_job.py | import copy
from collections.abc import MutableMapping
from typing import Hashable
from deephyper.evaluator.storage import Storage, MemoryStorage
from deephyper.evaluator._run_function_utils import standardize_run_function_output
from deephyper.stopper._stopper import Stopper
class Job:
"""Represents an evaluat... | 5,441 | 31.011765 | 163 | py |
deephyper | deephyper-master/deephyper/evaluator/_thread_pool.py | import asyncio
import functools
import logging
from concurrent.futures import ThreadPoolExecutor
from typing import Callable, Hashable
from deephyper.evaluator._evaluator import Evaluator
from deephyper.evaluator._job import Job
from deephyper.evaluator.storage import Storage
logger = logging.getLogger(__name__)
cl... | 2,702 | 38.173913 | 178 | py |
deephyper | deephyper-master/deephyper/evaluator/_decorator.py | import time
from functools import wraps
# !info [why is it important to use "wraps"]
# !http://gael-varoquaux.info/programming/decoration-in-python-done-right-decorating-and-pickling.html
from deephyper.evaluator._run_function_utils import standardize_run_function_output
def profile(run_function):
"""Decorator ... | 1,101 | 25.878049 | 102 | py |
deephyper | deephyper-master/deephyper/evaluator/__init__.py | """
This evaluator sub-package provides a common interface to execute isolated tasks with different parallel backends and system properties. This interface is used by search algorithm to perform black-box optimization (the black-box being represented by the ``run``-function).
An ``Evaluator``, when instanciated, is bou... | 2,676 | 36.180556 | 304 | py |
deephyper | deephyper-master/deephyper/evaluator/_nest_asyncio.py | """From https://github.com/erdewit/nest_asyncio"""
import asyncio
import asyncio.events as events
import os
import sys
import threading
from contextlib import contextmanager, suppress
from heapq import heappop
def apply(loop=None):
"""Patch asyncio to make its event loop reentrant."""
_patch_asyncio()
_pa... | 7,828 | 31.086066 | 88 | py |
deephyper | deephyper-master/deephyper/evaluator/callback.py | """The callback module contains sub-classes of the ``Callback`` class used to trigger custom actions on the start and completion of jobs by the ``Evaluator``. Callbacks can be used with any Evaluator implementation.
"""
import deephyper.core.exceptions
import numpy as np
import pandas as pd
from deephyper.evaluator._ev... | 7,498 | 33.399083 | 255 | py |
deephyper | deephyper-master/deephyper/evaluator/storage/_memory_storage.py | import copy
from typing import Any, Dict, Hashable, List, Tuple
from deephyper.evaluator.storage._storage import Storage
class MemoryStorage(Storage):
"""Storage client for local in-memory storage.
This backend does not allow to share the data between evaluators running in different processes.
"""
... | 7,576 | 32.675556 | 100 | py |
deephyper | deephyper-master/deephyper/evaluator/storage/_redis_storage.py | import pickle
from typing import Any, Dict, Hashable, List, Tuple
import redis
from deephyper.evaluator.storage._storage import Storage
class RedisStorage(Storage):
"""Storage client for Redis.
The Redis server should be started with the Redis-JSON module loaded.
Args:
host (str, optional): T... | 8,727 | 32.060606 | 98 | py |
deephyper | deephyper-master/deephyper/evaluator/storage/__init__.py | from deephyper.evaluator.storage._storage import Storage
from deephyper.evaluator.storage._memory_storage import MemoryStorage
__all__ = ["Storage", "MemoryStorage"]
# optional import for RedisStorage
try:
from deephyper.evaluator.storage._redis_storage import RedisStorage # noqa: F401
__all__.append("Redi... | 360 | 24.785714 | 85 | py |
deephyper | deephyper-master/deephyper/evaluator/storage/_storage.py | import abc
import importlib
import logging
from typing import Any, Dict, Hashable, List, Tuple, TypeVar
StorageType = TypeVar("StorageType", bound="Storage")
STORAGES = {
"memory": "_memory_storage.MemoryStorage",
"redis": "_redis_storage.RedisStorage",
}
class Storage(abc.ABC):
"""An abstract interface... | 7,061 | 30.247788 | 112 | py |
deephyper | deephyper-master/deephyper/stopper/_idle_stopper.py | from deephyper.stopper._stopper import Stopper
class IdleStopper(Stopper):
"""Idle stopper which nevers stops the evaluation."""
| 135 | 21.666667 | 57 | py |
deephyper | deephyper-master/deephyper/stopper/_const_stopper.py | from deephyper.stopper._stopper import Stopper
class ConstantStopper(Stopper):
"""Constant stopping policy which will stop the evaluation of a configuration at a fixed step.
Args:
max_steps (int): the maximum number of steps which should be performed to evaluate the configuration fully.
stop_... | 616 | 33.277778 | 115 | py |
deephyper | deephyper-master/deephyper/stopper/_asha_stopper.py | import numpy as np
from deephyper.stopper._stopper import Stopper
class SuccessiveHalvingStopper(Stopper):
"""Stopper based on the asynchronous successive halving algorithm."""
def __init__(
self,
max_steps: int,
min_steps: float = 1,
reduction_factor: float = 3,
min_... | 3,345 | 32.79798 | 84 | py |
deephyper | deephyper-master/deephyper/stopper/__init__.py | """The ``stopper`` module provides features to observe intermediate performances of iterative algorithm and decide dynamically if its evaluation should be stopped or continued.
This module was inspired from the Pruner interface and implementation of `Optuna <https://optuna.readthedocs.io/en/stable/reference/pruners.ht... | 4,488 | 46.252632 | 552 | py |
deephyper | deephyper-master/deephyper/stopper/_lcmodel_stopper.py | import sys
from functools import partial
import jax
import jax.numpy as jnp
import numpy as np
import numpyro
import numpyro.distributions as dist
from numpyro.infer import MCMC, NUTS
from scipy.optimize import least_squares
from sklearn.base import BaseEstimator, RegressorMixin
from sklearn.utils import check_random_... | 19,786 | 36.263653 | 401 | py |
deephyper | deephyper-master/deephyper/stopper/_stopper.py | import abc
import copy
class Stopper(abc.ABC):
"""An abstract class describing the interface of a Stopper.
Args:
max_steps (int): the maximum number of calls to ``observe(budget, objective)``.
"""
def __init__(self, max_steps: int) -> None:
assert max_steps > 0
self.max_steps... | 2,333 | 31.416667 | 109 | py |
deephyper | deephyper-master/deephyper/stopper/_median_stopper.py | import numpy as np
from deephyper.stopper._stopper import Stopper
class MedianStopper(Stopper):
"""Stopper based on the median of observed objectives at similar budgets."""
def __init__(
self,
max_steps: int,
min_steps: int = 1,
min_competing: int = 0,
min_fully_compl... | 2,729 | 31.117647 | 84 | py |
deephyper | deephyper-master/deephyper/test/_command.py | import subprocess
import sys
def run(command, live_output=False):
"""Test command line interface.
Args:
command (str): the command line as a str.
"""
command = command.split()
try:
if live_output:
result = subprocess.run(
command,
check=... | 711 | 23.551724 | 88 | py |
deephyper | deephyper-master/deephyper/test/_parse_result.py | import parse
def parse_result(stream: str) -> float:
"""Parse the output of a DeepHyper test. The format of the parsed output should be as follows:
.. code-block::
DEEPHYPER-OUTPUT: <float>
Args:
stream (str): The output of a DeepHyper test.
Returns:
float: The parsed output... | 405 | 21.555556 | 98 | py |
deephyper | deephyper-master/deephyper/test/__init__.py | """Sub-package dedicated to reusable testing tools for DeepHyper"""
from ._command import run
from ._parse_result import parse_result
__all__ = ["run", "parse_result"]
| 170 | 23.428571 | 67 | py |
deephyper | deephyper-master/deephyper/test/nas/__init__.py | 0 | 0 | 0 | py | |
deephyper | deephyper-master/deephyper/test/nas/linearRegHybrid/problem.py | from deephyper.nas.spacelib.tabular import OneLayerSpace
from deephyper.problem import NaProblem
from deephyper.test.nas.linearReg.load_data import load_data
Problem = NaProblem()
Problem.load_data(load_data)
Problem.search_space(OneLayerSpace)
Problem.hyperparameters(
batch_size=Problem.add_hyperparameter((1, ... | 817 | 24.5625 | 99 | py |
deephyper | deephyper-master/deephyper/test/nas/linearRegHybrid/load_data.py | import numpy as np
def load_data(dim=10, verbose=0):
"""
Generate data for linear function -sum(x_i).
Return:
Tuple of Numpy arrays: ``(train_X, train_y), (valid_X, valid_y)``.
"""
rng = np.random.RandomState(42)
size = 10000
prop = 0.80
a, b = 0, 100
d = b - a
x = np.... | 897 | 23.944444 | 74 | py |
deephyper | deephyper-master/deephyper/test/nas/linearRegHybrid/__init__.py | from .problem import Problem # noqa: F401
| 43 | 21 | 42 | py |
deephyper | deephyper-master/deephyper/test/nas/linearRegMultiInputsGen/problem.py | from deephyper.problem import NaProblem
from deephyper.test.nas.linearRegMultiInputsGen.load_data import load_data
from deephyper.nas.preprocessing import minmaxstdscaler
from deephyper.nas.spacelib.tabular import OneLayerSpace
Problem = NaProblem()
Problem.load_data(load_data)
Problem.preprocessing(minmaxstdscaler)... | 680 | 23.321429 | 99 | py |
deephyper | deephyper-master/deephyper/test/nas/linearRegMultiInputsGen/load_data.py | from pprint import pformat
import numpy as np
import tensorflow as tf
def load_data(dim=10, size=100):
"""
Generate data for linear function -sum(x_i).
Return:
Tuple of Numpy arrays: ``(train_X, train_y), (valid_X, valid_y)``.
"""
rng = np.random.RandomState(42)
size = 1000
prop =... | 1,408 | 26.096154 | 82 | py |
deephyper | deephyper-master/deephyper/test/nas/linearRegMultiInputsGen/__init__.py | from .problem import Problem # noqa: F401
| 43 | 21 | 42 | py |
deephyper | deephyper-master/deephyper/test/nas/linearReg/problem.py | from deephyper.nas.spacelib.tabular import OneLayerSpace
from deephyper.problem import NaProblem
from deephyper.test.nas.linearReg.load_data import load_data
Problem = NaProblem()
Problem.load_data(load_data)
Problem.search_space(OneLayerSpace)
Problem.hyperparameters(
batch_size=100, learning_rate=0.1, optimiz... | 611 | 21.666667 | 99 | py |
deephyper | deephyper-master/deephyper/test/nas/linearReg/load_data.py | import numpy as np
def load_data(dim=10, verbose=0):
"""
Generate data for linear function -sum(x_i).
Return:
Tuple of Numpy arrays: ``(train_X, train_y), (valid_X, valid_y)``.
"""
rng = np.random.RandomState(42)
size = 10000
prop = 0.80
a, b = 0, 100
d = b - a
x = np.... | 897 | 23.944444 | 74 | py |
deephyper | deephyper-master/deephyper/test/nas/linearReg/__init__.py | from .problem import Problem # noqa: F401
| 43 | 21 | 42 | py |
deephyper | deephyper-master/deephyper/test/nas/linearRegMultiInputs/problem.py | from deephyper.problem import NaProblem
from deephyper.test.nas.linearRegMultiInputs.load_data import load_data
from deephyper.nas.preprocessing import minmaxstdscaler
from deephyper.nas.spacelib.tabular import OneLayerSpace
Problem = NaProblem()
Problem.load_data(load_data)
Problem.preprocessing(minmaxstdscaler)
... | 678 | 22.413793 | 99 | py |
deephyper | deephyper-master/deephyper/test/nas/linearRegMultiInputs/load_data.py | import numpy as np
def load_data(dim=10, verbose=0):
"""
Generate data for linear function -sum(x_i).
Return:
Tuple of Numpy arrays: ``(train_X, train_y), (valid_X, valid_y)``.
"""
rng = np.random.RandomState(42)
size = 1000
prop = 0.80
a, b = 0, 100
d = b - a
x = np.a... | 1,047 | 26.578947 | 74 | py |
deephyper | deephyper-master/deephyper/test/nas/linearRegMultiInputs/__init__.py | from .problem import Problem # noqa: F401
| 43 | 21 | 42 | py |
deephyper | deephyper-master/deephyper/nas/_nx_search_space.py | import abc
import traceback
from collections.abc import Iterable
import networkx as nx
from deephyper.core.exceptions.nas.space import (
NodeAlreadyAdded,
StructureHasACycle,
WrongSequenceToSetOperations,
)
from deephyper.nas.node import MimeNode, Node, VariableNode
class NxSearchSpace(abc.ABC):
"""A... | 7,301 | 30.747826 | 166 | py |
deephyper | deephyper-master/deephyper/nas/lr_scheduler.py | import tensorflow as tf
def exponential_decay(epoch, lr):
"""Keep the learning rate constant for the first 10 epochs. Then, decay the learning
rate exponentially."""
if epoch < 10:
return lr
else:
return lr * tf.math.exp(-0.1)
| 262 | 20.916667 | 88 | py |
deephyper | deephyper-master/deephyper/nas/losses.py | """This module provides different loss functions. A loss can be defined by a keyword (str) or a callable following the ``tensorflow.keras`` interface. If it is a keyword it has to be available in ``tensorflow.keras`` or in ``deephyper.losses``. The loss functions availble in ``deephyper.losses`` are:
* Negative Log Lik... | 1,605 | 34.688889 | 301 | py |
deephyper | deephyper-master/deephyper/nas/node.py | """This module provides the available node types to build a ``KSearchSpace``.
"""
import tensorflow as tf
import deephyper.core.exceptions
from deephyper.nas.operation import Operation
class Node:
"""Represents a node of a ``KSearchSpace``.
Args:
name (str): node name.
"""
# Number of 'Node... | 8,363 | 29.086331 | 218 | py |
deephyper | deephyper-master/deephyper/nas/_keras_search_space.py | import copy
import logging
import warnings
import networkx as nx
import numpy as np
import tensorflow as tf
from deephyper.core.exceptions.nas.space import (
InputShapeOfWrongType,
WrongSequenceToSetOperations,
)
from deephyper.nas._nx_search_space import NxSearchSpace
from deephyper.nas.node import ConstantNo... | 7,837 | 34.789954 | 170 | py |
deephyper | deephyper-master/deephyper/nas/metrics.py | """This module provides different metric functions. A metric can be defined by a keyword (str) or a callable. If it is a keyword it has to be available in ``tensorflow.keras`` or in ``deephyper.netrics``. The loss functions availble in ``deephyper.metrics`` are:
* Sparse Perplexity: ``sparse_perplexity``
* R2: ``r2``
*... | 3,474 | 31.175926 | 262 | py |
deephyper | deephyper-master/deephyper/nas/__init__.py | from ._nx_search_space import NxSearchSpace
from ._keras_search_space import KSearchSpace
__all__ = ["NxSearchSpace", "KSearchSpace"]
| 135 | 26.2 | 45 | py |
deephyper | deephyper-master/deephyper/nas/trainer/_utils.py | from collections import OrderedDict
import tensorflow as tf
optimizers_keras = OrderedDict()
optimizers_keras["sgd"] = tf.keras.optimizers.SGD
optimizers_keras["rmsprop"] = tf.keras.optimizers.RMSprop
optimizers_keras["adagrad"] = tf.keras.optimizers.Adagrad
optimizers_keras["adam"] = tf.keras.optimizers.Adam
optimiz... | 1,156 | 35.15625 | 88 | py |
deephyper | deephyper-master/deephyper/nas/trainer/_arch.py | # definition of a key
layer_type = "layer_type"
features = "features"
input_shape = "input_shape"
output_shape = "output_shape"
num_outputs = "num_outputs"
num_steps = "num_steps"
max_layers = "max_layers"
min_layers = "min_layers"
hyperparameters = "hyperparameters"
summary = "summary"
logs = "logs"
data = "data"
regr... | 973 | 20.644444 | 35 | py |
deephyper | deephyper-master/deephyper/nas/trainer/_horovod.py | import logging
import time
from inspect import signature
import deephyper.nas.trainer._arch as a
import deephyper.nas.trainer._utils as U
import horovod.tensorflow.keras as hvd
import numpy as np
import tensorflow as tf
from deephyper.core.exceptions import DeephyperRuntimeError
from deephyper.nas.losses import select... | 21,070 | 37.733456 | 241 | py |
deephyper | deephyper-master/deephyper/nas/trainer/_base.py | import inspect
import logging
import time
from inspect import signature
import deephyper.nas.trainer._arch as a
import deephyper.nas.trainer._utils as U
import numpy as np
import tensorflow as tf
from deephyper.core.exceptions import DeephyperRuntimeError
from deephyper.nas.losses import selectLoss
from deephyper.nas.... | 21,923 | 37.0625 | 241 | py |
deephyper | deephyper-master/deephyper/nas/trainer/__init__.py | from ._base import BaseTrainer
__all__ = ["BaseTrainer"]
try:
from ._horovod import HorovodTrainer # noqa: F401
__all__.append("HorovodTrainer")
except Exception:
pass
| 184 | 15.818182 | 54 | py |
deephyper | deephyper-master/deephyper/nas/spacelib/__init__.py | """Library of neural architecture search spaces."""
| 52 | 25.5 | 51 | py |
deephyper | deephyper-master/deephyper/nas/spacelib/tabular/one_layer.py | import tensorflow as tf
from deephyper.nas import KSearchSpace
from deephyper.nas.node import ConstantNode, VariableNode
from deephyper.nas.operation import operation, Concatenate
Dense = operation(tf.keras.layers.Dense)
Dropout = operation(tf.keras.layers.Dropout)
class OneLayerSpace(KSearchSpace):
def __init_... | 1,655 | 27.551724 | 87 | py |
deephyper | deephyper-master/deephyper/nas/spacelib/tabular/supervised_reg_auto_encoder.py | import tensorflow as tf
from deephyper.nas import KSearchSpace
from deephyper.nas.node import ConstantNode, VariableNode
from deephyper.nas.operation import Identity, operation
Dense = operation(tf.keras.layers.Dense)
class SupervisedRegAutoEncoderSpace(KSearchSpace):
def __init__(
self,
input_s... | 2,268 | 28.855263 | 85 | py |
deephyper | deephyper-master/deephyper/nas/spacelib/tabular/feed_forward.py | import tensorflow as tf
from deephyper.nas import KSearchSpace
from deephyper.nas.node import ConstantNode, VariableNode
from deephyper.nas.operation import Identity, operation
Dense = operation(tf.keras.layers.Dense)
class FeedForwardSpace(KSearchSpace):
"""Simple search space for a feed-forward neural network... | 2,179 | 32.030303 | 150 | py |
deephyper | deephyper-master/deephyper/nas/spacelib/tabular/dense_skipco.py | import collections
import tensorflow as tf
from deephyper.nas import KSearchSpace
from deephyper.nas.node import ConstantNode, VariableNode
from deephyper.nas.operation import operation, Zero, Connect, AddByProjecting, Identity
Dense = operation(tf.keras.layers.Dense)
Dropout = operation(tf.keras.layers.Dropout)
c... | 2,637 | 28.311111 | 87 | py |
deephyper | deephyper-master/deephyper/nas/spacelib/tabular/__init__.py | """Neural architecture search spaces for tabular data."""
from .dense_skipco import DenseSkipCoSpace
from .one_layer import OneLayerSpace
from .feed_forward import FeedForwardSpace
from .supervised_reg_auto_encoder import SupervisedRegAutoEncoderSpace
__all__ = [
"DenseSkipCoSpace",
"OneLayerSpace",
"FeedF... | 373 | 27.769231 | 70 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.