Skip to content

Ensure ONNX export is compatible with Windows RS5 #550

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

Merged
merged 9 commits into from
Jul 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Microsoft.ML.Data/Prediction/Calibrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,13 +1437,13 @@ public bool SaveAsOnnx(OnnxContext ctx, string[] scoreProbablityColumnNames, str
string opType = "Affine";
string linearOutput = ctx.AddIntermediateVariable(null, "linearOutput", true);
var node = ctx.CreateNode(opType, new[] { scoreProbablityColumnNames[0] },
new[] { linearOutput }, ctx.GetNodeName(opType), "ai.onnx");
new[] { linearOutput }, ctx.GetNodeName(opType), "");
node.AddAttribute("alpha", ParamA * -1);
node.AddAttribute("beta", -0.0000001);

opType = "Sigmoid";
node = ctx.CreateNode(opType, new[] { linearOutput },
new[] { scoreProbablityColumnNames[1] }, ctx.GetNodeName(opType), "ai.onnx");
new[] { scoreProbablityColumnNames[1] }, ctx.GetNodeName(opType), "");

return true;
}
Expand Down
1 change: 0 additions & 1 deletion src/Microsoft.ML.Data/Transforms/ConcatTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,6 @@ public void SaveAsOnnx(OnnxContext ctx)
var node = ctx.CreateNode(opType, inputList.Select(t => t.Key),
new[] { ctx.AddIntermediateVariable(outColType, outName) }, ctx.GetNodeName(opType));

node.AddAttribute("inputList", inputList.Select(x => x.Key));
node.AddAttribute("inputdimensions", inputList.Select(x => x.Value));
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/Microsoft.ML.Data/Transforms/TermTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,10 @@ protected override bool SaveAsOnnxCore(OnnxContext ctx, int iinfo, ColInfo info,
var node = ctx.CreateNode(opType, srcVariableName, dstVariableName, ctx.GetNodeName(opType));
node.AddAttribute("classes_strings", terms.DenseValues());
node.AddAttribute("default_int64", -1);
node.AddAttribute("default_string", DvText.Empty);
//default_string needs to be an empty string but there is a BUG in Lotus that
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is Lotus? Do you mean runtime?

//throws a validation error when default_string is empty. As a work around, set
//default_string to a space.
node.AddAttribute("default_string", " ");
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.ML.Onnx/OnnxUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,10 @@ public static ModelProto MakeModel(List<NodeProto> nodes, string producerName, s
model.Domain = domain;
model.ProducerName = producerName;
model.ProducerVersion = producerVersion;
model.IrVersion = (long)UniversalModelFormat.Onnx.Version.IrVersion;
model.IrVersion = (long)Version.IrVersion;
model.ModelVersion = modelVersion;
model.OpsetImport.Add(new OperatorSetIdProto() { Domain = "ai.onnx.ml", Version = 1 });
model.OpsetImport.Add(new OperatorSetIdProto() { Domain = "ai.onnx", Version = 6 });
model.OpsetImport.Add(new OperatorSetIdProto() { Domain = "", Version = 7 });
model.Graph = new GraphProto();
var graph = model.Graph;
graph.Node.Add(nodes);
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.ML.StandardLearners/Standard/LinearPredictor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,10 @@ public bool SaveAsOnnx(OnnxContext ctx, string[] outputs, string featureColumn)
string opType = "LinearRegressor";
var node = ctx.CreateNode(opType, new[] { featureColumn }, outputs, ctx.GetNodeName(opType));
// Selection of logit or probit output transform. enum {'NONE', 'LOGIT', 'PROBIT}
node.AddAttribute("post_transform", 0);
node.AddAttribute("post_transform", "NONE");
node.AddAttribute("targets", 1);
node.AddAttribute("coefficients", Weight.DenseValues());
node.AddAttribute("intercepts", Bias);
node.AddAttribute("intercepts", new float[] { Bias });
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,12 +845,12 @@ public bool SaveAsOnnx(OnnxContext ctx, string[] outputs, string featureColumn)

string opType = "LinearClassifier";
var node = ctx.CreateNode(opType, new[] { featureColumn }, outputs, ctx.GetNodeName(opType));
// Selection of logit or probit output transform. enum {'NONE', 'LOGIT', 'PROBIT}
node.AddAttribute("post_transform", 0);
// Selection of logit or probit output transform. enum {'NONE', 'SOFTMAX', 'LOGISTIC', 'SOFTMAX_ZERO', 'PROBIT}
node.AddAttribute("post_transform", "NONE");
node.AddAttribute("multi_class", true);
node.AddAttribute("coefficients", _weights.SelectMany(w => w.DenseValues()));
node.AddAttribute("intercepts", _biases);
node.AddAttribute("classlabels_strings", _labelNames);
node.AddAttribute("classlabels_ints", Enumerable.Range(0, _numClasses).Select(x => (long)x));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LR doesn't output labels (e.g., "A" and "B") anymore?

return true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.ML.Transforms/NAReplaceTransform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -633,13 +633,13 @@ protected override bool SaveAsOnnxCore(OnnxContext ctx, int iinfo, ColInfo info,
node.AddAttribute("replaced_value_float", Single.NaN);

if (!Infos[iinfo].TypeSrc.IsVector)
node.AddAttribute("imputed_value_float", Enumerable.Repeat((float)_repValues[iinfo], 1));
node.AddAttribute("imputed_value_floats", Enumerable.Repeat((float)_repValues[iinfo], 1));
else
{
if (_repIsDefault[iinfo] != null)
node.AddAttribute("imputed_value_floats", (float[])_repValues[iinfo]);
else
node.AddAttribute("imputed_value_float", Enumerable.Repeat((float)_repValues[iinfo], 1));
node.AddAttribute("imputed_value_floats", Enumerable.Repeat((float)_repValues[iinfo], 1));
}

return true;
Expand Down
Loading