-1

I used the following to install cleverhans in Colab:

!pip install -qq -e git+http://github.com/tensorflow/cleverhans.git#egg=cleverhans
import sys
sys.path.append('/content/src/cleverhans')
import cleverhans

And it seems to work good. Then I use the following:

from cleverhans.utils_keras import KerasModelWrapper
wrap = KerasModelWrapper(network)

And I get:

ModuleNotFoundError                       Traceback (most recent call last)

<ipython-input-42-bf6d85d04ab3> in <module>()
----> 1 from cleverhans.utils_keras import KerasModelWrapper
      2 wrap = KerasModelWrapper(network)

ModuleNotFoundError: No module named 'cleverhans.utils_keras'
Avi
  • 2,247
  • 4
  • 30
  • 52

1 Answers1

0

Module cleverhans.utils_keras is a part of cleverhans_v3.1.0. The subdirectory has its own setup.py, i.e. it's its own separate package. Install it with the command

!pip install -U "git+https://github.com/cleverhans-lab/cleverhans.git#egg=cleverhans&subdirectory=cleverhans_v3.1.0"
phd
  • 82,685
  • 13
  • 120
  • 165
  • Thanks @phd! I think you have to add ! before the pip (!pip). I succeeded to install as you mentioned but I still get error: 10 # Assignment rather than import because direct import from within Keras and AttributeError: module 'tensorflow' has no attribute 'GraphKeys – Avi Oct 06 '21 at 12:57