在窗户上安装cleverHans



我希望你们都做得很好。我需要在一些项目的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
~srccleverhanscleverhansattacks__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
~srccleverhanscleverhansattacksattack.py in <module>
11 
12 from cleverhans.compat import reduce_max
---> 13 from cleverhans.model import Model
14 from cleverhans import utils
15 
~srccleverhanscleverhansmodel.py in <module>
7 import tensorflow as tf
8 
----> 9 from cleverhans import utils_tf
10 
11 
~srccleverhanscleverhansutils_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'

我希望你能给我很多答案。祝你今天愉快。

看起来cleverhans是为使用tensorflow的旧版本而设计的。为了使其向下兼容,请更换

import tensorflow as tf

带有

import tensorflow.compat.v1 as tf

在cleverhans源代码中,或者查看是否有更新版本的clever汉斯可用,或者卸载tensorflow并安装旧版本(v1(。

请参阅:Tensorflow 2.1.0错误,模块';tensorflow;没有属性';GraphKeys';

来自cleverhans GitHub repo:

">当前支持的设置

尽管CleverHans可能在许多其他机器配置上工作,但我们目前在Ubuntu 14.04.5 LTS(Trusty Tahr(上用Python 3.5和TensorFlow{1.81.12}对其进行了测试">

最新更新