feedzai / timeshap

TimeSHAP explains Recurrent Neural Network predictions.
Other
162 stars 30 forks source link

timeshap_kernel, synth_hidden_states issue #11

Closed luxx0235 closed 2 years ago

luxx0235 commented 2 years ago

hello, great work but there just little thing really confuse me when reading your code, from line 688 to 690 in timeshap_kernel.py,

if not self.mode == 'pruning' and self.returns_hs: hidden_sates = self.synth_hiddenstates[self.nsamplesRun self.N:self.nsamplesAdded self.N,:, :] modelOut, = self.model.f(data, hidden_sates)

since the second dimension of self.synth_hidden_states is directly linked to self.nsamples, to create space for nsamples of enumerated feature combinations, I think hidden_sates = self.synth_hidden_states[:, self.nsamplesRun self.N:self.nsamplesAdded self.N, :] makes more sense to me whereas your code is doing the indexing on the first dimension.

Could you guys let me know if I understand it correctly? thanks and great work agian.

JoaoPBSousa commented 2 years ago

Hello @luxx0235 ,

Thanks for noting this issue. You are indeed correct and the code was wrong. I have pushed the fix into the repo hidden_sates = self.synth_hidden_states[:, self.nsamplesRun * self.N:self.nsamplesAdded * self.N, :]

I do not think any previous results were affected, and this indeed is the correct formulation of the code. Thank you very much

luxx0235 commented 2 years ago

you are welcome! thanks for quick reply:)