You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using a causal fidelity metric (either Insertion or Deletion) and setting steps=-1, the method returns an Attribute error.
Expected Behavior
I expect the method to support parameter values indicated in the documentation.
To solve it, in fidelity.py:
Change L306: tf.math.floor(self.nb_features * max_percentage_perturbed)
By: int(np.floor(self.nb_features * max_percentage_perturbed))
Version
1.3.1
Environment
No response
Relevant log output
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-8-ebb4e1c3761e>in<cell line: 7>()
6 i = 0
7 forexplanation_name, explanationsinexplanations_to_test.items():
----> 8 deletion_score = metric(explanations)
9 deletion_scores.append((explanation_name, deletion_score))
10
5 frames
/usr/local/lib/python3.10/dist-packages/xplique/metrics/base.py in __call__(self, explanations)
157 explanations: Union[tf.Tensor, np.array]) -> float:
158 """Evaluate alias"""
--> 159 return self.evaluate(explanations)
/usr/local/lib/python3.10/dist-packages/xplique/metrics/fidelity.py in evaluate(self, explanations)
326 better) curve.
327 """--> 328 scores_dict = self.detailed_evaluate(explanations) 329 330 # compute auc using trapezoidal rule (the steps are equally distributed)/usr/local/lib/python3.10/dist-packages/xplique/metrics/fidelity.py in detailed_evaluate(self, explanations) 379 baselines_flatten = baselines.reshape(self.inputs_flatten.shape) 380 --> 381 steps = np.linspace(0, self.max_nb_perturbed, self.steps + 1, dtype=np.int32) 382 383 if self.causal_mode == "deletion":/usr/local/lib/python3.10/dist-packages/numpy/core/overrides.py in linspace(*args, **kwargs)/usr/local/lib/python3.10/dist-packages/numpy/core/function_base.py in linspace(start, stop, num, endpoint, retstep, dtype, axis) 118 119 """
--> 120 num = operator.index(num)
121 if num < 0:
122 raise ValueError("Number of samples, %s, must be non-negative." % num)
/usr/local/lib/python3.10/dist-packages/tensorflow/python/framework/ops.py in __index__(self)
297
298 def __index__(self):
--> 299 returnself._numpy().__index__()
300
301 def __bool__(self) -> bool:
AttributeError: 'numpy.float64' object has no attribute '__index__'
To Reproduce
Initialize Insertion or Deletion with steps=-1 and call either evaluate or detailed_evaluate. It can easily be done in the Metrics: Getting started tuto.
The text was updated successfully, but these errors were encountered:
Module
Metrics
Current Behavior
When using a causal fidelity metric (either Insertion or Deletion) and setting
steps=-1
, the method returns anAttribute error
.Expected Behavior
I expect the method to support parameter values indicated in the documentation.
To solve it, in fidelity.py:
Change L306:
tf.math.floor(self.nb_features * max_percentage_perturbed)
By:
int(np.floor(self.nb_features * max_percentage_perturbed))
Version
1.3.1
Environment
No response
Relevant log output
To Reproduce
Initialize
Insertion
orDeletion
withsteps=-1
and call eitherevaluate
ordetailed_evaluate
. It can easily be done in the Metrics: Getting started tuto.The text was updated successfully, but these errors were encountered: