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

Can we get all m_{xy} or C_{xy} values from the model for all layers? #37

Closed
younglululu opened this issue Nov 5, 2017 · 2 comments
Closed

Comments

@younglululu
Copy link

No description provided.

@AvantiShri
Copy link
Collaborator

Hi younglululu,

I had to refresh my memory, but the answer is yes! find_scores_layer_idx (for a sequential model) and find_scores_layer_name (for a graph model) can actually be lists:

https://github.com/kundajelab/deeplift/blob/master/deeplift/models.py#L225-L227
https://github.com/kundajelab/deeplift/blob/master/deeplift/models.py#L278-L280

I would have changed the names of the arguments to reflect this, but I didn't want to break the API. Let me know if you have any issues.

@AvantiShri
Copy link
Collaborator

AvantiShri commented Nov 8, 2017

Oh, one more followup remark: for all layers except the input layer, multipliers are split up into pos_mxts and neg_mxts (as needed by the RevealCancel rule described in the DeepLIFT paper). For layers that act as inputs to nonlinearities, these will be different, but for layers that act as inputs to a linear layer, these should be the same. Because get_mxts() is not defined for anything other than Input layers (instead, there is get_pos_mxts() and get_neg_mxts()), you could modify the following line https://github.com/kundajelab/deeplift/blob/master/deeplift/models.py#L56 to use the average of get_pos_mxts() and get_neg_mxts() if get_mxts() is not defined for the layer. The code would look something like this:

output_symbolic_vars = [
             (find_scores_layer.get_mxts() if hasattr(find_scores_layer, 'get_mxts())
              else 0.5*(find_scores_layer.get_pos_mxts() + find_scores_layer.get_neg_mxts()))
             for find_scores_layer in find_scores_layers]

Let me know if that works for your purposes, and if it does, would be happy to accept a pull request to the main code base!

@AvantiShri AvantiShri reopened this Nov 8, 2017
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