xwjabc / hed

A PyTorch reimplementation of Holistically-Nested Edge Detection
170 stars 42 forks source link

About loss #39

Open long123524 opened 3 years ago

long123524 commented 3 years ago

I have a question. The training loss of the HED network is relatively large, thousands or even higher, but the result is not bad. Why is the loss of the HED relatively large? Under normal circumstances, loss should be a very small value.

xwjabc commented 3 years ago

I think the main reason is, the loss function only averages over batch size but not over spatial size. See https://github.com/xwjabc/hed/blob/master/hed.py#L296 for more information.

long123524 commented 2 years ago

Thanks, How can I reduce the values of loss while maintaining good results?

xwjabc commented 2 years ago

You may use the loss function averaged over both batch size and spatial size, and scale up the learning rate accordingly (i.e. new LR = spatial size * old LR).

long123524 commented 2 years ago

Thanks. Does the spatial size mean the size of the input image?

xwjabc commented 2 years ago

It should be the size of the output (i.e., the predicted edge map).