2

在拉取请求中,我看到 master 分支具有适用于 TF2 的代码。我正在研究如何使用它们。我使用带有 python 3.7.7 和 tf 2.2 的 conda env。然后我从 gihub celverhans 中提取了 master 分支。但是,当我尝试运行时mnist_tutorial_tfe.py,出现以下错误。

$ python ./cleverhans_tutorials/mnist_tutorial_tfe.py 
Traceback (most recent call last):
  File "./cleverhans_tutorials/mnist_tutorial_tfe.py", line 23, in <module>
    from cleverhans.utils_tfe import train, model_eval
  File "/media/Y/vish/hcraeser/code_repo/cleverhans/cleverhans/utils_tfe.py", line 17, in <module>
    from cleverhans.loss import LossCrossEntropy
  File "/media/Y/vish/hcraeser/code_repo/cleverhans/cleverhans/loss.py", line 10, in <module>
    from cleverhans.attacks import Attack
  File "/media/Y/vish/hcraeser/code_repo/cleverhans/cleverhans/attacks/__init__.py", line 12, in <module>
    from cleverhans.attacks.attack import Attack
  File "/media/Y/vish/hcraeser/code_repo/cleverhans/cleverhans/attacks/attack.py", line 13, in <module>
    from cleverhans.model import Model
  File "/media/Y/vish/hcraeser/code_repo/cleverhans/cleverhans/model.py", line 9, in <module>
    from cleverhans import utils_tf
  File "/media/Y/vish/hcraeser/code_repo/cleverhans/cleverhans/utils_tf.py", line 345, in <module>
    loss_collection=tf.GraphKeys.REGULARIZATION_LOSSES):
AttributeError: module 'tensorflow' has no attribute 'GraphKeys'

如何在 TF2 中使用cleverhans?似乎相关代码在cleverhans/future 目录下。但是如何让这些官方的例子在TF2下运行呢?

4

0 回答 0