dhlab-epfl / dhSegment

Generic framework for historical document processing
https://dhlab-epfl.github.com/dhSegment
GNU General Public License v3.0
370 stars 116 forks source link

What are the differences between these loss functions? How do I choose? #12

Closed xiaomaxiao closed 5 years ago

xiaomaxiao commented 6 years ago

What are the differences between these loss functions? How do I choose? especially REGRESSION

tf.squared_difference loss fuction

solivr commented 6 years ago

You don't really have to choose which loss function to use, you rather choose which type of prediction you need. If you have a classification problem (one label per pixel), then you should have PredictionType = CLASSIFICATION, this is by default. If you have a multilabel classification problem (multiple labels per pixel) then set PredictionType = MULTILABEL. I'd recommend using one of these two.

xiaomaxiao commented 5 years ago

thx , I use PredictionType = ClassFICATION , I don't know how to adjust the parameters of focal loss ,do you have any advice?

solivr commented 5 years ago

By default no focal loss is used. If you want to try it, I'd recommend having a look at the original paper to set the parameters.

xiaomaxiao commented 5 years ago

I found some errors .

https://github.com/dhlab-epfl/dhSegment/blob/265aa0a555fe89bfb263ca3644c43f2d4efd668b/dh_segment/estimator_fn.py#L99

Remove the negative sign tf.multiply(training_params.focal_loss_alpha*(1. - prediction_probs), onehot_labels)),

Unfortunately, I didn't get good results with focal loss , I am looking for the reason

I also try to use class weight

SeguinBe commented 5 years ago

Good catch, I corrected it in https://github.com/dhlab-epfl/dhSegment/commit/0cddcfabcec6943d13cbff6c8afaa307d6f0cfc6

And yeah class weight is basically the $\alpha_t$ in the focal loss paper