Skip to content

Commit 52aff02

Browse files
authored
Add TensorFlow documentation to the main class, and include examples on it. (#867)
* wiring the example and the text to the CSharpApi, so they appear in the Microsoft.ML.Transforms namespace, and get picked up by the documentation * Restructuring the doc so it includes the examples. Removing the reference from the CsharpApi, since the transform is already created in the right namespace: Microsoft.ML.Transforms. Changing the visibility of the Summary, UserName and ShortName to internal. * Addign the documentation to the generated class, to be consistent, since it will appear in the Microsoft.ML.Transforms namespace. * modifying the file post merge. * including the example inside the <member> node. adding the <include> to the class post-merge. * after restructuring the xml doc, the example is part of it. * Propagating the doc structure change.
1 parent 6ed90b7 commit 52aff02

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
lines changed

src/Microsoft.ML.TensorFlow/TensorflowTransform.cs

+10-5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
namespace Microsoft.ML.Transforms
3535
{
36+
/// <include file='doc.xml' path='doc/members/member[@name="TensorflowTransform"]/*' />
3637
public sealed class TensorFlowTransform : ITransformer, ICanSaveModel
3738
{
3839
public sealed class Arguments : TransformInputBase
@@ -62,10 +63,10 @@ public sealed class Arguments : TransformInputBase
6263
public readonly string[] Outputs;
6364

6465
public static int BatchSize = 1;
65-
public const string Summary = "Transforms the data using the TensorFlow model.";
66-
public const string UserName = "TensorFlowTransform";
67-
public const string ShortName = "TFTransform";
68-
public const string LoaderSignature = "TensorFlowTransform";
66+
internal const string Summary = "Transforms the data using the TensorFlow model.";
67+
internal const string UserName = "TensorFlowTransform";
68+
internal const string ShortName = "TFTransform";
69+
internal const string LoaderSignature = "TensorFlowTransform";
6970

7071
private static VersionInfo GetVersionInfo()
7172
{
@@ -548,7 +549,11 @@ public TFTensor GetTensor()
548549
}
549550
}
550551

551-
[TlcModule.EntryPoint(Name = "Transforms.TensorFlowScorer", Desc = Summary, UserName = UserName, ShortName = ShortName)]
552+
[TlcModule.EntryPoint(Name = "Transforms.TensorFlowScorer",
553+
Desc = Summary,
554+
UserName = UserName,
555+
ShortName = ShortName,
556+
XmlInclude = new[] { @"<include file='../Microsoft.ML.TensorFlow/doc.xml' path='doc/members/member[@name=""TensorflowTransform""]/*' />" })]
552557
public static CommonOutputs.TransformOutput TensorFlowScorer(IHostEnvironment env, Arguments input)
553558
{
554559
Contracts.CheckValue(env, nameof(env));

src/Microsoft.ML.TensorFlow/doc.xml

+17-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<member name="TensorflowTransform">
66
<summary>
7-
Extracts hidden layers' values from a pre-trained Tensorflow model.
7+
Extracts hidden layers&apos; values from a pre-trained Tensorflow model.
88
</summary>
99
<remarks>
1010
<para>
@@ -44,51 +44,49 @@
4444
</a>.
4545

4646
</remarks>
47-
</member>
48-
<example name="TensorflowTransform">
4947
<example>
5048
<code language="csharp">
5149
pipeline.Add(new TextLoader(dataFile).CreateFrom&lt;MNISTData&gt;(useHeader: false));
5250
pipeline.Add(new ColumnCopier(("NumericImageVec", "Input");
5351
pipeline.Add(new TensorFlowScorer()
5452
{
55-
ModelFile = model_location;
56-
InputColumns = new []{ &quot;Input&quot; };
57-
OutputColumns = &quot;Output&quot;
53+
ModelFile = model_location;
54+
InputColumns = new []{ "Input" };
55+
OutputColumns = "Output"
5856
}
5957
</code>
6058
</example>
6159
<example>
6260
<code language="csharp">
6361
var pipeline = new LearningPipeline(seed: 1);
6462
pipeline.Add(new TextLoader(dataFile).CreateFrom&lt;CifarData&gt;(useHeader: false));
65-
pipeline.Add(new ImageLoader((&quot;ImagePath&quot;, &quot;ImageReal&quot;))
63+
pipeline.Add(new ImageLoader(("ImagePath", "ImageReal"))
6664
{
67-
ImageFolder = imageFolder
65+
ImageFolder = imageFolder
6866
});
6967

70-
pipeline.Add(new ImageResizer((&quot;ImageReal&quot;, &quot;ImageCropped&quot;))
68+
pipeline.Add(new ImageResizer(("ImageReal", "ImageCropped"))
7169
{
72-
ImageHeight = imageHeight,
73-
ImageWidth = imageWidth,
74-
Resizing = ImageResizerTransformResizingKind.IsoCrop
70+
ImageHeight = imageHeight,
71+
ImageWidth = imageWidth,
72+
Resizing = ImageResizerTransformResizingKind.IsoCrop
7573
});
7674

77-
pipeline.Add(new ImagePixelExtractor((&quot;ImageCropped&quot;, &quot;Input&quot;))
75+
pipeline.Add(new ImagePixelExtractor(("ImageCropped", "Input"))
7876
{
79-
UseAlpha = false,
80-
InterleaveArgb = true
77+
UseAlpha = false,
78+
InterleaveArgb = true
8179
});
8280

8381
pipeline.Add(new TensorFlowScorer()
8482
{
85-
ModelFile = model_location,
86-
InputColumns = new[] { &quot;Input&quot; },
87-
OutputColumns = &quot;Output&quot;
83+
ModelFile = model_location,
84+
InputColumns = new[] { "Input" },
85+
OutputColumns = "Output"
8886
});
8987
</code>
90-
</example>
9188
</example>
89+
</member>
9290

9391
</members>
9492
</doc>

src/Microsoft.ML/CSharpApi.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -15777,9 +15777,7 @@ public SentimentAnalyzerPipelineStep(Output output)
1577715777
namespace Transforms
1577815778
{
1577915779

15780-
/// <summary>
15781-
/// Transforms the data using the TensorFlow model.
15782-
/// </summary>
15780+
/// <include file='../Microsoft.ML.TensorFlow/doc.xml' path='doc/members/member[@name="TensorflowTransform"]/*' />
1578315781
public sealed partial class TensorFlowScorer : Microsoft.ML.Runtime.EntryPoints.CommonInputs.ITransformInput, Microsoft.ML.ILearningPipelineItem
1578415782
{
1578515783

0 commit comments

Comments
 (0)