R Interface to the Microsoft Cognitive Toolkit
Please take a look at the package website microsoft.github.io/CNTK-R for complete documentation.
CNTK-R is an R package for CNTK, which uses the reticulate package to bind to CNTK's Python API. Since it binds directly to Python, the R interface can perform any operation the Python
bindings can, including running on the GPU. See the CIFAR-10 image classification vignette to see a basic example of training and evaluation of image classification on the CIFAR-10 dataset.
To use CNTK with R you'll need to have the appropriate Python wheel for your system already installed. See CNTK's documentation for help setting up CNTK's Python wheel on your system.
Then run the following to install CNTK's R package:
You can also take a look at our article on setting up CNTK and CNTK-R on your machine.
Documentation is still a work in progress, but the R package closely follows the CNTK Python interface where possible (Python docs). Here's the basic rundown of the differences:
Properties are the same as in Python, and are accessed using the dollar sign ($) syntax:
l <- Learner(parameters, lrschedule) l$parameters # returns parameters associated with learner
Class methods are made global, and take the class object as the first property:
learner.update(...) # Python update_learner(learner, ...) # R equivalent learner %>% update_learner(...) # R equivalent via pipe
Since class methods are made global, some renaming from the original python API was necessary to avoid conflicts. See the documentation for a list of all available functions.
R matrices are automatically converted to and from NumPy array's with float32 dtype.
Python enums are accessed via function argument, e.g.:
UnitType.Error # Python UnitType("Error") # R equivalent