raise error when spsa input does not have right dim
@@ -1672,6 +1672,9 @@ class SPSA(Attack):
different inputs.
:param is_debug: If True, print the adversarial loss after each update.
"""
+ if x.get_shape().as_list()[0] != 1:
+ raise ValueError("Input tensor x must have batch_size of 1 for SPSA.")
+
from .attacks_tf import SPSAAdam, pgd_attack, margin_logit_loss
if batch_size is not None:
warnings.warn(
