Model evaluation examples
Examples for using the CNTK Eval library in C++, C#/.NET and Python can be found in Examples/Evaluation folder in GitHub, as well as in the CNTK binary download package on the CNTK Releases page.
CNTK Library Eval C++/C# Examples
The CNTKLibraryEvalExamples contains code samples demonstrating how to use the CNTK Library Eval API in C++ and C#.
CNTKLibraryCSEvalCPUOnlyExamples uses the CNTK Library CPU-Only NuGet package to evaluate models on CPU-only devices in C#.
CNTKLibraryCSEvalGPUExamples uses the CNTK Library GPU NuGet package to evaluate models on devices with Nvidia GPU in C#.
CNTKLibraryCPPEvalCPUOnlyExamples uses the CNTK Library C++ API to evaluate models on CPU-only devices. It uses the CNTK Library CPU-Only NuGet package.
CNTKLibraryCPPEvalGPUExamples uses the CNTK Library C++ API to evaluate models on devices with Nvidia GPU. It uses the CNTK Library GPU NuGet package.
UWPImageRecognition contains an example using CNTK UWP library for model evaluation. It also shows how to use the library in C# via a C++/CX wrapper.
On Windows,
- You need Visual Studio 2017 for using these samples.
- The samples should be built for the 64-bit target platform. Otherwise some issues arise when calling the library. Please also refer to the Troubleshoot CNTK page for more information.
- After a successful build, the executable is saved under the $(SolutionDir)....$(Platform)$(ProjectName).$(Configuration)\ folder, e.g. ....\X64\CNTKLibraryCSEvalCPUOnlyExamples.Release\CNTKLibraryCSEvalCPUOnlyExamples.exe.
On Linux, only C++ is supported. Please refer to the Makefile
for building samples. The target name CNTKLIBRARY_CPP_EVAL_EXAMPLES is used to build CNTKLibraryCPPEvalExamples.
Examples for evaluating multiple requests in parallel
The CNTKLibraryEvalExamples includes sample code to evaluate multiple evaluation requests in parallel. The sample code also shows how to share model parameters among multiple instances of the same model to reduce memory usage.
- EvaluateMultipleImagesInParallelAsync() in C# demonstrates how to evaluate concurrent requests using CNTK C#/.NET Managed API.
- ParallelEvaluationExample() is the C++ example showing concurrent evaluation using CNTK C++ Library API.
Examples for evaluating intermediate layers
- EvaluateIntermediateLayer() in C# demonstrates how to evaluate intermediate layers in a model using CNTK C#/.NET Managed API.
- EvaluateIntermediateLayer() is the C++ example showing how to evaluate intermediate layers in a model using CNTK C++ Library API.
Examples for evaluating outputs from multiple nodes
- EvaluateCombinedOutputs() in C# demonstrates how to evaluate multiple outputs using CNTK C#/.NET Managed API.
- EvaluateCombinedOutputs() is the C++ example showing how to evaluate multiple outputs using CNTK C++ Library API.
C# Examples for running evaluation asynchronously
The example EvaluationSingleImageAsync()
demonstrates how to run evaluation asynchronously by using the extension method EvaluateAsync()
.
Python Eval Examples
You can also use Python to evaluate a pre-trained model as described here.
Java Eval Examples
The Java example shows how to evaluate a model using the Java API. Please note that the Java API is still experimental and subject to change.
Please refer to Windows and Linux instructions for how to build the Java example.
Examples for legacy applications using EvalDLL
Please refer to EvalDll-Examples for details.