本文整理汇总了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], []
示例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,
)
示例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], []
示例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')",
)
示例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')")
示例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')")
示例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')",
)
示例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')")
示例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')")
示例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)
示例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)
示例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')",
)
示例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')",
)
示例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')",
)
示例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')",
)