qubvel / segmentation_models

Segmentation models with pretrained backbones. Keras and TensorFlow Keras.
MIT License
4.75k stars 1.03k forks source link

train and test set result are not match? #285

Open xiaokeaiyayaya opened 4 years ago

xiaokeaiyayaya commented 4 years ago

I train this model on voc2012, Epoch 1/40 183/183 [==============================] - 480s 3s/step - loss: 0.9784 - iou_score: 0.4688 - f1-score: 0.4778 - val_loss: 0.9699 - val_iou_score: 0.9009 - val_f1-score: 0.9086 Epoch 2/40 183/183 [==============================] - 458s 3s/step - loss: 0.9315 - iou_score: 0.5993 - f1-score: 0.6138 - val_loss: 0.9605 - val_iou_score: 0.9164 - val_f1-score: 0.9240 ..... 183/183 [==============================] - 463s 3s/step - loss: 0.6871 - iou_score: 0.4393 - f1-score: 0.4783 - val_loss: 0.9174 - val_iou_score: 0.9176 - val_f1-score: 0.9255 Epoch 40/40 183/183 [==============================] - 465s 3s/step - loss: 0.6829 - iou_score: 0.4434 - f1-score: 0.4829 - val_loss: 0.9179 - val_iou_score: 0.8747 - val_f1-score: 0.8831 why the val result is better than train? what happend?

and I evaluate it on this val set code: scores = model.evaluate_generator(test_dataloader) print("Loss: {:.5}".format(scores[0])) for metric, value in zip(metrics, scores[1:]): print("mean {}: {:.5}".format(metric.name, value))

result:

Loss: 0.91655 mean iou_score: 0.91503 mean f1-score: 0.92299

JordanMakesMaps commented 4 years ago

Also weird is that by epoch 40, the training loss is lower that the validation, despite the results of the accuracy. That's the opposite of would you would expect. Usually when the training is performing worse than the validation it's due to your model underfitting on the data. This can sometimes be caused by using to much dropout or augmentation on the training data, or having too small of an architecture for the given dataset.

Are you using the same exact pre-processing steps for both the training and validation data?

xiaokeaiyayaya commented 4 years ago

yes. I also test others code and my code(deeplab with xception) and them reach dice 60 after 5 batch,but the result never get better after this.I try to predict some images.The predicted masks are totally wrong.I don't know why.Only your model's result are right(but the iou have some problems).Can you give me some advice about why mine and others can't work.

JordanMakesMaps commented 4 years ago

Which implementation of DeepLab are you using? If it's either the Bonlime or Golbstein I haven't been able to get results just like many others.

Without more information I can't really give you any help.

When you're training a model from this repo, are you freezing the encoder or decoder at all? Are you initializing the encode with imagenet weights? Is your training and validation data split correctly (in such a way that limits the potential for bias)?

xiaokeaiyayaya commented 4 years ago

This one https://github.com/bonlime/keras-deeplab-v3-plus Many people have the same problem https://github.com/bonlime/keras-deeplab-v3-plus/issues/79

xiaokeaiyayaya commented 4 years ago

just like the link you give me,I trained model and didn't load pretrained para.so my result is bad.I use your model and load para,the result is good.