You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm training a deep neural network predicting if two records refer to the same entity using LSTM layers. I can't get SHAP to work on the LSTM model, but it does provide values on regular Dense layers. I saw #3344 and wanted to provide another example, in case it's helpful.
For context, the model takes two inputs. Each input is an array of text embeddings for various fields (i.e., first_name, last_name, title, etc.), so the shape is (n, 15, 300), where n is the number of records, 15 is the number of fields, and 300 is the length of the text embeddings. These inputs are concatenated together and run through the model which makes a binary prediction (1=Match/0=Non-Match).
This might be a completely separate question, but the SHAP values for the Dense model are the same size as the input. I assume this is expected behavior, but for the text embeddings (size 300) I don't need a value for each number in the embedding array. Does it make sense to take the average of the embedding and use this as the SHAP value? Happy to do more research on this, just wanted to ask the experts.
Happy to provide more details if that's helpful! Thank you for such a useful package- you guys are awesome!
Thanks for reporting a clear and concise example of this bug.
As you already mentioned, this is a known issue that is reported over and over, see e.g. here #3344 (as you mentioned) or #3343. There is a draft PR #3419 that tries to solve it but this is a difficult problem.
Issue Description
I'm training a deep neural network predicting if two records refer to the same entity using LSTM layers. I can't get SHAP to work on the LSTM model, but it does provide values on regular Dense layers. I saw #3344 and wanted to provide another example, in case it's helpful.
For context, the model takes two inputs. Each input is an array of text embeddings for various fields (i.e.,
first_name
,last_name
,title
, etc.), so the shape is(n, 15, 300)
, wheren
is the number of records,15
is the number of fields, and300
is the length of the text embeddings. These inputs are concatenated together and run through the model which makes a binary prediction (1=Match/0=Non-Match).This might be a completely separate question, but the SHAP values for the Dense model are the same size as the input. I assume this is expected behavior, but for the text embeddings (size 300) I don't need a value for each number in the embedding array. Does it make sense to take the average of the embedding and use this as the SHAP value? Happy to do more research on this, just wanted to ask the experts.
Happy to provide more details if that's helpful! Thank you for such a useful package- you guys are awesome!
Versions:
python==3.9.18
tensorflow==2.12.0
keras==2.12.0
numpy==1.23.5
shap==0.45.0
Minimal Reproducible Example
Traceback
Expected Behavior
No response
Bug report checklist
Installed Versions
0.45.0
The text was updated successfully, but these errors were encountered: