Hi, I’m trying to reproduce results from this article “Implementations of saliency models described in "Visualizing and Understanding Neural Models in NLP 72”.
By building an very simple RNN model (for binary classificaition):
GRU_model2224×1264 311 KB
and training on IMDB dataset from torchtext datasets.IMDB, the model perform well on binary classification.
Then I start to call saliency using the well-trained model by the following code (referd from https://medium.com/datadriveninvestor/visualizing-neural-networks-using-saliency-maps-in-pytorch-289d8e244ab4 30,This Saliency is generated from CNN model )
Saliency_error2750×776 218 KB
However, when I run “model.eval()”, the error occur: RuntimeError: cudnn RNN backward can only be called in training mode.
I’m really confused why CNN can go through saliency easily but RNN goes very difficult? Is there any solution to generate saliency map for text classification (to show which word is most important for model prediction) by RNN model? Thanks a lot!