From fc17a17e74d9f4a952886a52d9906f68b44371ee Mon Sep 17 00:00:00 2001 From: Zeeshan Siddiqui Date: Tue, 26 Jun 2018 11:27:35 -0700 Subject: [PATCH 1/6] ONNX API documentation. --- src/Microsoft.ML/Models/OnnxConverter.cs | 30 ++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.ML/Models/OnnxConverter.cs b/src/Microsoft.ML/Models/OnnxConverter.cs index 03853097eb..ba90cd0e18 100644 --- a/src/Microsoft.ML/Models/OnnxConverter.cs +++ b/src/Microsoft.ML/Models/OnnxConverter.cs @@ -10,9 +10,35 @@ namespace Microsoft.ML.Models public sealed partial class OnnxConverter { /// - /// Converts the model to ONNX format. + /// + /// This API converts the model to ONNX format by inspecting the transform pipeline + /// from the end, checking for components that know how to save themselves as ONNX. + /// The first data view in the transform pipeline that does not know how to save itself + /// as ONNX, is considered the "input" to the ONNX pipeline. (Ideally this would be the + /// original loader itself, but this may not be possible if the user used unsavable + /// transforms in defining the pipe.) All the columns in the source that are a type the + /// ONNX knows what to deal with will be tracked. Intermediate transformations of the + /// data appearing as new columns will appear in the output block of the ONNX, with names + /// derived from the corresponding column names. The ONNX json will be serialized to a + /// path defined through the Json option. + /// + /// This API supports the following arguments: + /// indicates the file to write the ONNX protocol buffer file to. + /// indicates the file to write the JSON representation of the ONNX model. + /// indicates the name property in the ONNX model. If left unspecified, it will + /// be the extension-less name of the file specified in the onnx indicates the protocol buffer file + /// to write the ONNX representation to. + /// indicates the domain name of the model. We use reverse domain name space indicators. + /// For example com.microsoft.cognitiveservices. This is a required field. + /// is a string array of input column names to omit from the input mapping. + /// A common scenario might be to drop the label column, for instance, since it may not be practically + /// useful for the pipeline. Note that any columns depending on these naturally cannot be saved. + /// is similar, except for the output schema. Note that the pipeline handler + /// is currently not intelligent enough to drop intermediate calculations that produce this value: this will + /// merely omit that value from the actual output. + /// /// See - /// for an example. + /// for an example on how to train a model and then convert that model to ONNX. /// /// Model that needs to be converted to ONNX format. public void Convert(PredictionModel model) From 3619573b1234ccab621d4101749c3ac065fe876c Mon Sep 17 00:00:00 2001 From: Zeeshan Siddiqui Date: Tue, 26 Jun 2018 11:35:51 -0700 Subject: [PATCH 2/6] add list of transforms and learners that can be converted to ONNX. --- src/Microsoft.ML/Models/OnnxConverter.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Microsoft.ML/Models/OnnxConverter.cs b/src/Microsoft.ML/Models/OnnxConverter.cs index ba90cd0e18..ce90ea8cb0 100644 --- a/src/Microsoft.ML/Models/OnnxConverter.cs +++ b/src/Microsoft.ML/Models/OnnxConverter.cs @@ -37,6 +37,21 @@ public sealed partial class OnnxConverter /// is currently not intelligent enough to drop intermediate calculations that produce this value: this will /// merely omit that value from the actual output. /// + /// Transforms that can be exported to ONNX + /// 1. Concat + /// 2. KeyToVector + /// 3. NAReplace + /// 4. Normalize + /// 5. Term + /// 6. Categorical + /// + /// Learners that can be exported to ONNX + /// 1. FastTree + /// 2. LightGBM + /// 3. LibSVM + /// 4. Multi Class Logistic Regression + /// 5. Logistic Regression + /// /// See /// for an example on how to train a model and then convert that model to ONNX. /// From e31d4cab6de6e8db1b475ca19bad6292b54dd7a9 Mon Sep 17 00:00:00 2001 From: Zeeshan Siddiqui Date: Tue, 26 Jun 2018 12:54:17 -0700 Subject: [PATCH 3/6] PR feedback. --- src/Microsoft.ML/Models/OnnxConverter.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.ML/Models/OnnxConverter.cs b/src/Microsoft.ML/Models/OnnxConverter.cs index ce90ea8cb0..abe0876954 100644 --- a/src/Microsoft.ML/Models/OnnxConverter.cs +++ b/src/Microsoft.ML/Models/OnnxConverter.cs @@ -13,18 +13,18 @@ public sealed partial class OnnxConverter /// /// This API converts the model to ONNX format by inspecting the transform pipeline /// from the end, checking for components that know how to save themselves as ONNX. - /// The first data view in the transform pipeline that does not know how to save itself + /// The first item in the transform pipeline that does not know how to save itself /// as ONNX, is considered the "input" to the ONNX pipeline. (Ideally this would be the /// original loader itself, but this may not be possible if the user used unsavable /// transforms in defining the pipe.) All the columns in the source that are a type the - /// ONNX knows what to deal with will be tracked. Intermediate transformations of the + /// ONNX knows how to deal with will be tracked. Intermediate transformations of the /// data appearing as new columns will appear in the output block of the ONNX, with names /// derived from the corresponding column names. The ONNX json will be serialized to a /// path defined through the Json option. /// /// This API supports the following arguments: - /// indicates the file to write the ONNX protocol buffer file to. - /// indicates the file to write the JSON representation of the ONNX model. + /// indicates the file to write the ONNX protocol buffer file to. This is optional. + /// indicates the file to write the JSON representation of the ONNX model. This is optional. /// indicates the name property in the ONNX model. If left unspecified, it will /// be the extension-less name of the file specified in the onnx indicates the protocol buffer file /// to write the ONNX representation to. From ca7942c726bbb28f058a5140d20117cb9320c5f3 Mon Sep 17 00:00:00 2001 From: Zeeshan Siddiqui Date: Tue, 26 Jun 2018 15:08:34 -0700 Subject: [PATCH 4/6] PR feedback. --- src/Microsoft.ML/Models/OnnxConverter.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.ML/Models/OnnxConverter.cs b/src/Microsoft.ML/Models/OnnxConverter.cs index abe0876954..3060223b7f 100644 --- a/src/Microsoft.ML/Models/OnnxConverter.cs +++ b/src/Microsoft.ML/Models/OnnxConverter.cs @@ -10,8 +10,12 @@ namespace Microsoft.ML.Models public sealed partial class OnnxConverter { /// - /// - /// This API converts the model to ONNX format by inspecting the transform pipeline + /// ONNX is an intermediate representation format + /// for machine learing models. It is used to make models portable such that you can + /// train a model using ML.NET(or any ONNX compatible toolkit), convert it to ONNX and + /// then the ONNX model can be converted into say, CoreML, TensorFlow or WinML model + /// to run on the respective runtime. + /// This API converts an ML.NET model to ONNX format by inspecting the transform pipeline /// from the end, checking for components that know how to save themselves as ONNX. /// The first item in the transform pipeline that does not know how to save itself /// as ONNX, is considered the "input" to the ONNX pipeline. (Ideally this would be the @@ -19,7 +23,7 @@ public sealed partial class OnnxConverter /// transforms in defining the pipe.) All the columns in the source that are a type the /// ONNX knows how to deal with will be tracked. Intermediate transformations of the /// data appearing as new columns will appear in the output block of the ONNX, with names - /// derived from the corresponding column names. The ONNX json will be serialized to a + /// derived from the corresponding column names. The ONNX JSON will be serialized to a /// path defined through the Json option. /// /// This API supports the following arguments: @@ -28,7 +32,7 @@ public sealed partial class OnnxConverter /// indicates the name property in the ONNX model. If left unspecified, it will /// be the extension-less name of the file specified in the onnx indicates the protocol buffer file /// to write the ONNX representation to. - /// indicates the domain name of the model. We use reverse domain name space indicators. + /// indicates the domain name of the model. ONNX uses reverse domain name space indicators. /// For example com.microsoft.cognitiveservices. This is a required field. /// is a string array of input column names to omit from the input mapping. /// A common scenario might be to drop the label column, for instance, since it may not be practically @@ -48,9 +52,7 @@ public sealed partial class OnnxConverter /// Learners that can be exported to ONNX /// 1. FastTree /// 2. LightGBM - /// 3. LibSVM - /// 4. Multi Class Logistic Regression - /// 5. Logistic Regression + /// 3. Logistic Regression /// /// See /// for an example on how to train a model and then convert that model to ONNX. From 48ab0b457920ecea3644811cae0a71e9fd81df7d Mon Sep 17 00:00:00 2001 From: Zeeshan Siddiqui Date: Tue, 26 Jun 2018 15:11:50 -0700 Subject: [PATCH 5/6] fix typo. --- src/Microsoft.ML/Models/OnnxConverter.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.ML/Models/OnnxConverter.cs b/src/Microsoft.ML/Models/OnnxConverter.cs index 3060223b7f..8cb8283e79 100644 --- a/src/Microsoft.ML/Models/OnnxConverter.cs +++ b/src/Microsoft.ML/Models/OnnxConverter.cs @@ -11,8 +11,9 @@ public sealed partial class OnnxConverter { /// /// ONNX is an intermediate representation format - /// for machine learing models. It is used to make models portable such that you can - /// train a model using ML.NET(or any ONNX compatible toolkit), convert it to ONNX and + /// for machine learning models. It is used to make models portable such that you can + /// train a model using a toolkit and run it in another tookit's runtime, for example, + /// you can create a model using ML.NET(or any ONNX compatible toolkit), convert it to ONNX and /// then the ONNX model can be converted into say, CoreML, TensorFlow or WinML model /// to run on the respective runtime. /// This API converts an ML.NET model to ONNX format by inspecting the transform pipeline From 67e1d00961b1e984e788385eaa552116957a7137 Mon Sep 17 00:00:00 2001 From: Zeeshan Siddiqui Date: Tue, 26 Jun 2018 15:36:25 -0700 Subject: [PATCH 6/6] PR feedback. --- src/Microsoft.ML/Models/OnnxConverter.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.ML/Models/OnnxConverter.cs b/src/Microsoft.ML/Models/OnnxConverter.cs index 8cb8283e79..dd8ca383fd 100644 --- a/src/Microsoft.ML/Models/OnnxConverter.cs +++ b/src/Microsoft.ML/Models/OnnxConverter.cs @@ -13,9 +13,10 @@ public sealed partial class OnnxConverter /// ONNX is an intermediate representation format /// for machine learning models. It is used to make models portable such that you can /// train a model using a toolkit and run it in another tookit's runtime, for example, - /// you can create a model using ML.NET(or any ONNX compatible toolkit), convert it to ONNX and + /// you can create a model using ML.NET (or any ONNX compatible toolkit), convert it to ONNX and /// then the ONNX model can be converted into say, CoreML, TensorFlow or WinML model /// to run on the respective runtime. + /// /// This API converts an ML.NET model to ONNX format by inspecting the transform pipeline /// from the end, checking for components that know how to save themselves as ONNX. /// The first item in the transform pipeline that does not know how to save itself