Skip to content

CNTK Library API

Zhou Wang edited this page May 23, 2017 · 33 revisions

Python API

CNTK Python API consists of abstractions for model definition and compute, learning algorithms, data reading and distributed training.

  • Flexibility and compactness: These abstractions orthogonally compose offering both flexibility and conciseness in definition and training of arbitrary neural networks.
  • Efficient data interfaces: Simple yet light-weight data interfaces allow users to efficiently feed data in the form of native numpy arrays to the compute engine.
  • Built-in data readers: CNTKs built-in optimized and scalable data readers for image, text format and speech HTK data formats are also available from the python APIs for ease of directly training with existing data without users having to author any data reading code.
  • Highly scalable learning: The API exposes CNTK's highly scalable distributed training capabilities (parallelization algorithms like 1-Bit SGD). The distributed training example illustrates the training parallelization API.
  • Concise network definition: The API includes a high level layers library that enables concise advanced neural networks definition including recurrences similar to CNTK V1. The toolkit supports representation of recurrent models in symbolic form as cycles in the neural network instead of requiring static unrolling of the recurrence steps. This results in much more general, concise and efficient representation and execution of recurrent neural networks.

All the core computation, learning, and data reading API abstractions in the CNTK python API are very easily extensible from both Python and C++ allowing users to easily implement new operators, learners and data readers which freely compose with the built-in facilities of the library.

The API introduces new Protocol Buffers based model serialization format which supports backwards and upwards compatibility for saved models.

C++ API

The CNTK Library C++ API exposes CNTK's core computational, neural network composition & training, efficient data reading, and scalable model training facilities for developers. The C++ APIs are fully featured for both model training as well as evaluation, allowing for both training and model serving to be driven from native code. This enables your native code to tune the model using new data as part of a evaluation requiest (i.e. online learning).

The examples CNTKLibraryCPPEvalCPUOnlyExamples and CNTKLibraryCPPEvalGPUExamples illustrate the use of the C++ APIs for evaluating previously trained CNTK models. We are also actively working on creating C++ examples illustrating how model training can be performed using the native C++ API and these will become available in a few weeks.

Currently the best source of API documentation is inline in the API header file (CNTKLibrary.h) that contains the full C++ API definition.The API header files are also included in the binary release package under the Include directory.

C#/.NET Managed API

The CNTK Library Managed API exposes Evaluation related APIs for developers using C# or other .NET languages. It is provided as Nuget packages. The Nuget package CNTK.CPUOnly is for evaluation on CPU, and the CNTK.GPU is for evalution on devices with NVIDIA GPU.

For details regarding the CNTK Library managed API, please refer to the CNTK Library Managed API page.

There are several Eval Examples inside the CNTKLibraryEvalExamples.sln project shows how to evaluate a model in C#.

Java API (Experimental)

The CNTK Java API supports model evaluation in Java. This API is still experimental and subject to change. It is provided as a jar file (cntk.jar) that can be included in Java projects.

Please refer to Windows and Linux instructions for how to use the Java API.

The Java example shows how to evaluate a model in Java.

Clone this wiki locally