### Oveview

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:

- Bayesian Regularized Neural Networks
- Extreme Learning Machine
- Model Averaged Neural Network
- Monotone Multi-Layer Perceptron Neural Network
- Multi-Layer Perceptron (multiple options)
- Neural network: nnet, mxnet, mxnetAdam, neuralnet, and more
- Stacked AutoEncoder Deep Neural Network

Where to start?

Apply nnet in the caret package

Overview of 4 packages for deep learning in R: by Oksana Kutina and Stefan Feuerriegel fom University of Freiburg.

### 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.

The R package called keras is an R interface for the Python-based Keras library which runs on the TensorFlow platform. Yes, it is confusing to have keras (R) and Keras (Python)!

- Rstudio's keras pages.
- The Python-based Keras package is an API. An application programming interface (API) is a program which allows multiple software packages to interact. Keras is a neural network API that can run either TensorFlow or Theano. The Python-based Keras package webpage is useful for understanding details of the functions you'll be using.
- The R package keras requires you to install both Keras and TensorFlow.
There are other R packages that you can use to access Keras. Read more here.

#### Installing the R keras package

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

```
install.packages("devtools")
devtools::install_github("rstudio/keras")
```

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.

```
library(keras)
install_keras()
```

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

```
library(keras)
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.