aurora95 / Keras-FCN

Keras-tensorflow implementation of Fully Convolutional Networks for Semantic Segmentation(Unfinished)
MIT License
650 stars 268 forks source link

ValueError: Error when checking target: expected bilinear_up_sampling2d_1 to have shape (None, 320, 320, 21) but got array with shape (16, 320, 320, 1) #62

Open d13g0 opened 6 years ago

d13g0 commented 6 years ago

I am running your code (train.py) "as is" without any modification from the repo and after downloading the VOC dataset (following your instructions).

I am getting the error:

ValueError: Error when checking target: expected bilinear_up_sampling2d_1 to have shape (None, 320, 320, 21) but got array with shape (16, 320, 320, 1)

inside fit_generator > train_on_batch > _standarize_input_data (keras.engine.training)

Can you comment on this problem? thanks.

F951 commented 6 years ago

I have exactly the same problem. Right now I'm trying with different versions of tensorflow-gpu/Keras, in case that it be a version issue. Regards.

Edit: the error was solved installing a version of Keras >=2.1.2

musematics commented 6 years ago

Same problem here. Currently using Keras 2.2.4. Does anyone know how to fix this? Thanks a lot.

musematics commented 6 years ago

Um... I ve just found that the format of my training labels (which contains only one channel) is inconsistent with the network. If training a binary classifier, an additional conv layer would help.

SuperBlc commented 5 years ago

I use keras == 2.1.6, error was solved.[my environment: python3.5, tf-1.4.2]

meiqing-wang commented 5 years ago

Um... I ve just found that the format of my training labels (which contains only one channel) is inconsistent with the network. If training a binary classifier, an additional conv layer would help.

Hi,I am also using this network to train binary segmentation and I also get a similar error. Can you give me some points about adding an additional conv layer? Many thanks...

musematics commented 5 years ago

Um... I ve just found that the format of my training labels (which contains only one channel) is inconsistent with the network. If training a binary classifier, an additional conv layer would help.

Hi,I am also using this network to train binary segmentation and I also get a similar error. Can you give me some points about adding an additional conv layer? Many thanks...

This error might be caused by different issues. Here is my case. I added the following line: x = Conv2D(1, 1, activation = 'sigmoid')(x) above the line: model = Model(img_input, x) in model.py Hope it helps!