keras-team / keras-contrib

Keras community contributions
MIT License
1.58k stars 651 forks source link

cifar10_densenet.py issue #304

Open haramoz opened 6 years ago

haramoz commented 6 years ago

Hello I am unable to run the example cifar10_densenet.py of the self. Can anyone help with this issue??

File "cifar10_densenet.py", line 80, in verbose=2) File "/home/arka/anaconda2/envs/hyperas/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(*args, **kwargs) File "/home/arka/anaconda2/envs/hyperas/lib/python3.6/site-packages/keras/engine/training.py", line 1415, in fit_generator initial_epoch=initial_epoch) File "/home/arka/anaconda2/envs/hyperas/lib/python3.6/site-packages/keras/engine/training_generator.py", line 140, in fit_generator val_x, val_y, val_sample_weight) File "/home/arka/anaconda2/envs/hyperas/lib/python3.6/site-packages/keras/engine/training.py", line 787, in _standardize_user_data exception_prefix='target') File "/home/arka/anaconda2/envs/hyperas/lib/python3.6/site-packages/keras/engine/training_utils.py", line 127, in standardize_input_data 'with shape ' + str(data_shape)) ValueError: Error when checking target: expected dense_1 to have 4 dimensions, but got array with shape (10000, 10)

Dense_1 is the very last layer of the block by the way. Thanks.

CJunLee commented 5 years ago

@haramoz Same issue here! Have you solved it yet?

ghost commented 5 years ago

Hello I am unable to run the example cifar10_densenet.py of the self. Can anyone help with this issue??

File "cifar10_densenet.py", line 80, in verbose=2) File "/home/arka/anaconda2/envs/hyperas/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper return func(*args, **kwargs) File "/home/arka/anaconda2/envs/hyperas/lib/python3.6/site-packages/keras/engine/training.py", line 1415, in fit_generator initial_epoch=initial_epoch) File "/home/arka/anaconda2/envs/hyperas/lib/python3.6/site-packages/keras/engine/training_generator.py", line 140, in fit_generator val_x, val_y, val_sample_weight) File "/home/arka/anaconda2/envs/hyperas/lib/python3.6/site-packages/keras/engine/training.py", line 787, in _standardize_user_data exception_prefix='target') File "/home/arka/anaconda2/envs/hyperas/lib/python3.6/site-packages/keras/engine/training_utils.py", line 127, in standardize_input_data 'with shape ' + str(data_shape)) ValueError: Error when checking target: expected dense_1 to have 4 dimensions, but got array with shape (10000, 10)

Dense_1 is the very last layer of the block by the way. Thanks.

You just need to flatten the last layer in DenseNet before output the logits:

x = Flatten()(x) x = Dense(n_classes)(x)