Skip to content

Cannot fit an Onnx Transform as part of a pipeline #2981

@rogancarr

Description

@rogancarr

It is possible to fit an ONNX model by itself:

var onnxEstimator = mlContext.Transforms.ApplyOnnxModel(modelPath)
var onnxModel = onnxEstimator.Fit(data);

But it throws when it is part of a pipeline:

var onnxEstimator = mlContext.Transforms.ApplyOnnxModel(modelPath)
    // TODO #2980: ONNX outputs don't match the outputs of the model, so we must hand-correct this for now.
    .Append(mlContext.Transforms.CopyColumns("Score", "Score0"));
    .Append(mlContext.Transforms.CopyColumns("Label", "Fable"));
    .Append(mlContext.Transforms.NormalizeLpNorm("Features2", "Features", LpNormNormalizingEstimatorBase.NormFunction.L2));
var onnxModel = onnxEstimator.Fit(data);

Any of these Append statements cause a throw. They do not affect the ONNX model at all, and use either the result of the calculation (Score0), rows unused by the model (Label) or rows also used by the transform (Features).

In this case, the error message is:
System.ArgumentOutOfRangeException : Schema mismatch for input column 'Label': expected vector, got R4 Parameter name: inputSchema

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions