# Convolutional Neural Networks in R

I don't see a package for doing Convolutional Neural Networks in R. Has anyone implemented this kind of algorithm in R?

• don't think so, even if it was implemented, it would probably lack support for using. I would suggest Tensorflow or Skflow for python, caffe for C++ or caffe on spark for Apache Spark. – GameOfThrows May 25 '16 at 13:34
• @GameOfThrows Thanks, I think you're right. I use Tensorflow and Caffe but I'd just like to use R. – Hack-R May 25 '16 at 13:38

I guess there is no package for cnn but you can write your own convolutional layer. mxnet or h2o will be useful for it.

check this out:

http://dmlc.ml/rstats/2015/11/03/training-deep-net-with-R.html

The following 2 packages are available in R for deep neural network training:

1. darch: Package for Deep Architectures and Restricted Boltzmann Machines. The darch package is built on the basis of the code from G. E. Hinton and R. R. Salakhutdinov (available under Matlab Code for deep belief nets). This package is for generating neural networks with many layers (deep architectures), train them and fine tuning with common known training algorithms like backpropagation or conjugate gradients. Additionally, supervised fine-tuning can be enhanced with maxout and dropout, two recently developed techniques to improve fine-tuning for deep learning. CRAN link: http://cran.um.ac.ir/web/packages/darch/index.html

2. deepnet: deep learning toolkit in R. Implement some deep learning architectures and neural network algorithms, including BP,RBM,DBN,Deep autoencoder and so on. CRAN link: https://cran.r-project.org/web/packages/deepnet/index.html

• Thanks for your answer. I've used both and did not think that they provided CNN algorithms? I just searched the documentation for both for the word convolutional and nothing came up. Do they actually have this functionality? – Hack-R Aug 20 '16 at 12:01

I think mxnet is one of the best options if you code in R. They have an R wrapper but the core is in C++.

They have several examples in the web. One of them is the character recognition with MNIST database. They have support for multi-gpus and also for Spark.

• Yes, also RNN, LSTM. They have many examples in their github – hoaphumanoid Aug 20 '16 at 12:10
• Ah, yes thanks. I have used mxnet for image classification but didn't think it had CNN algorithms for the same. I see a CNN text classification example. I probably should've specified image classification. Still, perhaps it can be leveraged as such. I will look into it. Thanks! +1 – Hack-R Aug 20 '16 at 13:38

The MXNetR package is an interface of the MXNet library written in C++. It contains feed-forward neural networks and convolutional neural networks (CNN) (MXNetR 2016a).

https://www.is.uni-freiburg.de/resources/r-oeffentlicher-zugriff/deep-learning-in-r/deep-learning-in-r-en?set_language=en

# Installation

To get started, install the tensorflow R package from GitHub as follows:

devtools::install_github("rstudio/tensorflow")


Then, use the install_tensorflow() function to install TensorFlow:

library(tensorflow)
install_tensorflow()


You can confirm that the installation succeeded with:

sess = tf$Session() hello <- tf$constant('Hello, TensorFlow!')
sess\$run(hello)


This will provide you with a default installation of TensorFlow suitable for getting started with the tensorflow R package. See the article on installation to learn about more advanced options, including installing a version of TensorFlow that takes advantage of Nvidia GPUs if you have the correct CUDA libraries installed.