select_model_inputs_outputs seems to change the shape metadata of the output selected. The output itself is still OK.
For example
from skl2onnx import convert_sklearn
from skl2onnx.common.data_types import FloatTensorType
from skl2onnx.helpers.onnx_helper import select_model_inputs_outputs
from sklearn.ensemble import RandomForestClassifier
import numpy as np
import onnxruntime
# Get simple ONNX model
feature_names = "abcd"
X = np.random.normal(size=(500, len(feature_names)))
y = np.random.randint(0, 2, 500)
model = RandomForestClassifier(n_estimators=10)
model.fit(X, y)
# The output names of onnx_model will be ['output_label', 'output_probability']
onnx_model = convert_sklearn(
model,
initial_types=[("input", FloatTensorType((None, len(feature_names))))],
)
# print session output shape before selecting outputs
with open("model.onnx", "wb") as f:
f.write(onnx_model.SerializeToString())
session = onnxruntime.InferenceSession("model.onnx", None)
print("Output 0 shape before using select_model_inputs_outputs")
print(session.get_outputs()[0].shape)
# print session output shape after selecting outputs
onnx_model = select_model_inputs_outputs(onnx_model, outputs=["output_label"])
with open("model.onnx", "wb") as f:
f.write(onnx_model.SerializeToString())
session = onnxruntime.InferenceSession("model.onnx", None)
print("\nOutput 0 shape after using select_model_inputs_outputs")
print(session.get_outputs()[0].shape)
Prints
Output 0 shape before using select_model_inputs_outputs
[None]
Output 0 shape after using select_model_inputs_outputs
[]
It seems like any original output shape, not just [None], will go to [] after selecting it as an output.
Is this indeed just the output metadata that's being affected? Is there any workaround for now that would let me correct the shape after selecting model outputs?
The larger context is that I'm trying to serve my model with Triton, which complains that my model's output shape is [] or empty.
I'm using skl2onnx==1.11.1
select_model_inputs_outputsseems to change the shape metadata of the output selected. The output itself is still OK.For example
Prints
It seems like any original output shape, not just
[None], will go to[]after selecting it as an output.Is this indeed just the output metadata that's being affected? Is there any workaround for now that would let me correct the shape after selecting model outputs?
The larger context is that I'm trying to serve my model with Triton, which complains that my model's output shape is
[]or empty.I'm using
skl2onnx==1.11.1