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


Python chainer.__version__方法代码示例

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


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

示例1: test_second_order

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def test_second_order(self):
        # Second order, so its Hessian will be non-zero
        params, y = self._generate_params_and_second_order_output()

        old_style_funcs = trpo._find_old_style_function([y])
        if old_style_funcs:
            self.skipTest("\
Chainer v{} does not support double backprop of these functions: {}.".format(
                chainer.__version__, old_style_funcs))

        def test_hessian_vector_product_nonzero(vec):
            hvp = compute_hessian_vector_product(y, params, vec)
            hessian = compute_hessian(y, params)
            self.assertGreater(np.count_nonzero(hvp), 0)
            self.assertGreater(np.count_nonzero(hessian), 0)
            np.testing.assert_allclose(hvp, hessian.dot(vec), atol=1e-3)

        # Test with two different random vectors, reusing y
        test_hessian_vector_product_nonzero(
            np.random.rand(4).astype(np.float32))
        test_hessian_vector_product_nonzero(
            np.random.rand(4).astype(np.float32)) 
开发者ID:chainer,项目名称:chainerrl,代码行数:24,代码来源:test_trpo.py

示例2: get_version_dict

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def get_version_dict():
    import nmt_chainer._version
    result = OrderedDict({"package_version": nmt_chainer._version.__version__})
    current_git_hash = get_current_git_hash()
    if current_git_hash is not None:
        result["git"] = current_git_hash
        current_git_status = is_current_git_dirty()
        result["dirty_status"] = current_git_status
        if current_git_status == "dirty":
            result["diff"] = get_current_git_diff()
        result["version_from"] = "git call"
    else:
        package_git_hash = get_package_git_hash()
        if package_git_hash is not None:
            result["git"] = package_git_hash
            current_git_status = get_package_dirty_status()
            result["dirty_status"] = current_git_status
            if current_git_status == "dirty":
                result["diff"] = get_package_git_diff()
            result["version_from"] = "setup info"
        else:
            result["git"] = "unavailable"

    result["chainer"] = get_chainer_infos()
    return result 
开发者ID:fabiencro,项目名称:knmt,代码行数:27,代码来源:versioning_tools.py

示例3: create_logger

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def create_logger(args, result_dir):
    root = logging.getLogger()
    root.setLevel(logging.DEBUG)
    msg_format = '%(asctime)s [%(levelname)s] %(message)s'
    formatter = logging.Formatter(msg_format)
    ch = logging.StreamHandler(sys.stdout)
    ch.setLevel(logging.DEBUG)
    ch.setFormatter(formatter)
    root.addHandler(ch)
    fileHandler = logging.FileHandler("{}/stdout.log".format(result_dir))
    fileHandler.setFormatter(formatter)
    root.addHandler(fileHandler)
    logging.info(sys.version_info)
    logging.info('chainer version: {}'.format(chainer.__version__))
    logging.info('cuda: {}, cudnn: {}'.format(
        chainer.cuda.available, chainer.cuda.cudnn_enabled))
    logging.info(args) 
开发者ID:pfnet-research,项目名称:chainer-segnet,代码行数:19,代码来源:train_utils.py

示例4: test_first_order

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def test_first_order(self):
        # First order, so its Hessian will contain None
        params, y = self._generate_params_and_first_order_output()

        old_style_funcs = trpo._find_old_style_function([y])
        if old_style_funcs:
            self.skipTest("\
Chainer v{} does not support double backprop of these functions: {}.".format(
                chainer.__version__, old_style_funcs))

        vec = np.random.rand(4).astype(np.float32)
        # Hessian-vector product computation should raise an error due to None
        with self.assertRaises(AssertionError):
            compute_hessian_vector_product(y, params, vec) 
开发者ID:chainer,项目名称:chainerrl,代码行数:16,代码来源:test_trpo.py

示例5: get_chainer_infos

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def get_chainer_infos():
    try:
        import chainer
        result = OrderedDict([
            ("version", chainer.__version__),
            ("cuda", chainer.cuda.available),
            ("cudnn", chainer.cuda.cudnn_enabled),
        ])
        if chainer.cuda.available:
            try:
                import cupy
                cuda_version = cupy.cuda.runtime.driverGetVersion()
            except BaseException:
                cuda_version = "unavailable"
            result["cuda_version"] = cuda_version
        else:
            result["cuda_version"] = "unavailable"

        if chainer.cuda.cudnn_enabled:
            try:
                cudnn_version = chainer.cuda.cudnn.cudnn.getVersion()
            except BaseException:
                cudnn_version = "unavailable"
            result["cudnn_version"] = cudnn_version
        else:
            result["cudnn_version"] = "unavailable"

    except ImportError:
        result = OrderedDict([
            ("version", "unavailable"),
            ("cuda", "unavailable"),
            ("cudnn", "unavailable"),
            ("cuda_version", "unavailable"),
            ("cudnn_version", "unavailable")
        ])

    return result 
开发者ID:fabiencro,项目名称:knmt,代码行数:39,代码来源:versioning_tools.py

示例6: main

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def main(options=None):
    import nmt_chainer._version
    print("package version:", nmt_chainer._version.__version__)
    print("installed in:", get_installed_path())

    print("\n*********** chainer version ***********")
    chainer_infos = get_chainer_infos()
    for keyword in "version cuda cudnn cuda_version cudnn_version".split():
        print(keyword, chainer_infos[keyword])

    print("\n\n********** package build info ***********")
    print("package build (git hash):", get_package_git_hash())
    package_dirty_status = get_package_dirty_status()
    if package_dirty_status == "clean":
        print("  - package git index is clean")
    elif package_dirty_status == "dirty":
        print("  - package git index is dirty")
        print("\npackage build diff (git diff):\n", get_package_git_diff())

    print("\n\n********** current version info ***********")
    print("git hash:", get_current_git_hash())

    current_dirty_status = is_current_git_dirty()

    if current_dirty_status == "clean":
        print("  - git index is clean")
    elif current_dirty_status == "dirty":
        print("  - git index is dirty")
        print("\ngit diff:\n")
        print(get_current_git_diff()) 
开发者ID:fabiencro,项目名称:knmt,代码行数:32,代码来源:versioning_tools.py

示例7: print_system_info

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def print_system_info():
    pyver = sys.version.replace('\n', ' ')
    print(f"python version: {pyver}")
    print(f"chainer version: {chainer.__version__}")
    print(f"cupy version: {cupy.__version__}")
    print(f"cuda version: {cupy.cuda.runtime.runtimeGetVersion()}")
    print(f"cudnn version: {cudnn.getVersion()}") 
开发者ID:hitachi-speech,项目名称:EEND,代码行数:9,代码来源:system_info.py

示例8: test_get_runtime_info

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def test_get_runtime_info(self):
        info = _runtime_info._get_runtime_info()
        assert chainer.__version__ in str(info) 
开发者ID:chainer,项目名称:chainer,代码行数:5,代码来源:test_runtime_info.py

示例9: __init__

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def __init__(self):
        self.chainer_version = chainer.__version__
        self.chainerx_available = chainerx.is_available()
        self.numpy_version = numpy.__version__
        self.platform_version = platform.platform()
        if cuda.available:
            self.cuda_info = cuda.cupyx.get_runtime_info()
        else:
            self.cuda_info = None
        if intel64.is_ideep_available():
            self.ideep_version = intel64.ideep.__version__
        else:
            self.ideep_version = None 
开发者ID:chainer,项目名称:chainer,代码行数:15,代码来源:_runtime_info.py

示例10: create_logger

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def create_logger(args, result_dir):
    logging.basicConfig(filename='{}/log.txt'.format(result_dir))
    root = logging.getLogger()
    root.setLevel(logging.DEBUG)
    ch = logging.StreamHandler(sys.stdout)
    ch.setLevel(logging.DEBUG)
    msg_format = '%(asctime)s [%(levelname)s] %(message)s'
    formatter = logging.Formatter(msg_format)
    ch.setFormatter(formatter)
    root.addHandler(ch)
    logging.info(sys.version_info)
    logging.info('chainer version: {}'.format(chainer.__version__))
    logging.info('cuda: {}, cudnn: {}'.format(
        chainer.cuda.available, chainer.cuda.cudnn_enabled))
    logging.info(args) 
开发者ID:mitmul,项目名称:deeppose,代码行数:17,代码来源:train.py

示例11: test_backward_cpu

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def test_backward_cpu(model_no_dropout, data):
    atom_data, adj_data, y_grad = data
    if int(chainer.__version__[0]) <= 2:
        # somehow the test fails with `params` when using chainer version 2...
        # TODO(nakago): investigate why the test fails.
        params = ()
    else:
        params = tuple(model_no_dropout.params())
    # TODO(nakago): check why tolerance is high
    gradient_check.check_backward(
        model_no_dropout, (atom_data, adj_data), y_grad,
        params=params,
        atol=1e-1, rtol=1e-1, no_grads=[True, True]) 
开发者ID:chainer,项目名称:chainer-chemistry,代码行数:15,代码来源:test_rsgcn.py

示例12: test_backward_gpu

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def test_backward_gpu(model_no_dropout, data):
    atom_data, adj_data, y_grad = [cuda.to_gpu(d) for d in data]
    model_no_dropout.to_gpu()
    if int(chainer.__version__[0]) <= 2:
        # somehow the test fails with `params` when using chainer version 2...
        # TODO(nakago): investigate why the test fails.
        params = ()
    else:
        params = tuple(model_no_dropout.params())
    # TODO(nakago): check why tolerance is high
    gradient_check.check_backward(
        model_no_dropout, (atom_data, adj_data), y_grad,
        params=params,
        atol=1e-1, rtol=1e-1, no_grads=[True, True]) 
开发者ID:chainer,项目名称:chainer-chemistry,代码行数:16,代码来源:test_rsgcn.py

示例13: test_backward_cpu_with_nfp

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def test_backward_cpu_with_nfp(model_with_nfp_no_dropout, data):
    atom_data, adj_data, y_grad = data
    if int(chainer.__version__[0]) <= 2:
        params = ()
    else:
        params = tuple(model_with_nfp_no_dropout.params())
    gradient_check.check_backward(
        model_with_nfp_no_dropout, (atom_data, adj_data), y_grad,
        params=params,
        atol=1e-4, rtol=1e-4, no_grads=[True, True]) 
开发者ID:chainer,项目名称:chainer-chemistry,代码行数:12,代码来源:test_rsgcn.py

示例14: __init__

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def __init__(self, model, gpu=-1):
        self.model = model
        self.gpu = gpu

        if self.gpu >= 0:
            # if using pyCUDA version (v1.2.0 earlier)
            if chainer.__version__ <= '1.2.0':
                chainer.cuda.init(self.gpu)
            # CuPy (1.3.0 later) version
            else:
                chainer.cuda.get_device(self.gpu).use()

            self.model = self.model.to_gpu() 
开发者ID:tochikuji,项目名称:chainer-libDNN,代码行数:15,代码来源:nnbase.py

示例15: require_chainer_version

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import __version__ [as 别名]
def require_chainer_version(ver_oldest, ver_newest=None):
    """Decorator to turn on/off a test case by Chainer version

    Test case with this decorator is automatically activated for testing
    if the current Chainer version is between `ver_oldest` and `ver_newest`.
    In case `ver_newest` is not specified it is ignored.

    This is useful when the version of Chainer the current environment has does
    not suppor the operator that the test case tests.
    For example, Chaienr v3 doesn't have `groups` argument in Convolution2D.
    It cannot be checked by @require_import decorator so in this case
    this making use of this decorator like `@require_chainer_version('4.0.0')`
    would be appropriate.

    Args:
        ver_oldest: Version string of lower bound (inclusive).
          For example, '3.0.0'.
        ver_newest: Version string of upper bound (inclusive). Can be omitted.
    """
    def nothing(tester_func):
        def nothing_body(*args):
            ver_msg = "newer than or equals to {}".format(ver_oldest)
            if ver_newest is not None:
                ver_msg += " and older than or equal to {}".format(ver_newest)
            msg = "The test case \"{}\" requires Chainer version to be {}. "\
                  "Actual version is {}. Skipping."\
                  .format(tester_func.__name__, ver_msg, chainer.__version__)
            warnings.warn(msg)
            return None
        return nothing_body

    def run_test(tester_func):
        def f(*args):
            return tester_func(*args)
        return f

    ver_current = LooseVersion(chainer.__version__)
    if LooseVersion(ver_oldest) <= ver_current:
        if ver_newest is None or ver_current <= LooseVersion(ver_newest):
            return run_test
    return nothing 
开发者ID:belltailjp,项目名称:chainer_computational_cost,代码行数:43,代码来源:helpers.py


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