Skip to content

Commit e464102

Browse files
committed
fixes based on PR comments
1 parent d251bb5 commit e464102

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

src/Microsoft.ML.TensorFlow/TensorflowTransform.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,9 @@ internal TensorFlowTransformer(IHostEnvironment env, TensorFlowModel tfModelInfo
110110
/// <param name="outputColumnNames">The output columns to generate. Names must match model specifications. Data types are inferred from model.</param>
111111
/// <param name="addBatchDimensionInput">Add a batch dimension to the input e.g. input = [224, 224, 3] => [-1, 224, 224, 3].
112112
/// This parameter is used to deal with models that have unknown shape but the internal operators in the model require data to have batch dimension as well.</param>
113-
internal TensorFlowTransformer(IHostEnvironment env, TensorFlowModel tfModelInfo, string[] outputColumnNames, string[] inputColumnNames, bool addBatchDimensionInput = false)
114-
: this(env, tfModelInfo.Session, outputColumnNames, inputColumnNames, IsSavedModel(env, tfModelInfo.ModelPath) ? tfModelInfo.ModelPath : null, false, addBatchDimensionInput)
113+
/// <param name="treatOutputAsBatched">If the first dimension of the output is unknown, should it be treated as batched or not.</param>
114+
internal TensorFlowTransformer(IHostEnvironment env, TensorFlowModel tfModelInfo, string[] outputColumnNames, string[] inputColumnNames, bool addBatchDimensionInput = false, bool treatOutputAsBatched = true)
115+
: this(env, tfModelInfo.Session, outputColumnNames, inputColumnNames, IsSavedModel(env, tfModelInfo.ModelPath) ? tfModelInfo.ModelPath : null, false, addBatchDimensionInput, treatOutputAsBatched: treatOutputAsBatched)
115116
{
116117
}
117118

@@ -898,9 +899,9 @@ internal sealed class Options : TransformInputBase
898899
/// If the first dimension of the output is unknown, should it be treated as batched or not. e.g. output = [-1] will be read as a vector of unknown length when this is false.
899900
/// </summary>
900901
/// <remarks>
901-
/// This parameter is used to deal with models that have unknown output shape and it needs to be interpreted in ML.NET as a vector of unkown length and not as a batch dimension.
902+
/// This parameter is used to deal with models that have unknown output shape and it needs to be interpreted in ML.NET as a vector of unknown length and not as a batch dimension.
902903
/// </remarks>
903-
[Argument(ArgumentType.AtMostOnce, HelpText = "If the first dimension of the output is unknown, should it be treated as batched or not. e.g. output = [-1] will be read as a vector of unkown length when this is false.", SortOrder = 17)]
904+
[Argument(ArgumentType.AtMostOnce, HelpText = "If the first dimension of the output is unknown, should it be treated as batched or not. e.g. output = [-1] will be read as a vector of unknown length when this is false.", SortOrder = 17)]
904905
public bool TreatOutputAsBatched = true;
905906
}
906907

src/Microsoft.ML.TensorFlow/TensorflowUtils.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ internal static DataViewSchema GetModelSchema(IExceptionContext ectx, Graph grap
9999
columnType = new VectorDataViewType(mlType, tensorShape[0] > 0 ? tensorShape : tensorShape.Skip(1).ToArray());
100100
}
101101
// When treatOutputAsBatched is false, if the first value is less than 0 we want to set it to 0. TensorFlow
102-
// represents an unkown size as -1, but ML.NET represents it as 0 so we need to convert it.
103-
// I.E. if the input dimensions are [-1, 5], ML.NET will read the -1 as a dimension of unkown length, and so the ML.NET
104-
// data type will be a vector of 2 dimensions, where the first dimension is unkown and the second has a length of 5.
102+
// represents an unknown size as -1, but ML.NET represents it as 0 so we need to convert it.
103+
// I.E. if the input dimensions are [-1, 5], ML.NET will read the -1 as a dimension of unknown length, and so the ML.NET
104+
// data type will be a vector of 2 dimensions, where the first dimension is unknown and the second has a length of 5.
105105
else
106106
{
107107
if (tensorShape[0] < 0)

test/BaselineOutput/Common/EntryPoints/core_manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23617,7 +23617,7 @@
2361723617
{
2361823618
"Name": "TreatOutputAsBatched",
2361923619
"Type": "Bool",
23620-
"Desc": "If the first dimension of the output is unknown, should it be treated as batched or not. e.g. output = [-1] will be read as a vector of unkown length when this is false.",
23620+
"Desc": "If the first dimension of the output is unknown, should it be treated as batched or not. e.g. output = [-1] will be read as a vector of unknown length when this is false.",
2362123621
"Required": false,
2362223622
"SortOrder": 17.0,
2362323623
"IsNullable": false,

test/Microsoft.ML.Tests/TensorFlowEstimatorTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public void TestTensorFlow()
183183
Assert.Equal(4, numRows);
184184
}
185185
}
186-
186+
187187
[TensorFlowFact]
188188
public void TreatOutputAsBatched()
189189
{
@@ -211,7 +211,7 @@ public void TreatOutputAsBatched()
211211
var schema = pipe.Fit(data).Transform(data).Schema;
212212

213213
// The dimensions of the output with treatOutputAsBatched set to false should be * 10
214-
// as the first dimension of -1 is treated as an unkown dimension.
214+
// as the first dimension of -1 is treated as an unknown dimension.
215215
Assert.Equal(new VectorDataViewType(NumberDataViewType.Single, 0, 10), schema["Output"].Type);
216216

217217
// Note that CamelCase column names are there to match the TF graph node names.

0 commit comments

Comments
 (0)