Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python example_gan.py --> ModuleNotFoundError: No module named 'keras_adversarial.legacy' #46

Open
PredM opened this issue Dec 4, 2017 · 1 comment

Comments

@PredM
Copy link

PredM commented Dec 4, 2017

Hello,

I have no clue why I get the following error when I am executing: python example_gan.py

Using TensorFlow backend.
Traceback (most recent call last):
  File "example_gan.py", line 16, in <module>
    from keras_adversarial.legacy import l1l2, Dense, fit
ModuleNotFoundError: No module named 'keras_adversarial.legacy'

I cloned your repo and executed setup.py. The file legacy.py is also in the right folder. Has anybody a suggestion what I can do to fix it?

Thanks in advance!

@mdbloice
Copy link

I got the same error as this.

The only way I was able to get this to work was to first make sure I didn't have the package installed with pip (I installed via pip rather than cloning the repository as I didn't read the README properly...), so the first thing I did was to uninstall the pip version:

pip uninstall keras_adversarial

Then, I installed it by cloning the repo and using setup.py as per the README.

However, when running python gan_example.py I then got the error:

Traceback (most recent call last):
  File "example_gan.py", line 18, in <module>
    from mnist_utils import mnist_data
ImportError: No module named mnist_utils

And I found that mnist_utils was actually just a small module with two functions in it:

def mnist_process(x):
    x = x.astype(np.float32) / 255.0
    return x

def mnist_data():
    (xtrain, ytrain), (xtest, ytest) = mnist.load_data()
    return mnist_process(xtrain), mnist_process(xtest)

See https://github.com/bstriner/keras-adversarial/blob/master/examples/mnist_utils.py.

So I commented out line 18 of example_gan.py and added an import for mnist from the keras.datasets module:

#from mnist_utils import mnist_data
from keras.datasets import mnist

and finally pasted in the two functions, mnist_process() and mnist_data() that I showed above, just below the imports.

That got it working. Maybe this helps someone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants