This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
TheIEstimator<TTransformer> for training a Deep Neural Network(DNN) to classify images.
public sealed class ImageClassificationTrainer : Microsoft.ML.Trainers.TrainerEstimatorBase<Microsoft.ML.Data.MulticlassPredictionTransformer<Microsoft.ML.Vision.ImageClassificationModelParameters>,Microsoft.ML.Vision.ImageClassificationModelParameters>
type ImageClassificationTrainer = class inherit TrainerEstimatorBase<MulticlassPredictionTransformer<ImageClassificationModelParameters>, ImageClassificationModelParameters>
Public NotInheritable Class ImageClassificationTrainerInherits TrainerEstimatorBase(Of MulticlassPredictionTransformer(Of ImageClassificationModelParameters), ImageClassificationModelParameters)
To create this trainer, useImageClassification.
The input label column data must bekey type and the feature column must be a variable-sized vector ofByte.
This trainer outputs the following columns:
Output Column Name | Column Type | Description |
---|---|---|
Score | Vector ofSingle | The scores of all classes.Higher value means higher probability to fall into the associated class. If the i-th element has the largest value, the predicted label index would be i.Note that i is zero-based index. |
PredictedLabel | key type | The predicted label's index. If its value is i, the actual label would be the i-th category in the key-valued input label type. |
Machine learning task | Multiclass classification |
Is normalization required? | No |
Is caching required? | No |
Required NuGet in addition to Microsoft.ML | Microsoft.ML.Vision and SciSharp.TensorFlow.Redist / SciSharp.TensorFlow.Redist-Windows-GPU / SciSharp.TensorFlow.Redist-Linux-GPU |
Exportable to ONNX | No |
In order to run any TensorFlow based ML.Net APIs you must first add a NuGet dependencyon the TensorFlow redist library. There are currently two versions you can use. One which iscompiled for GPU support, and one which has CPU support only.
CPU based TensorFlow is currently supported on:
To get TensorFlow working on the CPU only all that is to take a NuGet dependency onSciSharp.TensorFlow.Redist v1.14.0
GPU based TensorFlow is currently supported on:
You must have at least one CUDA compatible GPU, for a list of compatible GPUs seeNvidia's Guide.
InstallCUDA v10.1 andCUDNN v7.6.4.
Make sure you install CUDA v10.1, not any other newer version.After downloading CUDNN v7.6.4 .zip file and unpacking it, you need to do the following steps:
copy <CUDNN_zip_files_path>\cuda\bin\cudnn64_7.dll to <YOUR_DRIVE>\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin
For C/C++ development:
Copy <CUDNN_zip_files_path>\cuda\ include\cudnn.h to <YOUR_DRIVE>\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include
Copy <CUDNN_zip_files_path>\cuda\lib\x64\cudnn.lib to <YOUR_DRIVE>\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\lib\x64
For further details in cuDNN you can follow thecuDNN Installation guide.
To use TensorFlow with GPU support take a NuGet dependency on the following package depending on your OS:
No code modification should be necessary to leverage the GPU for TensorFlow operations.
If you are not able to use your GPU after adding the GPU based TensorFlow NuGet,make sure that there is only a dependency on the GPU based version. If you havea dependency on both NuGets, the CPU based TensorFlow will run instead.
Trains a Deep Neural Network(DNN) by leveraging an existing pre-trained model such as Resnet50 for the purposeof classifying images. The technique was inspired fromTensorFlow's retrain image classification tutorial
FeatureColumn | The feature column that the trainer expects. (Inherited fromTrainerEstimatorBase<TTransformer,TModel>) |
LabelColumn | The label column that the trainer expects. Can be |
WeightColumn | The weight column that the trainer expects. Can be |
Info | Auxiliary information about the trainer in terms of its capabilitiesand requirements. |
Finalize() | |
Fit(IDataView, IDataView) | Trains aImageClassificationTrainer using both training and validation data,returns aImageClassificationModelParameters. |
Fit(IDataView) | Trains and returns aITransformer. (Inherited fromTrainerEstimatorBase<TTransformer,TModel>) |
GetOutputSchema(SchemaShape) | (Inherited fromTrainerEstimatorBase<TTransformer,TModel>) |
AppendCacheCheckpoint<TTrans>(IEstimator<TTrans>, IHostEnvironment) | Append a 'caching checkpoint' to the estimator chain. This will ensure that the downstream estimators will be trained againstcached data. It is helpful to have a caching checkpoint before trainers that take multiple data passes. |
WithOnFitDelegate<TTransformer>(IEstimator<TTransformer>, Action<TTransformer>) | Given an estimator, return a wrapping object that will call a delegate onceFit(IDataView)is called. It is often important for an estimator to return information about what was fit, which is why theFit(IDataView) method returns a specifically typed object, rather than just a generalITransformer. However, at the same time,IEstimator<TTransformer> are often formed into pipelineswith many objects, so we may need to build a chain of estimators viaEstimatorChain<TLastTransformer> where theestimator for which we want to get the transformer is buried somewhere in this chain. For that scenario, we can through thismethod attach a delegate that will be called once fit is called. |