RuntimeError: You set the target layer to an activation layer
MayurDivate opened this issue · comments
Mayur Divate commented
Hi,
I trying to implement DeepLIFT to interpret CNN model.
However, I am not able get through following error.
target_layer_idx=-1)
File "/Users/n10337547/PycharmProjects/Bitbucket/ModelInterpretation/venv/lib/python3.6/site-packages/deeplift/models.py", line 113, in get_target_contribs_func
return self._get_func(*args, func_type=FuncType.contribs, **kwargs)
File "/Users/n10337547/PycharmProjects/Bitbucket/ModelInterpretation/venv/lib/python3.6/site-packages/deeplift/models.py", line 234, in _get_func
**kwargs)
File "/Users/n10337547/PycharmProjects/Bitbucket/ModelInterpretation/venv/lib/python3.6/site-packages/deeplift/models.py", line 47, in _get_func
self._set_scoring_mode_for_target_layer(target_layer)
File "/Users/n10337547/PycharmProjects/Bitbucket/ModelInterpretation/venv/lib/python3.6/site-packages/deeplift/models.py", line 133, in _set_scoring_mode_for_target_layer
+" classification)")
RuntimeError: You set the target layer to an activation layer, which is unusual so I am throwing an error - did you mean to set the target layer to the layer *before* the activation layer instead? (recommended for classification)
Process finished with exit code 1
My activation layer is softmax layer.
I was wondering whether DeepLIFT supports multi-class classification model?
Thanks,
Mayur
Av Shrikumar commented
Hi Mayur,
It's throwing this error because in accordance with Section 3.6 ("Choice of
Target Layer") of the DeepLIFT paper (https://arxiv.org/pdf/1704.02685.pdf),
it is recommended that you set your target layer to the layer *prior* to
the final nonlinearity to avoid artifacts caused by the saturating nature
of a sigmoid/softmax. So if you set your target_layer_idx to -2, you should
be fine. Does that make sense?
- Avanti
…On Thu, 24 Oct 2019 at 22:09, Mayur Divate ***@***.***> wrote:
Hi,
I trying to implement DeepLIFT to interpret CNN model.
However, I am not able get through following error.
target_layer_idx=-1)
File "/Users/n10337547/PycharmProjects/Bitbucket/ModelInterpretation/venv/lib/python3.6/site-packages/deeplift/models.py", line 113, in get_target_contribs_func
return self._get_func(*args, func_type=FuncType.contribs, **kwargs)
File "/Users/n10337547/PycharmProjects/Bitbucket/ModelInterpretation/venv/lib/python3.6/site-packages/deeplift/models.py", line 234, in _get_func
**kwargs)
File "/Users/n10337547/PycharmProjects/Bitbucket/ModelInterpretation/venv/lib/python3.6/site-packages/deeplift/models.py", line 47, in _get_func
self._set_scoring_mode_for_target_layer(target_layer)
File "/Users/n10337547/PycharmProjects/Bitbucket/ModelInterpretation/venv/lib/python3.6/site-packages/deeplift/models.py", line 133, in _set_scoring_mode_for_target_layer
+" classification)")
RuntimeError: You set the target layer to an activation layer, which is unusual so I am throwing an error - did you mean to set the target layer to the layer *before* the activation layer instead? (recommended for classification)
Process finished with exit code 1
My activation layer is softmax layer.
I was wondering whether DeepLIFT supports multi-class classification model?
Thanks,
Mayur
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#90?email_source=notifications&email_token=AARSFBQRB4J44JEP5ZZTZQTQQJ5RPA5CNFSM4JE6TJV2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HUJFNDQ>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARSFBTLXKA6ICBUCG5VFD3QQJ5RPANCNFSM4JE6TJVQ>
.
Av Shrikumar commented
What are you supplying for the argument input_data_list? It needs to be a
list of numpy arrays, one for each input mode.
On Thu, Oct 24, 2019 at 10:40 PM Mayur Divate ***@***.***> wrote:
If I do so it throws new error.
File "/Users/n10337547/PycharmProjects/Bitbucket/ModelInterpretation/venv/lib/python3.6/site-packages/deeplift/util.py", line 127, in run_function_in_batches
while i < len(input_data_list[0]):
TypeError: object of type 'Preprocessor' has no len()
Mayur
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#90?email_source=notifications&email_token=AARSFBQASSQGENUFN6AF4A3QQKBD5A5CNFSM4JE6TJV2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECHHZ7Y#issuecomment-546209023>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARSFBRSZMHF7ZFULDS5ZHTQQKBD5ANCNFSM4JE6TJVQ>
.
--
Sent from my phone, please excuse brevity/typos
Mayur Divate commented
Sorry, I just realized that.
Wait I will try that.
Mayur
Mayur Divate commented
Hey, it worked!
Thanks,
Mayur