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


Python onnx.__version__方法代码示例

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


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

示例1: get_default_conda_env

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx 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()`.
    """
    import onnx
    import onnxruntime
    return _mlflow_conda_env(
        additional_conda_deps=None,
        additional_pip_deps=[
            "onnx=={}".format(onnx.__version__),
            # The ONNX pyfunc representation requires the OnnxRuntime
            # inference engine. Therefore, the conda environment must
            # include OnnxRuntime
            "onnxruntime=={}".format(onnxruntime.__version__),
        ],
        additional_conda_channels=None,
    ) 
开发者ID:mlflow,项目名称:mlflow,代码行数:20,代码来源:onnx.py

示例2: _check_opset_version

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import __version__ [as 别名]
def _check_opset_version(cls, opset_version):
        if opset_version is None:
            opset_version = list(cls.OPSET_VERSIONS.keys())[-1]
        else:
            if opset_version not in cls.OPSET_VERSIONS:
                detail_msg = 'OpSet %d is not supported.\n' % opset_version
                detail_msg += 'Following opset versions are available: {\n'
                for k, v in cls.OPSET_VERSIONS.items():
                    detail_msg += '  * Opset = %d, ONNX >= %s,\n' % (k, v)
                raise ValueError(detail_msg + '}')
        onnx_version = cls.OPSET_VERSIONS[opset_version]
        if onnx.__version__ < onnx_version:
            raise RuntimeError(
                'OpSet {} requires ONNX version >= {}. '
                '({} currently installed.)'
                .format(opset_version, onnx_version, onnx.__version__)
            )
        return opset_version 
开发者ID:seetaresearch,项目名称:dragon,代码行数:20,代码来源:frontend.py

示例3: test_model_tfidf_vectorizer11_short_word

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import __version__ [as 别名]
def test_model_tfidf_vectorizer11_short_word(self):
        corpus = numpy.array([
                'This is the first document.',
                'This document is the second document.',
                ]).reshape((2, 1))
        vect = TfidfVectorizer(ngram_range=(1, 1), norm=None,
                               analyzer='word', token_pattern=".{1,2}")
        vect.fit(corpus.ravel())
        model_onnx = convert_sklearn(vect, 'TfidfVectorizer',
                                     [('input', StringTensorType([1]))])
        self.assertTrue(model_onnx is not None)

        dump_data_and_model(
            corpus, vect, model_onnx,
            basename="SklearnTfidfVectorizer11CharW2-OneOff-SklCol",
            allow_failure="StrictVersion(onnxruntime.__version__) <= "
                          "StrictVersion('0.3.0')",
            verbose=False) 
开发者ID:onnx,项目名称:sklearn-onnx,代码行数:20,代码来源:test_sklearn_tfidf_vectorizer_converter_char.py

示例4: test_model_tfidf_vectorizer11_char

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import __version__ [as 别名]
def test_model_tfidf_vectorizer11_char(self):
        corpus = numpy.array([
                'This is the first document.',
                'This document is the second document.',
                ]).reshape((2, 1))
        vect = TfidfVectorizer(ngram_range=(1, 1), norm=None,
                               analyzer='char')
        vect.fit(corpus.ravel())
        model_onnx = convert_sklearn(vect, 'TfidfVectorizer',
                                     [('input', StringTensorType([1]))])
        self.assertTrue(model_onnx is not None)

        dump_data_and_model(
            corpus, vect, model_onnx,
            basename="SklearnTfidfVectorizer11Char-OneOff-SklCol",
            allow_failure="StrictVersion(onnxruntime.__version__) <= "
                          "StrictVersion('0.3.0')",
            verbose=False) 
开发者ID:onnx,项目名称:sklearn-onnx,代码行数:20,代码来源:test_sklearn_tfidf_vectorizer_converter_char.py

示例5: test_model_tfidf_vectorizer11_char_doublespace

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import __version__ [as 别名]
def test_model_tfidf_vectorizer11_char_doublespace(self):
        corpus = numpy.array([
                'This is the first  document.',
                'This document is the second document.',
                ]).reshape((2, 1))
        vect = TfidfVectorizer(ngram_range=(1, 1), norm=None,
                               analyzer='char')
        vect.fit(corpus.ravel())
        model_onnx = convert_sklearn(vect, 'TfidfVectorizer',
                                     [('input', StringTensorType([1]))])
        self.assertTrue(model_onnx is not None)

        dump_data_and_model(
            corpus, vect, model_onnx,
            basename="SklearnTfidfVectorizer11CharSpace-OneOff-SklCol",
            allow_failure="StrictVersion(onnxruntime.__version__) <= "
                          "StrictVersion('0.3.0')",
            verbose=False) 
开发者ID:onnx,项目名称:sklearn-onnx,代码行数:20,代码来源:test_sklearn_tfidf_vectorizer_converter_char.py

示例6: test_model_tfidf_vectorizer12_char

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import __version__ [as 别名]
def test_model_tfidf_vectorizer12_char(self):
        corpus = numpy.array([
                'This is the first document.',
                'This document is the second document.',
                ]).reshape((2, 1))
        vect = TfidfVectorizer(ngram_range=(1, 2), norm=None,
                               analyzer='char')
        vect.fit(corpus.ravel())
        model_onnx = convert_sklearn(vect, 'TfidfVectorizer',
                                     [('input', StringTensorType([1]))])
        self.assertTrue(model_onnx is not None)

        dump_data_and_model(
            corpus, vect, model_onnx,
            basename="SklearnTfidfVectorizer12Char-OneOff-SklCol",
            allow_failure="StrictVersion(onnxruntime.__version__) <= "
                          "StrictVersion('0.3.0')",
            verbose=False) 
开发者ID:onnx,项目名称:sklearn-onnx,代码行数:20,代码来源:test_sklearn_tfidf_vectorizer_converter_char.py

示例7: test_model_tfidf_vectorizer12_normL1_char

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import __version__ [as 别名]
def test_model_tfidf_vectorizer12_normL1_char(self):
        corpus = numpy.array([
                'This is the first document.',
                'This document is the second document.',
                'And this is the third one.',
                'Is this the first document?',
                ]).reshape((4, 1))
        vect = TfidfVectorizer(ngram_range=(1, 2), norm='l1', analyzer='char')
        vect.fit(corpus.ravel())
        model_onnx = convert_sklearn(vect, 'TfidfVectorizer',
                                     [('input', StringTensorType([1]))])
        self.assertTrue(model_onnx is not None)
        dump_data_and_model(
            corpus, vect, model_onnx,
            basename="SklearnTfidfVectorizer12L1Char-OneOff-SklCol",
            allow_failure="StrictVersion(onnxruntime.__version__) <= "
                          "StrictVersion('0.3.0')") 
开发者ID:onnx,项目名称:sklearn-onnx,代码行数:19,代码来源:test_sklearn_tfidf_vectorizer_converter_char.py

示例8: test_model_count_vectorizer_wrong_ngram

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import __version__ [as 别名]
def test_model_count_vectorizer_wrong_ngram(self):
        corpus = numpy.array([
            'A AABBB0',
            'AAABB B1',
            'AA ABBB2',
            'AAAB BB3',
            'AAA BBB4',
        ]).reshape((5, 1))
        vect = TfidfVectorizer(ngram_range=(1, 2),
                               token_pattern=r"(?u)\b\w\w+\b")
        vect.fit(corpus.ravel())

        model_onnx = convert_sklearn(vect, 'TfidfVectorizer',
                                     [('input', StringTensorType([1]))])

        self.assertTrue(model_onnx is not None)
        dump_data_and_model(
            corpus, vect, model_onnx,
            basename="SklearnTfidfVectorizer12Wngram-OneOff-SklCol",
            allow_failure="StrictVersion(onnxruntime.__version__) <= "
                          "StrictVersion('0.3.0')") 
开发者ID:onnx,项目名称:sklearn-onnx,代码行数:23,代码来源:test_sklearn_count_vectorizer_converter_bug.py

示例9: test_model_ordinal_encoder

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import __version__ [as 别名]
def test_model_ordinal_encoder(self):
        model = OrdinalEncoder(dtype=np.int64)
        data = np.array([[1, 2, 3], [4, 3, 0], [0, 1, 4], [0, 5, 6]],
                        dtype=np.int64)
        model.fit(data)
        model_onnx = convert_sklearn(
            model,
            "scikit-learn ordinal encoder",
            [("input", Int64TensorType([None, 3]))],
        )
        self.assertTrue(model_onnx is not None)
        dump_data_and_model(
            data,
            model,
            model_onnx,
            basename="SklearnOrdinalEncoderInt64-SkipDim1",
            allow_failure="StrictVersion("
            "onnxruntime.__version__)"
            "<= StrictVersion('0.5.0')",
        ) 
开发者ID:onnx,项目名称:sklearn-onnx,代码行数:22,代码来源:test_sklearn_ordinal_encoder.py

示例10: test_ordinal_encoder_onecat

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import __version__ [as 别名]
def test_ordinal_encoder_onecat(self):
        data = [["cat"], ["cat"]]
        model = OrdinalEncoder(categories="auto")
        model.fit(data)
        inputs = [("input1", StringTensorType([None, 1]))]
        model_onnx = convert_sklearn(model, "ordinal encoder one string cat",
                                     inputs)
        self.assertTrue(model_onnx is not None)
        dump_data_and_model(
            data,
            model,
            model_onnx,
            basename="SklearnOrdinalEncoderOneStringCat",
            allow_failure="StrictVersion("
            "onnxruntime.__version__)"
            "<= StrictVersion('0.5.0')",
        ) 
开发者ID:onnx,项目名称:sklearn-onnx,代码行数:19,代码来源:test_sklearn_ordinal_encoder.py

示例11: test_model_ordinal_encoder_cat_list

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import __version__ [as 别名]
def test_model_ordinal_encoder_cat_list(self):
        model = OrdinalEncoder(categories=[[0, 1, 4, 5],
                                           [1, 2, 3, 5],
                                           [0, 3, 4, 6]])
        data = np.array([[1, 2, 3], [4, 3, 0], [0, 1, 4], [0, 5, 6]],
                        dtype=np.int64)
        model.fit(data)
        model_onnx = convert_sklearn(
            model,
            "scikit-learn ordinal encoder",
            [("input", Int64TensorType([None, 3]))],
        )
        self.assertTrue(model_onnx is not None)
        dump_data_and_model(
            data,
            model,
            model_onnx,
            basename="SklearnOrdinalEncoderCatList",
            allow_failure="StrictVersion("
            "onnxruntime.__version__)"
            "<= StrictVersion('0.5.0')",
        ) 
开发者ID:onnx,项目名称:sklearn-onnx,代码行数:24,代码来源:test_sklearn_ordinal_encoder.py

示例12: test_convert_svc_multi_linear_ptrue

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import __version__ [as 别名]
def test_convert_svc_multi_linear_ptrue(self):
        model, X = self._fit_multi_classification(
            SVC(kernel="linear", probability=True))
        model_onnx = convert_sklearn(
            model, "SVC", [("input", FloatTensorType([None, X.shape[1]]))])
        nodes = model_onnx.graph.node
        self.assertIsNotNone(nodes)
        svc_node = nodes[0]
        self._check_attributes(
            svc_node, {
                "coefficients": None, "kernel_params": None,
                "kernel_type": "LINEAR", "post_transform": None,
                "rho": None, "support_vectors": None,
                "vectors_per_class": None})
        dump_data_and_model(
            X, model, model_onnx,
            basename="SklearnMclSVCLinearPT-Dec2",
            allow_failure="StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.4.0')") 
开发者ID:onnx,项目名称:sklearn-onnx,代码行数:21,代码来源:test_sklearn_svm_converters.py

示例13: test_convert_svr_int

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import __version__ [as 别名]
def test_convert_svr_int(self):
        model, X = fit_regression_model(
            SVR(), is_int=True)
        model_onnx = convert_sklearn(
            model,
            "SVR",
            [("input", Int64TensorType([None, X.shape[1]]))],
        )
        self.assertIsNotNone(model_onnx)
        dump_data_and_model(
            X,
            model,
            model_onnx,
            basename="SklearnSVRInt-Dec4",
            allow_failure="StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.2.1')"
        ) 
开发者ID:onnx,项目名称:sklearn-onnx,代码行数:19,代码来源:test_sklearn_svm_converters.py

示例14: test_convert_nusvr_int

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import __version__ [as 别名]
def test_convert_nusvr_int(self):
        model, X = fit_regression_model(
            NuSVR(), is_int=True)
        model_onnx = convert_sklearn(
            model,
            "NuSVR",
            [("input", Int64TensorType([None, X.shape[1]]))],
        )
        self.assertIsNotNone(model_onnx)
        dump_data_and_model(
            X,
            model,
            model_onnx,
            basename="SklearnNuSVRInt-Dec4",
            allow_failure="StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.2.1')"
        ) 
开发者ID:onnx,项目名称:sklearn-onnx,代码行数:19,代码来源:test_sklearn_svm_converters.py

示例15: test_convert_nusvr_bool

# 需要导入模块: import onnx [as 别名]
# 或者: from onnx import __version__ [as 别名]
def test_convert_nusvr_bool(self):
        model, X = fit_regression_model(
            NuSVR(), is_bool=True)
        model_onnx = convert_sklearn(
            model,
            "NuSVR",
            [("input", BooleanTensorType([None, X.shape[1]]))],
        )
        self.assertIsNotNone(model_onnx)
        dump_data_and_model(
            X,
            model,
            model_onnx,
            basename="SklearnNuSVRBool",
            allow_failure="StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.2.1')"
        ) 
开发者ID:onnx,项目名称:sklearn-onnx,代码行数:19,代码来源:test_sklearn_svm_converters.py


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