当前位置: 首页>>代码示例>>Python>>正文


Python joblib.effective_n_jobs方法代码示例

本文整理汇总了Python中joblib.effective_n_jobs方法的典型用法代码示例。如果您正苦于以下问题:Python joblib.effective_n_jobs方法的具体用法?Python joblib.effective_n_jobs怎么用?Python joblib.effective_n_jobs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在joblib的用法示例。


在下文中一共展示了joblib.effective_n_jobs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _partition_bmus

# 需要导入模块: import joblib [as 别名]
# 或者: from joblib import effective_n_jobs [as 别名]
def _partition_bmus(self, X):
        """Private function used to partition bmus between jobs.

        Parameters
        ----------
        X : np.array
            List of datapoints

        Returns
        -------
        n_jobs : int
            Number of jobs
        list of int
            List of number of datapoints per job
        list of int
            List of start values for every job list

        """
        n_datapoints = len(X)
        n_jobs = min(effective_n_jobs(self.n_jobs), n_datapoints)

        n_datapoints_per_job = np.full(
            n_jobs, n_datapoints // n_jobs, dtype=np.int)

        n_datapoints_per_job[:n_datapoints % n_jobs] += 1
        starts = np.cumsum(n_datapoints_per_job)

        return n_jobs, n_datapoints_per_job.tolist(), [0] + starts.tolist() 
开发者ID:felixriese,项目名称:susi,代码行数:30,代码来源:SOMClustering.py

示例2: effective_n_jobs_with_context

# 需要导入模块: import joblib [as 别名]
# 或者: from joblib import effective_n_jobs [as 别名]
def effective_n_jobs_with_context(n_jobs=None):
    """Find the effective number of jobs, either specified directly, or from the joblib.parallel_backend context."""
    if n_jobs is None:
        _, n_jobs_from_context = joblib.parallel.get_active_backend()
        n_jobs = n_jobs_from_context
    return joblib.effective_n_jobs(n_jobs) 
开发者ID:lmcinnes,项目名称:pynndescent,代码行数:8,代码来源:threaded.py

示例3: _partition_estimators

# 需要导入模块: import joblib [as 别名]
# 或者: from joblib import effective_n_jobs [as 别名]
def _partition_estimators(n_estimators, n_jobs):
    """Private function used to partition estimators between jobs."""
    # Compute the number of jobs
    n_jobs = min(effective_n_jobs(n_jobs), n_estimators)

    # Partition estimators between jobs
    n_estimators_per_job = np.full(n_jobs, n_estimators // n_jobs,
                                   dtype=np.int)
    n_estimators_per_job[:n_estimators % n_jobs] += 1
    starts = np.cumsum(n_estimators_per_job)

    xdiff = [starts[n] - starts[n - 1] for n in range(1, len(starts))]

    print("Split among workers default:", starts, xdiff)
    return n_estimators_per_job.tolist(), [0] + starts.tolist(), n_jobs 
开发者ID:yzhao062,项目名称:SUOD,代码行数:17,代码来源:demo_balanced_scheduling.py

示例4: maybe_cythonize_extensions

# 需要导入模块: import joblib [as 别名]
# 或者: from joblib import effective_n_jobs [as 别名]
def maybe_cythonize_extensions(top_path, config):
    """Tweaks for building extensions between release and development mode."""
    with_openmp = check_openmp_support()

    is_release = os.path.exists(os.path.join(top_path, 'PKG-INFO'))

    if is_release:
        build_from_c_and_cpp_files(config.ext_modules)
    else:
        message = ('Please install Cython with a version >= {0} in order '
                   'to build a sktime development version.').format(
            CYTHON_MIN_VERSION)
        try:
            import Cython
            if LooseVersion(Cython.__version__) < CYTHON_MIN_VERSION:
                message += ' Your version of Cython was {0}.'.format(
                    Cython.__version__)
                raise ValueError(message)
            from Cython.Build import cythonize
        except ImportError as exc:
            exc.args += (message,)
            raise

        n_jobs = 1
        with contextlib.suppress(ImportError):
            import joblib
            if LooseVersion(joblib.__version__) > LooseVersion("0.13.0"):
                # earlier joblib versions don't account for CPU affinity
                # constraints, and may over-estimate the number of available
                # CPU particularly in CI (cf loky#114)
                n_jobs = joblib.effective_n_jobs()

        config.ext_modules = cythonize(
            config.ext_modules,
            nthreads=n_jobs,
            compile_time_env={'SKTIME_OPENMP_SUPPORTED': with_openmp},
            compiler_directives={'language_level': 3}
        ) 
开发者ID:alan-turing-institute,项目名称:sktime,代码行数:40,代码来源:__init__.py


注:本文中的joblib.effective_n_jobs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。