ModuleNotFoundError: No module named 'cleverhans.utils_keras' in Colab

997 Views Asked by At

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'
1

There are 1 best solutions below

1
On

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"