Skip to content
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

Which kind of layer does DeepLIFT support as its last layer? #22

Closed
KeLanhhh opened this issue Mar 31, 2017 · 2 comments
Closed

Which kind of layer does DeepLIFT support as its last layer? #22

KeLanhhh opened this issue Mar 31, 2017 · 2 comments

Comments

@KeLanhhh
Copy link

Hello,

I was trying to use the function get_target_contribs_func for my model built with keras. However, I got following error:

RuntimeError: There is a layer after your target layer but it is not an activation layer, which seems odd...if doing regression, make sure to set the target layer to the last layer

My last layer is a linear layer, it was generated by keras.layers.core.Activation("linear"). This error will disappear when changing "linear" to "sigmoid", So I guess "linear" is not supported by DeepLIFT as last layer. Would you add it in the future? Or it's just something wrong with my model?

@AvantiShri
Copy link
Collaborator

When calling deeplift_model.get_target_contribs_func, the default value for target_layer_idx is -2. You should set it to -1 if your last layer is a linear layer, as this is the layer that you want to measure contributions to (as recommended in the deeplift paper, if your last layer were a sigmoid, then contributions should be measured w.r.t the linearity immediately preceding the final sigmoid transformation). The error is intended to catch cases where people are not aware that target_layer_idx defaults to -2.

Let me know if you have any more questions!

  • Avanti

@KeLanhhh
Copy link
Author

KeLanhhh commented Apr 1, 2017

Than you very much! I changed target_layer_idx to -1, and it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants