當前位置: 首頁>>代碼示例>>Python>>正文


Python onnxruntime.__version__方法代碼示例

本文整理匯總了Python中onnxruntime.__version__方法的典型用法代碼示例。如果您正苦於以下問題:Python onnxruntime.__version__方法的具體用法?Python onnxruntime.__version__怎麽用?Python onnxruntime.__version__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在onnxruntime的用法示例。


在下文中一共展示了onnxruntime.__version__方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: kerasonnx_version_role

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime import __version__ [as 別名]
def kerasonnx_version_role(role, rawtext, text, lineno, inliner, options=None, content=None):
    """
    Defines custom role *keras2onnx-version* which returns
    *keras2onnx* version.
    """
    if options is None:
        options = {}
    if content is None:
        content = []
    if text == 'v':
        version = 'v' + keras2onnx.__version__
    elif text == 'rt':
        version = 'v' + onnxruntime.__version__
    else:
        raise RuntimeError("keras2onnx_version_role cannot interpret content '{0}'.".format(text))
    node = nodes.Text(version)
    return [node], [] 
開發者ID:onnx,項目名稱:keras-onnx,代碼行數:19,代碼來源:sphinx_keras2onnx_extension.py

示例2: get_default_conda_env

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime 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

示例3: skl2onnx_version_role

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime import __version__ [as 別名]
def skl2onnx_version_role(role, rawtext, text, lineno, inliner, options=None, content=None):
    """
    Defines custom role *skl2onnx-version* which returns
    *skl2onnx* version.
    """
    if options is None:
        options = {}
    if content is None:
        content = []
    if text == 'v':
        version = 'v' + skl2onnx.__version__
    elif text == 'rt':
        version = 'v' + onnxruntime.__version__
    else:
        raise RuntimeError("skl2onnx_version_role cannot interpret content '{0}'.".format(text))
    node = nodes.literal(version)
    return [node], [] 
開發者ID:onnx,項目名稱:sklearn-onnx,代碼行數:19,代碼來源:sphinx_skl2onnx_extension.py

示例4: test_extra_tree_classifier

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime import __version__ [as 別名]
def test_extra_tree_classifier(self):
        model = ExtraTreeClassifier()
        dump_one_class_classification(
            model,
            # Operator cast-1 is not implemented in onnxruntime
            allow_failure="StrictVersion(onnx.__version__)"
                          " < StrictVersion('1.3') or "
                          "StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.2.1')",
        )
        dump_binary_classification(
            model,
            allow_failure="StrictVersion(onnx.__version__)"
                          " < StrictVersion('1.3') or "
                          "StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.2.1')",
        )
        dump_multiple_classification(
            model,
            allow_failure="StrictVersion(onnx.__version__)"
                          " < StrictVersion('1.3') or "
                          "StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.2.1')",
        ) 
開發者ID:onnx,項目名稱:sklearn-onnx,代碼行數:26,代碼來源:test_sklearn_decision_tree_converters.py

示例5: test_decision_tree_regressor_int

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime import __version__ [as 別名]
def test_decision_tree_regressor_int(self):
        model, X = fit_regression_model(
            DecisionTreeRegressor(random_state=42), is_int=True)
        model_onnx = convert_sklearn(
            model,
            "decision tree regression",
            [("input", Int64TensorType([None, X.shape[1]]))],
        )
        self.assertIsNotNone(model_onnx)
        dump_data_and_model(
            X,
            model,
            model_onnx,
            basename="SklearnDecisionTreeRegressionInt",
            allow_failure="StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.2.1')") 
開發者ID:onnx,項目名稱:sklearn-onnx,代碼行數:18,代碼來源:test_sklearn_decision_tree_converters.py

示例6: test_model_multi_class_nocl

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime import __version__ [as 別名]
def test_model_multi_class_nocl(self):
        model, X = fit_classification_model(
            DecisionTreeClassifier(),
            4, label_string=True)
        model_onnx = convert_sklearn(
            model,
            "multi-class nocl",
            [("input", FloatTensorType([None, X.shape[1]]))],
            options={id(model): {'nocl': True}})
        self.assertIsNotNone(model_onnx)
        sonx = str(model_onnx)
        assert 'classlabels_strings' not in sonx
        assert 'cl0' not in sonx
        dump_data_and_model(
            X, model, model_onnx, classes=model.classes_,
            basename="SklearnDTMultiNoCl",
            allow_failure="StrictVersion(onnx.__version__)"
                          " < StrictVersion('1.2') or "
                          "StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.2.1')") 
