Python 通过任何方法生成对抗性样本时接收断言失败
我在通过任何方法生成对抗性示例时收到以下错误Python 通过任何方法生成对抗性样本时接收断言失败,python,tensorflow,keras,cleverhans,Python,Tensorflow,Keras,Cleverhans,我在通过任何方法生成对抗性示例时收到以下错误 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}}]] 模型
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}}]]
模型代码在这里
tensorflow版本=1.13.1
全堆栈跟踪
---------------------------------------------------------------------------
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) ]]
---------------------------------------------------------------------------
InvalidArgumentError回溯(最后一次最近调用)
调用中的~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py(self,fn,*args)
1333尝试:
->1334返回fn(*args)
1335错误除外。操作错误为e:
运行fn中的~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py(提要、获取列表、目标列表、选项、运行元数据)
1318返回self.\u调用\u tf\u sessionrun(
->1319选项、提要、获取列表、目标列表、运行元数据)
1320
~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py in\u call\u tf\u sessionrun(self、options、feed\u dict、fetch\u list、target\u list、run\u元数据)
1406 self.\u会话、选项、提要、获取列表、目标列表、,
->1407运行单元(元数据)
1408
InvalidArgumentError:断言失败:[]条件x 10 adv_x=fgsm.generate_np(x_测试,**fgsm_参数)
生成中的~/anaconda3/lib/python3.7/site packages/cleverhans/attacks/\uuuuu init\uuuuuu.py(self,x\u val,**kwargs)
201 feed_dict[new_kwargs[name]]=可供喂养的[name]
202
-->203返回自存储运行(x_adv,feed_dict)
204
205 def构造_变量(self、kwargs):
运行中的~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py(self、fetches、feed\u dict、options、run\u元数据)
927尝试:
928结果=self.\u运行(无、取数、输入、选项、,
-->929运行(元数据)
930如果运行元数据:
931 proto_data=tf_session.tf_GetBuffer(run_metadata_ptr)
运行中的~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py(self、handle、fetches、feed、dict、options、run\u元数据)
1150如果final_获取或final_目标或(句柄和馈送dict_张量):
1151 results=self.\u do\u run(句柄、最终目标、最终获取、,
->1152提要(输入张量、选项、运行元数据)
1153其他:
1154结果=[]
运行中的~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py(self、handle、target\u list、fetch\u list、feed\u dict、options、run\u元数据)
1326如果句柄为“无”:
1327返回self.\u do\u call(\u run\u fn,feed,fetches,targets,options,
->1328运行单元(元数据)
1329其他:
1330返回self.\u do\u调用(\u prun\u fn,句柄,提要,获取)
调用中的~/anaconda3/lib/python3.7/site-packages/tensorflow/python/client/session.py(self,fn,*args)
1346通行证
1347消息=错误\u插值。插值(消息,自我图形)
->1348提升类型(e)(节点定义,操作,消息)
1349
1350 def扩展图(自):
InvalidArgumentError:断言失败:[]条件x看起来您的输入不在[clip\u min,clip\u max]间隔内。您是否确保在将x\u test
输入到generate\u np
之前将其剪切到该间隔
---------------------------------------------------------------------------
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) ]]