keras-fine-tune-inception icon indicating copy to clipboard operation
keras-fine-tune-inception copied to clipboard

Error when checking model target: expected dense_2 to have shape (None, 2) but got array with shape (24, 13)

Open ohmerhe opened this issue 6 years ago • 1 comments

Traceback (most recent call last): File "fine_tune_inceptionv3.py", line 129, in callbacks=[mc_top, tb]) File "/home/heliangwei/tensorflow3/lib/python3.6/site-packages/keras/engine/training.py", line 1557, in fit_generator class_weight=class_weight) File "/home/heliangwei/tensorflow3/lib/python3.6/site-packages/keras/engine/training.py", line 1314, in train_on_batch check_batch_axis=True) File "/home/heliangwei/tensorflow3/lib/python3.6/site-packages/keras/engine/training.py", line 1033, in _standardize_user_data exception_prefix='model target') File "/home/heliangwei/tensorflow3/lib/python3.6/site-packages/keras/engine/training.py", line 124, in standardize_input_data str(array.shape)) ValueError: Error when checking model target: expected dense_2 to have shape (None, 2) but got array with shape (24, 13)

ohmerhe avatar Aug 02 '18 03:08 ohmerhe

it may be because your generator is not getting 2 classes. (getting an array )

Found 25000 images belonging to 2 classes.
Found 1000 images belonging to 2 classes.

you must get this (ignore no. of images).

to get it, follow this convention(also given in code itself).

data/
    train/
        dogs/
            dog001.jpg
            dog002.jpg
            ...
        cats/
            cat001.jpg
            cat002.jpg
            ...
    validation/
        dogs/
            dog001.jpg
            dog002.jpg
            ...
        cats/
            cat001.jpg
            cat002.jpg
            ...

ParthPurani avatar Jan 02 '19 09:01 ParthPurani