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
first of all thanks a lot for all of your efforts.
I am currently trying to convert a XGBoost classifier to ONNX format using a toy example. While doing that I am getting the following error AttributeError: 'numpy.uint8' object has no attribute 'encode'.
I am running on macOS Catalina, Version 10.15.6 and using the following Python (3.7.7) packages:
xgboost==1.1.0
onnx==1.6.0
onnxconverter-common==1.7.0
onnxmltools==1.7.0
The minimum working example is:
importtensorflowastffrompathlibimportPathfromsklearn.preprocessingimportStandardScalerimportxgboostasxgbimportonnxmltoolsdefxgboost_example():
""" Train a simple xgboost model and store associated artefacts. """path=Path('/PATH/TO/LOCAL/FOLDER')
(X_train, y_train), (X_test, y_test) =tf.keras.datasets.mnist.load_data()
X_train=X_train.reshape((X_train.shape[0], -1))
#X_test = X_test.reshape((X_test.shape[0], -1))scaler=StandardScaler()
X_train=scaler.fit_transform(X_train)
#X_test = scaler.transform(X_test)sh=X_train[0].reshape(1, -1).shapeclf=xgb.XGBClassifier(objective="multi:softprob", n_jobs=-1)
clf.fit(X_train, y_train)
onnx_model=onnxmltools.convert_xgboost(clf, initial_types=[
('float_input', onnxmltools.convert.common.data_types.FloatTensorType(sh))])
onnxmltools.utils.save_model(onnx_model, path.joinpath('model_onnxmltools.onnx'))
if__name__=="__main__":
xgboost_example()
Dear all,
first of all thanks a lot for all of your efforts.
I am currently trying to convert a XGBoost classifier to ONNX format using a toy example. While doing that I am getting the following error
AttributeError: 'numpy.uint8' object has no attribute 'encode'
.I am running on macOS Catalina, Version 10.15.6 and using the following Python (3.7.7) packages:
The minimum working example is:
The traceback is:
Do you have any ideas on whether I am doing something wrong or whether there is another issue?
Thanks a lot!
The text was updated successfully, but these errors were encountered: