DiCE icon indicating copy to clipboard operation
DiCE copied to clipboard

IndexError: tuple index out of range

Open djlwzw opened this issue 4 years ago • 5 comments

Hi,I have a question there, so I hope to get some help. I use a dateset about MOOC, and I use a LSTM model. I want to predict whether students will drop out of school in the next week based on the data of the previous few weeks. Then I want to use DICE to generate some counterfactual examples for drop-out students. But I get a problem, I don’t know how to solve it. What does 'self.num_output_nodes' mean? Could you give me some help? Thank you.

Traceback (most recent call last): File "E:/DJL/my-experiment/cnnlstm_torch/mycode/my_lstm/my_lstm.py", line 189, in exp = dice_ml.Dice(d, m) File "D:\Anaconda3\envs\cnnlstm_torch\lib\site-packages\dice_ml\dice.py", line 19, in init self.decide_implementation_type(data_interface, model_interface, method, **kwargs) File "D:\Anaconda3\envs\cnnlstm_torch\lib\site-packages\dice_ml\dice.py", line 24, in decide_implementation_type self.init(data_interface, model_interface, **kwargs) File "D:\Anaconda3\envs\cnnlstm_torch\lib\site-packages\dice_ml\explainer_interfaces\dice_pytorch.py", line 39, in init self.num_output_nodes = self.model.get_num_output_nodes(len(self.data_interface.ohe_encoded_feature_names)).shape[1] IndexError: tuple index out of range

djlwzw avatar Jul 04 '21 05:07 djlwzw

@djlwzw, the num_output_nodes is internal to DiCE nd represent the number of classes in a classification problem.

Whis version of dice-ml are you using in your environment?

Regards,

gaugup avatar Jul 05 '21 18:07 gaugup

Thank you for your reply, I am using the latest dice-ml release 0.6.1.

djlwzw avatar Jul 07 '21 05:07 djlwzw

@djlwzw have you tried the getting-started example with pytorch in this notebook?

Does this simple example work? It will also help if you can share a minimum working example that produces this error. My guess is that the LSTM output may be of a different dimension than the classification models.

amit-sharma avatar Jul 07 '21 16:07 amit-sharma

I tried that simple example, and it ran successfully. Your guess is correct. The output of my model is inconsistent with the classification dimension. Then I found the reason and I have succeeded. Thank you for your help.

djlwzw avatar Jul 08 '21 03:07 djlwzw

@djlwzw could you close this issue if you are unblocked?

Regards,

gaugup avatar Aug 20 '21 19:08 gaugup