# LSTM or other RNN package for R

I saw some impressive result from LSTM models producing Shakespeare like texts. I was wondering if an LSTM package exists for R. I googled for it but only found packages for Python and Julia. (maybe there are some performance issue which explains why these programs are more preferred over R) Do You know about an LSTM (or at least an RNN) package for R? If exists are there any tutorials for using them?

• Example link of such results: karpathy.github.io/2015/05/21/rnn-effectiveness (not sure if this is one you have seen) – Neil Slater Sep 10 '15 at 9:08
• @NeilSlater Yes, that's one nice implementation I saw but unfortunately not for R. – Viktor Sep 10 '15 at 9:13
• I updated my answer to mention the now available LSTM and GRU algorithms in rnn. – Bastiaan Quast Sep 27 '16 at 10:36

Have a look at the rnn package (full disclosure, I am the author). It implements a multilayer RNN, GRU, and LSTM directly in R, i.e. not an underlying C++ library, so you should also be able to read the code and understand what is going on.

install.packages('rnn')


The CRAN version is quite up to date, but the GitHub version is bleeding edge and can be installed using:

if (!require('devtools')) install.packages('devtools')
devtools::install_github('bquast/rnn')

• Thanks for the nice package! I just started experimenting with it. I wonder if you have made any speed comparison with other implementations. – Viktor Feb 3 '17 at 10:54
• if its in R is it really slow? – ran8 Apr 8 '18 at 22:58
• not really, it's fast enough for reasonable work, there are ofc memory limitations – Bastiaan Quast Apr 11 '18 at 10:17

Keras is also now available for R. Here's an example of an LSTM with the R API.