<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/tutorial-deep-learning-with-r-on-azure-with-keras-and-cntk/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2017/08/keras-and-cntk.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p><em>by Le Zhang (Data Scientist, Microsoft) and Graham Williams (Director of Data Science, Microsoft)</em></p>
<p><a rel="nofollow" href="https://www.microsoft.com/en-us/cognitive-toolkit/" target="_blank">Microsoft's Cognitive Toolkit</a> (better known as CNTK) is a commercial-grade and open-source framework for deep learning tasks. At present CNTK does not have a native R interface but can be accessed through <a rel="nofollow" href="https://keras.io/" target="_blank">Keras</a>, a high-level API which wraps various deep learning backends including CNTK, TensorFlow, and Theano, for the convenience of modularizing deep neural network construction. The latest version of CNTK (2.1) supports Keras. The RStudio team has developed an <a rel="nofollow" href="https://github.com/rstudio/keras" target="_blank">R interface for Keras</a> making it possible to run different deep learning backends, including CNTK, from within an R session.</p>
<p>This tutorial illustrates how to simply and quickly spin up a Ubuntu-based <a rel="nofollow" href="https://docs.microsoft.com/en-us/azure/machine-learning/machine-learning-data-science-virtual-machine-overview" target="_blank">Azure Data Science Virtual Machine</a> (DSVM) and to configure a Keras and CNTK environment. An Azure DSVM is a curated virtual machine image coming with an extensive collection of pre-installed open source data science tools. The Keras R package can be readily setup up on the DSVM so as to experience the fun of deep learning.</p>
<p>The deployment of a DSVM is also largely simplified through a few R commands from a local R session (running on your own laptop), thanks to the <a rel="nofollow" href="https://github.com/Microsoft/AzureSMR" target="_blank">AzureSMR</a> and <a rel="nofollow" href="https://github.com/Azure/AzureDSVM" target="_blank">AzureDSVM</a> packages for R. With an Azure subscription (visit <a rel="nofollow" href="https://azure.microsoft.com/en-us/free/" target="_blank">Microsoft</a> for a free trial subscription) and an initial setup of the <a rel="nofollow" href="http://htmlpreview.github.io/?https://github.com/Microsoft/AzureSMR/blob/master/inst/doc/Authentication.html" target="_blank">Azure Active Directory App</a> for authority to access and manage Azure resources, data scientists can use R to manage and operate selected Azure resources, including to easily interact with and use Azure DSVMs for data analytical jobs. A deploy-compute-destroy cycle is now trivial to orchestrate within R.</p>
<p>The following code snippets create an Azure resource group (a logical collection of related resources) and a Ubuntu DSVM of a specified size within the new resource group:</p>
<div>
<pre>library(AzureSMR)
library(AzureDSVM)

<span># Authentication.</span>

asc <span>&lt;-</span> createAzureContext(tenantID <span>=</span> <span>&quot;</span></pre></div></div>