Using Keras for Deep Learning with R

[This article was first published on RStudio | Open source & professional software for data science teams on RStudio, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Photo by Preethi Viswanathan on Unsplash

We are excited to announce new developments in Keras for R. Together with our current integration with torch, data scientists can use the most popular and powerful deep learning frameworks all within R.

Expand data science capabilities with deep learning

Data scientists use machine learning to create models that improve without explicit instructions. Deep learning is a subset of machine learning. It is particularly powerful in applications such as image recognition, natural language processing, and audio processing.

Deep learning allows data scientists to create more accurate and efficient models, sometimes even outperforming human cognition. With improved machine learning capabilities, data scientists can provide better answers to their data questions.

Add essential tools to your toolkit

Data scientists have done significant work to develop the deep learning sector. Among deep learning libraries, Keras stands out for its productivity, flexibility, and user-friendly API. TensorFlow is a machine learning platform that is both extremely adaptable and well-suited for production. Together, users can use these libraries to train and deploy powerful deep learning models.

The Keras for R package provides an R interface to Keras. With it, data scientists can leverage the power of Keras and Tensorflow in R.

Train neural networks with easy-to-write code

Keras for R allows data scientists to run deep learning models in an R interface. They can write in their preferred programming language while taking full advantage of the deep learning methods and architecture.

  • The package provides familiar syntax. Users can write natural-feeling, idiomatic-looking code with Keras for R (including the pipe operator!). Take a look: the image classification example on the Tensorflow for R website uses code very familiar to those who use the tidyverse syntax.

Scrolling through a Tensorflow for R tutorial

  • The package supports users in translating Python code. Using %py_class%, data scientists can directly subclass Python objects, making it much easier to translate Python code found on the web.
NonNegative(keras$constraints$Constraint) %py_class% {
  "__call__" <- function(x) {
    w * k_cast(w >= 0, k_floatx())

No need to switch between environments or languages — users can use Keras functionality all within R.

What’s next?

We will continue developing Keras for R to help R users develop sophisticated deep learning models in R. Stay tuned for:

  • A new version of Deep Learning for R, with updated functionality and architecture;
  • More expansion of Keras for R’s extensive low-level refactoring and enhancements; and
  • More detailed introductions to the powerful new features.

Check out the “Keras for R is Back!” post to learn about the state of the ecosystem and the package’s new functionalities. Subscribe to the RStudio AI Blog for the latest news, insights, and examples of using AI-related technologies with R.

To leave a comment for the author, please follow the link and comment on their blog: RStudio | Open source & professional software for data science teams on RStudio. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)