開發者ID:onnx,項目名稱:sklearn-onnx,代碼行數:22,代碼來源:test_sklearn_decision_tree_converters.py

示例7: test_model_extra_tree_classifier_multilabel

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime import __version__ [as 別名]
def test_model_extra_tree_classifier_multilabel(self):
        model, X_test = fit_multilabel_classification_model(
            ExtraTreeClassifier(random_state=42))
        options = {id(model): {'zipmap': False}}
        model_onnx = convert_sklearn(
            model,
            "scikit-learn ExtraTreeClassifier",
            [("input", FloatTensorType([None, X_test.shape[1]]))],
            options=options,
            target_opset=TARGET_OPSET
        )
        self.assertTrue(model_onnx is not None)
        assert 'zipmap' not in str(model_onnx).lower()
        dump_data_and_model(
            X_test,
            model,
            model_onnx,
            basename="SklearnExtraTreeClassifierMultiLabel-Out0",
            allow_failure="StrictVersion("
            "onnxruntime.__version__) <= StrictVersion('0.2.1')",
        ) 
開發者ID:onnx,項目名稱:sklearn-onnx,代碼行數:23,代碼來源:test_sklearn_decision_tree_converters.py

示例8: test_decision_tree_regressor_bool

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime import __version__ [as 別名]
def test_decision_tree_regressor_bool(self):
        model, X = fit_regression_model(
            DecisionTreeRegressor(random_state=42), is_bool=True)
        model_onnx = convert_sklearn(
            model,
            "decision tree regressor",
            [("input", BooleanTensorType([None, X.shape[1]]))],
        )
        self.assertIsNotNone(model_onnx)
        dump_data_and_model(
            X,
            model,
            model_onnx,
            basename="SklearnDecisionTreeRegressionBool-Dec4",
            allow_failure="StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.2.1')") 
開發者ID:onnx,項目名稱:sklearn-onnx,代碼行數:18,代碼來源:test_sklearn_decision_tree_converters.py

示例9: test_extra_tree_regressor_bool

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime import __version__ [as 別名]
def test_extra_tree_regressor_bool(self):
        model, X = fit_regression_model(
            ExtraTreeRegressor(random_state=42), is_bool=True)
        model_onnx = convert_sklearn(
            model,
            "extra tree regressor",
            [("input", BooleanTensorType([None, X.shape[1]]))],
        )
        self.assertIsNotNone(model_onnx)
        dump_data_and_model(
            X,
            model,
            model_onnx,
            basename="SklearnExtraTreeRegressionBool-Dec4",
            allow_failure="StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.2.1')") 
開發者ID:onnx,項目名稱:sklearn-onnx,代碼行數:18,代碼來源:test_sklearn_decision_tree_converters.py

示例10: test_model_tfidf_vectorizer11

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime import __version__ [as 別名]
def test_model_tfidf_vectorizer11(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, 1), norm=None)
        vect.fit(corpus.ravel())
        model_onnx = convert_sklearn(vect, "TfidfVectorizer",
                                     [("input", StringTensorType())],
                                     options=self.get_options())
        self.assertTrue(model_onnx is not None)
        dump_data_and_model(
            corpus,
            vect,
            model_onnx,
            basename="SklearnTfidfVectorizer11-OneOff-SklCol",
            allow_failure="StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.4.0')",
        )

        sess = InferenceSession(model_onnx.SerializeToString())
        res = sess.run(None, {'input': corpus.ravel()})[0]
        assert res.shape == (4, 9) 
開發者ID:onnx,項目名稱:sklearn-onnx,代碼行數:27,代碼來源:test_sklearn_tfidf_vectorizer_converter.py

