Python onnx.__version__() Examples
The following are 30
code examples of onnx.__version__().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
onnx
, or try the search function
.
Example #1
Source File: test_sklearn_tfidf_vectorizer_converter.py From sklearn-onnx with MIT License | 7 votes |
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)
Example #2
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_bernoulli_nb_binary_classification_bool(self): model, X = fit_classification_model( BernoulliNB(), 2, is_bool=True) model_onnx = convert_sklearn( model, "bernoulli naive bayes", [("input", BooleanTensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET, ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnBinBernoulliNBBool", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #3
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_multinomial_nb_multiclass(self): model, X = fit_classification_model( MultinomialNB(), 5, pos_features=True) model_onnx = convert_sklearn( model, "multinomial naive bayes", [("input", FloatTensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnMclMultinomialNB-Dec4", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #4
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_bernoulli_nb_binary_classification_int(self): model, X = fit_classification_model( BernoulliNB(), 2, is_int=True) model_onnx = convert_sklearn( model, "bernoulli naive bayes", [("input", Int64TensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnBinBernoulliNBInt", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #5
Source File: test_sklearn_k_means_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_batchkmeans_clustering(self): data = load_iris() X = data.data model = MiniBatchKMeans(n_clusters=3) model.fit(X) model_onnx = convert_sklearn(model, "kmeans", [("input", FloatTensorType([None, 4]))], target_opset=TARGET_OPSET) self.assertIsNotNone(model_onnx) dump_data_and_model( X.astype(numpy.float32)[40:60], model, model_onnx, basename="SklearnKMeans-Dec4", allow_failure="StrictVersion(onnx.__version__)" " < StrictVersion('1.2')", )
Example #6
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_bernoulli_nb_multiclass_params(self): model, X = fit_classification_model( BernoulliNB(alpha=0, binarize=1.0, fit_prior=False), 4) model_onnx = convert_sklearn( model, "bernoulli naive bayes", [("input", FloatTensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnMclBernoulliNBParams", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #7
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_bernoulli_nb_multiclass(self): model, X = fit_classification_model( BernoulliNB(), 4) model_onnx = convert_sklearn( model, "bernoulli naive bayes", [("input", FloatTensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnMclBernoulliNB", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #8
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_multinomial_nb_multiclass_params(self): model, X = fit_classification_model( MultinomialNB(alpha=0.5, fit_prior=False), 5, pos_features=True) model_onnx = convert_sklearn( model, "multinomial naive bayes", [("input", FloatTensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) pp = model.predict_proba(X) col = pp.shape[1] pps = np.sort(pp, axis=1) diff = pps[:, col-1] - pps[:, col-2] ind = diff >= 1e-4 dump_data_and_model( X[ind], model, model_onnx, basename="SklearnMclMultinomialNBParams-Dec4", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #9
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_multinomial_nb_binary_classification_bool(self): model, X = fit_classification_model( MultinomialNB(), 2, is_bool=True, pos_features=True) model_onnx = convert_sklearn( model, "multinomial naive bayes", [("input", BooleanTensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET, ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnBinMultinomialNBBool-Dec4", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #10
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_bernoulli_nb_multiclass_int(self): model, X = fit_classification_model( BernoulliNB(), 4, is_int=True) model_onnx = convert_sklearn( model, "bernoulli naive bayes", [("input", Int64TensorType([None, X.shape[1]]))], target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnMclBernoulliNBInt-Dec4", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #11
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_gaussian_nb_multiclass(self): model, X = fit_classification_model( GaussianNB(), 4) model_onnx = convert_sklearn( model, "gaussian naive bayes", [("input", FloatTensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnMclGaussianNB", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #12
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_gaussian_nb_binary_classification_int(self): model, X = fit_classification_model( GaussianNB(), 2, is_int=True) model_onnx = convert_sklearn( model, "gaussian naive bayes", [("input", Int64TensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnBinGaussianNBInt", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #13
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_gaussian_nb_multiclass_int(self): model, X = fit_classification_model( GaussianNB(), 5, is_int=True) model_onnx = convert_sklearn( model, "gaussian naive bayes", [("input", Int64TensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnMclGaussianNBInt-Dec4", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #14
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_gaussian_nb_multiclass_bool(self): model, X = fit_classification_model( GaussianNB(), 5, is_bool=True) model_onnx = convert_sklearn( model, "gaussian naive bayes", [("input", BooleanTensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET, ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnMclGaussianNBBool-Dec4", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #15
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_complement_nb_binary_classification(self): model, X = fit_classification_model( ComplementNB(), 2, pos_features=True) model_onnx = convert_sklearn( model, "complement naive bayes", [("input", FloatTensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnBinComplementNB-Dec4", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #16
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_complement_nb_binary_classification_int(self): model, X = fit_classification_model( ComplementNB(), 2, is_int=True, pos_features=True) model_onnx = convert_sklearn( model, "complement naive bayes", [("input", Int64TensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnBinComplementNBInt-Dec4", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')" )
Example #17
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_multinomial_nb_multiclass_int(self): model, X = fit_classification_model( MultinomialNB(), 5, is_int=True, pos_features=True) model_onnx = convert_sklearn( model, "multinomial naive bayes", [("input", Int64TensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnMclMultinomialNBInt-Dec4", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #18
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_bernoulli_nb_binary_classification(self): model, X = fit_classification_model( BernoulliNB(), 2) model_onnx = convert_sklearn( model, "bernoulli naive bayes", [("input", FloatTensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnBinBernoulliNB", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #19
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_complement_nb_multiclass_int(self): model, X = fit_classification_model( ComplementNB(), 5, is_int=True, pos_features=True) model_onnx = convert_sklearn( model, "complement naive bayes", [("input", Int64TensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnMclComplementNBInt-Dec4", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')")
Example #20
Source File: test_sklearn_tfidf_vectorizer_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_tfidf_vectorizer_binary(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(binary=True) 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="SklearnTfidfVectorizerBinary-OneOff-SklCol", allow_failure="StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.4.0')", )
Example #21
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_complement_nb_multiclass_bool(self): model, X = fit_classification_model( ComplementNB(), 5, is_bool=True, pos_features=True) model_onnx = convert_sklearn( model, "complement naive bayes", [("input", BooleanTensorType([None, X.shape[1]]))], dtype=np.float32, target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X, model, model_onnx, basename="SklearnMclComplementNBBool-Dec4", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')")
Example #22
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_categorical_nb(self): model, X = fit_classification_model( CategoricalNB(), 3, is_int=True, pos_features=True) model_onnx = convert_sklearn( model, "categorical naive bayes", [("input", Int64TensorType([None, X.shape[1]]))], target_opset=TARGET_OPSET ) self.assertIsNotNone(model_onnx) dump_data_and_model( X[10:13], model, model_onnx, basename="SklearnCategoricalNB", allow_failure="StrictVersion(onnxruntime.__version__)" "<= StrictVersion('0.2.1')", )
Example #23
Source File: test_sklearn_tfidf_vectorizer_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_tfidf_vectorizer13(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, 3), 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="SklearnTfidfVectorizer13-OneOff-SklCol", allow_failure="StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.4.0')", )
Example #24
Source File: test_sklearn_tfidf_vectorizer_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_tfidf_vectorizer12_normL1(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") 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="SklearnTfidfVectorizer22L1-OneOff-SklCol", allow_failure="StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.4.0')", )
Example #25
Source File: test_sklearn_tfidf_vectorizer_converter.py From sklearn-onnx with MIT License | 6 votes |
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')", )
Example #26
Source File: test_sklearn_tfidf_vectorizer_converter.py From sklearn-onnx with MIT License | 6 votes |
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')", )
Example #27
Source File: test_sklearn_tfidf_vectorizer_converter.py From sklearn-onnx with MIT License | 6 votes |
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')", )
Example #28
Source File: test_sklearn_naive_bayes_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_gaussian_nb_multi_class_nocl(self): model, X = fit_classification_model( GaussianNB(), 2, label_string=True) model_onnx = convert_sklearn( model, "GaussianNB multi-class nocl", [("input", FloatTensorType([None, X.shape[1]]))], options={id(model): {'nocl': True}}, target_opset=TARGET_OPSET) 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="SklearnGaussianNBMultiNoCl", verbose=False, allow_failure="StrictVersion(onnx.__version__)" " < StrictVersion('1.2') or " "StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.2.1')")
Example #29
Source File: test_sklearn_tfidf_vectorizer_converter.py From sklearn-onnx with MIT License | 6 votes |
def test_model_tfidf_vectorizer11_empty_string_case1(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[:3].ravel()) model_onnx = convert_sklearn(vect, 'TfidfVectorizer', [('input', StringTensorType([1]))], options=self.get_options()) self.assertTrue(model_onnx is not None) # TfidfVectorizer in onnxruntime fails with empty strings, # which was fixed in version 0.3.0 afterward dump_data_and_model( corpus[2:], vect, model_onnx, basename="SklearnTfidfVectorizer11EmptyStringSepCase1-" "OneOff-SklCol", allow_failure="StrictVersion(onnxruntime.__version__)" " <= StrictVersion('0.4.0')")
Example #30
Source File: test_sklearn_tfidf_vectorizer_converter.py From sklearn-onnx with MIT License | 6 votes |
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)