Hello CNTK from C#


Less than two months ago CNTK 2.2 is released with support of training and evaluating models in C#. For this post we will go through the process of creating  .NET application which has ability to call CNTK. The CNTK library is accessible by using NuGet package.

First,  open Visual Studio and create Classic Windows desktop console application.

Once we have starting application, open NuGet package window by right click on Solution item and select “Manage NuGet package for the solution”.

Browse for CNTK and select CNTK.CPUOnly library version, select the project and press install.

Once the installation package is completed, the .NET application can use CNTK library and perform training and evaluation actions. To see the library is available write the flowing code in the main method of the demo application:

var cpu = DeviceDescriptor.UseDefaultDevice();
Console.WriteLine($"Hello from CNTK for {cpu.Type} only!");

Before compile,CNTK project should be changed from Any CPU into x64. This is accomplished by copy the current configuration in to x64.
The flowing picture shows how to do that.

Compile and run the application. The flowing output should be shown in case the CNTK for C# is successful installed.

Once we have configured the CNTK library to run on .NET platform , we can start building some more interesting NN models.
Stay tuned.

Advertisements

About Bahrudin Hrnjica

PhD in Mechanical Engineering, Microsoft MVP for Visual Studio and Development Technologies. Likes .NET, Math,Data Science, Evolutionary Algorithms, Machine Learning, Blogging.

Posted on 12/11/2017, in .NET, C#, CNTK and tagged , , . Bookmark the permalink. 1 Comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s