DiCE icon indicating copy to clipboard operation
DiCE copied to clipboard

Generating CF examples for the multi-class classification case using the GD-based method

Open ah-ansari opened this issue 3 years ago • 4 comments

Hi,

I was wondering if the current implementation of the GD-based method (I mean the loss-based method described in your paper, Mothilal et al. (2020)) can handle the multi-class classification case?

I see in dice_tensorflow2.py, that the "desired_class" parameter can only be 0 or 1.

Many thanks that you take the time to answer the questions.

ah-ansari avatar Jun 03 '22 04:06 ah-ansari

We are working on supporting multi-class, but the current version on tensorflow supports only binary at the moment.

amit-sharma avatar Jun 03 '22 04:06 amit-sharma

Thanks for your response.

For a submission, I need to apply your method to a multi-class problem, for which I will cite your work. Unfortunately, my time is limited, and I would appreciate it if you describe how I modify the code so it can be applied for multi-class case (if the change is simple and theoretically fine). I think if I modify the "predict_fn" function in dice_tensorflow2.py, then the method would work without any further changes. Am I correct?

ah-ansari avatar Jun 03 '22 05:06 ah-ansari

That's correct. you will need to change the predict_fn. But you may find that the rest of the code expects a single-dimensional value as output of classifier---so you may need to change those parts to do "max of the output scores" rather than "is output score more than 0.5/threshold".

Hope this helps. Happy to answer any questions as you go through the code, and would love if you can raise a PR with these changes after your submission.

amit-sharma avatar Jun 03 '22 05:06 amit-sharma

Many thanks for your help. Sure, I will raise a PR after I applied the changes.

ah-ansari avatar Jun 03 '22 05:06 ah-ansari

Could you kindly confirm if multi-class classification is supported for "gradient" method with PyTorch/Tensorflow backend now?

jainspoornima avatar Feb 29 '24 14:02 jainspoornima

yes, it is supported now in the latest release.

amit-sharma avatar Feb 29 '24 15:02 amit-sharma