Cast to x.dtype
@@ -622,9 +622,9 @@ class ProjectedGradientDescent(Attack):
# The 1e-6 is needed to compensate for numerical error.
# Without the 1e-6 this fails when e.g. eps=.2, clip_min=.5,
# clip_max=.7
- asserts.append(tf.assert_less_equal(tf.cast(self.eps, self.tf_dtype),
- 1e-6 + tf.cast(self.clip_max, self.tf_dtype)
- - tf.cast(self.clip_min, self.tf_dtype)))
+ asserts.append(tf.assert_less_equal(tf.cast(self.eps, x.dtype),
+ 1e-6 + tf.cast(self.clip_max, x.dtype)
+ - tf.cast(self.clip_min, x.dtype)))
if self.sanity_checks:
with tf.control_dependencies(asserts):
