jacobgil / keras-dcgan

Keras implementation of Deep Convolutional Generative Adversarial Networks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

doesn't work out of the box

ikamensh opened this issue · comments

Hello,

I tried to launch this project locally. I set my keras to use theano, python = 2.7; its ubuntu.

Traceback (most recent call last):
File "dcgun.py", line 167, in
train(BATCH_SIZE=args.batch_size)
File "dcgun.py", line 80, in train
discriminator = discriminator_model()
File "dcgun.py", line 46, in discriminator_model
model.add(Dense(1024))
File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 312, in add
output_tensor = layer(self.outputs[0])
File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 487, in call
self.build(input_shapes[0])
File "/usr/local/lib/python2.7/dist-packages/keras/layers/core.py", line 695, in build
name='{}_W'.format(self.name))
File "/usr/local/lib/python2.7/dist-packages/keras/initializations.py", line 59, in glorot_uniform
return uniform(shape, s, name=name)
File "/usr/local/lib/python2.7/dist-packages/keras/initializations.py", line 32, in uniform
return K.random_uniform_variable(shape, -scale, scale, name=name)
File "/usr/local/lib/python2.7/dist-packages/keras/backend/theano_backend.py", line 140, in random_uniform_variable
return variable(np.random.uniform(low=low, high=high, size=shape),
File "mtrand.pyx", line 1565, in mtrand.RandomState.uniform (numpy/random/mtrand/mtrand.c:17319)
OverflowError: Range exceeds valid bounds

This seems like a potential problem with keras / theano.
Please upgrade both versions and try again.

Also please check the versions of both by:
import tensorflow as tf
print tf.__version__
import keras
print keras.__version__

Actual problem was mismatch between backend and image_dim_ordering; I changed the backend to theano but forgot the image ordering.

A correction to ~/.keras/keras.json solved it:

{
"image_dim_ordering": "th",
"epsilon": 1e-07,
"floatx": "float32",
"backend": "theano"
}