我希望你们都做得很好。我需要在windows上为一些项目安装cleverhans,但一旦安装,它就无法访问其中的任何python文件,我得到了许多错误,如:
<ipython-input-12-4fbd91cef426> in <module>
10 import numpy as np
11
---> 12 from cleverhans.attacks import FastGradientMethod
13 from cleverhans.compat import flags
14 from cleverhans.dataset import MNIST
~\src\cleverhans\cleverhans\attacks\__init__.py in <module>
10
11 from cleverhans import utils
---> 12 from cleverhans.attacks.attack import Attack
13 from cleverhans.attacks.basic_iterative_method import BasicIterativeMethod
14 from cleverhans.attacks.carlini_wagner_l2 import CarliniWagnerL2
~\src\cleverhans\cleverhans\attacks\attack.py in <module>
11
12 from cleverhans.compat import reduce_max
---> 13 from cleverhans.model import Model
14 from cleverhans import utils
15
~\src\cleverhans\cleverhans\model.py in <module>
7 import tensorflow as tf
8
----> 9 from cleverhans import utils_tf
10
11
~\src\cleverhans\cleverhans\utils_tf.py in <module>
343
344 def kl_with_logits(p_logits, q_logits, scope=None,
--> 345 loss_collection=tf.GraphKeys.REGULARIZATION_LOSSES):
346 """Helper function to compute kl-divergence KL(p || q)
347 """
AttributeError: module 'tensorflow' has no attribute 'GraphKeys'我希望从你那里得到更多的答案。祝您今天愉快。
发布于 2020-07-18 20:03:25
看起来cleverhans被设计为使用旧版本的tensorflow。要使其向下兼容,请替换
import tensorflow as tf使用
import tensorflow.compat.v1 as tf在cleverhans源代码中,或者查看是否有可用的cleverhans更新版本,或者卸载tensorflow并安装旧版本(v1)。
请参阅:Tensorflow 2.1.0 Error, module 'tensorflow' has no attribute 'GraphKeys'
来自cleverhans GitHub存储库:
“当前支持的安装程序
虽然CleverHans可能可以在许多其他机器配置上运行,但我们目前在Ubuntu14.04.5LTS (Trusty )上使用Python3.5和TensorFlow {1.8,1.12}对其进行了测试。“
https://stackoverflow.com/questions/62968101
复制相似问题