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


Python mxnet.__version__方法代码示例

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


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

示例1: check_mxnet

# 需要导入模块: import mxnet [as 别名]
# 或者: from mxnet import __version__ [as 别名]
def check_mxnet():
    print('----------MXNet Info-----------')
    try:
        import mxnet
        print('Version      :', mxnet.__version__)
        mx_dir = os.path.dirname(mxnet.__file__)
        print('Directory    :', mx_dir)
        commit_hash = os.path.join(mx_dir, 'COMMIT_HASH')
        with open(commit_hash, 'r') as f:
            ch = f.read().strip()
            print('Commit Hash   :', ch)
    except ImportError:
        print('No MXNet installed.')
    except IOError:
        print('Hashtag not found. Not installed from pre-built package.')
    except Exception as e:
        import traceback
        if not isinstance(e, IOError):
            print("An error occured trying to import mxnet.")
            print("This is very likely due to missing missing or incompatible library files.")
        print(traceback.format_exc()) 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:23,代码来源:diagnose.py

示例2: check_version

# 需要导入模块: import mxnet [as 别名]
# 或者: from mxnet import __version__ [as 别名]
def check_version(min_version, warning_only=False):
    """Check the version of gluoncv satisfies the provided minimum version.
    An exception is thrown if the check does not pass.

    Parameters
    ----------
    min_version : str
        Minimum version
    warning_only : bool
        Printing a warning instead of throwing an exception.
    """
    from .. import __version__
    from distutils.version import LooseVersion
    bad_version = LooseVersion(__version__) < LooseVersion(min_version)
    if bad_version:
        msg = 'Installed GluonCV version (%s) does not satisfy the ' \
              'minimum required version (%s)'%(__version__, min_version)
        if warning_only:
            warnings.warn(msg)
        else:
            raise AssertionError(msg) 
开发者ID:dmlc,项目名称:gluon-cv,代码行数:23,代码来源:version.py

示例3: _require_mxnet_version

# 需要导入模块: import mxnet [as 别名]
# 或者: from mxnet import __version__ [as 别名]
def _require_mxnet_version(mx_version, max_mx_version='2.0.0'):
    try:
        import mxnet as mx
        from distutils.version import LooseVersion
        if LooseVersion(mx.__version__) < LooseVersion(mx_version) or \
            LooseVersion(mx.__version__) >= LooseVersion(max_mx_version):
            version_str = '>={},<{}'.format(mx_version, max_mx_version)
            msg = (
                "Legacy mxnet-mkl=={0} detected, some modules may not work properly. "
                "mxnet-mkl{1} is required. You can use pip to upgrade mxnet "
                "`pip install -U 'mxnet-mkl{1}'` "
                "or `pip install -U 'mxnet-cu100mkl{1}'`\
                ").format(mx.__version__, version_str)
            raise RuntimeError(msg)
    except ImportError:
        raise ImportError(
            "Unable to import dependency mxnet. "
            "A quick tip is to install via "
            "`pip install 'mxnet-cu100mkl<{}'`. "
            "please refer to https://gluon-cv.mxnet.io/#installation for details.".format(
                max_mx_version)) 
开发者ID:dmlc,项目名称:gluon-cv,代码行数:23,代码来源:version.py

示例4: update_metric

# 需要导入模块: import mxnet [as 别名]
# 或者: from mxnet import __version__ [as 别名]
def update_metric(self, eval_metric, labels, pre_sliced=False):
        """Evaluates and accumulates evaluation metric on outputs of the last forward computation.

        See Also
        ----------
        :meth:`BaseModule.update_metric`.

        Parameters
        ----------
        eval_metric : EvalMetric
            Evaluation metric to use.
        labels : list of NDArray if `pre_sliced` parameter is set to `False`,
            list of lists of NDArray otherwise. Typically `data_batch.label`.
        pre_sliced: bool
            Whether the labels are already sliced per device (default: False).
        """
        if mxnet.__version__ >= "1.3.0":
            self._exec_group.update_metric(eval_metric, labels, pre_sliced)
        else:
            self._exec_group.update_metric(eval_metric, labels) 
开发者ID:TuSimple,项目名称:simpledet,代码行数:22,代码来源:detection_module.py

示例5: update

# 需要导入模块: import mxnet [as 别名]
# 或者: from mxnet import __version__ [as 别名]
def update(self):
        """Update parameters according to the installed optimizer and the gradients computed
        in the previous forward-backward batch.
        """
        assert self.binded and self.params_initialized and self.optimizer_initialized

        self._params_dirty = True
        if self._update_on_kvstore:
            if int(mx.__version__[0]) == 1:
                _update_params_on_kvstore(self._exec_group.param_arrays,
                                      self._exec_group.grad_arrays,
                                      self._kvstore,
                                      self._exec_group.param_names)
            else:
                _update_params_on_kvstore(self._exec_group.param_arrays,
                                      self._exec_group.grad_arrays,
                                      self._kvstore)
        else:
            _update_params(self._exec_group.param_arrays,
                           self._exec_group.grad_arrays,
                           updater=self._updater,
                           num_device=len(self._context),
                           kvstore=self._kvstore) 
开发者ID:i-pan,项目名称:kaggle-rsna18,代码行数:25,代码来源:module.py

示例6: check_mxnet_version

# 需要导入模块: import mxnet [as 别名]
# 或者: from mxnet import __version__ [as 别名]
def check_mxnet_version(min_ver):
    if not int(os.environ.get('UPDATE_MXNET_FOR_ONNX_EXPORTER', '1')):
        print("Env var set to not upgrade MxNet for ONNX exporter. Skipping.")
        return False
    try:
        print("Checking if MxNet is installed.")
        import mxnet as mx
    except ImportError:
        print("MxNet is not installed. Installing version from requirements.txt")
        return False
    ver = float(re.match(extract_major_minor, mx.__version__).group(1))
    min_ver = float(re.match(extract_major_minor, min_ver).group(1))
    if ver < min_ver:
        print("MxNet is installed, but installed version (%s) is older than expected (%s). Upgrading." % (str(ver).rstrip('0'), str(min_ver).rstrip('0')))
        return False
    print("Installed MxNet version (%s) meets the requirement of >= (%s). No need to install." % (str(ver).rstrip('0'), str(min_ver).rstrip('0')))
    return True 
开发者ID:NVIDIA,项目名称:mxnet_to_onnx,代码行数:19,代码来源:setup.py

示例7: try_import_mxnet

# 需要导入模块: import mxnet [as 别名]
# 或者: from mxnet import __version__ [as 别名]
def try_import_mxnet():
    mx_version = '1.4.1'
    try:
        import mxnet as mx
        from distutils.version import LooseVersion

        if LooseVersion(mx.__version__) < LooseVersion(mx_version):
            msg = (
                "Legacy mxnet-mkl=={} detected, some new modules may not work properly. "
                "mxnet-mkl>={} is required. You can use pip to upgrade mxnet "
                "`pip install mxnet-mkl --pre --upgrade` "
                "or `pip install mxnet-cu90mkl --pre --upgrade`").format(mx.__version__, mx_version)
            raise ImportError(msg)
    except ImportError:
        raise ImportError(
            "Unable to import dependency mxnet. "
            "A quick tip is to install via `pip install mxnet-mkl/mxnet-cu90mkl --pre`. ") 
开发者ID:awslabs,项目名称:autogluon,代码行数:19,代码来源:try_import.py

示例8: try_import_gluonnlp

# 需要导入模块: import mxnet [as 别名]
# 或者: from mxnet import __version__ [as 别名]
def try_import_gluonnlp():
    try:
        import gluonnlp
        # TODO After 1.0 is supported,
        #  we will remove the checking here and use gluonnlp.utils.check_version instead.
        from pkg_resources import parse_version  # pylint: disable=import-outside-toplevel
        gluonnlp_version = parse_version(gluonnlp.__version__)
        assert gluonnlp_version >= parse_version('0.8.1') and\
               gluonnlp_version <= parse_version('0.8.3'), \
            'Currently, we only support 0.8.1<=gluonnlp<=0.8.3'
    except ImportError:
        raise ImportError(
            "Unable to import dependency gluonnlp. The NLP model won't be available "
            "without installing gluonnlp. "
            "A quick tip is to install via `pip install gluonnlp==0.8.1`. ")
    return gluonnlp 
开发者ID:awslabs,项目名称:autogluon,代码行数:18,代码来源:try_import.py

示例9: check_pip

# 需要导入模块: import mxnet [as 别名]
# 或者: from mxnet import __version__ [as 别名]
def check_pip():
    print('------------Pip Info-----------')
    try:
        import pip
        print('Version      :', pip.__version__)
        print('Directory    :', os.path.dirname(pip.__file__))
    except ImportError:
        print('No corresponding pip install for current python.') 
开发者ID:awslabs,项目名称:dynamic-training-with-apache-mxnet-on-aws,代码行数:10,代码来源:diagnose.py

示例10: log_sockeye_version

# 需要导入模块: import mxnet [as 别名]
# 或者: from mxnet import __version__ [as 别名]
def log_sockeye_version(logger):
    from sockeye import __version__, __file__
    try:
        from sockeye.git_version import git_hash
    except ImportError:
        git_hash = "unknown"
    logger.info("Sockeye version %s, commit %s, path %s", __version__, git_hash, __file__) 
开发者ID:awslabs,项目名称:sockeye,代码行数:9,代码来源:log.py

示例11: log_mxnet_version

# 需要导入模块: import mxnet [as 别名]
# 或者: from mxnet import __version__ [as 别名]
def log_mxnet_version(logger):
    from mxnet import __version__, __file__
    logger.info("MXNet version %s, path %s", __version__, __file__) 
开发者ID:awslabs,项目名称:sockeye,代码行数:5,代码来源:log.py

示例12: get_default_conda_env

# 需要导入模块: import mxnet [as 别名]
# 或者: from mxnet import __version__ [as 别名]
def get_default_conda_env():
    """
    :return: The default Conda environment for MLflow Models produced by calls to
             :func:`save_model()` and :func:`log_model()`.
    """
    pip_deps = ["mxnet=={}".format(mx.__version__)]

    return _mlflow_conda_env(additional_pip_deps=pip_deps) 
开发者ID:mlflow,项目名称:mlflow,代码行数:10,代码来源:gluon.py

示例13: __init__

# 需要导入模块: import mxnet [as 别名]
# 或者: from mxnet import __version__ [as 别名]
def __init__(self, config, model, criterion, ctx, sample_input):
        config['trainer']['output_dir'] = os.path.join(str(pathlib.Path(os.path.abspath(__name__)).parent),
                                                       config['trainer']['output_dir'])
        config['name'] = config['name'] + '_' + model.model_name
        self.save_dir = os.path.join(config['trainer']['output_dir'], config['name'])
        self.checkpoint_dir = os.path.join(self.save_dir, 'checkpoint')
        self.alphabet = config['dataset']['alphabet']

        if config['trainer']['resume_checkpoint'] == '' and config['trainer']['finetune_checkpoint'] == '':
            shutil.rmtree(self.save_dir, ignore_errors=True)
        if not os.path.exists(self.checkpoint_dir):
            os.makedirs(self.checkpoint_dir)
        # 保存本次实验的alphabet 到模型保存的地方
        save(list(self.alphabet), os.path.join(self.save_dir, 'dict.txt'))
        self.global_step = 0
        self.start_epoch = 0
        self.config = config

        self.model = model
        self.criterion = criterion
        # logger and tensorboard
        self.tensorboard_enable = self.config['trainer']['tensorboard']
        self.epochs = self.config['trainer']['epochs']
        self.display_interval = self.config['trainer']['display_interval']
        if self.tensorboard_enable:
            from mxboard import SummaryWriter
            self.writer = SummaryWriter(self.save_dir, verbose=False)

        self.logger = setup_logger(os.path.join(self.save_dir, 'train.log'))
        self.logger.info(pformat(self.config))
        self.logger.info(self.model)
        # device set
        self.ctx = ctx
        mx.random.seed(2)  # 设置随机种子

        self.logger.info('train with mxnet: {} and device: {}'.format(mx.__version__, self.ctx))
        self.metrics = {'val_acc': 0, 'train_loss': float('inf'), 'best_model': ''}

        schedule = self._initialize('lr_scheduler', mx.lr_scheduler)
        optimizer = self._initialize('optimizer', mx.optimizer, lr_scheduler=schedule)
        self.trainer = gluon.Trainer(self.model.collect_params(), optimizer=optimizer)

        if self.config['trainer']['resume_checkpoint'] != '':
            self._laod_checkpoint(self.config['trainer']['resume_checkpoint'], resume=True)
        elif self.config['trainer']['finetune_checkpoint'] != '':
            self._laod_checkpoint(self.config['trainer']['finetune_checkpoint'], resume=False)

        if self.tensorboard_enable:
            try:
                # add graph
                from mxnet.gluon import utils as gutils
                self.model(sample_input)
                self.writer.add_graph(model)
            except:
                self.logger.error(traceback.format_exc())
                self.logger.warn('add graph to tensorboard failed') 
开发者ID:WenmuZhou,项目名称:crnn.gluon,代码行数:58,代码来源:base_trainer.py


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