From 14f1db709050dd6925081f666d619aab5b311d19 Mon Sep 17 00:00:00 2001 From: Harshitha Parnandi Venkata Date: Thu, 7 Nov 2019 13:57:18 -0800 Subject: [PATCH] Retro fitted changes made to the ml docs repo into ML.NET --- .../ImageClassificationTrainer.cs | 39 ++++++++-------- src/Microsoft.ML.Vision/VisionCatalog.cs | 46 ++++++++++--------- 2 files changed, 44 insertions(+), 41 deletions(-) diff --git a/src/Microsoft.ML.Vision/ImageClassificationTrainer.cs b/src/Microsoft.ML.Vision/ImageClassificationTrainer.cs index 23d7eece24..e6006775b8 100644 --- a/src/Microsoft.ML.Vision/ImageClassificationTrainer.cs +++ b/src/Microsoft.ML.Vision/ImageClassificationTrainer.cs @@ -42,10 +42,10 @@ namespace Microsoft.ML.Vision /// /// /// . + /// The input label column data must be [key](xref:Microsoft.ML.Data.KeyDataViewType) type and the feature column must be a variable-sized vector of . /// /// This trainer outputs the following columns: /// @@ -66,8 +66,7 @@ namespace Microsoft.ML.Vision /// /// ### Training Algorithm Details /// Trains a Deep Neural Network(DNN) by leveraging an existing pre-trained model such as Resnet50 for the purpose - /// of classifying images. The technique was inspired from [TensorFlow's retrain image classification tutorial] - /// (https://www.tensorflow.org/hub/tutorials/image_retraining) + /// of classifying images. The technique was inspired from [TensorFlow's retrain image classification tutorial](https://www.tensorflow.org/hub/tutorials/image_retraining) /// ]]> /// /// @@ -339,79 +338,79 @@ public enum Dataset public sealed class Options : TrainerInputBaseWithLabel { /// - /// Number of samples to use for mini-batch training. + /// Number of samples to use for mini-batch training. The default value for BatchSize is 10. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Number of samples to use for mini-batch training.", SortOrder = 9)] public int BatchSize = 10; /// - /// Number of training iterations. + /// Number of training iterations. The default value for Epoch is 200. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Number of training iterations.", SortOrder = 10)] public int Epoch = 200; /// - /// Learning rate to use during optimization. + /// Learning rate to use during optimization. The default value for Learning Rate is 0.01. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Learning rate to use during optimization.", SortOrder = 12)] public float LearningRate = 0.01f; /// - /// Early stopping technique parameters to be used to terminate training when training metric stops improving. + /// Early stopping technique parameters to be used to terminate training when training metric stops improving. By default EarlyStopping is turned on and the monitoring metric is Accuracy. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Early stopping technique parameters to be used to terminate training when training metric stops improving.", SortOrder = 15)] public EarlyStopping EarlyStoppingCriteria = new EarlyStopping(); /// - /// Specifies the model architecture to be used in the case of image classification training using transfer learning. + /// Specifies the model architecture to be used in the case of image classification training using transfer learning. The default Architecture is Resnet_v2_50. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Model architecture to be used in transfer learning for image classification.", SortOrder = 15)] public Architecture Arch = Architecture.ResnetV250; /// - /// Name of the tensor that will contain the output scores of the last layer when transfer learning is done. + /// Name of the tensor that will contain the output scores of the last layer when transfer learning is done. The default tensor name is "Score". /// [Argument(ArgumentType.AtMostOnce, HelpText = "Softmax tensor of the last layer in transfer learning.", SortOrder = 15)] public string ScoreColumnName = "Score"; /// - /// Name of the tensor that will contain the predicted label from output scores of the last layer when transfer learning is done. + /// Name of the tensor that will contain the predicted label from output scores of the last layer when transfer learning is done. The default tensor name is "PredictedLabel". /// [Argument(ArgumentType.AtMostOnce, HelpText = "Argmax tensor of the last layer in transfer learning.", SortOrder = 15)] public string PredictedLabelColumnName = "PredictedLabel"; /// - /// Final model and checkpoint files/folder prefix for storing graph files. + /// Final model and checkpoint files/folder prefix for storing graph files. The default prefix is "custom_retrained_model_based_on_". /// [Argument(ArgumentType.AtMostOnce, HelpText = "Final model and checkpoint files/folder prefix for storing graph files.", SortOrder = 15)] public string FinalModelPrefix = "custom_retrained_model_based_on_"; /// - /// Callback to report statistics on accuracy/cross entropy during training phase. + /// Callback to report statistics on accuracy/cross entropy during training phase. Metrics Callback is set to null by default. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Callback to report metrics during training and validation phase.", SortOrder = 15)] public Action MetricsCallback = null; /// - /// Indicates the path where the image bottleneck cache files and trained model are saved, default is a new temporary directory + /// Indicates the path where the image bottleneck cache files and trained model are saved, default is a new temporary directory. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Indicates the path where the models get downloaded to and cache files saved, default is a new temporary directory.", SortOrder = 15)] public string WorkspacePath = null; /// - /// Indicates to evaluate the model on train set after every epoch. + /// Indicates to evaluate the model on train set after every epoch. Test on trainset is set to true by default. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Indicates to evaluate the model on train set after every epoch.", SortOrder = 15)] public bool TestOnTrainSet = true; /// - /// Indicates to not re-compute cached bottleneck trainset values if already available in the bin folder. + /// Indicates to not re-compute cached bottleneck trainset values if already available in the bin folder. This parameter is set to false by default. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Indicates to not re-compute trained cached bottleneck values if already available in the bin folder.", SortOrder = 15)] public bool ReuseTrainSetBottleneckCachedValues = false; /// - /// Indicates to not re-compute cached bottleneck validationset values if already available in the bin folder. + /// Indicates to not re-compute cached bottleneck validationset values if already available in the bin folder. This parameter is set to false by default. /// [Argument(ArgumentType.AtMostOnce, HelpText = "Indicates to not re-compute validataionset cached bottleneck validationset values if already available in the bin folder.", SortOrder = 15)] public bool ReuseValidationSetBottleneckCachedValues = false; @@ -423,19 +422,19 @@ public sealed class Options : TrainerInputBaseWithLabel public IDataView ValidationSet; /// - /// Indicates the file name within the workspace to store trainset bottleneck values for caching. + /// Indicates the file name within the workspace to store trainset bottleneck values for caching, default file name is "trainSetBottleneckFile.csv". /// [Argument(ArgumentType.AtMostOnce, HelpText = "Indicates the file name to store trainset bottleneck values for caching.", SortOrder = 15)] public string TrainSetBottleneckCachedValuesFileName = "trainSetBottleneckFile.csv"; /// - /// Indicates the file name within the workspace to store validationset bottleneck values for caching. + /// Indicates the file name within the workspace to store validationset bottleneck values for caching, default file name is "validationSetBottleneckFile.csv". /// [Argument(ArgumentType.AtMostOnce, HelpText = "Indicates the file name to store validationset bottleneck values for caching.", SortOrder = 15)] public string ValidationSetBottleneckCachedValuesFileName = "validationSetBottleneckFile.csv"; /// - /// A class that performs learning rate scheduling. + /// A class that performs learning rate scheduling. The default learning rate scheduler is exponential learning rate decay. /// [Argument(ArgumentType.AtMostOnce, HelpText = "A class that performs learning rate scheduling.", SortOrder = 15)] public LearningRateScheduler LearningRateScheduler = new ExponentialLRDecay(); diff --git a/src/Microsoft.ML.Vision/VisionCatalog.cs b/src/Microsoft.ML.Vision/VisionCatalog.cs index 61476e04a2..b41aaec377 100644 --- a/src/Microsoft.ML.Vision/VisionCatalog.cs +++ b/src/Microsoft.ML.Vision/VisionCatalog.cs @@ -10,6 +10,12 @@ namespace Microsoft.ML { + /// + /// Collection of extension methods for to create instances of ImageClassification trainer components. + /// + /// + /// This requires additional nuget dependencies to link against Tensorflow native dlls. See for more information. + /// public static class VisionCatalog { @@ -79,18 +85,17 @@ internal static DnnRetrainEstimator RetrainDnnModel( } /// - /// Performs image classification using transfer learning. - /// Usage of this API requires additional NuGet dependencies on TensorFlow redist, see linked document - /// for more information. - /// - /// - /// + /// Create using advanced options, which trains a Deep Neural Network(DNN) to classify images. /// /// Catalog /// An object specifying advanced /// options for . + /// + /// + /// + /// public static ImageClassificationTrainer ImageClassification( this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog, @@ -98,21 +103,20 @@ public static ImageClassificationTrainer ImageClassification( new ImageClassificationTrainer(CatalogUtils.GetEnvironment(catalog), options); /// - /// Performs image classification using transfer learning. - /// Usage of this API requires additional NuGet dependencies on TensorFlow redist, see linked document for - /// more information. - /// - /// - /// + /// Create , which trains a Deep Neural Network(DNN) to classify images. /// /// Catalog - /// The name of the labels column. - /// The name of the input features column. - /// The name of the output score column. - /// The name of the output predicted label columns. - /// The validation set used while training to improve model quality. + /// The name of the labels column. The default for this parameter is "label". + /// The name of the input features column. The default for this parameter is "Features". + /// The name of the output score column. The default for this parameter is "Score" + /// The name of the output predicted label columns. The default for this parameter is "PredictedLabel" + /// The validation set used while training to improve model quality. The default for this parameter is null. + /// + /// + /// + /// public static ImageClassificationTrainer ImageClassification( this MulticlassClassificationCatalog.MulticlassClassificationTrainers catalog,