File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
tensorflow_privacy/privacy/privacy_tests/membership_inference_attack Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -316,6 +316,21 @@ class AttackInputData:
316316 # treated as multilabel data.
317317 force_multilabel_data : bool = False
318318
319+ # Directly comparing members of the type `np.ndarray` can throw an error:
320+ # "The truth value of an array with more than one element is ambiguous."
321+ # So we bring back an explicit implementation of __eq__ like it was prior to
322+ # Python 3.13 in order work around this possibility.
323+ def __eq__ (self , other ):
324+ if self is other :
325+ return True
326+ if other .__class__ is self .__class__ :
327+ return tuple (
328+ getattr (self , field .name ) for field in dataclasses .fields (self )
329+ ) == tuple (
330+ getattr (other , field .name ) for field in dataclasses .fields (other )
331+ )
332+ return NotImplemented
333+
319334 @property
320335 def num_classes (self ):
321336 if self .labels_train is None or self .labels_test is None :
You can’t perform that action at this time.
0 commit comments