@@ -252,6 +252,11 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
252252 if y is None :
253253 y = get_labels_np_array (self .estimator .predict (x , batch_size = self .batch_size ))
254254
255+ if self .estimator .nb_classes == 2 and y .shape [1 ] == 1 :
256+ raise ValueError (
257+ "This attack has not yet been tested for binary classification with a single output classifier."
258+ )
259+
255260 # Compute perturbation with implicit batching
256261 nb_batches = int (np .ceil (x_adv .shape [0 ] / float (self .batch_size )))
257262 for batch_id in trange (nb_batches , desc = "C&W L_2" , disable = not self .verbose ):
@@ -656,6 +661,11 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
656661 if y is None :
657662 y = get_labels_np_array (self .estimator .predict (x , batch_size = self .batch_size ))
658663
664+ if self .estimator .nb_classes == 2 and y .shape [1 ] == 1 :
665+ raise ValueError (
666+ "This attack has not yet been tested for binary classification with a single output classifier."
667+ )
668+
659669 # Compute perturbation with implicit batching
660670 nb_batches = int (np .ceil (x_adv .shape [0 ] / float (self .batch_size )))
661671 for batch_id in trange (nb_batches , desc = "C&W L_inf" , disable = not self .verbose ):
@@ -971,6 +981,11 @@ def generate(self, x: np.ndarray, y: Optional[np.ndarray] = None, **kwargs) -> n
971981 if y is None :
972982 y = get_labels_np_array (self .estimator .predict (x , batch_size = self .batch_size ))
973983
984+ if self .estimator .nb_classes == 2 and y .shape [1 ] == 1 :
985+ raise ValueError (
986+ "This attack has not yet been tested for binary classification with a single output classifier."
987+ )
988+
974989 if self .mask is None :
975990 # No initial activation provided, use the full feature set
976991 activation = np .ones (x .shape )
0 commit comments