简体   繁体   English

接收断言失败虽然通过任何方法生成对抗样本

[英]Receiving Assertion failed While generate adversarial samples by any methods

I am receiving following error while generating adversarial examples by any method 我通过任何方法生成对抗示例时收到以下错误

InvalidArgumentError: assertion failed: [] [Condition x <= y did not hold element-wise:x (Placeholder_173:0) = ] [[[[158 112 49]]]...] [y (Cast_6:0) = ] [1]
     [[{{node assert_less_equal_1/Assert/AssertGuard/Assert}}]]

My Code for generating adversarial examples 我的代码用于生成对抗性示例


from cleverhans.utils_keras import KerasModelWrapper
from cleverhans.attacks import FastGradientMethod
model=build_model()
sess =  K.get_session()
wrap = KerasModelWrapper(model)
fgsm = FastGradientMethod(wrap, sess=sess)
fgsm_params = {'eps': 0.3,
               'clip_min': 0.,
               'clip_max': 1.}
adv_x = fgsm.generate_np(x_test, **fgsm_params)

Model Code here tensorflow version = 1.13.1 型号代码在这里tensorflow版本= 1.13.1

https://github.com/geifmany/cifar-vgg/blob/master/cifar10vgg.py https://github.com/geifmany/cifar-vgg/blob/master/cifar10vgg.py

full stack trace 完整的堆栈跟踪

---------------------------------------------------------------------------
InvalidArgumentError                      Traceback (most recent call last)
~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1333     try:
-> 1334       return fn(*args)
   1335     except errors.OpError as e:

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
   1318       return self._call_tf_sessionrun(
-> 1319           options, feed_dict, fetch_list, target_list, run_metadata)
   1320 

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
   1406         self._session, options, feed_dict, fetch_list, target_list,
-> 1407         run_metadata)
   1408 

InvalidArgumentError: assertion failed: [] [Condition x <= y did not hold element-wise:x (Placeholder_173:0) = ] [[[[158 112 49]]]...] [y (Cast_6:0) = ] [1]
     [[{{node assert_less_equal_1/Assert/AssertGuard/Assert}}]]

During handling of the above exception, another exception occurred:

InvalidArgumentError                      Traceback (most recent call last)
<ipython-input-4-8941aeed68c9> in <module>
      8                'clip_min': 0.,
      9                'clip_max': 1.}
---> 10 adv_x = fgsm.generate_np(x_test, **fgsm_params)

~/anaconda3/lib/python3.7/site-packages/cleverhans/attacks/__init__.py in generate_np(self, x_val, **kwargs)
    201       feed_dict[new_kwargs[name]] = feedable[name]
    202 
--> 203     return self.sess.run(x_adv, feed_dict)
    204 
    205   def construct_variables(self, kwargs):

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
    927     try:
    928       result = self._run(None, fetches, feed_dict, options_ptr,
--> 929                          run_metadata_ptr)
    930       if run_metadata:
    931         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
   1150     if final_fetches or final_targets or (handle and feed_dict_tensor):
   1151       results = self._do_run(handle, final_targets, final_fetches,
-> 1152                              feed_dict_tensor, options, run_metadata)
   1153     else:
   1154       results = []

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
   1326     if handle is None:
   1327       return self._do_call(_run_fn, feeds, fetches, targets, options,
-> 1328                            run_metadata)
   1329     else:
   1330       return self._do_call(_prun_fn, handle, feeds, fetches)

~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in _do_call(self, fn, *args)
   1346           pass
   1347       message = error_interpolation.interpolate(message, self._graph)
-> 1348       raise type(e)(node_def, op, message)
   1349 
   1350   def _extend_graph(self):

InvalidArgumentError: assertion failed: [] [Condition x <= y did not hold element-wise:x (Placeholder_173:0) = ] [[[[158 112 49]]]...] [y (Cast_6:0) = ] [1]
     [[node assert_less_equal_1/Assert/AssertGuard/Assert (defined at /home/munib/anaconda3/lib/python3.7/site-packages/cleverhans/utils_tf.py:615) ]]


It looks like your inputs are not within the [clip_min, clip_max] interval. 看起来您的输入不在[clip_min,clip_max]间隔内。 Did you ensure that x_test is clipped to that interval before feeding it to generate_np ? 您是否确保在将x_test提供给generate_np 之前将其剪切到该时间间隔?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法使用经过训练的 NSGA-Net PyTorch 模型生成对抗样本 - Failed to generate adversarial examples using trained NSGA-Net PyTorch models 安装Google Assistant SDK示例时收到CFFI丢失 - Receiving CFFI missing while install Google Assistant SDK Samples 错误: (-215:Assertion failed) 使用 openCV 时 - error: (-215:Assertion failed) while using openCV Jupyter 实验室无法安装任何扩展:断言“数据”失败 - Jupyter lab fails to install any extension: Assertion `data' failed 有什么方法可以在 python 中生成这样的随机表吗? - Is there any methods to generate such a random table in python? 错误:(-215:Assertion failed) npoints > 0 while working with contours using OpenCV - Error: (-215:Assertion failed) npoints > 0 while working with contours using OpenCV OpenCV 错误:使用 cv2.undistortpoints 时断言失败 - OpenCV Error: Assertion failed while using cv2.undistortpoints 在 function 'cvtColor' 中收到 Opencv: (-215:Assertion failed)._src.empty() 中的错误 - Receiving the error in Opencv: (-215:Assertion failed) !_src.empty() in function 'cvtColor' 如何使用我自己的图片使用 FGSM 生成对抗样本? - How to use my own picture to generate adversarial example using FGSM? 检测不正确的断言方法 - Detecting incorrect assertion methods
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM