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

Use of CuDNNLSTM for training and LSTM for testing #14

Open
rohithmars opened this issue Mar 16, 2022 · 1 comment
Open

Use of CuDNNLSTM for training and LSTM for testing #14

rohithmars opened this issue Mar 16, 2022 · 1 comment

Comments

@rohithmars
Copy link

rohithmars commented Mar 16, 2022

Hello,
I have used
self.intra_rnn = keras.layers.Bidirectional(keras.layers.CuDNNLSTM(units=self.numUnits//2, return_sequences=True))
and
self.inter_rnn = keras.layers.CuDNNLSTM(units=self.numUnits, return_sequences=True)
during the training process, which significantly increases the training speed.

However, is it possible to use LSTM using inference to run on cpu?

If so, what would be the LSTM parameters? Using the below may give different result compared to CuDNNLSTM?
keras.layers.LSTM(units=self.numUnits//2, return_sequences=True,implementation = 2,recurrent_activation = 'hard_sigmoid')

@Le-Xiaohuai-speech
Copy link
Owner

Le-Xiaohuai-speech commented Mar 16, 2022

In TenosrFlow 2.X the requirements to use the cuDNN implementation are:

  1. activation == tanh
  2. recurrent_activation == sigmoid
  3. recurrent_dropout == 0
  4. unroll is False
  5. use_bias is True
  6. Inputs are not masked or strictly right padded.
  7. implementation == 2,
    I haven't compared the code of LSTM in tf1 with tf2. Maybe they are a little different. If you use the above parameters, be careful of the alignment when loading the weights.

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

No branches or pull requests

2 participants