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

OverflowError: Range exceeds valid bounds #3781

Closed
jagiella opened this issue Sep 15, 2016 · 7 comments
Closed

OverflowError: Range exceeds valid bounds #3781

jagiella opened this issue Sep 15, 2016 · 7 comments

Comments

@jagiella
Copy link

I just transfered my scripts to a different machine (both Ubuntu 16.04) and the error (see Issue title) popped up. On my old machine it is working flawlessly.

My code causing the problem:

model = Sequential()

model.add(Convolution2D(nb_conv_filters, conv_kernel_size, conv_kernel_size, border_mode='valid', input_shape=(1, img_rows, img_cols)))
model.add(Activation('relu'))
model.add(MaxPooling2D(pool_size=(pool_kernel_size, pool_kernel_size)))

model.add(Flatten())

model.add(Dense(nb_dense_neurons)) #128
model.add(Activation('relu'))
model.add(Dropout(0.5))

model.add(Dense(nb_classes))
model.add(Activation('softmax'))

model.compile(loss='categorical_crossentropy',
                  optimizer='adadelta',
                  metrics=['accuracy'])

The error is the following:

Traceback (most recent call last):
  File "sensitivityAnalysis.py", line 14, in <module>
    cnn.buildModelLargeKernels( [4])
  File "/home/user/CNN.py", line 341, in buildModelLargeKernels
    model.add(Dense(nb_dense_neurons)) #128
  File "/usr/local/lib/python3.5/dist-packages/keras/models.py", line 308, in add
    output_tensor = layer(self.outputs[0])
  File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 487, in __call__
    build(input_shapes[0])
  File "/usr/local/lib/python3.5/dist-packages/keras/layers/core.py", line 695, in build
    name='{}_W'.format(self.name))
  File "/usr/local/lib/python3.5/dist-packages/keras/initializations.py", line 59, in glorot_uniform
    return uniform(shape, s, name=name)
  File "/usr/local/lib/python3.5/dist-packages/keras/initializations.py", line 32, in uniform
    return K.random_uniform_variable(shape, -scale, scale, name=name)
  File "/usr/local/lib/python3.5/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:17311)
OverflowError: Range exceeds valid bounds

Any idea what causes this problem and how to get rid of it? It seems to occure while adding a dense layer.

@varoudis
Copy link

#2681
Same problem with me and others

@Viveksbawa
Copy link

I am facing the same problem. the networked which were working perfect on ubuntu 14 are generating error "OverflowError: Range exceeds valid bounds" in ubuntu 16. issue is with dense layer. can't figure out the problem. please share if anyone has resolved this issue.

@Simmetria0
Copy link

Simmetria0 commented Oct 8, 2016

I had the same problem using the same code but updating the system. I solved the problem adding these two lines at the beginning of the code:

from keras import backend as K
K.set_image_dim_ordering('th')

Hope can help

@wac81
Copy link

wac81 commented Nov 30, 2016

@Simmetria0 it works for me! thanks!

@dpanugroho
Copy link

@Simmetria0 it also works for me. Thank you.

@jiangyangbo
Copy link

is works for me, tks

@wenliang
Copy link

Thanks. It works for me.

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

8 participants