Open pl8787 opened 6 years ago
Embedding layers by definition do not pass gradient through it. The layer uses dictionally lookup from word index to whatever dimension embedding that you decide to use. There is no gradient going back to the indexes themselves.
However, there are gradients flowing back to the embedded vectors, so you can sum the attribution to the vectors to get the actual attribution values. At the end of the day, embedding layers are equivalent to fully connected layers with one-hot encoded inputs.
Thanks, I have modified code to set the start nodes of the network in https://github.com/pl8787/IntegratedGradients.
Sounds good!
I also encounter this gradient value to be None
issue, so after I check the code I solved by switching the default None
option to Zero
. Here, in this file
/Users/username/opt/anaconda3/envs/ml/lib/python3.7/site-packages/tensorflow/python/ops/gradients_impl.py
there is this function signature:
It actually lets you to choose default output for those unconnected node's gradient output. After I chose ZERO
that issue solved.
The model can only get gradient for embedding layer. If the input of the model is word id and use Embedding Layer, the Integrated-Gradients return an error.
However, I can get the gradient of embedding, how to determine the value of single words, for example in paper
Section 6.3
Question Classification?