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
I get the following error when using the OneHotEncoder of the sklearn library. NotImplemented: [ONNXRuntimeError] : 9 : NOT_IMPLEMENTED : Could not find an implementation for Reshape(19) node with name 'Reshape'
As you can see in the code below, the model is really simple:
import pandas as pd
import numpy as np
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import RobustScaler, OneHotEncoder
from sklearn.compose import ColumnTransformer
from sklearn.neural_network import MLPRegressor
import skl2onnx
from skl2onnx import convert_sklearn
from skl2onnx.algebra.type_helper import guess_initial_types
import onnxruntime as rt
X=pd.DataFrame({"A":[1,2,3], "B":["dog", "cat", "dog"], "C":["blue", "red", "green"]})
y=np.array([0,1,42])
preprocessor = ColumnTransformer(
transformers=[
("num", RobustScaler(), ["A"]),
("cat", OneHotEncoder(), ["B", "C"]),
]
)
pipeline = Pipeline([
('Preprocessing', preprocessor),
('Estimator', MLPRegressor(
hidden_layer_sizes=[10],
max_iter=2))
])
pipeline.fit(X,y)
initial_types = guess_initial_types(X=X, initial_types=None)
onx = convert_sklearn(pipeline, initial_types=initial_types)
with open("./example.onnx", "wb") as f:
f.write(onx.SerializeToString())
sess = rt.InferenceSession("example.onnx", providers=rt.get_available_providers())
Traceback:
NotImplemented Traceback (most recent call last)
Cell In[5], line 36
33 with open("./example.onnx", "wb") as f:
34 f.write(onx.SerializeToString())
---> 36 sess = rt.InferenceSession("example.onnx", providers=rt.get_available_providers())
File /anaconda/envs/azureml_py310_sdkv2/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py:383, in InferenceSession.__init__(self, path_or_bytes, sess_options, providers, provider_options, **kwargs)
380 disabled_optimizers = kwargs["disabled_optimizers"] if "disabled_optimizers" in kwargs else None
382 try:
--> 383 self._create_inference_session(providers, provider_options, disabled_optimizers)
384 except (ValueError, RuntimeError) as e:
385 if self._enable_fallback:
File /anaconda/envs/azureml_py310_sdkv2/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_inference_collection.py:435, in InferenceSession._create_inference_session(self, providers, provider_options, disabled_optimizers)
432 disabled_optimizers = set(disabled_optimizers)
434 # initialize the C++ InferenceSession
--> 435 sess.initialize_session(providers, provider_options, disabled_optimizers)
437 self._sess = sess
438 self._sess_options = self._sess.session_options
NotImplemented: [ONNXRuntimeError] : 9 : NOT_IMPLEMENTED : Could not find an implementation for Reshape(19) node with name 'Reshape'
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I get the following error when using the OneHotEncoder of the sklearn library.
NotImplemented: [ONNXRuntimeError] : 9 : NOT_IMPLEMENTED : Could not find an implementation for Reshape(19) node with name 'Reshape'
As you can see in the code below, the model is really simple:
Traceback:
Beta Was this translation helpful? Give feedback.
All reactions