The best deep learning packages are currently in Python (PyTorch, TensorFlow, PyTorch, Keras, and more). These generally require learning Python. However, many people are more familiar with R and thus we focus on that here.

There are several packages in R that make deep learning accessible to R users. There are pros and cons to these packages. Due to the success of deep learning, I expect that there will more resources developed for R in the next few years.

Basic neural network models

Neural network models available using the Caret package:

  1. Bayesian Regularized Neural Networks
  2. Extreme Learning Machine
  3. Model Averaged Neural Network
  4. Monotone Multi-Layer Perceptron Neural Network
  5. Multi-Layer Perceptron (multiple options)
  6. Neural network: nnet, mxnet, mxnetAdam, neuralnet, and more
  7. Stacked AutoEncoder Deep Neural Network

Where to start?

R keras package

Depending on your computer set-up installing the R keras package may be very challenging. The R keras package appears to be unstable as this problem comes and goes over time when R and the python packages are updated. I've included this information in the hope that some students will get it to work and/or you may use a later version of the package once the package again becomes stable.

Installing the R keras package

Currently you can't get keras from CRAN. You can install the keras R package from GitHub as follows:


Note: for some people the installation of devtools appears to stall, but it is probably just taking a lont time. Two options are to wait longer or restart Rstudio and rerun the above lines. The install_keras() line below may also take a very long time to finish.

The R package keras accesses the Python library called Keras. Keras runs on the TensorFlow platform. To install Keras and TensorFlow, use the following code.


Use this to check that your installation is working (from the Rstudio's keras page: https://keras.rstudio.com/)

mnist <- dataset_mnist()

For more sophisticated deep learning installations (such as using NVIDIA GPUs), see the documentation for install_keras().

Problems installing the keras package?

First, do you have the latest version of R and R Studio? I've had some students have to uninstall and reinstall R and RStudio to get things to work. Also, exiting R Studio and re-entering it can fix some problems.

More problems? You'll need to do some sleuthing to get things working. Examine any the error messages in R. Try Googling the error message or maybe try another R/keras interface like the kerasR package.

Still can't get keras to work from within R? For this shortcourse, you can try more modeling with the caret package. If you are new to neural networks, try nnet and mxnet from using the caret train function. There are some deep learning packages that you can access in caret like DeepBoost and deepnet. Finally, keras is R is still developing, so try back in a month or two.