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

set_input_shape for Convolutional layer #8

Closed
EnriqueSMarquez opened this issue Feb 25, 2016 · 0 comments
Closed

set_input_shape for Convolutional layer #8

EnriqueSMarquez opened this issue Feb 25, 2016 · 0 comments

Comments

@EnriqueSMarquez
Copy link

When I use the layer method set_input_shape it sets the batch_input_shape, which in a convolutional layer case requires a 4dim tuple (batch_size,nb_channels,width,height).

When training a CNN with batch_input_shape rather than input_shape(3 dim), it throws an error at the end of the first epoch when training it.

This is the error:
Epoch 1/1 49920/50000 [============================>.] - ETA: 0s - loss: 1.9490 - acc: 0.3118Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pdb.py", line 1314, in main pdb._runscript(mainpyfile) File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pdb.py", line 1233, in _runscript self.run(statement) File "/usr/local/Cellar/python/2.7.10/Frameworks/Python.framework/Versions/2.7/lib/python2.7/bdb.py", line 400, in run exec cmd in globals, locals File "<string>", line 1, in <module> File "CNN_CIFAR_10_6.py", line 6, in <module> from keras.datasets import cifar10 File "CNN_CIFAR_10_6.py", line 49, in trainingMethod2 modelsToGatherFV[k].fit(X_train_tmp, Y_training, batch_size=batch_size, nb_epoch=nb_epochs,show_accuracy=True) File "/usr/local/lib/python2.7/site-packages/keras/models.py", line 646, in fit shuffle=shuffle, metrics=metrics) File "/usr/local/lib/python2.7/site-packages/keras/models.py", line 280, in _fit outs = f(ins_batch) File "/usr/local/lib/python2.7/site-packages/keras/backend/theano_backend.py", line 384, in __call__ return self.function(*inputs) File "/usr/local/lib/python2.7/site-packages/theano/compile/function_module.py", line 871, in __call__ storage_map=getattr(self.fn, 'storage_map', None)) File "/usr/local/lib/python2.7/site-packages/theano/gof/link.py", line 314, in raise_with_op reraise(exc_type, exc_value, exc_trace) File "/usr/local/lib/python2.7/site-packages/theano/compile/function_module.py", line 859, in __call__ outputs = self.fn() ValueError: GpuReshape: cannot reshape input of shape (80, 32, 30, 30) to shape (128, 28800). Apply node that caused the error: GpuReshape{2}(GpuElemwise{Composite{(i0 * (i1 + Abs(i1)))},no_inplace}.0, TensorConstant{[ 128 28800]}) Toposort index: 48 Inputs types: [CudaNdarrayType(float32, 4D), TensorType(int64, vector)] Inputs shapes: [(80, 32, 30, 30), (2,)] Inputs strides: [(28800, 900, 30, 1), (8,)] Inputs values: ['not shown', array([ 128, 28800])] Outputs clients: [[GpuDimShuffle{1,0}(GpuReshape{2}.0), GpuDot22(GpuReshape{2}.0, <CudaNdarrayType(float32, matrix)>)]]
If I set the input shape when initializing the layer it does not throw any error. So I would guess there is a conflict when using the full input shape (including batch size) and the fit method. Also, the batch size I am setting at the on the layer, is the same as in the fit method. Thank you.

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

1 participant