-
Notifications
You must be signed in to change notification settings - Fork 555
[BMS] StageNet with Attention #707
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
base: master
Are you sure you want to change the base?
Conversation
8895b0c to
e9b34e5
Compare
jhnwu3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add it to the docs/?
I think it makes sense to stack attention between each RNN pass. So it's probably good enough here. We just need to rename the StageNet layer and also check that we can pull out both the attention scores and its gradients for the attn-grad visualizations.
| attn_output, _ = self.mha( | ||
| hidden_seq, hidden_seq, hidden_seq, key_padding_mask=key_padding_mask | ||
| ) | ||
| attn_output = self.attn_norm(attn_output + hidden_seq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to hook the attention scores from self.mha here? This way, we can pull out the attention weights visualization + its gradients for both attention-grad visualization/ interpretability approach. It would be cool to see how AttentionGrad, DeepLift, and GIM compare
Transformer hooks (ver. might not be required) https://github.com/sunlabuiuc/PyHealth/blob/master/pyhealth/models/transformer.py
and
https://github.com/sunlabuiuc/PyHealth/blob/master/pyhealth/interpret/methods/chefer.py
Chefer's attribution approach method.
The goal is to be able to visualize each feature's tokens contribution. We may need to rewrite later how we process the StageNet task to support more granular lab events support (i.e instead of a 10 vector, we give each lab event its own embedding).
Contributor: Yongda Fan (yongdaf2@illinois.edu)
Contribution Type: Model
Description
Create a new model StageNet with Attention, with MHA layers inserted between SA-LSTM and SA-CNN.
Files to Review
pyhealth/models/stagenet_mha.py
tests/core/test_stagenet_mha.py