本文整理匯總了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,
)
示例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
示例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)
示例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)
示例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)
示例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)
示例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')")
示例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')")
示例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')",
)
示例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')",
)
示例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')",
)
示例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')")
示例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')"
)
示例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')"
)
示例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')"
)