示例11: test_model_tfidf_vectorizer11_nolowercase

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime import __version__ [as 別名]
def test_model_tfidf_vectorizer11_nolowercase(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, 1), norm=None, lowercase=False)
        vect.fit(corpus.ravel())
        model_onnx = convert_sklearn(vect, "TfidfVectorizer",
                                     [("input", StringTensorType())],
                                     options=self.get_options())
        self.assertTrue(model_onnx is not None)
        dump_data_and_model(
            corpus,
            vect,
            model_onnx,
            basename="SklearnTfidfVectorizer11NoL-OneOff-SklCol",
            allow_failure="StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.4.0')",
        )

        sess = InferenceSession(model_onnx.SerializeToString())
        res = sess.run(None, {'input': corpus.ravel()})[0]
        assert res.shape == (4, 11) 
開發者ID:onnx,項目名稱:sklearn-onnx,代碼行數:27,代碼來源:test_sklearn_tfidf_vectorizer_converter.py

示例12: test_model_tfidf_vectorizer11_empty_string_case2

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime import __version__ [as 別名]
def test_model_tfidf_vectorizer11_empty_string_case2(self):
        corpus = numpy.array([
            "This is the first document.",
            "This document is the second document.",
            "And this is the third one.",
            "",
        ]).reshape((4, 1))
        vect = TfidfVectorizer(ngram_range=(1, 1), norm=None)
        vect.fit(corpus.ravel())
        model_onnx = convert_sklearn(vect, "TfidfVectorizer",
                                     [("input", StringTensorType([1]))],
                                     options=self.get_options())
        self.assertTrue(model_onnx is not None)
        # onnxruntime fails with empty strings
        dump_data_and_model(
            corpus,
            vect,
            model_onnx,
            basename="SklearnTfidfVectorizer11EmptyString-OneOff-SklCol",
            allow_failure="StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.4.0')",
        ) 
開發者ID:onnx,項目名稱:sklearn-onnx,代碼行數:24,代碼來源:test_sklearn_tfidf_vectorizer_converter.py

示例13: test_model_tfidf_vectorizer22

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime import __version__ [as 別名]
def test_model_tfidf_vectorizer22(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=(2, 2), norm=None)
        vect.fit(corpus.ravel())
        model_onnx = convert_sklearn(vect, "TfidfVectorizer",
                                     [("input", StringTensorType([1]))],
                                     options=self.get_options())
        self.assertTrue(model_onnx is not None)
        dump_data_and_model(
            corpus,
            vect,
            model_onnx,
            basename="SklearnTfidfVectorizer22-OneOff-SklCol",
            allow_failure="StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.4.0')",
        ) 
開發者ID:onnx,項目名稱:sklearn-onnx,代碼行數:23,代碼來源:test_sklearn_tfidf_vectorizer_converter.py

示例14: test_model_tfidf_vectorizer21

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime import __version__ [as 別名]
def test_model_tfidf_vectorizer21(self):
        corpus = numpy.array(["AA AA", "AA AA BB"]).reshape((2, 1))
        vect = TfidfVectorizer(ngram_range=(1, 2), norm=None)
        vect.fit(corpus.ravel())
        model_onnx = convert_sklearn(vect, "TfidfVectorizer",
                                     [("input", StringTensorType([1]))],
                                     options=self.get_options())
        self.assertTrue(model_onnx is not None)
        dump_data_and_model(
            corpus,
            vect,
            model_onnx,
            basename="SklearnTfidfVectorizer22S-OneOff-SklCol",
            allow_failure="StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.4.0')",
        ) 
開發者ID:onnx,項目名稱:sklearn-onnx,代碼行數:18,代碼來源:test_sklearn_tfidf_vectorizer_converter.py

示例15: test_model_tfidf_vectorizer12

# 需要導入模塊: import onnxruntime [as 別名]
# 或者: from onnxruntime import __version__ [as 別名]
def test_model_tfidf_vectorizer12(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=None)
        vect.fit(corpus.ravel())
        model_onnx = convert_sklearn(vect, "TfidfVectorizer",
                                     [("input", StringTensorType([1]))],
                                     options=self.get_options())
        self.assertTrue(model_onnx is not None)
        dump_data_and_model(
            corpus,
            vect,
            model_onnx,
            basename="SklearnTfidfVectorizer22-OneOff-SklCol",
            allow_failure="StrictVersion(onnxruntime.__version__)"
                          " <= StrictVersion('0.4.0')",
        ) 
開發者ID:onnx,項目名稱:sklearn-onnx,代碼行數:23,代碼來源:test_sklearn_tfidf_vectorizer_converter.py


注:本文中的onnxruntime.__version__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。