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

None is not supported in input_shape [bug] #5900

Closed
rex-yue-wu opened this issue Mar 21, 2017 · 5 comments
Closed

None is not supported in input_shape [bug] #5900

rex-yue-wu opened this issue Mar 21, 2017 · 5 comments

Comments

@rex-yue-wu
Copy link

In the new release v2.0.1, None is not supported in input_shape, while None is must-have for a fully-convolutional network. Below is an example

>>> model = Sequential()
model = Sequential()
>>> model.add(Conv2D(32, (3, 3), activation='relu', input_shape=(3, None, None)))
)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/nfs/isicvlnas01/share/anaconda/lib/python2.7/site-packages/keras/models.py", line 422, in add
    layer(x)
  File "/nfs/isicvlnas01/share/anaconda/lib/python2.7/site-packages/keras/engine/topology.py", line 528, in __call__
    self.build(input_shapes[0])
  File "/nfs/isicvlnas01/share/anaconda/lib/python2.7/site-packages/keras/layers/convolutional.py", line 125, in build
    raise ValueError('The channel dimension of the inputs '
ValueError: The channel dimension of the inputs should be defined. Found `None`.
>>> print keras.__version__
print keras.__version__
2.0.1
@kivantium
Copy link

Your problem is the order of input_shape. You assume channels come first, but whether channels come first or last depends on the configuration in $HOME/.keras/keras.json. See https://keras.io/backend/.

If your image_data_format is channels_last, your input_shape should be (None, None, 3).

@rex-yue-wu
Copy link
Author

Nope. I use theano backend, and the order should be ( 3, None, None ).

@bstriner
Copy link
Contributor

Tried your code and works for me on Theano. Double check the ordering actually loaded in keras.

import keras.backend as K
print(K.image_dim_ordering())

'th'

Cheers

@bstriner
Copy link
Contributor

Just realized I gave you the old API.

import keras.backend as K
print(K.image_dim_ordering())
print(K.image_data_format())

th
channels_first

@rex-yue-wu
Copy link
Author

rex-yue-wu commented Mar 21, 2017

Thank you. As you both said, the image_data_format caused my error. The real problem is that I did not update my keras.json for the new version, because image_data_format is not in a 1.x version.

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

3 participants