You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi fellow developers, i was working on a simple 3d regressor model and i used the following parameters
#my code extract:
from mlprodict.onnxrt import OnnxInference
import numpy
import onnxruntime as onnx_RT
from sklearn.datasets import load_iris, load_diabetes, make_classification
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from xgboost import XGBClassifier, XGBRegressor, DMatrix, train as train_xgb
from skl2onnx.common.data_types import FloatTensorType
from skl2onnx import convert_sklearn, to_onnx, update_registered_converter
from skl2onnx.common.shape_calculator import (
calculate_linear_classifier_output_shapes,
calculate_linear_regressor_output_shapes)
from onnxmltools.convert.xgboost.operator_converters.XGBoost import (
convert_xgboost)
from onnxmltools.convert import convert_xgboost as convert_xgboost_booster
data = load_iris()
X = data.data[:, :2]
y = data.target
ind = numpy.arange(X.shape[0])
numpy.random.shuffle(ind)
X = X[ind, :].copy()
y = y[ind].copy()
models_01 = XGBRegressor( booster='gblinear', objective='reg:squarederror')
models_01.fit(X, y)
**#Register the converter for XGBRegressor**
update_registered_converter(
XGBRegressor, 'XGBoostXGBRegressor',
calculate_linear_regressor_output_shapes, convert_xgboost,
options={'nocl': [True, True], 'zipmap': [False, False, 'columns']}
)
**#convert to ONNX**
onnx_result = convert_sklearn( models_01, "My_simple_XGBRegressor",
[('input', FloatTensorType([None, X.shape[1] ]))],
target_opset={'': 12, 'ai.onnx.ml': 2}, options={'zipmap': False},
)
I then tried to convert to load an inference session but it always returned the following error.....
#test the ONNX model onnx_model_inference = onnx_RT.InferenceSession( onnx_result.SerializeToString() ) #throws an error
#the error InvalidGraph: [ONNXRuntimeError] : 10 : INVALID_GRAPH : Load model from models_01.onnx failed: This is an invalid model. In Node, ("TreeEnsembleRegressor", TreeEnsembleRegressor, "ai.onnx.ml", -1) : ("input": tensor(float),) -> ("variable": tensor(float),) , Error Attribute 'nodes_falsenodeids' is expected to have field 'ints' #the error
please help... Thank you.
The text was updated successfully, but these errors were encountered:
Hi fellow developers, i was working on a simple 3d regressor model and i used the following parameters
#my code extract:
I then tried to convert to load an inference session but it always returned the following error.....
#test the ONNX model
onnx_model_inference = onnx_RT.InferenceSession( onnx_result.SerializeToString() ) #throws an error
#the error
InvalidGraph: [ONNXRuntimeError] : 10 : INVALID_GRAPH : Load model from models_01.onnx failed: This is an invalid model. In Node, ("TreeEnsembleRegressor", TreeEnsembleRegressor, "ai.onnx.ml", -1) : ("input": tensor(float),) -> ("variable": tensor(float),) , Error Attribute 'nodes_falsenodeids' is expected to have field 'ints'
#the error
please help... Thank you.
The text was updated successfully, but these errors were encountered: