{"action":"created","issue":{"url":"https://api.github.com/repos/sebastian-lapuschkin/lrp_toolbox/issues/12","repository_url":"https://api.github.com/repos/sebastian-lapuschkin/lrp_toolbox","labels_url":"https://api.github.com/repos/sebastian-lapuschkin/lrp_toolbox/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/sebastian-lapuschkin/lrp_toolbox/issues/12/comments","events_url":"https://api.github.com/repos/sebastian-lapuschkin/lrp_toolbox/issues/12/events","html_url":"https://github.com/sebastian-lapuschkin/lrp_toolbox/issues/12","id":327471111,"number":12,"title":"LRP for 1. Regression 2. In Keras","user":{"login":"vedhas","id":6374703,"avatar_url":"https://avatars2.githubusercontent.com/u/6374703?v=4","gravatar_id":"","url":"https://api.github.com/users/vedhas","html_url":"https://github.com/vedhas","followers_url":"https://api.github.com/users/vedhas/followers","following_url":"https://api.github.com/users/vedhas/following{/other_user}","gists_url":"https://api.github.com/users/vedhas/gists{/gist_id}","starred_url":"https://api.github.com/users/vedhas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vedhas/subscriptions","organizations_url":"https://api.github.com/users/vedhas/orgs","repos_url":"https://api.github.com/users/vedhas/repos","events_url":"https://api.github.com/users/vedhas/events{/privacy}","received_events_url":"https://api.github.com/users/vedhas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-05-29T20:15:21Z","updated_at":"2018-05-30T08:48:45Z","closed_at":null,"author_association":"NONE","body":"#  Question 1\r\n\r\nTo use this toolbox for a regression task, I changed \r\n`#predict and perform LRP for the 10 first samples\r\n` part of [lrp_demo.py](https://github.com/sebastian-lapuschkin/lrp_toolbox/blob/master/python/lrp_demo.py) to the following:\r\n\r\n```\r\nfor cId,ixs in enumerate(xs):  \r\n    # forward pass and prediction\r\n    ypred = nn.forward(ixs)\r\n    print 'True Value:     ', ys[cId]\r\n    print 'Predicted Value:', ypred, '\\n'\r\n    #\r\n    R = nn.lrp(ypred)  # as Eq(56) from DOI: 10.1371/journal.pone.0130140\r\n    # R = nn.lrp(ypred, 'alphabeta', 2.)  # as Eq(60) from DOI: 10.1371/journal.pone.0130140\r\n    # R = nn.lrp(ypred, 'epsilon', 1.)  # as Eq(58) from DOI: 10.1371/journal.pone.0130140\r\n    plt.figure();  # heatmap(attributions[:1],annot=1,annot_kws=np.expand_dims(Vocab,0))\r\n    plt.plot(np.sort(R));\r\n    plt.xticks(np.arange(Vocab.shape[0]),\r\n               Vocab[np.argsort(R)]\r\n               , rotation='vertical')\r\n    plt.title('Ep'+str(cId))\r\n    plt.show()\r\n```\r\nHowever, I get the following error. Kindly advise! \r\n```\r\nTraceback (most recent call last):\r\n  File \"/home/panditve/workspace/CurWorkDir/LrpExplainClose2BL.py\", line 546, in <module>\r\n    R = nn.lrp(ypred, 'alphabeta', 2.)  # as Eq(58) from DOI: 10.1371/journal.pone.0130140\r\n  File \"/home/panditve/workspace/CurWorkDir/modules/sequential.py\", line 316, in lrp\r\n    R = m.lrp(R,lrp_var,param)\r\n  File \"/home/panditve/workspace/CurWorkDir/modules/module.py\", line 120, in lrp\r\n    return self._alphabeta_lrp(R,param)\r\n  File \"/home/panditve/workspace/CurWorkDir/modules/linear.py\", line 152, in _alphabeta_lrp\r\n    Z = self.W[na,:,:]*self.X[:,:,na] # localized preactivations\r\nIndexError: too many indices for array\r\n```\r\nOR\r\n```\r\nR = nn.lrp(ypred)  # as Eq(58) from DOI: 10.1371/journal.pone.0130140\r\n  File \"/home/panditve/workspace/CurWorkDir/modules/sequential.py\", line 316, in lrp\r\n    R = m.lrp(R,lrp_var,param)\r\n  File \"/home/panditve/workspace/CurWorkDir/modules/module.py\", line 112, in lrp\r\n    return self._simple_lrp(R)\r\n  File \"/home/panditve/workspace/CurWorkDir/modules/linear.py\", line 114, in _simple_lrp\r\n    Z = self.W[na,:,:]*self.X[:,:,na] #localized preactivations\r\n```\r\n\r\n`xs` and `ys` are both 2 dimensional `[number of samples, number of features (or num predictions for ys)]`. For the sake of simplicity, I am predicting only 1 dimension at the moment i.e. `ys.shape [N,1]' and I got the error above.\r\n\r\n# Question2: \r\nIn the code above, I rewrote my network model going by your `modules` class. However, in most of my work so far, I have trained numerous keras models, and it is hard to rewrite them all + network may end up having very different weights. Do you plan to release Keras model compatible code anytime soon? Or have I missed something and  I can use lrp_toolbox for my Keras models already somehow?? \r\n\r\n# Question 3:\r\nAs I understand, LRP (deep taylor decomposition) is powerful enough to be able to tell me which of the features contributed most to my model's continuous valued output, per https://www.sciencedirect.com/science/article/pii/S0031320316303582 and https://www.youtube.com/watch?v=gy_Cb4Do_YE  Kindly let me know though, if I am anyway wrong in my understanding. :)"},"comment":{"url":"https://api.github.com/repos/sebastian-lapuschkin/lrp_toolbox/issues/comments/393081950","html_url":"https://github.com/sebastian-lapuschkin/lrp_toolbox/issues/12#issuecomment-393081950","issue_url":"https://api.github.com/repos/sebastian-lapuschkin/lrp_toolbox/issues/12","id":393081950,"user":{"login":"christiantinauer","id":16046522,"avatar_url":"https://avatars3.githubusercontent.com/u/16046522?v=4","gravatar_id":"","url":"https://api.github.com/users/christiantinauer","html_url":"https://github.com/christiantinauer","followers_url":"https://api.github.com/users/christiantinauer/followers","following_url":"https://api.github.com/users/christiantinauer/following{/other_user}","gists_url":"https://api.github.com/users/christiantinauer/gists{/gist_id}","starred_url":"https://api.github.com/users/christiantinauer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christiantinauer/subscriptions","organizations_url":"https://api.github.com/users/christiantinauer/orgs","repos_url":"https://api.github.com/users/christiantinauer/repos","events_url":"https://api.github.com/users/christiantinauer/events{/privacy}","received_events_url":"https://api.github.com/users/christiantinauer/received_events","type":"User","site_admin":false},"created_at":"2018-05-30T08:48:45Z","updated_at":"2018-05-30T08:48:45Z","author_association":"NONE","body":"It is part of my research. I can make a simple repo and at the implementation there. Just a few minutes."}}
{"actor":{"display_login":"christiantinauer"}}