當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。