Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support stateful=True on the LMU (and other RNN flags) #35

Open
arvoelke opened this issue Mar 25, 2021 · 2 comments
Open

Support stateful=True on the LMU (and other RNN flags) #35

arvoelke opened this issue Mar 25, 2021 · 2 comments

Comments

@arvoelke
Copy link
Contributor

The LMU layer currently accepts return_sequences and passes that through to tf.keras.layers.RNN with the created LMUCell. However, there are a number of other RNN flags that are ignored (https://www.tensorflow.org/api_docs/python/tf/keras/layers/RNN):

  • return_state
  • go_backwards
  • stateful
  • unroll
  • time_major

In order to use any of these additional flags, the LMUCell must be invoked directly then and passed to tf.keras.layers.RNN alongside the flags. Supporting the flags at the layer level would mirror the pattern for other recurrent layers such as tf.keras.layers.LSTM.

@Ondrysak
Copy link

Ondrysak commented Apr 10, 2021

@arvoelke does the absence of support for go_backwards mean that using LMU in Bidirectional manner is not going to perform as expected using the standard keras Bidirectional wrapper, but only if using LMU layer not LMUCell?

Is something something like this going to work as expected?


x = layers.Bidirectional(tf.keras.layers.RNN(
    keras_lmu.LMUCell(
        memory_d=1,
        order=64 ,
        theta=maxlen,     
    hidden_cell=tf.keras.layers.SimpleRNNCell(units=64),
        hidden_to_memory=False,
        memory_to_memory=False,
        input_to_hidden=True,
        kernel_initializer="ones",
    )))(x)

@arvoelke
Copy link
Contributor Author

arvoelke commented Apr 11, 2021

That example should work as expected. If you were to try tf.keras.layers.Bidirectional(keras_lmu.LMU(...)) instead then you should see a KeyError: 'go_backwards' (at least I do on tensorflow==2.3.1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants