12
$\begingroup$

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?

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

5 Answers 5

8
$\begingroup$

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')
$\endgroup$
3
  • $\begingroup$ Thanks for the nice package! I just started experimenting with it. I wonder if you have made any speed comparison with other implementations. $\endgroup$
    – Viktor
    Commented Feb 3, 2017 at 10:54
  • $\begingroup$ if its in R is it really slow? $\endgroup$
    – ran8
    Commented Apr 8, 2018 at 22:58
  • $\begingroup$ not really, it's fast enough for reasonable work, there are ofc memory limitations $\endgroup$ Commented Apr 11, 2018 at 10:17
7
$\begingroup$

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

$\endgroup$
4
$\begingroup$

You might have to extend another package to implement LSTM and RNN in R. Here are some packages to get you started:

  • deepnet Implements a variety of deep learning architectures
  • darch A deep architecture
  • H2O An open-source company with deep learning packages
$\endgroup$
4
$\begingroup$

I found this page, but the R package seems not to be open source : link.

$\endgroup$
1
  • 2
    $\begingroup$ It seems promising. According to the author he will publish it on CRAN when finished. $\endgroup$
    – Viktor
    Commented Sep 10, 2015 at 9:15
3
$\begingroup$

You might want to take a look at mxnet. It is a distributed library for deep learning. It supports C++, python, scala and R. There are many examples with R. Here you have an example of LSTM in R with this library.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.