arrayfire-ml icon indicating copy to clipboard operation
arrayfire-ml copied to clipboard

RNN Models

Open jramapuram opened this issue 10 years ago • 12 comments

Once we have an implementation of the Layer Class https://github.com/arrayfire/arrayfire_ml/issues/17 , the Optimizer class and the DataSet class we can go about creating RNN flavors. There are 3 models that should be implemented:

  • [ ] Vanilla RNN
  • [ ] LSTM
  • [ ] GRU

These will require the implementation of their derivatives and their forward prop values. Certain details to consider:

  • RNN's have a stack of weight matrices and bias' (not just 1 per Layer, thus the Layer needs to be general enough to handle this)
  • The optimization needs to be handled via two methods:
    • [ ] RTRL (real time recurrent learning) &
    • [ ] BPTT (backprop through time)

To enable the above two methods of learning we should consider inheriting from Layer and implementing a Recurrent Layer.

jramapuram avatar Jun 18 '15 09:06 jramapuram

BPTT is much more popularly used than RTRL, so might be better to prioritize BPTT over RTRL.

sherjilozair avatar Aug 29 '15 06:08 sherjilozair

BPTT doesn't solve the stateful RNN problem unfortunately. Truncated BPTT is a crude approximation as well as i Also, there are a plethora of BPTT solutions already: keras, blocks, lasagne, chainer, ...

The only way to have an online RNN is to use RTRL as each step utilizes the full jacobian product from the previous time step as this allows for smooth information flow.

jramapuram avatar Aug 29 '15 07:08 jramapuram

Pretty much all other RNN implementations are slow, and not suitable for production. My own reason for betting on arrayfire is that this might yield production-ready implementations for deep learning algorithms.

sherjilozair avatar Aug 29 '15 08:08 sherjilozair

I will be doing an internship till Sept and won't have time to update till then most likely. If someone wants to implement these first that would be great now that we have AD setup.

jramapuram avatar Jul 10 '17 22:07 jramapuram

Hi, I would be interested by either LSTM or GRU, forward pass would be a good first step before implementing backward/training.

WilliamTambellini avatar Jul 10 '17 23:07 WilliamTambellini

@jramapuram I am going to try and implement this. May be you and @WilliamTambellini review this once I send a PR.

pavanky avatar Jul 11 '17 04:07 pavanky

Hi @pavanky it sounds good. GRU is usually a little simpler to implement than LSTM but your choice. Have you thought about a possible example application (text generation, summarization, translation, question&answer, ...) ? Cheers W.

WilliamTambellini avatar Jul 12 '17 02:07 WilliamTambellini

I suggest a simple char-run type problem

jramapuram avatar Jul 12 '17 02:07 jramapuram

@jramapuram @WilliamTambellini If you have specific examples in mind please let me know. Preferably implemented as an example in another ML toolkit already :)

pavanky avatar Jul 12 '17 04:07 pavanky

@jramapuram @WilliamTambellini I think I am going to target this example as a first step: https://github.com/pytorch/examples/tree/master/word_language_model

pavanky avatar Jul 12 '17 05:07 pavanky

Hi @pavanky It sounds very good: the Penn db is quite small (about 5M) and training time should nt be long. Perfect for an example. Have you opted between Elman, GRU, or LSTM ?

WilliamTambellini avatar Aug 29 '17 20:08 WilliamTambellini

@WilliamTambellini Will start with plain (Elman) RNNs first.

pavanky avatar Aug 29 '17 21:08 pavanky