This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug while removing identity nodes
- Loading branch information
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
_unittests/ut_onnxrt/test_onnxrt_simple_gaussian_process.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" | ||
@brief test log(time=2s) | ||
""" | ||
import unittest | ||
from logging import getLogger | ||
import numpy | ||
from sklearn.datasets import load_iris | ||
from sklearn.model_selection import train_test_split | ||
from sklearn.gaussian_process import GaussianProcessRegressor | ||
from sklearn.gaussian_process.kernels import ExpSineSquared | ||
from pyquickhelper.pycode import ExtTestCase | ||
from skl2onnx import __version__ as skl2onnx_version | ||
from mlprodict.onnxrt import OnnxInference, to_onnx | ||
from mlprodict.onnxrt.optim import onnx_optimisations | ||
|
||
|
||
class TestOnnxrtSimpleGaussianProcess(ExtTestCase): | ||
|
||
def setUp(self): | ||
logger = getLogger('skl2onnx') | ||
logger.disabled = True | ||
|
||
def test_onnxt_gpr_iris(self): | ||
iris = load_iris() | ||
X, y = iris.data, iris.target | ||
X_train, _, y_train, __ = train_test_split(X, y, random_state=11) | ||
clr = GaussianProcessRegressor(ExpSineSquared(), alpha=20.) | ||
clr.fit(X_train, y_train) | ||
|
||
model_def = to_onnx(clr, X_train, dtype=numpy.float64) | ||
oinf = OnnxInference(model_def) | ||
res1 = oinf.run({'X': X_train}) | ||
new_model = onnx_optimisations(model_def) | ||
oinf = OnnxInference(new_model) | ||
res2 = oinf.run({'X': X_train}) | ||
self.assertEqualArray(res1['GPmean'], res2['GPmean']) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters