Integrated gradient for LSTM shows 'cudnn RNN backward can only be called in training mode'
See original GitHub issueHi all,
I have a trained LSTM model and the output is a time series. I tried to apply integrated gradient but got the error showing ‘cudnn RNN backward can only be called in training mode’. Any ideas how to solve it? Here is the code.
def forward_fun(x_d, x_s, x_one_hot):
out = lstm(x_d, x_s, x_one_hot)[0][:,-1] #0 is for the cell output and -1 is for the last index in the ouput series
return out
ig = IntegratedGradients(forward_fun)
attrs = []
for i in range(x_d.shape[0]):
attr = ig.attribute(inputs=(x_d[i:i+1]), additional_forward_args=(x_s[i:i+1], x_one_hot)).cpu().data.numpy()
attrs.append(attr)
attrs = np.concatenate(attrs, axis=0)
Then I tried to move all the model and data to CPU and it is working now (slowly). How can I make it on the GPU??
Thanks all!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
cudnn RNN backward can only be called in training mode ...
Your model needs to be in train mode throughout the the whole training. And you never set your model back to train after...
Read more >Cudnn RNN backward can only be called in training mode
I write a code but it has a error, I can not fix it my environment is : cuda9 + cudnn 7.1 python=3.6.6...
Read more >Sequence Classification with LSTM Recurrent Neural ...
In this post, you will discover how you can develop LSTM recurrent neural network models for sequence classification problems in Python using ...
Read more >TensorFlow RNN models - Jonathan Hui - Medium
The following diagram shows a bidirectional RNN which contains a forward LSTM and a backward LSTM. For each timestep, we merge the result...
Read more >Use of cudnn rnn forwardtraining and backwardtraining
I want to train a recurrent neural network with outputs that don't occur at every time step. It is a many-to-one RNN. I...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ShihengDuan , I saw similar problem too and setting the following flag helped to fix the problem:
@ShihengDuan, CuDNN with RNN doesn’t support gradient computation in eval mode that’s why we need to disable cudnn for RNN in eval mode. I do not know the exact reasons. That would be a good question for pytorch discussion forum.