-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onnx converted : xgboostRegressor multioutput model predicts 1 dimension instead of original 210 dimensions. #676
Comments
devspatron
changed the title
xgboost multioutput model predicts 1 dimension instead of original 210 dimensions.
onnx converted : xgboostRegressor multioutput model predicts 1 dimension instead of original 210 dimensions.
Jan 16, 2024
Did you try since the PR was merged? |
Will try soonest possible
…On Thu, Feb 8, 2024, 16:50 Xavier Dupré ***@***.***> wrote:
Did you try since the PR was merged?
—
Reply to this email directly, view it on GitHub
<#676 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUR5T7TKAUS3IEL5WAF3FJLYSTJY5AVCNFSM6AAAAABB46AY7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZUGE3DGMRYGY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Hello Xavier Dupré, its blurshift again with the same problem i have ran
this code on google colab
------------------------------
the code
code= "
//export models as ONNX
!pip install onnx
!pip install onnxmltools
!pip install skl2onnx
!pip install keras2onnx
!pip install onnxruntime
//!pip uninstall protobuf
//!pip install protobuf==4.21.9
!pip install protobuf==3.20.*
!pip freeze | grep protobuf
//use my cpu specifi version
!pip install -U xgboost==1.7.5
//code as follows:
import xgboost
import numpy as np
import onnxmltools
from skl2onnx import convert_sklearn
from skl2onnx.common.data_types import FloatTensorType
from skl2onnx import update_registered_converter
//Your data and labels [-Ox (253, 84) -Oy (253, 112) -]
X = np.random.rand(100, 10 )
y = np.random.rand(100, 210 )
//Train XGBoost regressor
model = xgboost.XGBRegressor(objective='reg:squarederror', n_estimators=10,
);
model.fit(X, y);
//Define input type (adjust shape according to your input)
num_features0 = X.shape[-1];
initial_type = [('float_input', FloatTensorType([None, num_features0 ]))]
//Convert XGBoost model to ONNX
onnx_model = convert_sklearn( model, initial_types=initial_type,
target_opset=12, );
//onnx_model = onnxmltools.convert_xgboost( model=model,
initial_types=[('input', FloatTensorType([None, num_features0 ]))], );
//Save the ONNX model /content/sample_data
with open( "/content/xgboost_model.onnx", "wb" ) as f:
f.write( onnx_model.SerializeToString())
";
------------------------------
the error
the error i get
error ="
MissingShapeCalculator Traceback (most recent call last)
<https://localhost:8080/#> in <cell line: 22>()
20
21 # Convert XGBoost model to ONNX
---> 22 onnx_model = convert_sklearn( model, initial_types=initial_type,
target_opset=12, );
23 # onnx_model = onnxmltools.convert_xgboost( model=model,
initial_types=[('input', FloatTensorType([None, num_features0 ]))], );
24
4 frames
/usr/local/lib/python3.10/dist-packages/skl2onnx/common/_topology.py
<https://localhost:8080/#> in infer_types(self)
628 # Invoke a core inference function
629 if self.type is None:
--> 630 raise MissingShapeCalculator(
631 "Unable to find a shape calculator for type '{}'.".format(
632 type(self.raw_operator)
MissingShapeCalculator: Unable to find a shape calculator for type '<class
'xgboost.sklearn.XGBRegressor'>'.
It usually means the pipeline being converted contains a
transformer or a predictor with no corresponding converter
implemented in sklearn-onnx. If the converted is implemented
in another library, you need to register
the converted so that it can be used by sklearn-onnx (function
update_registered_converter). If the model is not yet covered
by sklearn-onnx, you may raise an issue to
https://github.com/onnx/sklearn-onnx/issues
to get the converter implemented or even contribute to the
project. If the model is a custom model, a new converter must
be implemented. Examples can be found in the gallery.
";
This problem still persists, even after installing new packages, Could you
try running my code on google colab and try to examine the resulting
converted onnx model using 'https://netron.app/'. Ensure the app has output
shape=(-1, 210).
Thank you.
…On Wed, Feb 14, 2024 at 11:09 PM Patron Devs ***@***.***> wrote:
Will try soonest possible
On Thu, Feb 8, 2024, 16:50 Xavier Dupré ***@***.***> wrote:
> Did you try since the PR was merged?
>
> —
> Reply to this email directly, view it on GitHub
> <#676 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AUR5T7TKAUS3IEL5WAF3FJLYSTJY5AVCNFSM6AAAAABB46AY7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZUGE3DGMRYGY>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
Hi, I am experiencing the same problem with @devspatron. Onnx'ed model predicts just 1d instead of 2d in my case. Any help? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello machine learning engineers, i have tried to convert an xgboost regressor multi-output model trained on dataset shape=(1000, 210).
on the python runtime the model prediction predicts the correct shape = (1000,210) . However after converting the model into ONNX, the resulting onnx file is used with onnx_model = onnx_RT.InferenceSession(model_file_name), only predicts one dimension shape = (1000,1) instead of shape = (1000,210)
please help ASAP, PLEASE
The text was updated successfully, but these errors were encountered: